/** * Add base javascript variables to the page. */ protected function _addBaseVars() { global $conf, $injector, $prefs, $registry; $auth_name = $registry->getAuth(); $has_tasks = Kronolith::hasApiPermission('tasks'); $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create(); $app_urls = $js_vars = array(); if (isset($conf['menu']['apps']) && is_array($conf['menu']['apps'])) { foreach ($conf['menu']['apps'] as $app) { $app_urls[$app] = strval(Horde::url($registry->getInitialPage($app), true)); } } /* Variables used in core javascript files. */ $js_vars['conf'] = array_filter(array('URI_CALENDAR_EXPORT' => str_replace(array('%23', '%2523', '%7B', '%257B', '%7D', '%257D'), array('#', '#', '{', '{', '}', '}'), strval($registry->downloadUrl('#{calendar}.ics', array('actionID' => 'export', 'all_events' => 1, 'exportID' => Horde_Data::EXPORT_ICALENDAR, 'exportCal' => 'internal_#{calendar}'))->setRaw(true))), 'URI_RESOURCE_EXPORT' => str_replace(array('%23', '%2523', '%7B', '%257B', '%7D', '%257D'), array('#', '#', '{', '{', '}', '}'), strval($registry->downloadUrl('#{calendar}.ics', array('actionID' => 'export', 'all_events' => 1, 'exportID' => Horde_Data::EXPORT_ICALENDAR, 'exportCal' => 'resource_#{calendar}'))->setRaw(true))), 'URI_EVENT_EXPORT' => str_replace(array('%23', '%7B', '%7D'), array('#', '{', '}'), Horde::url('event.php', true)->add(array('view' => 'ExportEvent', 'eventID' => '#{id}', 'calendar' => '#{calendar}', 'type' => '#{type}'))), 'images' => array('alarm' => strval(Horde_Themes::img('alarm-fff.png')), 'attendees' => strval(Horde_Themes::img('attendees-fff.png')), 'exception' => strval(Horde_Themes::img('exception-fff.png')), 'new_event' => strval(Horde_Themes::img('new.png')), 'new_task' => strval(Horde_Themes::img('new_task.png')), 'recur' => strval(Horde_Themes::img('recur-fff.png'))), 'new_event' => $injector->getInstance('Kronolith_View_Sidebar')->newLink . $injector->getInstance('Kronolith_View_Sidebar')->newText . '</a>', 'new_task' => $injector->getInstance('Kronolith_View_SidebarTasks')->newLink . $injector->getInstance('Kronolith_View_SidebarTasks')->newText . '</a>', 'user' => $registry->convertUsername($auth_name, false), 'name' => $identity->getName(), 'email' => strval($identity->getDefaultFromAddress()), 'prefs_url' => strval($registry->getServiceLink('prefs', 'kronolith')->setRaw(true)), 'app_urls' => $app_urls, 'name' => $registry->get('name'), 'has_tasks' => intval($has_tasks), 'has_resources' => intval(!empty($conf['resource']['driver'])), 'login_view' => $prefs->getValue('defaultview') == 'workweek' ? 'week' : $prefs->getValue('defaultview'), 'default_calendar' => 'internal|' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT), 'max_events' => intval($prefs->getValue('max_events')), 'date_format' => Horde_Core_Script_Package_Datejs::translateFormat(Horde_Nls::getLangInfo(D_FMT)), 'time_format' => $prefs->getValue('twentyFour') ? 'HH:mm' : 'hh:mm tt', 'import_file' => Horde_Data::IMPORT_FILE, 'import_url' => Horde_Data::IMPORT_URL, 'show_time' => Kronolith::viewShowTime(), 'default_alarm' => intval($prefs->getValue('default_alarm')), 'status' => array('cancelled' => Kronolith::STATUS_CANCELLED, 'confirmed' => Kronolith::STATUS_CONFIRMED, 'free' => Kronolith::STATUS_FREE, 'tentative' => Kronolith::STATUS_TENTATIVE), 'recur' => array(Horde_Date_Recurrence::RECUR_NONE => 'None', Horde_Date_Recurrence::RECUR_DAILY => 'Daily', Horde_Date_Recurrence::RECUR_WEEKLY => 'Weekly', Horde_Date_Recurrence::RECUR_MONTHLY_DATE => 'Monthly', Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY => 'Monthly', Horde_Date_Recurrence::RECUR_YEARLY_DATE => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_DAY => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY => 'Yearly'), 'perms' => array('all' => Horde_Perms::ALL, 'show' => Horde_Perms::SHOW, 'read' => Horde_Perms::READ, 'edit' => Horde_Perms::EDIT, 'delete' => Horde_Perms::DELETE, 'delegate' => Kronolith::PERMS_DELEGATE), 'tasks' => $has_tasks ? $registry->tasks->ajaxDefaults() : null)); /* Make sure this value is not optimized out by array_filter(). */ $js_vars['conf']['week_start'] = intval($prefs->getValue('week_start_monday')); /* Gettext strings. */ $js_vars['text'] = array('alarm' => _("Alarm:"), 'alerts' => _("Notifications"), 'allday' => _("All day"), 'delete_calendar' => _("Are you sure you want to delete this calendar and all the events in it?"), 'delete_tasklist' => _("Are you sure you want to delete this task list and all the tasks in it?"), 'external_category' => _("Other events"), 'fix_form_values' => _("Please enter correct values in the form first."), 'geocode_error' => _("Unable to locate requested address"), 'hidelog' => _("Hide Notifications"), 'import_warning' => _("Importing calendar data. This may take a while..."), 'more' => _("more..."), 'no_assignee' => _("None"), 'no_calendar_title' => _("The calendar title must not be empty."), 'no_parent' => _("No parent task"), 'no_tasklist_title' => _("The task list title must not be empty."), 'no_url' => _("You must specify a URL."), 'prefs' => _("Preferences"), 'searching' => sprintf(_("Events matching \"%s\""), '#{term}'), 'shared' => _("Shared"), 'tasks' => _("Tasks"), 'unknown_resource' => _("Unknown resource."), 'wrong_auth' => _("The authentication information you specified wasn't accepted."), 'wrong_date_format' => sprintf(_("You used an unknown date format \"%s\". Please try something like \"%s\"."), '#{wrong}', '#{right}'), 'wrong_time_format' => sprintf(_("You used an unknown time format \"%s\". Please try something like \"%s\"."), '#{wrong}', '#{right}')); for ($i = 1; $i <= 12; ++$i) { $js_vars['text']['month'][$i - 1] = Horde_Nls::getLangInfo(constant('MON_' . $i)); } for ($i = 1; $i <= 7; ++$i) { $js_vars['text']['weekday'][$i] = Horde_Nls::getLangInfo(constant('DAY_' . $i)); } foreach (array_diff(array_keys($js_vars['conf']['recur']), array(Horde_Date_Recurrence::RECUR_NONE)) as $recurType) { $js_vars['text']['recur'][$recurType] = Kronolith::recurToString($recurType); } $js_vars['text']['recur']['exception'] = _("Exception"); // Maps $js_vars['conf']['maps'] = $conf['maps']; return $js_vars; }
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; } global $conf, $prefs; $this->_event->loadHistory(); $creatorId = $this->_event->creator; $description = $this->_event->description; $location = $this->_event->location; $eventurl = $this->_event->url; $private = $this->_event->isPrivate(); $owner = Kronolith::getUserName($creatorId); $status = Kronolith::statusToString($this->_event->status); $attendees = $this->_event->attendees; $resources = $this->_event->getResources(); if ($datetime = Horde_Util::getFormData('datetime')) { $datetime = new Horde_Date($datetime); $month = $datetime->month; $year = $datetime->year; } else { $month = (int) Horde_Util::getFormData('month', date('n')); $year = (int) Horde_Util::getFormData('year', date('Y')); } $dateFormat = $prefs->getValue('date_format'); $timeFormat = $prefs->getValue('twentyFour') ? 'G:i' : 'g:ia'; // Tags $tags = implode(', ', $this->_event->tags); echo '<div id="Event"' . ($active ? '' : ' style="display:none"') . '>'; require KRONOLITH_TEMPLATES . '/view/view.inc'; echo '</div>'; if ($active && $GLOBALS['browser']->hasFeature('dom')) { /* We check for read permissions, because we can always save a * copy if we can read the event. */ if ($this->_event->hasPermission(Horde_Perms::READ) && Kronolith::getDefaultCalendar(Horde_Perms::EDIT)) { $edit = new Kronolith_View_EditEvent($this->_event); $edit->html(false); } if ($this->_event->hasPermission(Horde_Perms::DELETE)) { $delete = new Kronolith_View_DeleteEvent($this->_event); $delete->html(false); } } }
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; } if ($datetime = Horde_Util::getFormData('datetime')) { $datetime = new Horde_Date($datetime); $month = $datetime->month; $year = $datetime->year; $day = $datetime->mday; } else { $month = Horde_Util::getFormData('month', date('n')); $day = Horde_Util::getFormData('mday', date('j')); $year = Horde_Util::getFormData('year', date('Y')); } $url = Horde_Util::getFormData('url'); echo '<div id="DeleteEvent"' . ($active ? '' : ' style="display:none"') . '>'; if (!$this->_event->recurs()) { require KRONOLITH_TEMPLATES . '/delete/one.inc'; } else { require KRONOLITH_TEMPLATES . '/delete/delete.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::READ) && Kronolith::getDefaultCalendar(Horde_Perms::EDIT)) { $edit = new Kronolith_View_EditEvent($this->_event); $edit->html(false); } } }
public function getLink($datetime = null, $icons = true, $from_url = null, $full = false, $encoded = true) { global $prefs; if (is_null($datetime)) { $datetime = $this->start; } if (is_null($from_url)) { $from_url = Horde::selfUrl(true, false, true); } $event_title = $this->getTitle(); $view_url = $this->getViewUrl(array('datetime' => $datetime->strftime('%Y%m%d%H%M%S'), 'url' => $from_url), $full, $encoded); $read_permission = $this->hasPermission(Horde_Perms::READ); $link = '<span' . $this->getCSSColors() . '>'; if ($read_permission && $view_url) { $link .= Horde::linkTooltip($view_url, $event_title, $this->getStatusClass(), '', '', $this->getTooltip(), '', array('style' => $this->getCSSColors(false))); } $link .= htmlspecialchars($event_title); if ($read_permission && $view_url) { $link .= '</a>'; } if ($icons && $prefs->getValue('show_icons')) { $icon_color = $this->_foregroundColor == '#000' ? '000' : 'fff'; $status = ''; if ($this->alarm) { if ($this->alarm % 10080 == 0) { $alarm_value = $this->alarm / 10080; $title = sprintf(ngettext("Alarm %d week before", "Alarm %d weeks before", $alarm_value), $alarm_value); } elseif ($this->alarm % 1440 == 0) { $alarm_value = $this->alarm / 1440; $title = sprintf(ngettext("Alarm %d day before", "Alarm %d days before", $alarm_value), $alarm_value); } elseif ($this->alarm % 60 == 0) { $alarm_value = $this->alarm / 60; $title = sprintf(ngettext("Alarm %d hour before", "Alarm %d hours before", $alarm_value), $alarm_value); } else { $alarm_value = $this->alarm; $title = sprintf(ngettext("Alarm %d minute before", "Alarm %d minutes before", $alarm_value), $alarm_value); } $status .= Horde::fullSrcImg('alarm-' . $icon_color . '.png', array('attr' => array('alt' => $title, 'title' => $title, 'class' => 'iconAlarm'))); } if ($this->recurs()) { $title = Kronolith::recurToString($this->recurrence->getRecurType()); $status .= Horde::fullSrcImg('recur-' . $icon_color . '.png', array('attr' => array('alt' => $title, 'title' => $title, 'class' => 'iconRecur'))); } elseif ($this->baseid) { $title = _("Exception"); $status .= Horde::fullSrcImg('exception-' . $icon_color . '.png', array('attr' => array('alt' => $title, 'title' => $title, 'class' => 'iconRecur'))); } if ($this->private) { $title = _("Private event"); $status .= Horde::fullSrcImg('private-' . $icon_color . '.png', array('attr' => array('alt' => $title, 'title' => $title, 'class' => 'iconPrivate'))); } if (!empty($this->attendees)) { $status .= Horde::fullSrcImg('attendees-' . $icon_color . '.png', array('attr' => array('alt' => _("Meeting"), 'title' => _("Meeting"), 'class' => 'iconPeople'))); } $space = ' '; if (!empty($this->icon)) { $link = $status . '<img class="kronolithEventIcon" src="' . $this->icon . '" /> ' . $link; } elseif (!empty($status)) { $link .= ' ' . $status; $space = ''; } if ((!$this->private || $this->creator == $GLOBALS['registry']->getAuth()) && Kronolith::getDefaultCalendar(Horde_Perms::EDIT)) { $url = $this->getEditUrl(array('datetime' => $datetime->strftime('%Y%m%d%H%M%S'), 'url' => $from_url), $full); if ($url) { $link .= $space . $url->link(array('title' => sprintf(_("Edit %s"), $event_title), 'class' => 'iconEdit')) . Horde::fullSrcImg('edit-' . $icon_color . '.png', array('attr' => array('alt' => _("Edit")))) . '</a>'; $space = ''; } } if ($this->hasPermission(Horde_Perms::DELETE)) { $url = $this->getDeleteUrl(array('datetime' => $datetime->strftime('%Y%m%d%H%M%S'), 'url' => $from_url), $full); if ($url) { $link .= $space . $url->link(array('title' => sprintf(_("Delete %s"), $event_title), 'class' => 'iconDelete')) . Horde::fullSrcImg('delete-' . $icon_color . '.png', array('attr' => array('alt' => _("Delete")))) . '</a>'; } } } return $link . '</span>'; }
<?php global $prefs, $registry; $kronolith_webroot = $registry->get('webroot'); $horde_webroot = $registry->get('webroot', 'horde'); $has_tasks = Kronolith::hasApiPermission('tasks'); /* Variables used in core javascript files. */ $code['conf'] = array('images' => array('attendees' => (string) Horde_Themes::img('attendees-fff.png'), 'alarm' => (string) Horde_Themes::img('alarm-fff.png'), 'recur' => (string) Horde_Themes::img('recur-fff.png'), 'exception' => (string) Horde_Themes::img('exception-fff.png')), 'user' => $GLOBALS['registry']->convertUsername($GLOBALS['registry']->getAuth(), false), 'prefs_url' => strval($registry->getServiceLink('prefs', 'kronolith')->setRaw(true)), 'name' => $registry->get('name'), 'has_tasks' => $has_tasks, 'default_calendar' => 'internal|' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT), 'week_start' => (int) $prefs->getValue('week_start_monday'), 'max_events' => (int) $prefs->getValue('max_events'), 'date_format' => str_replace(array('%e', '%d', '%a', '%A', '%m', '%h', '%b', '%B', '%y', '%Y'), array('d', 'dd', 'ddd', 'dddd', 'MM', 'MMM', 'MMM', 'MMMM', 'yy', 'yyyy'), Horde_Nls::getLangInfo(D_FMT)), 'time_format' => $prefs->getValue('twentyFour') ? 'HH:mm' : 'hh:mm tt', 'status' => array('tentative' => Kronolith::STATUS_TENTATIVE, 'confirmed' => Kronolith::STATUS_CONFIRMED, 'cancelled' => Kronolith::STATUS_CANCELLED, 'free' => Kronolith::STATUS_FREE), 'recur' => array(Horde_Date_Recurrence::RECUR_NONE => 'None', Horde_Date_Recurrence::RECUR_DAILY => 'Daily', Horde_Date_Recurrence::RECUR_WEEKLY => 'Weekly', Horde_Date_Recurrence::RECUR_MONTHLY_DATE => 'Monthly', Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY => 'Monthly', Horde_Date_Recurrence::RECUR_MONTHLY_LAST_WEEKDAY => 'Monthly', Horde_Date_Recurrence::RECUR_YEARLY_DATE => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_DAY => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY => 'Yearly'), 'perms' => array('all' => Horde_Perms::ALL, 'show' => Horde_Perms::SHOW, 'read' => Horde_Perms::READ, 'edit' => Horde_Perms::EDIT, 'delete' => Horde_Perms::DELETE, 'delegate' => Kronolith::PERMS_DELEGATE)); if ($has_tasks) { $code['conf']['tasks'] = $registry->tasks->ajaxDefaults(); } // Calendars foreach (array(true, false) as $my) { foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_CALENDARS) as $id => $calendar) { $owner = $GLOBALS['registry']->getAuth() && $calendar->owner() == $GLOBALS['registry']->getAuth(); if ($my && $owner || !$my && !$owner) { $code['conf']['calendars']['internal'][$id] = array('name' => ($owner || !$calendar->owner() ? '' : '[' . $GLOBALS['registry']->convertUsername($calendar->owner(), false) . '] ') . $calendar->name(), 'desc' => $calendar->description(), 'owner' => $owner, 'fg' => $calendar->foreground(), 'bg' => $calendar->background(), 'show' => in_array($id, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS)), 'edit' => $calendar->hasPermission(Horde_Perms::EDIT), 'feed' => (string) Kronolith::feedUrl($id), 'embed' => Kronolith::embedCode($id)); if ($owner) { $code['conf']['calendars']['internal'][$id]['perms'] = Kronolith::permissionToJson($calendar->share()->getPermission()); } } } // Tasklists if (!$has_tasks) { continue; } foreach ($registry->tasks->listTasklists($my, Horde_Perms::SHOW) as $id => $tasklist) { $owner = $GLOBALS['registry']->getAuth() && $tasklist->get('owner') == $GLOBALS['registry']->getAuth(); if ($my && $owner || !$my && !$owner) { $code['conf']['calendars']['tasklists']['tasks/' . $id] = array('name' => Kronolith::getLabel($tasklist), 'desc' => $tasklist->get('desc'), 'owner' => $owner, 'fg' => Kronolith::foregroundColor($tasklist), 'bg' => Kronolith::backgroundColor($tasklist), 'show' => in_array('tasks/' . $id, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS)), 'edit' => $tasklist->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)); if ($owner) {
* @author Chuck Hagenbuch <*****@*****.**> */ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('kronolith'); if (Kronolith::showAjaxView()) { Horde::url('', true)->setAnchor('event')->redirect(); } /* Check permissions. */ $url = Horde::url($prefs->getValue('defaultview') . '.php', true)->add(array('month' => Horde_Util::getFormData('month'), 'year' => Horde_Util::getFormData('year'))); $perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms'); if ($perms->hasAppPermission('max_events') !== true && $perms->hasAppPermission('max_events') <= Kronolith::countEvents()) { Horde::permissionDeniedError('kronolith', 'max_events', sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events'))); $url->redirect(); } $display_resource = $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_RESOURCE_CALENDARS); $calendar_id = Horde_Util::getFormData('calendar', empty($display_resource) ? 'internal_' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT) : 'resource_' . $display_resource[0]); if ($calendar_id == 'internal_' || $calendar_id == 'resource_') { $url->redirect(); } $event = Kronolith::getDriver()->getEvent(); $session->set('kronolith', 'attendees', $event->attendees); $session->set('kronolith', 'resources', $event->getResources()); $date = Horde_Util::getFormData('datetime'); if ($date) { $event->start = new Horde_Date($date); } else { $date = Horde_Util::getFormData('date', date('Ymd')) . '000600'; $event->start = new Horde_Date($date); if ($prefs->getValue('twentyFour')) { $event->start->hour = 12; }
$_prefs['sync_calendars'] = array('value' => 'a:0:{}', 'type' => 'multienum', 'enum' => array(), 'desc' => _("Select the calendars that, in addition to the default, should be used for synchronization with external devices:"), 'on_init' => function ($ui) { $enum = array(); $sync = @unserialize($GLOBALS['prefs']->getValue('sync_calendars')); if (empty($sync)) { $GLOBALS['prefs']->setValue('sync_calendars', serialize(array(Kronolith::getDefaultCalendar(Horde_Perms::EDIT)))); } foreach (Kronolith::listInternalCalendars(false, Horde_Perms::DELETE) as $key => $cal) { if ($cal->getName() != Kronolith::getDefaultCalendar(Horde_Perms::DELETE)) { $enum[$key] = Kronolith::getLabel($cal); } } $ui->prefs['sync_calendars']['enum'] = $enum; }, 'on_change' => function () { $sync = @unserialize($GLOBALS['prefs']->getValue('sync_calendars')); $haveDefault = false; $default = Kronolith::getDefaultCalendar(Horde_Perms::DELETE); foreach ($sync as $cid) { if ($cid == $default) { $haveDefault = true; break; } } if (!$haveDefault) { $sync[] = $default; $GLOBALS['prefs']->setValue('sync_calendars', serialize($sync)); } if ($GLOBALS['conf']['activesync']['enabled']) { try { $sm = $GLOBALS['injector']->getInstance('Horde_ActiveSyncState'); $sm->setLogger($GLOBALS['injector']->getInstance('Horde_Log_Logger')); $devices = $sm->listDevices($GLOBALS['registry']->getAuth());
/** * 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); }
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); } } }
$_prefs['sync_calendars'] = array('value' => 'a:0:{}', 'type' => 'multienum', 'enum' => array(), 'desc' => _("Select the calendars that, in addition to the default, should be used for synchronization with external devices:"), 'on_init' => function ($ui) { $enum = array(); $sync = @unserialize($GLOBALS['prefs']->getValue('sync_calendars')); if (empty($sync)) { $GLOBALS['prefs']->setValue('sync_calendars', serialize(array(Kronolith::getDefaultCalendar()))); } foreach (Kronolith::listInternalCalendars(!$GLOBALS['prefs']->getValue('activesync_no_multiplex'), Horde_Perms::EDIT) as $key => $cal) { if ($cal->getName() != Kronolith::getDefaultCalendar(Horde_Perms::EDIT)) { $enum[$key] = Kronolith::getLabel($cal); } } $ui->prefs['sync_calendars']['enum'] = $enum; }, 'on_change' => function () { $sync = @unserialize($GLOBALS['prefs']->getValue('sync_calendars')); $haveDefault = false; $default = Kronolith::getDefaultCalendar(Horde_Perms::EDIT); foreach ($sync as $cid) { if ($cid == $default) { $haveDefault = true; break; } } if (!$haveDefault) { $sync[] = $default; $GLOBALS['prefs']->setValue('sync_calendars', serialize($sync)); } if ($GLOBALS['conf']['activesync']['enabled'] && !$GLOBALS['prefs']->getValue('activesync_no_multiplex')) { try { $sm = $GLOBALS['injector']->getInstance('Horde_ActiveSyncState'); $sm->setLogger($GLOBALS['injector']->getInstance('Horde_Log_Logger')); $devices = $sm->listDevices($GLOBALS['registry']->getAuth());
/** * Adds additional items to the sidebar. * * This is for the traditional view. For the dynamic view, see * Kronolith_View_Sidebar. * * @param Horde_View_Sidebar $sidebar The sidebar object. */ public function sidebar($sidebar) { global $calendar_manager, $conf, $injector, $prefs, $registry, $session; $admin = $registry->isAdmin(); $perms = $injector->getInstance('Horde_Core_Perms'); if (Kronolith::getDefaultCalendar(Horde_Perms::EDIT) && ($perms->hasAppPermission('max_events') === true || $perms->hasAppPermission('max_events') > Kronolith::countEvents())) { $sidebar->addNewButton(_("_New Event"), Horde::url('new.php')->add('url', Horde::selfUrl(true, false, true))); } if (strlen($session->get('kronolith', 'display_cal'))) { $calendars = Kronolith::displayedCalendars(); $sidebar->containers['calendars'] = array('header' => array('id' => 'kronolith-toggle-calendars', 'label' => ngettext("Showing calendar:", "Showing calendars:", count($calendars)), 'collapsed' => false)); foreach ($calendars as $calendar) { $row = array('label' => $calendar->name(), 'color' => $calendar->background(), 'type' => 'checkbox'); $sidebar->addRow($row, 'calendars'); } return; } $user = $registry->getAuth(); $url = Horde::selfUrl(); $edit = Horde::url('calendars/edit.php'); $sidebar->containers['my'] = array('header' => array('id' => 'kronolith-toggle-my', 'label' => _("My Calendars"), 'collapsed' => false)); if (!$prefs->isLocked('default_share')) { $sidebar->containers['my']['header']['add'] = array('url' => Horde::url('calendars/create.php'), 'label' => _("Create a new Local Calendar")); } if ($admin) { $sidebar->containers['system'] = array('header' => array('id' => 'kronolith-toggle-system', 'label' => _("System Calendars"), 'collapsed' => true)); $sidebar->containers['system']['header']['add'] = array('url' => Horde::url('calendars/create.php')->add('system', 1), 'label' => _("Create a new System Calendar")); } $sidebar->containers['shared'] = array('header' => array('id' => 'kronolith-toggle-shared', 'label' => _("Shared Calendars"), 'collapsed' => true)); foreach (Kronolith::listInternalCalendars() as $id => $calendar) { $owner = $calendar->get('owner'); if ($admin && empty($owner)) { continue; } $row = array('selected' => in_array($id, $calendar_manager->get(Kronolith::DISPLAY_CALENDARS)), 'url' => $url->copy()->add('toggle_calendar', $id), 'label' => Kronolith::getLabel($calendar), 'color' => Kronolith::backgroundColor($calendar), 'edit' => $edit->add('c', $calendar->getName()), 'type' => 'checkbox'); if ($calendar->get('owner') && $calendar->get('owner') == $user) { $sidebar->addRow($row, 'my'); } else { $sidebar->addRow($row, 'shared'); } } if ($admin) { foreach ($injector->getInstance('Kronolith_Shares')->listSystemShares() as $id => $calendar) { $row = array('selected' => in_array($id, $calendar_manager->get(Kronolith::DISPLAY_CALENDARS)), 'url' => $url->copy()->add('toggle_calendar', $id), 'label' => $calendar->get('name'), 'color' => Kronolith::backgroundColor($calendar), 'edit' => $edit->add('c', $calendar->getName()), 'type' => 'checkbox'); $sidebar->addRow($row, 'system'); } } if (!empty($conf['resources']['enabled']) && ($admin || $perms->hasAppPermission('resource_management'))) { $sidebar->containers['groups'] = array('header' => array('id' => 'kronolith-toggle-groups', 'label' => _("Resource Groups"), 'collapsed' => true, 'add' => array('url' => Horde::url('resources/groups/create.php'), 'label' => _("Create a new Resource Group")))); $editGroups = Horde::url('resources/groups/edit.php'); $sidebar->containers['resources'] = array('header' => array('id' => 'kronolith-toggle-resources', 'label' => _("Resources"), 'collapsed' => true, 'add' => array('url' => Horde::url('resources/create.php'), 'label' => _("Create a new Resource")))); $edit = Horde::url('resources/edit.php'); foreach (Kronolith::getDriver('Resource')->listResources() as $resource) { if ($resource->get('isgroup')) { $row = array('label' => $resource->get('name'), 'color' => '#dddddd', 'edit' => $editGroups->add('c', $resource->getId()), 'type' => 'radiobox'); $sidebar->addRow($row, 'groups'); } else { $calendar = new Kronolith_Calendar_Resource(array('resource' => $resource)); $row = array('selected' => in_array($resource->get('calendar'), $calendar_manager->get(Kronolith::DISPLAY_RESOURCE_CALENDARS)), 'url' => $url->copy()->add('toggle_calendar', 'resource_' . $resource->get('calendar')), 'label' => $calendar->name(), 'color' => $calendar->background(), 'edit' => $edit->add('c', $resource->getId()), 'type' => 'checkbox'); $sidebar->addRow($row, 'resources'); } } } foreach ($calendar_manager->get(Kronolith::ALL_EXTERNAL_CALENDARS) as $id => $calendar) { if (!$calendar->display()) { continue; } $app = $registry->get('name', $registry->hasInterface($calendar->api())); if (!strlen($app)) { $app = _("Other events"); } $container = 'external_' . $app; if (!isset($sidebar->containers[$container])) { $sidebar->containers[$container] = array('header' => array('id' => 'kronolith-toggle-external-' . $calendar->api(), 'label' => $app, 'collapsed' => true)); } $row = array('selected' => in_array($id, $calendar_manager->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS)), 'url' => $url->copy()->add('toggle_calendar', 'external_' . $id), 'label' => $calendar->name(), 'color' => $calendar->background(), 'type' => 'checkbox'); $sidebar->addRow($row, $container); } $sidebar->containers['remote'] = array('header' => array('id' => 'kronolith-toggle-remote', 'label' => _("Remote Calendars"), 'collapsed' => true, 'add' => array('url' => Horde::url('calendars/remote_subscribe.php'), 'label' => _("Subscribe to a Remote Calendar")))); $edit = Horde::url('calendars/remote_edit.php'); foreach ($calendar_manager->get(Kronolith::ALL_REMOTE_CALENDARS) as $calendar) { $row = array('selected' => in_array($calendar->url(), $calendar_manager->get(Kronolith::DISPLAY_REMOTE_CALENDARS)), 'url' => $url->copy()->add('toggle_calendar', 'remote_' . $calendar->url()), 'label' => $calendar->name(), 'color' => $calendar->background(), 'edit' => $edit->add('url', $calendar->url()), 'type' => 'checkbox'); $sidebar->addRow($row, 'remote'); } if (!empty($conf['holidays']['enable'])) { $sidebar->containers['holidays'] = array('header' => array('id' => 'kronolith-toggle-holidays', 'label' => _("Holidays"), 'collapsed' => true)); foreach ($calendar_manager->get(Kronolith::ALL_HOLIDAYS) as $id => $calendar) { $row = array('selected' => in_array($id, $calendar_manager->get(Kronolith::DISPLAY_HOLIDAYS)), 'url' => $url->copy()->add('toggle_calendar', 'holiday_' . $id), 'label' => $calendar->name(), 'color' => $calendar->background(), 'type' => 'checkbox'); $sidebar->addRow($row, 'holidays'); } } }
public function html() { global $prefs; if (!$this->_parsed) { $this->parse(); } $started = false; $first_row = true; $addLinks = Kronolith::getDefaultCalendar(Horde_Perms::EDIT) && ($GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') > Kronolith::countEvents()); $showLocation = Kronolith::viewShowLocation(); $showTime = Kronolith::viewShowTime(); require KRONOLITH_TEMPLATES . '/day/head.inc'; if ($this->sidebyside) { require KRONOLITH_TEMPLATES . '/day/head_side_by_side.inc'; } echo '<tbody>'; if ($addLinks) { $newEventUrl = Horde::url('new.php')->add(array('datetime' => sprintf($this->dateString() . '%02d%02d00', $this->slots[0]['hour'], $this->slots[0]['min']), 'allday' => 1, 'url' => $this->link(0, true)))->link(array('title' => _("Create a New Event"))) . _("All day") . '</a>'; } else { $newEventUrl = _("All day"); } $row = '<td colspan="' . $this->totalspan . '">'; foreach (array_keys($this->_currentCalendars) as $cid) { foreach ($this->all_day_events[$cid] as $event) { $row .= '<div class="kronolith-event"' . $event->getCSSColors() . '>' . $event->getLink($this, true, $this->link(0, true)); if (!$event->isPrivate() && $showLocation) { $row .= '<span class="event-location">' . htmlspecialchars($event->getLocation()) . '</span>'; } $row .= '</div>'; } } $row .= '</td>'; require KRONOLITH_TEMPLATES . '/day/all_day.inc'; $day_hour_force = $prefs->getValue('day_hour_force'); $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->slotsPerHour; $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->slotsPerHour; $rows = array(); $covered = array(); for ($i = 0; $i < $this->slotsPerDay; ++$i) { if ($i >= $day_hour_end && $i > $this->_last) { break; } if ($i < $this->_first && $i < $day_hour_start) { continue; } $row = ''; if (!count($this->_currentCalendars)) { $row .= '<td> </td>'; } foreach (array_keys($this->_currentCalendars) as $cid) { $hspan = 0; foreach ($this->_event_matrix[$cid][$i] as $key) { $event =& $this->events[$key]; // Since we've made sure that this event's overlap is a // factor of the total span, we get this event's // individual span by dividing the total span by this // event's overlap. $span = $this->span[$cid] / $event->overlap; // Store the indent we're starting this event at // for future use. if (!isset($event->indent)) { $event->indent = $hspan; } // If the first node that we would cover is // already covered, we can assume that table // rendering will take care of pushing the event // over. However, if the first node _isn't_ // covered but any others that we would cover // _are_, we only cover the available nodes. if (!isset($covered[$i][$event->indent])) { $collision = false; $available = 0; for ($y = $event->indent; $y < $span + $event->indent; ++$y) { if (isset($covered[$i][$y])) { $collision = true; break; } $available++; } if ($collision) { $span = $available; } } $hspan += $span; $start = new Horde_Date(array('hour' => floor($i / $this->slotsPerHour), 'min' => $i % $this->slotsPerHour * $this->slotLength, 'month' => $this->month, 'mday' => $this->mday, 'year' => $this->year)); $end_slot = new Horde_Date($start); $end_slot->min += $this->slotLength; if ((!$day_hour_force || $i >= $day_hour_start) && $event->start->compareDateTime($start) >= 0 && $event->start->compareDateTime($end_slot) < 0 || $start->compareDateTime($this) == 0 || $day_hour_force && $i == $day_hour_start && $event->start->compareDateTime($start) < 0) { // Store the nodes that we're covering for // this event in the coverage graph. for ($x = $i; $x < $i + $event->rowspan; ++$x) { for ($y = $event->indent; $y < $hspan; ++$y) { $covered[$x][$y] = true; } } $row .= '<td class="kronolith-event"' . $event->getCSSColors() . 'width="' . round(90 / count($this->_currentCalendars) * ($span / $this->span[$cid])) . '%" ' . 'valign="top" colspan="' . $span . '" rowspan="' . $event->rowspan . '">' . '<div class="kronolith-event-info">'; if ($showTime) { $row .= '<span class="kronolith-time">' . htmlspecialchars($event->getTimeRange()) . '</span>'; } $row .= $event->getLink($this, true, $this->link(0, true)); if (!$event->isPrivate() && $showLocation) { $row .= '<span class="kronolith-location">' . htmlspecialchars($event->getLocation()) . '</span>'; } $row .= '</div></td>'; } } $diff = $this->span[$cid] - $hspan; if ($diff > 0) { $row .= '<td colspan="' . $diff . '"> </td>'; } } $time = $this->prefHourFormat($this->slots[$i]['hour'], $i % $this->slotsPerHour * $this->slotLength); if ($addLinks) { $newEventUrl = Horde::url('new.php')->add(array('datetime' => sprintf($this->dateString() . '%02d%02d00', $this->slots[$i]['hour'], $this->slots[$i]['min']), 'url' => $this->link(0, true)))->link(array('title' => _("Create a New Event"))) . $time . '</a>'; } else { $newEventUrl = $time; } $rows[] = array('row' => $row, 'slot' => $newEventUrl); } $template = $GLOBALS['injector']->createInstance('Horde_Template'); $template->set('rows', $rows); $template->set('show_slots', true, true); echo $template->fetch(KRONOLITH_TEMPLATES . '/day/rows.html') . '</tbody></table>'; }
public function html() { global $prefs; $sidebyside = $prefs->getValue('show_shared_side_by_side'); $twentyFour = $prefs->getValue('twentyFour'); $addLinks = Kronolith::getDefaultCalendar(Horde_Perms::EDIT) && ($GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') > Kronolith::countEvents()); if ($sidebyside) { require KRONOLITH_TEMPLATES . '/month/head_side_by_side.inc'; } else { require KRONOLITH_TEMPLATES . '/month/head.inc'; } $html = ''; if (!$sidebyside && count($this->_currentCalendars)) { $html .= '<tr>'; } $showLocation = Kronolith::viewShowLocation(); $showTime = Kronolith::viewShowTime(); $day_url = Horde::url('day.php'); $this_link = $this->link(0, true); $new_url = Horde::url('new.php')->add('url', $this_link); $new_img = Horde::img('new_small.png', '+'); foreach ($this->_currentCalendars as $id => $cal) { if ($sidebyside) { $html .= '<tr>'; } $cell = 0; for ($day = $this->_startOfView; $day < $this->_startOfView + $this->_daysInView; ++$day) { $date = new Kronolith_Day($this->month, $day, $this->year); $date->hour = $twentyFour ? 12 : 6; $week = $date->weekOfYear(); if ($cell % 7 == 0) { $weeklink = Horde::url('week.php')->add('date', $date->dateString())->link(array('class' => 'kronolith-weeklink')) . ($sidebyside ? sprintf(_("Week %d"), $week) : $week) . '</a>'; if ($sidebyside) { $html .= sprintf('<td class="kronolith-first-col">%s<br />%s</td>', $weeklink, htmlspecialchars(Kronolith::getLabel($cal))); } else { if ($cell != 0) { $html .= "</tr>\n<tr>"; } $html .= '<td class="kronolith-first-col">' . $weeklink . '</td>'; } } if ($date->isToday()) { $style = ' class="kronolith-today"'; } elseif ($date->month != $this->month) { $style = ' class="kronolith-other-month"'; } elseif ($date->dayOfWeek() == 0 || $date->dayOfWeek() == 6) { $style = ' class="kronolith-weekend"'; } else { $style = ''; } $html .= '<td' . $style . '><div class="kronolith-day">'; $html .= $day_url->add('date', $date->dateString())->link() . $date->mday . '</a>'; if ($addLinks) { $new_url->add('date', $date->dateString()); if ($sidebyside) { $new_url->add('calendar', $id); } $html .= $new_url->link(array('title' => _("Create a New Event"), 'class' => 'newEvent')) . $new_img . '</a>'; } $html .= '</div>'; $date_stamp = $date->dateString(); if (!empty($this->_events[$date_stamp])) { foreach ($this->_events[$date_stamp] as $event) { if (!$sidebyside || $event->calendar == $id) { $html .= '<div class="kronolith-event"' . $event->getCSSColors() . '>'; if ($showTime && !$event->isAllDay()) { $html .= '<span class="kronolith-time">' . htmlspecialchars($event->getTimeRange()) . '</span>'; } $html .= $event->getLink($date, true, $this_link); if (!$event->isPrivate() && $showLocation) { $html .= '<span class="kronolith-location">' . htmlspecialchars($event->getLocation()) . '</span>'; } $html .= '</div>'; } } } $html .= "</td>\n"; ++$cell; } if ($sidebyside) { $html .= '</tr>'; } } if (!$sidebyside && count($this->_currentCalendars)) { $html .= '</tr>'; } echo $html . '</tbody></table>'; }