Generates the free/busy text for $calendars.
public static generate ( string | array $calendars, integer $startstamp = null, integer $endstamp = null, boolean $returnObj = false, string $user = null ) : string | ||
$calendars | string | array | The calendar to view free/busy slots for. |
$startstamp | integer | The start of the time period to retrieve. |
$endstamp | integer | The end of the time period to retrieve. |
$returnObj | boolean | Default false. Return a vFreebusy object instead of text. |
$user | string | Set organizer to this user. |
return | string | The free/busy text. |
/** * Generates free/busy information for a given time period. * * @param integer $startstamp The start of the time period to retrieve. * @param integer $endstamp The end of the time period to retrieve. * @param string $calendar The calendar to view free/busy slots for. * Defaults to the user's default calendar. * * @return Horde_Icalendar_Vfreebusy A freebusy object that covers the * specified time period. * @throws Kronolith_Exception */ public function getFreeBusy($startstamp = null, $endstamp = null, $calendar = null) { if (is_null($calendar)) { $calendar = Kronolith::getDefaultCalendar(); } // Free/Busy information is globally available; no permission // check is needed. return Kronolith_FreeBusy::generate($calendar, $startstamp, $endstamp, true); }
/** * 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; }
$key = 'kronolith.fb.' . ($user ? 'u.' . $user : '******' . $cal); $fb = $cache->get($key, 360); if (!$fb) { if ($user) { $prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('kronolith', array('cache' => false, 'user' => $user)); $registry->setTimeZone(); $cal = @unserialize($prefs->getValue('fb_cals')); if (is_array($cal)) { $cal = implode('|', $cal); } // If the free/busy calendars preference is empty, default to // the user's default_share preference, and if that's empty, // to their username. if (!$cal) { $cal = $prefs->getValue('default_share'); if (!$cal) { $cal = $user; } $cal = 'internal_' . $cal; } } try { $fb = Kronolith_FreeBusy::generate(explode('|', $cal), null, null, false, $user); } catch (Exception $e) { Horde::log($e, 'ERR'); exit; } $cache->set($key, $fb); } $browser->downloadHeaders(($user ? $user : $cal) . '.vfb', 'text/calendar; charset=' . 'UTF-8', true, strlen($fb)); echo $fb;
// Add the creator as a required attendee in the Free/Busy display $cal = @unserialize($prefs->getValue('fb_cals')); if (!is_array($cal)) { $cal = null; } // If the free/busy calendars preference is empty, default to the user's // default_share preference, and if that's empty, to their username. if (!$cal) { $cal = 'internal_' . $prefs->getValue('default_share'); if (!$cal) { $cal = 'internal_' . $GLOBALS['registry']->getAuth(); } $cal = array($cal); } try { $vfb = Kronolith_FreeBusy::generate($cal, null, null, true, $GLOBALS['registry']->getAuth()); $attendee_view->addRequiredMember($vfb); } catch (Exception $e) { $notification->push(sprintf(_("Error retrieving your free/busy information: %s"), $e->getMessage())); } // Add the Free/Busy information for each attendee. foreach ($session->get('kronolith', 'attendees', Horde_Session::TYPE_ARRAY) as $email => $status) { if (strpos($email, '@') !== false && ($status['attendance'] == Kronolith::PART_REQUIRED || $status['attendance'] == Kronolith::PART_OPTIONAL)) { try { $vfb = Kronolith_FreeBusy::get($email); $organizer = $vfb->getAttribute('ORGANIZER'); if (empty($organizer)) { $vfb->setAttribute('ORGANIZER', 'mailto:' . $email, array(), false); } if ($status['attendance'] == Kronolith::PART_REQUIRED) { $attendee_view->addRequiredMember($vfb);