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); } } }
/** * Responsible for any logic needed before the event is saved. Called for * EVERY component in the iCalendar object. Returning false from this method * will cause the current component to be ignored. Returning true causes it * to be processed. * * @param Horde_Icalendar $component The iCalendar component. * * @return boolean True to continue processing, false to ignore. */ protected function _preSave($component) { // Short circuit if we know we don't pass the parent test. if (!parent::_preSave($component)) { return false; } // Ensure we start with a fresh state. $this->_existingEvent = null; $this->_oldAttendees = new Kronolith_Attendee_List(); $this->_noItips = array(); // Get the internal id of the existing copy of the event, if it exists. try { $existing_id = $this->_dav->getInternalObjectId($this->_params['object'], $this->_calendar) ?: preg_replace('/\\.ics$/', '', $this->_params['object']); } catch (Horde_Dav_Exception $e) { $existing_id = $this->_params['object']; } // Check that we don't have newer information already on the server. try { // Exception event, so we can't compare timestamps using ids. // Instead look for baseid/recurrence-id. $rid = $component->getAttribute('RECURRENCE-ID'); $uid = $component->getAttribute('UID'); if (!empty($rid) && !empty($uid)) { $search = new stdClass(); $search->baseid = $uid; $search->recurrenceid = $rid; $results = $this->_driver->search($search); foreach ($results as $days) { foreach ($days as $exception) { // Should only be one... $modified = $exception->modified ?: $exception->created; } } } } catch (Horde_Icalendar_Exception $e) { // Base event or event with no recurrence. try { $this->_existingEvent = $this->_driver->getEvent($existing_id); $this->_existingEvent->loadHistory(); $modified = $this->_existingEvent->modified ?: $this->_existingEvent->created; // Get list of existing attendees. $this->_oldAttendees = $this->_existingEvent->attendees; } catch (Horde_Exception_NotFound $e) { $this->_existingEvent = null; } } try { if (!empty($modified) && $component->getAttribute('LAST-MODIFIED') < $modified->timestamp()) { /* LAST-MODIFIED timestamp of existing entry is newer: * don't replace it. */ return false; } } catch (Horde_Icalendar_Exception $e) { } try { $organizer = $component->getAttribute('ORGANIZER'); $organizer_params = $component->getAttribute('ORGANIZER', true); if (!empty($organizer_params[0]['SCHEDULE-AGENT']) && ($organizer_params[0]['SCHEDULE-AGENT'] == 'CLIENT' || $organizer_params[0]['SCHEDULE-AGENT'] == 'NONE')) { $tmp = str_replace(array('MAILTO:', 'mailto:'), '', $organizer); $tmp = new Horde_Mail_Rfc822_Address($tmp); $this->_noItips[] = $tmp->bare_address; } } catch (Horde_Icalendar_Exception $e) { } try { $attendee = $component->getAttribute('ATTENDEE'); $params = $component->getAttribute('ATTENDEE', true); for ($i = 0; $i < count($attendee); ++$i) { if (!empty($params[$i]['SCHEDULE-AGENT']) && ($params[$i]['SCHEDULE-AGENT'] == 'CLIENT' || $params[$i]['SCHEDULE-AGENT'] == 'NONE')) { $tmp = str_replace(array('MAILTO:', 'mailto:'), '', $attendee[$i]); $tmp = new Horde_Mail_Rfc822_Address($tmp); $this->_noItips[] = $tmp->bare_address; } } } catch (Horde_Icalendar_Exception $e) { } return true; }