Kronolith::listCalendars PHP Метод

listCalendars() публичный статический Метод

Returns all calendars a user has access to, according to several parameters/permission levels.
public static listCalendars ( integer $permission = Horde_Perms::SHOW, boolean $display = false ) : array
$permission integer The permission to filter calendars by.
$display boolean Only return calendars that are supposed to be displayed per configuration and user preference.
Результат array The calendar list.
    public static function listCalendars($permission = Horde_Perms::SHOW, $display = false)
    {
        $calendars = array();
        foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_CALENDARS) as $id => $calendar) {
            if ($calendar->hasPermission($permission) && (!$display || $calendar->display())) {
                $calendars['internal_' . $id] = $calendar;
            }
        }
        foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_REMOTE_CALENDARS) as $id => $calendar) {
            try {
                if ($calendar->hasPermission($permission) && (!$display || $calendar->display())) {
                    $calendars['remote_' . $id] = $calendar;
                }
            } catch (Kronolith_Exception $e) {
                $GLOBALS['notification']->push(sprintf(_("The calendar %s returned the error: %s"), $calendar->name(), $e->getMessage()), 'horde.error');
            }
        }
        foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_EXTERNAL_CALENDARS) as $id => $calendar) {
            if ($calendar->hasPermission($permission) && (!$display || $calendar->display())) {
                $calendars['external_' . $id] = $calendar;
            }
        }
        foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_HOLIDAYS) as $id => $calendar) {
            if ($calendar->hasPermission($permission) && (!$display || $calendar->display())) {
                $calendars['holiday_' . $id] = $calendar;
            }
        }
        return $calendars;
    }

Usage Example

Пример #1
0
 /**
  */
 public function menu($menu)
 {
     global $browser, $conf, $notification, $page_output, $registry, $session;
     /* Check here for guest calendars so that we don't get multiple
      * messages after redirects, etc. */
     if (!$registry->getAuth() && !count(Kronolith::listCalendars())) {
         $notification->push(_("No calendars are available to guests."));
     }
     if ($browser->hasFeature('dom')) {
         Horde_Core_Ui_JsCalendar::init(array('click_month' => true, 'click_week' => true, 'click_year' => true, 'full_weekdays' => true));
         $page_output->addScriptFile('goto.js');
         $page_output->addInlineJsVars(array('KronolithGoto.dayurl' => strval(Horde::url('day.php')), 'KronolithGoto.monthurl' => strval(Horde::url('month.php')), 'KronolithGoto.weekurl' => strval(Horde::url('week.php')), 'KronolithGoto.yearurl' => strval(Horde::url('year.php'))));
         $menu->add(new Horde_Url(''), _("_Goto"), 'kronolith-icon-goto', null, '', null, 'kgotomenu');
     }
     $menu->add(Horde::url('search.php'), _("_Search"), 'kronolith-icon-search');
     /* Import/Export. */
     if ($conf['menu']['import_export'] && !Kronolith::showAjaxView()) {
         $menu->add(Horde::url('data.php'), _("_Import/Export"), 'horde-data');
     }
     if (strlen($session->get('kronolith', 'display_cal'))) {
         $menu->add(Horde::selfUrl(true)->add('display_cal', ''), $registry->getAuth() ? _("Return to my calendars") : _("Return to calendars"), 'kronolith-icon-back', null, null, null, '__noselection');
     }
 }
All Usage Examples Of Kronolith::listCalendars