function _check_max() { $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'))); return false; } return true; }
/** * Save a new or update an existing event from the AJAX event detail view. * * Request parameters used: * - event: The event id. * - cal: The calendar id. * - targetcalendar: If moving events, the targetcalendar to move to. * - as_new: Save an existing event as a new event. * - recur_edit: If editing an instance of a recurring event series, * how to apply the edit [current|future|all]. * - rstart: If editing an instance of a recurring event series, * the original start datetime of this instance. * - rend: If editing an instance of a recurring event series, * the original ending datetime of this instance. * - sendupdates: Should updates be sent to attendees? * - cstart: Start time of the client cache. * - cend: End time of the client cache. */ public function saveEvent() { global $injector, $notification, $registry; $result = $this->_signedResponse($this->vars->targetcalendar); if (!($kronolith_driver = $this->_getDriver($this->vars->targetcalendar))) { return $result; } if ($this->vars->as_new) { unset($this->vars->event); } if (!$this->vars->event) { $perms = $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'))); return $result; } } if ($this->vars->event && $this->vars->cal && $this->vars->cal != $this->vars->targetcalendar) { if (strpos($kronolith_driver->calendar, '\\')) { list($target, $user) = explode('\\', $kronolith_driver->calendar, 2); } else { $target = $kronolith_driver->calendar; $user = $registry->getAuth(); } $kronolith_driver = $this->_getDriver($this->vars->cal); // Only delete the event from the source calendar if this user has // permissions to do so. try { $sourceShare = Kronolith::getInternalCalendar($kronolith_driver->calendar); $share = Kronolith::getInternalCalendar($target); if ($sourceShare->hasPermission($registry->getAuth(), Horde_Perms::DELETE) && ($user == $registry->getAuth() && $share->hasPermission($registry->getAuth(), Horde_Perms::EDIT) || $user != $registry->getAuth() && $share->hasPermission($registry->getAuth(), Kronolith::PERMS_DELEGATE))) { $kronolith_driver->move($this->vars->event, $target); $kronolith_driver = $this->_getDriver($this->vars->targetcalendar); } } catch (Exception $e) { $notification->push(sprintf(_("There was an error moving the event: %s"), $e->getMessage()), 'horde.error'); return $result; } } if ($this->vars->as_new) { $event = $kronolith_driver->getEvent(); } else { try { // Note that when this is a new event, $this->vars->event will // be empty, so this will create a new event. $event = $kronolith_driver->getEvent($this->vars->event); } catch (Horde_Exception_NotFound $e) { $notification->push(_("The requested event was not found."), 'horde.error'); return $result; } catch (Exception $e) { $notification->push($e); return $result; } } if (!$event->hasPermission(Horde_Perms::EDIT)) { $notification->push(_("You do not have permission to edit this event."), 'horde.warning'); return $result; } $removed_attendees = $old_attendees = array(); if ($this->vars->recur_edit && $this->vars->recur_edit != 'all') { switch ($this->vars->recur_edit) { case 'current': $attributes = new stdClass(); $attributes->rstart = $this->vars->rstart; $attributes->rend = $this->vars->rend; $this->_addException($event, $attributes); // Create a copy of the original event so we can read in the // new form values for the exception. We also MUST reset the // recurrence property even though we won't be using it, since // clone() does not do a deep copy. Otherwise, the original // event's recurrence will become corrupt. $newEvent = clone $event; $newEvent->recurrence = new Horde_Date_Recurrence($event->start); $newEvent->readForm($event); // Create an exception event from the new properties. $exception = $this->_copyEvent($event, $newEvent, $attributes); $exception->start = $newEvent->start; $exception->end = $newEvent->end; // Save the new exception. $attributes->cstart = $this->vars->cstart; $attributes->cend = $this->vars->cend; $result = $this->_saveEvent($exception, $event, $attributes); break; case 'future': $instance = new Horde_Date($this->vars->rstart, $event->timezone); $exception = clone $instance; $exception->mday--; if ($event->end->compareDate($exception) > 0) { // Same as 'all' since this is the first recurrence. $this->vars->recur_edit = 'all'; return $this->saveEvent(); } else { $event->recurrence->setRecurEnd($exception); $newEvent = $kronolith_driver->getEvent(); $newEvent->readForm(); $newEvent->uid = null; $result = $this->_saveEvent($newEvent, $event, $this->vars, true); } } } else { try { $old_attendees = $event->attendees; $event->readForm(); $removed_attendees = array_diff(array_keys($old_attendees), array_keys($event->attendees)); $result = $this->_saveEvent($event); } catch (Exception $e) { $notification->push($e); return $result; } } if ($result !== true && $this->vars->sendupdates) { $type = $event->status == Kronolith::STATUS_CANCELLED ? Kronolith::ITIP_CANCEL : Kronolith::ITIP_REQUEST; Kronolith::sendITipNotifications($event, $notification, $type); } // Send a CANCEL iTip for attendees that have been removed, but only if // the entire event isn't being marked as cancelled (which would be // caught above). if (!empty($removed_attendees)) { $to_cancel = array(); foreach ($removed_attendees as $email) { $to_cancel[$email] = $old_attendees[$email]; } $cancelEvent = clone $event; Kronolith::sendITipNotifications($cancelEvent, $notification, Kronolith::ITIP_CANCEL, null, null, $to_cancel); } Kronolith::notifyOfResourceRejection($event); return $result; }
* Copyright 1999-2016 Horde LLC (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.horde.org/licenses/gpl. * * @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 {
if ($data) { $notification->push($e, 'horde.error'); $next_step = $data->cleanup(); } else { $notification->push(_("This file format is not supported."), 'horde.error'); $next_step = Horde_Data::IMPORT_FILE; } } } /* We have a final result set. */ if (is_array($next_step)) { $events = array(); $error = false; $max_events = $perms->hasAppPermission('max_events'); if ($max_events !== true) { $num_events = Kronolith::countEvents(); } list($type, $calendar) = explode('_', $storage->get('import_cal'), 2); $kronolith_driver = Kronolith::getDriver($type, $calendar); if (!count($next_step)) { $notification->push(sprintf(_("The %s file didn't contain any events."), $file_types[$storage->get('format')]), 'horde.error'); $error = true; } else { /* Purge old calendar if requested. */ if ($storage->get('purge')) { try { $kronolith_driver->delete($calendar); $notification->push(_("Calendar successfully purged."), 'horde.success'); } catch (Exception $e) { $notification->push(sprintf(_("The calendar could not be purged: %s"), $e->getMessage()), 'horde.error'); }
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); } } }
/** * 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>'; }