public static function toJson(Horde_Icalendar_Vfreebusy $fb)
{
$json = new stdClass();
$start = $fb->getStart();
if ($start) {
$start = new Horde_Date($start);
$json->s = $start->dateString();
}
$end = $fb->getEnd();
if ($end) {
$end = new Horde_Date($end);
$json->e = $end->dateString();
}
$b = $fb->getBusyPeriods();
if (empty($b)) {
$b = new StdClass();
}
$new = new StdClass();
foreach ($b as $from => $to) {
$from = new Horde_Date($from);
$to = new Horde_Date($to);
$new->{$from->toJson()} = $to->toJson();
}
$json->b = $new;
return $json;
}
/** * Obtain the freebusy information for this resource. * * @return mixed string|Horde_Icalendar_Vfreebusy The Freebusy object or * the iCalendar text. */ public function getFreeBusy($startstamp = null, $endstamp = null, $asObject = false, $json = false) { $vfb = Kronolith_FreeBusy::generate($this->get('calendar'), $startstamp, $endstamp, true); $vfb->removeAttribute('ORGANIZER'); $vfb->setAttribute('ORGANIZER', $this->get('name')); if ($json) { return Kronolith_FreeBusy::toJson($vfb); } elseif (!$asObject) { return $vfb->exportvCalendar(); } return $vfb; }