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 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'); } }
$date = Horde_Util::getFormData('date', date('Ymd')) . '000600'; $event->start = new Horde_Date($date); if ($prefs->getValue('twentyFour')) { $event->start->hour = 12; } } $event->end = new Horde_Date($event->start); if (Horde_Util::getFormData('allday')) { $event->end->mday++; } else { // Default to a 1 hour duration. $event->end->hour++; } $month = $event->start->month; $year = $event->start->year; $buttons = array('<input type="submit" class="horde-default" name="save" value="' . _("Save Event") . '" />'); $url = Horde_Util::getFormData('url'); if (isset($url)) { $cancelurl = new Horde_Url($url); } else { $cancelurl = Horde::url('month.php', true)->add('month', $month); } $calendars = Kronolith::listCalendars(Horde_Perms::EDIT | Kronolith::PERMS_DELEGATE, true); Horde_Core_Ui_JsCalendar::init(array('full_weekdays' => true)); $page_output->addScriptFile('edit.js'); $page_output->addScriptFile('popup.js', 'horde'); $page_output->header(array('title' => _("Add a new event"))); require KRONOLITH_TEMPLATES . '/javascript_defs.php'; $notification->notify(array('listeners' => 'status')); require KRONOLITH_TEMPLATES . '/edit/edit.inc'; $page_output->footer();
// Refer to turba/config/sources.php for possible source and field values // // If you want to provide a default value, this field depends on the // search_sources preference. For example: // 'value' => json_encode(array( // 'source_one' => array('field_one', 'field_two'), // 'source_two' => array('field_three') // )) // will search the fields 'field_one' and 'field_two' in source_one and // 'field_three' in source_two. $_prefs['search_fields'] = array('value' => ''); $_prefs['fb_url'] = array('value' => '<strong>' . _("My Free/Busy URL") . '</strong><div class="fburl"><div>' . _("Copy this URL for use wherever you need your Free/Busy URL:") . '</div><div class="fixed">' . Horde::url('fb.php', true, array('append_session' => -1))->add('u', $GLOBALS['registry']->getAuth()) . '</div></div>', 'type' => 'rawhtml'); // Calendars to include in generating Free/Busy URLs. $_prefs['fb_cals'] = array('value' => 'a:0:{}', 'type' => 'multienum', 'enum' => array(), 'desc' => _("Choose the calendars to include in the above Free/Busy URL:"), 'on_init' => function ($ui) { $enum = array(); foreach (Kronolith::listCalendars() as $fb_cal => $cal) { if ($cal->display()) { $enum[htmlspecialchars($fb_cal)] = htmlspecialchars($cal->name()); } } $ui->prefs['fb_cals']['enum'] = $enum; }, 'on_change' => function () { $GLOBALS['injector']->getInstance('Horde_Cache')->expire('kronolith.fb.u.' . $GLOBALS['registry']->getAuth()); }); // Login Tasks preferences $_prefs['purge_events'] = array('value' => 0, 'type' => 'checkbox', 'desc' => _("Purge old events from your calendar?")); $_prefs['purge_events_interval'] = array('value' => Horde_LoginTasks::MONTHLY, 'type' => 'enum', 'enum' => Horde_LoginTasks::getLabels(), 'desc' => _("Purge old events how often:")); $_prefs['purge_events_keep'] = array('value' => 365, 'type' => 'number', 'desc' => _("Purge old events older than this amount of days.")); // End Login Tasks preferences $_prefs['activesync_identity'] = array('value' => 'horde', 'type' => 'enum', 'enum' => array_merge($GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($GLOBALS['registry']->getAuth())->getAll('id'), array('horde' => _("Use Horde Default"))), 'desc' => _("Choose the identity to use for ActiveSync. This determines the email address used as the ORGANIZER for events you create.")); $_prefs['itip_silent'] = array('value' => 0, 'type' => 'checkbox', 'desc' => _("If checked, NEVER SEND any iTip messages. This means invitees will NOT receive meeting requests and organizers will NOT receive any messages when an existing meeting is altered."));
$notification->push($e, 'horde.error'); $error = true; break; } } if (!$error) { $notification->push(sprintf(_("%s file successfully imported"), $file_types[$storage->get('format')]), 'horde.success'); } if (Horde_Util::getFormData('import_ajax')) { $page_output->includeScriptFiles(); $page_output->addInlineScript('(function(window){window.KronolithCore.loading--;if(!window.KronolithCore.loading)window.$(\'kronolithLoading\').hide();window.KronolithCore.loadCalendar(\'' . $type . '\', \'' . $calendar . '\');})(window.parent)'); } $next_step = $data->cleanup(); } if (Horde_Util::getFormData('import_ajax')) { $page_output->addInlineScript('window.parent.$(window.name).remove();'); $page_output->outputInlineScript(); exit; } $import_calendars = $export_calendars = array(); if ($GLOBALS['registry']->getAuth()) { $import_calendars = Kronolith::listCalendars(Horde_Perms::EDIT, true); } $export_calendars = Kronolith::listCalendars(Horde_Perms::READ, true); $page_output->header(array('title' => _("Import/Export Calendar"))); require KRONOLITH_TEMPLATES . '/javascript_defs.php'; $notification->notify(array('listeners' => 'status')); foreach ($templates[$next_step] as $template) { require $template; } $page_output->footer();
public function html($active = true) { if (!$this->_event) { echo '<h3>' . _("Event not found") . '</h3>'; exit; } if (is_string($this->_event)) { echo '<h3>' . $this->_event . '</h3>'; exit; } $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create(); if ($this->_event->hasPermission(Horde_Perms::EDIT)) { $calendar_id = $this->_event->calendarType . '_' . $this->_event->calendar; } else { $calendar_id = 'internal_' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT); } if (!$this->_event->hasPermission(Horde_Perms::EDIT)) { try { $calendar_id .= '\\' . $this->_event->getShare()->get('owner'); } catch (Exception $e) { } } $GLOBALS['session']->set('kronolith', 'attendees', $this->_event->attendees); $GLOBALS['session']->set('kronolith', 'resources', $this->_event->getResources()); if ($datetime = Horde_Util::getFormData('datetime')) { $datetime = new Horde_Date($datetime); $month = $datetime->month; $year = $datetime->year; } else { $month = Horde_Util::getFormData('month', date('n')); $year = Horde_Util::getFormData('year', date('Y')); } $url = Horde_Util::getFormData('url'); $perms = Horde_Perms::EDIT; if ($this->_event->creator == $GLOBALS['registry']->getAuth()) { $perms |= Kronolith::PERMS_DELEGATE; } $calendars = Kronolith::listCalendars($perms, true); $buttons = array(); if (!$this->_event->hasPermission(Horde_Perms::EDIT) && ($GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') > Kronolith::countEvents())) { $buttons[] = '<input type="submit" class="horde-create" name="saveAsNew" value="' . _("Save As New") . '" />'; } else { if ($this->_event->hasPermission(Horde_Perms::EDIT)) { $buttons[] = '<input type="submit" class="horde-default" name="save" value="' . _("Save Event") . '" />'; } if ($this->_event->initialized) { if (!$this->_event->recurs() && ($GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') > Kronolith::countEvents())) { $buttons[] = '<input type="submit" class="horde-create" name="saveAsNew" value="' . _("Save As New") . '" />'; } } } if (isset($url)) { $cancelurl = new Horde_Url($url); } else { $cancelurl = Horde::url('month.php', true)->add(array('month' => $month, 'year' => $year)); } $event =& $this->_event; $tags = implode(',', array_values($event->tags)); Horde_Core_Ui_JsCalendar::init(array('full_weekdays' => true)); global $page_output; $page_output->addScriptFile('hordecore.js', 'horde'); $page_output->addScriptFile('edit.js'); $page_output->addScriptFile('popup.js', 'horde'); echo '<div id="EditEvent"' . ($active ? '' : ' style="display:none"') . '>'; require KRONOLITH_TEMPLATES . '/edit/edit.inc'; echo '</div>'; if ($active && $GLOBALS['browser']->hasFeature('dom')) { if ($this->_event->hasPermission(Horde_Perms::READ)) { $view = new Kronolith_View_Event($this->_event); $view->html(false); } if ($this->_event->hasPermission(Horde_Perms::DELETE)) { $delete = new Kronolith_View_DeleteEvent($this->_event); $delete->html(false); } } }
/** */ protected function _content() { $GLOBALS['page_output']->addScriptFile('tooltips.js', 'horde'); $now = new Horde_Date($_SERVER['REQUEST_TIME']); $today = date('j'); $startDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n'), 'mday' => date('j'))); $endDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n'), 'mday' => date('j') + $this->_params['days'])); try { if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') { $calendars = Kronolith::listCalendars(); if (!isset($calendars[$this->_params['calendar']])) { return _("Calendar not found"); } if (!$calendars[$this->_params['calendar']]->hasPermission(Horde_Perms::READ)) { return _("Permission Denied"); } list($type, $calendar) = explode('_', $this->_params['calendar'], 2); $driver = Kronolith::getDriver($type, $calendar); $all_events = Kronolith::sortEvents($driver->listEvents($startDate, $endDate, array('show_recurrence' => true))); } else { $all_events = Kronolith::listEvents($startDate, $endDate, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS)); } } catch (Exception $e) { return '<em>' . $e->getMessage() . '</em>'; } $html = ''; $iMax = $today + $this->_params['days']; $firstday = true; $totalevents = 0; for ($i = $today; $i < $iMax; ++$i) { $day = new Kronolith_Day(date('n'), $i); $date_stamp = $day->dateString(); if (empty($all_events[$date_stamp])) { continue; } $firstevent = true; $tomorrow = $day->getTomorrow(); foreach ($all_events[$date_stamp] as $event) { if (!empty($this->_params['maxevents']) && $totalevents >= $this->_params['maxevents']) { break 2; } if ($event->start->compareDate($day) < 0) { $event->start = $day; } if ($event->end->compareDate($tomorrow) >= 0) { $event->end = $tomorrow; } if ($event->end->compareDateTime($now) < 0) { continue; } if (!empty($this->_params['alarms']) && !$event->alarm) { continue; } $event_active = $event->start->compareDateTime($now) < 0 && $event->end->compareDateTime($now) > 0; if ($firstevent) { $html .= '<tr><td colspan="3" class="control"><strong>'; if ($day->isToday()) { $dayname = _("Today"); } elseif ($day->isTomorrow()) { $dayname = _("Tomorrow"); } elseif ($day->diff() < 7) { $dayname = $day->strftime('%A'); } else { $dayname = $day->strftime($GLOBALS['prefs']->getValue('date_format')); } $url = Horde::url('day.php', true)->setRaw(false)->add('date', $day->dateString()); if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') { $url->add('display_cal', $this->_params['calendar']); } $html .= $url->link(array('title' => sprintf(_("Goto %s"), $dayname))) . $dayname . '</a></strong></td></tr>'; $firstevent = false; $firstday = false; } $html .= '<tr class="linedRow"><td class="text nowrap" valign="top">'; if ($event_active) { $html .= '<strong>'; } if ($event->isAllDay()) { $time = _("All day"); } else { $time = $event->start->format($GLOBALS['prefs']->getValue('twentyFour') ? 'H:i' : 'h:ia') . '-' . $event->end->format($GLOBALS['prefs']->getValue('twentyFour') ? 'H:i' : 'h:ia'); } $html .= $time; if ($event_active) { $html .= '</strong>'; } $html .= ' </td>'; $html .= '<td class="text" valign="top"' . $event->getCSSColors() . '>'; if ($event_active) { $html .= '<strong>'; } $html .= ' ' . $event->getLink(null, true, null, true, true); if ($event_active) { $html .= '</strong>'; } $html .= '</td></tr>'; $totalevents++; } } if (empty($html)) { return '<em>' . _("No events to display") . '</em>'; } return '<table cellspacing="0" width="100%">' . $html . '</table>'; }
/** */ protected function _content() { global $page_output; $page_output->addScriptFile('tooltips.js', 'horde'); $now = new Horde_Date($_SERVER['REQUEST_TIME']); $today = date('j'); $current_month = ''; $startDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n'), 'mday' => date('j'))); $endDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n') + $this->_params['months'], 'mday' => date('j') - 1)); try { if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') { $calendars = Kronolith::listCalendars(); if (!isset($calendars[$this->_params['calendar']])) { return _("Calendar not found"); } if (!$calendars[$this->_params['calendar']]->hasPermission(Horde_Perms::READ)) { return _("Permission Denied"); } list($type, $calendar) = explode('_', $this->_params['calendar'], 2); $driver = Kronolith::getDriver($type, $calendar); $all_events = $driver->listEvents($startDate, $endDate, array('show_recurrence' => true, 'has_alarm' => !empty($this->_params['alarms']), 'cover_dates' => false)); } else { $all_events = Kronolith::listEvents($startDate, $endDate, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS), array('has_alarm' => !empty($this->_params['alarms']), 'cover_dates' => false)); } } catch (Exception $e) { return '<em>' . $e->getMessage() . '</em>'; } /* How many days do we need to check. */ $days = Date_Calc::dateDiff($startDate->mday, $startDate->month, $startDate->year, $endDate->mday, $endDate->month, $endDate->year); /* Loop through the days. */ $totalevents = 0; $html = ''; for ($i = 0; $i < $days; ++$i) { $day = new Kronolith_Day($startDate->month, $today + $i); $date_stamp = $day->dateString(); if (empty($all_events[$date_stamp])) { continue; } if (!empty($this->_params['maxevents']) && $totalevents >= $this->_params['maxevents']) { break; } /* Output month header. */ if ($current_month != $day->month) { $html .= '<tr><td colspan="4" class="control"><strong>' . $day->strftime('%B') . '</strong></td></tr>'; } $firstevent = true; $tomorrow = $day->getTomorrow(); foreach ($all_events[$date_stamp] as $event) { $isMultiDay = false; if ($event->start->compareDate($day) < 0) { $event->start = new Horde_Date($day); } if ($event->end->compareDate($tomorrow) >= 1) { $isMultiDay = true; } if ($event->end->compareDate($now) < 0 && !$event->isAllDay() || !empty($this->_params['alarms']) && !$event->alarm) { continue; } if ($firstevent || $isMultiDay) { $html .= '<tr'; if ($current_month == $day->month) { $html .= ' class="upcomingday"'; } $html .= '><td class="text" valign="top" align="right"><strong>'; if ($day->isToday()) { $html .= _("Today"); } elseif ($day->isTomorrow()) { $html .= _("Tomorrow"); } else { $html .= $day->mday; } if ($isMultiDay) { $endDay = new Kronolith_Day($event->end->month, $event->end->mday); $html .= ' - '; if ($endDay->isTomorrow()) { $html .= _("Tomorrow"); } else { $html .= $event->end->mday; } } $html .= '</strong> </td>'; $firstevent = $isMultiDay; } else { $html .= '<tr><td class="text"> </td>'; } $html .= '<td class="text" nowrap="nowrap" valign="top">'; if ($event->start->compareDate($now) < 0 && $event->end->compareDate($now) > 0) { $html .= '<strong>' . htmlspecialchars($event->getLocation()) . '</strong>'; } else { $html .= htmlspecialchars($event->getLocation()); } if ($event->start->compareDate($now) < 0 && $event->end->compareDate($now) > 0) { $html .= '<strong>'; } $html .= $event->getLink(null, true, null, true); if ($event->start->compareDate($now) < 0 && $event->end->compareDate($now) > 0) { $html .= '</strong>'; } $html .= '</td></tr>'; $totalevents++; } $current_month = $day->strftime('%m'); } if (empty($html)) { return '<em>' . _("No events to display") . '</em>'; } return '<table cellspacing="0" width="100%">' . $html . '</table>'; }
/** */ protected function _content() { global $prefs; if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') { $calendars = Kronolith::listCalendars(); if (!isset($calendars[$this->_params['calendar']])) { return _("Calendar not found"); } if (!$calendars[$this->_params['calendar']]->hasPermission(Horde_Perms::READ)) { return _("Permission Denied"); } } $year = date('Y'); $month = date('m'); $startday = new Horde_Date(array('mday' => 1, 'month' => $month, 'year' => $year)); $startday = $startday->dayOfWeek(); if (!$prefs->getValue('week_start_monday')) { $startOfView = 1 - $startday; $endday = new Horde_Date(array('mday' => Horde_Date_Utils::daysInMonth($month, $year), 'month' => $month, 'year' => $year)); } else { if ($startday == Horde_Date::DATE_SUNDAY) { $startOfView = -5; } else { $startOfView = 2 - $startday; } } $startDate = new Horde_Date($year, $month, $startOfView); $endDate = new Horde_Date($year, $month, Horde_Date_Utils::daysInMonth($month, $year) + 1); $endDate->mday += (7 - ($endDate->format('w') - $prefs->getValue('week_start_monday'))) % 7; /* Table start. and current month indicator. */ $html = '<table cellspacing="1" class="monthgrid" width="100%"><tr>'; /* Set up the weekdays. */ $weekdays = array(_("Mo"), _("Tu"), _("We"), _("Th"), _("Fr"), _("Sa")); if (!$prefs->getValue('week_start_monday')) { array_unshift($weekdays, _("Su")); } else { $weekdays[] = _("Su"); } foreach ($weekdays as $weekday) { $html .= '<th class="item">' . $weekday . '</th>'; } try { if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') { list($type, $calendar) = explode('_', $this->_params['calendar'], 2); $driver = Kronolith::getDriver($type, $calendar); $all_events = $driver->listEvents($startDate, $endDate, array('show_recurrence' => true)); } else { $all_events = Kronolith::listEvents($startDate, $endDate, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS)); } } catch (Exception $e) { return '<em>' . $e->getMessage() . '</em>'; } $weekday = 0; $week = -1; $weekStart = $prefs->getValue('week_start_monday'); for ($date_ob = new Kronolith_Day($month, $startOfView, $year); $date_ob->compareDate($endDate) < 0; $date_ob->mday++) { if ($weekday == 7) { $weekday = 0; } if ($weekday == 0) { ++$week; $html .= '</tr><tr>'; } if ($date_ob->isToday()) { $td_class = 'kronolith-today'; } elseif ($date_ob->month != $month) { $td_class = 'kronolith-othermonth'; } elseif ($date_ob->dayOfWeek() == 0 || $date_ob->dayOfWeek() == 6) { $td_class = 'kronolith-weekend'; } else { $td_class = ''; } $html .= '<td align="center" class="' . $td_class . '">'; /* Set up the link to the day view. */ $url = Horde::url('day.php', true)->add('date', $date_ob->dateString()); if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') { $url->add('display_cal', $this->_params['calendar']); } $date_stamp = $date_ob->dateString(); if (empty($all_events[$date_stamp])) { /* No events, plain link to the day. */ $cell = Horde::linkTooltip($url, _("View Day")) . $date_ob->mday . '</a>'; } else { /* There are events; create a cell with tooltip to * list them. */ $day_events = ''; foreach ($all_events[$date_stamp] as $event) { if ($event->isAllDay()) { $day_events .= _("All day"); } else { $day_events .= $event->start->strftime($prefs->getValue('twentyFour') ? '%R' : '%I:%M%p') . '-' . $event->end->strftime($prefs->getValue('twentyFour') ? '%R' : '%I:%M%p'); } $location = $event->getLocation(); $day_events .= ':' . ($location ? ' (' . htmlspecialchars($location) . ')' : '') . ' ' . $event->getTitle() . "\n"; } $cell = Horde::linkTooltip($url, _("View Day"), '', '', '', $day_events) . $date_ob->mday . '</a>'; } /* Bold the cell if there are events. */ if (!empty($all_events[$date_stamp])) { $cell = '<strong>' . $cell . '</strong>'; } $html .= $cell . '</td>'; ++$weekday; } return $html . '</tr></table>'; }