/** * Returns a list of all calendars. */ public function listCalendars() { Kronolith::initialize(); $all_external_calendars = $GLOBALS['calendar_manager']->get(Kronolith::ALL_EXTERNAL_CALENDARS); $result = new stdClass(); $auth_name = $GLOBALS['registry']->getAuth(); // Calendars. Do some twisting to sort own calendar before shared // calendars. foreach (array(true, false) as $my) { foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_CALENDARS) as $id => $calendar) { $owner = $auth_name && $calendar->owner() == $auth_name; if ($my && $owner || !$my && !$owner) { $result->calendars['internal'][$id] = $calendar->toHash(); } } // Tasklists if (Kronolith::hasApiPermission('tasks')) { foreach ($GLOBALS['registry']->tasks->listTasklists($my, Horde_Perms::SHOW, false) as $id => $tasklist) { if (isset($all_external_calendars['tasks/' . $id])) { $owner = $auth_name && $tasklist->get('owner') == $auth_name; if ($my && $owner || !$my && !$owner) { $result->calendars['tasklists']['tasks/' . $id] = $all_external_calendars['tasks/' . $id]->toHash(); } } } } } // Resources if (!empty($GLOBALS['conf']['resources']['enabled'])) { foreach (Kronolith::getDriver('Resource')->listResources() as $resource) { if ($resource->get('isgroup')) { $rcal = new Kronolith_Calendar_ResourceGroup(array('resource' => $resource)); $result->calendars['resourcegroup'][$resource->getId()] = $rcal->toHash(); } else { $rcal = new Kronolith_Calendar_Resource(array('resource' => $resource)); $result->calendars['resource'][$resource->get('calendar')] = $rcal->toHash(); } } } // Timeobjects foreach ($all_external_calendars as $id => $calendar) { if ($calendar->api() != 'tasks' && $calendar->display()) { $result->calendars['external'][$id] = $calendar->toHash(); } } // Remote calendars foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_REMOTE_CALENDARS) as $url => $calendar) { $result->calendars['remote'][$url] = $calendar->toHash(); } // Holidays foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_HOLIDAYS) as $id => $calendar) { $result->calendars['holiday'][$id] = $calendar->toHash(); } return $result; }
/** * Global variables defined: * - $kronolith_shares: TODO */ protected function _init() { /* For now, autoloading the Content_* classes depend on there being a * registry entry for the 'content' application that contains at least * the fileroot entry. */ $GLOBALS['injector']->getInstance('Horde_Autoloader')->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Content_/', $GLOBALS['registry']->get('fileroot', 'content') . '/lib/')); if (!class_exists('Content_Tagger')) { throw new Horde_Exception(_("The Content_Tagger class could not be found. Make sure the Content application is installed.")); } $GLOBALS['injector']->bindFactory('Kronolith_Geo', 'Kronolith_Factory_Geo', 'create'); $GLOBALS['injector']->bindFactory('Kronolith_Shares', 'Kronolith_Factory_Shares', 'create'); /* Set the timezone variable, if available. */ $GLOBALS['registry']->setTimeZone(); /* Store the request timestamp if it's not already present. */ if (!isset($_SERVER['REQUEST_TIME'])) { $_SERVER['REQUEST_TIME'] = time(); } if (!$GLOBALS['prefs']->getValue('dynamic_view')) { $this->features['dynamicView'] = false; } if ($GLOBALS['registry']->getView() != Horde_Registry::VIEW_DYNAMIC || !$GLOBALS['prefs']->getValue('dynamic_view') || empty($this->initParams['nodynamicinit'])) { Kronolith::initialize(); } }
public function testDefaultShareDeletePermission() { $GLOBALS['conf']['share']['auto_create'] = true; Kronolith::initialize(); $shares = $GLOBALS['injector']->getInstance('Kronolith_Shares')->listShares('*****@*****.**'); $default = array_pop($shares); $this->assertTrue($default->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)); }