Overview

Packages

  • Kronolith
  • None

Classes

  • Kronolith
  • Kronolith_Ajax_Application
  • Kronolith_Ajax_Imple_ContactAutoCompleter
  • Kronolith_Ajax_Imple_Embed
  • Kronolith_Ajax_Imple_TagActions
  • Kronolith_Ajax_Imple_TagAutoCompleter
  • Kronolith_Api
  • Kronolith_Calendar
  • Kronolith_Calendar_External
  • Kronolith_Calendar_External_Tasks
  • Kronolith_Calendar_Holiday
  • Kronolith_Calendar_Internal
  • Kronolith_Calendar_Remote
  • Kronolith_Calendar_Resource
  • Kronolith_Calendars_Base
  • Kronolith_Calendars_Default
  • Kronolith_Calendars_Kolab
  • Kronolith_Day
  • Kronolith_Driver
  • Kronolith_Driver_Holidays
  • Kronolith_Driver_Horde
  • Kronolith_Driver_Ical
  • Kronolith_Driver_Kolab
  • Kronolith_Driver_Mock
  • Kronolith_Driver_Resource
  • Kronolith_Driver_Sql
  • Kronolith_Event
  • Kronolith_Event_Holidays
  • Kronolith_Event_Horde
  • Kronolith_Event_Ical
  • Kronolith_Event_Kolab
  • Kronolith_Event_Resource
  • Kronolith_Event_Sql
  • Kronolith_Exception
  • Kronolith_Factory_Calendars
  • Kronolith_Factory_Geo
  • Kronolith_Form_CreateCalendar
  • Kronolith_Form_CreateResource
  • Kronolith_Form_CreateResourceGroup
  • Kronolith_Form_DeleteCalendar
  • Kronolith_Form_DeleteResource
  • Kronolith_Form_DeleteResourceGroup
  • Kronolith_Form_EditCalendar
  • Kronolith_Form_EditRemoteCalendar
  • Kronolith_Form_EditResource
  • Kronolith_Form_EditResourceGroup
  • Kronolith_Form_SubscribeRemoteCalendar
  • Kronolith_Form_UnsubscribeRemoteCalendar
  • Kronolith_FreeBusy
  • Kronolith_FreeBusy_View
  • Kronolith_FreeBusy_View_Day
  • Kronolith_FreeBusy_View_Month
  • Kronolith_FreeBusy_View_Week
  • Kronolith_FreeBusy_View_Workweek
  • Kronolith_Geo_Base
  • Kronolith_Geo_Mysql
  • Kronolith_Geo_Sql
  • Kronolith_LoginTasks_SystemTask_Upgrade
  • Kronolith_LoginTasks_Task_PurgeEvents
  • Kronolith_Notification_Listener_AjaxStatus
  • Kronolith_Resource
  • Kronolith_Resource_Base
  • Kronolith_Resource_Group
  • Kronolith_Resource_Single
  • Kronolith_Storage
  • Kronolith_Storage_Kolab
  • Kronolith_Storage_Sql
  • Kronolith_Tagger
  • Kronolith_Test
  • Kronolith_View_Day
  • Kronolith_View_DeleteEvent
  • Kronolith_View_EditEvent
  • Kronolith_View_Event
  • Kronolith_View_ExportEvent
  • Kronolith_View_Month
  • Kronolith_View_Week
  • Kronolith_View_WorkWeek
  • Kronolith_View_Year
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * The Kronolith_View_EditEvent:: class provides an API for viewing
  4:  * event edit forms.
  5:  *
  6:  * @author  Chuck Hagenbuch <chuck@horde.org>
  7:  * @package Kronolith
  8:  */
  9: class Kronolith_View_EditEvent
 10: {
 11:     /**
 12:      *
 13:      * @var Kronolith_Event
 14:      */
 15:     protected $_event;
 16: 
 17:     /**
 18:      * @param Kronolith_Event $event
 19:      */
 20:     public function __construct(Kronolith_Event $event)
 21:     {
 22:         $this->_event = $event;
 23:     }
 24: 
 25:     public function __get($property)
 26:     {
 27:         switch ($property) {
 28:         case 'event':
 29:             return $this->_event;
 30:         default:
 31:             throw new Kronolith_Exception('Property does not exist.');
 32:         }
 33:     }
 34: 
 35:     public function getTitle()
 36:     {
 37:         if (!$this->_event) {
 38:             return _("Not Found");
 39:         }
 40:         if (is_string($this->_event)) {
 41:             return $this->_event;
 42:         }
 43:         return sprintf(_("Edit %s"), $this->_event->getTitle());
 44:     }
 45: 
 46:     public function link()
 47:     {
 48:         return $this->_event->getEditUrl();
 49:     }
 50: 
 51:     public function html($active = true)
 52:     {
 53:         if (!$this->_event) {
 54:             echo '<h3>' . _("Event not found") . '</h3>';
 55:             exit;
 56:         }
 57:         if (is_string($this->_event)) {
 58:             echo '<h3>' . $this->_event . '</h3>';
 59:             exit;
 60:         }
 61: 
 62:         $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
 63: 
 64:         if ($this->_event->hasPermission(Horde_Perms::EDIT)) {
 65:             $calendar_id = $this->_event->calendarType . '_' . $this->_event->calendar;
 66:         } else {
 67:             $calendar_id = 'internal_' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT);
 68:         }
 69:         if (!$this->_event->hasPermission(Horde_Perms::EDIT)) {
 70:             try {
 71:                 $calendar_id .= '\\' . $this->_event->getShare()->get('owner');
 72:             } catch (Exception $e) {
 73:             }
 74:         }
 75:         $GLOBALS['session']->set('kronolith', 'attendees', $this->_event->attendees);
 76:         $GLOBALS['session']->set('kronolith', 'resources', $this->_event->getResources());
 77:         if ($datetime = Horde_Util::getFormData('datetime')) {
 78:             $datetime = new Horde_Date($datetime);
 79:             $month = $datetime->month;
 80:             $year = $datetime->year;
 81:         } else {
 82:             $month = Horde_Util::getFormData('month', date('n'));
 83:             $year = Horde_Util::getFormData('year', date('Y'));
 84:         }
 85: 
 86:         $url = Horde_Util::getFormData('url');
 87:         $perms = Horde_Perms::EDIT;
 88:         if ($this->_event->creator == $GLOBALS['registry']->getAuth()) {
 89:             $perms |= Kronolith::PERMS_DELEGATE;
 90:         }
 91:         $calendars = Kronolith::listCalendars($perms, true);
 92: 
 93:         $buttons = array();
 94:         if (!$this->_event->hasPermission(Horde_Perms::EDIT) &&
 95:             ($GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') === true ||
 96:              $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') > Kronolith::countEvents())) {
 97:             $buttons[] = '<input type="submit" class="button" name="saveAsNew" value="' . _("Save As New") . '" />';
 98:         } else {
 99:             if ($this->_event->hasPermission(Horde_Perms::EDIT)) {
100:                 $buttons[] = '<input type="submit" class="button" name="save" value="' . _("Save Event") . '" />';
101:             }
102:             if ($this->_event->initialized) {
103:                 if (!$this->_event->recurs() &&
104:                     ($GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') === true ||
105:                      $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_events') > Kronolith::countEvents())) {
106:                     $buttons[] = '<input type="submit" class="button" name="saveAsNew" value="' . _("Save As New") . '" />';
107:                 }
108:             }
109:         }
110: 
111:         if (isset($url)) {
112:             $cancelurl = new Horde_Url($url);
113:         } else {
114:             $cancelurl = Horde::url('month.php', true)
115:                 ->add(array('month' => $month, 'year' => $year));
116:         }
117: 
118:         $event = &$this->_event;
119:         $tags = implode(',', array_values($event->tags));
120: 
121:         Horde_Core_Ui_JsCalendar::init(array(
122:             'full_weekdays' => true
123:         ));
124: 
125:         Horde::addScriptFile('edit.js', 'kronolith');
126:         Horde::addScriptFile('popup.js', 'horde');
127: 
128:         echo '<div id="EditEvent"' . ($active ? '' : ' style="display:none"') . '>';
129:         require KRONOLITH_TEMPLATES . '/edit/edit.inc';
130:         echo '</div>';
131: 
132:         if ($active && $GLOBALS['browser']->hasFeature('dom')) {
133:             if ($this->_event->hasPermission(Horde_Perms::READ)) {
134:                 $view = new Kronolith_View_Event($this->_event);
135:                 $view->html(false);
136:             }
137:             if ($this->_event->hasPermission(Horde_Perms::DELETE)) {
138:                 $delete = new Kronolith_View_DeleteEvent($this->_event);
139:                 $delete->html(false);
140:             }
141:         }
142:     }
143: 
144:     public function getName()
145:     {
146:         return 'EditEvent';
147:     }
148: 
149: }
150: 
API documentation generated by ApiGen