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:  * Copyright 1999-2012 Horde LLC (http://www.horde.org/)
  4:  *
  5:  * See the enclosed file COPYING for license information (GPL). If you
  6:  * did not receive this file, see http://www.horde.org/licenses/gpl.
  7:  *
  8:  * @author  Luc Saillard <luc.saillard@fr.alcove.com>
  9:  * @author  Chuck Hagenbuch <chuck@horde.org>
 10:  * @author  Jan Schneider <jan@horde.org>
 11:  * @package Kronolith
 12:  */
 13: class Kronolith_Event_Sql extends Kronolith_Event
 14: {
 15:     /**
 16:      * The type of the calender this event exists on.
 17:      *
 18:      * @var string
 19:      */
 20:     public $calendarType = 'internal';
 21: 
 22:     /**
 23:      * Const'r
 24:      *
 25:      * @param Kronolith_Driver $driver  The backend driver that this event is
 26:      *                                  stored in.
 27:      * @param mixed $eventObject        Backend specific event object
 28:      *                                  that this will represent.
 29:      */
 30:     public function __construct($driver, $eventObject = null)
 31:     {
 32:         /* Set default alarm value. */
 33:         if (!isset($alarm) && isset($GLOBALS['prefs'])) {
 34:             $this->alarm = $GLOBALS['prefs']->getValue('default_alarm');
 35:         }
 36: 
 37:         parent::__construct($driver, $eventObject);
 38: 
 39:         if (!empty($this->calendar) &&
 40:             isset($GLOBALS['all_calendars'][$this->calendar])) {
 41:             $this->_backgroundColor = $GLOBALS['all_calendars'][$this->calendar]->background();
 42:             $this->_foregroundColor = $GLOBALS['all_calendars'][$this->calendar]->foreground();
 43:         }
 44:     }
 45: 
 46:     /**
 47:      * Imports a backend specific event object.
 48:      *
 49:      * @param array $event  Backend specific event object that this object
 50:      *                      will represent.
 51:      */
 52:     public function fromDriver($SQLEvent)
 53:     {
 54:         $driver = $this->getDriver();
 55: 
 56:         $this->allday = (bool)$SQLEvent['event_allday'];
 57:         if (!$this->allday && $driver->getParam('utc')) {
 58:             $tz_local = date_default_timezone_get();
 59:             $this->start = new Horde_Date($SQLEvent['event_start'], 'UTC');
 60:             $this->start->setTimezone($tz_local);
 61:             $this->end = new Horde_Date($SQLEvent['event_end'], 'UTC');
 62:             $this->end->setTimezone($tz_local);
 63:         } else {
 64:             $this->start = new Horde_Date($SQLEvent['event_start']);
 65:             $this->end = new Horde_Date($SQLEvent['event_end']);
 66:         }
 67: 
 68:         $this->durMin = ($this->end->timestamp() - $this->start->timestamp()) / 60;
 69: 
 70:         $this->title = $driver->convertFromDriver($SQLEvent['event_title']);
 71:         $this->id = $SQLEvent['event_id'];
 72:         $this->uid = $SQLEvent['event_uid'];
 73:         $this->creator = $SQLEvent['event_creator_id'];
 74: 
 75:         if (!empty($SQLEvent['event_recurtype'])) {
 76:             $this->recurrence = new Horde_Date_Recurrence($this->start);
 77:             $this->recurrence->setRecurType((int)$SQLEvent['event_recurtype']);
 78:             $this->recurrence->setRecurInterval((int)$SQLEvent['event_recurinterval']);
 79:             if (isset($SQLEvent['event_recurenddate']) &&
 80:                 $SQLEvent['event_recurenddate'] != '9999-12-31 23:59:59') {
 81:                 if ($driver->getParam('utc')) {
 82:                     $recur_end = new Horde_Date($SQLEvent['event_recurenddate'], 'UTC');
 83:                     if ($recur_end->min == 0) {
 84:                         /* Old recurrence end date format. */
 85:                         $recur_end = new Horde_Date($SQLEvent['event_recurenddate']);
 86:                         $recur_end->hour = 23;
 87:                         $recur_end->min = 59;
 88:                         $recur_end->sec = 59;
 89:                     } else {
 90:                         $recur_end->setTimezone(date_default_timezone_get());
 91:                     }
 92:                 } else {
 93:                     $recur_end = new Horde_Date($SQLEvent['event_recurenddate']);
 94:                     $recur_end->hour = 23;
 95:                     $recur_end->min = 59;
 96:                     $recur_end->sec = 59;
 97:                 }
 98:                 $this->recurrence->setRecurEnd($recur_end);
 99:             }
100:             if (isset($SQLEvent['event_recurcount'])) {
101:                 $this->recurrence->setRecurCount((int)$SQLEvent['event_recurcount']);
102:             }
103:             if (isset($SQLEvent['event_recurdays'])) {
104:                 $this->recurrence->recurData = (int)$SQLEvent['event_recurdays'];
105:             }
106:             if (!empty($SQLEvent['event_exceptions'])) {
107:                 $this->recurrence->exceptions = explode(',', $SQLEvent['event_exceptions']);
108:             }
109:         }
110: 
111:         if (isset($SQLEvent['event_location'])) {
112:             $this->location = $driver->convertFromDriver($SQLEvent['event_location']);
113:         }
114:         if (isset($SQLEvent['event_url'])) {
115:             $this->url = $SQLEvent['event_url'];
116:         }
117:         if (isset($SQLEvent['event_private'])) {
118:             $this->private = (bool)($SQLEvent['event_private']);
119:         }
120:         if (isset($SQLEvent['event_status'])) {
121:             $this->status = (int)$SQLEvent['event_status'];
122:         }
123:         if (isset($SQLEvent['event_attendees'])) {
124:             $this->attendees = array_change_key_case($driver->convertFromDriver(unserialize($SQLEvent['event_attendees'])));
125:         }
126:         if (isset($SQLEvent['event_resources'])) {
127:             $this->_resources = array_change_key_case($driver->convertFromDriver(unserialize($SQLEvent['event_resources'])));
128:         }
129:         if (isset($SQLEvent['event_description'])) {
130:             $this->description = $driver->convertFromDriver($SQLEvent['event_description']);
131:         }
132:         if (isset($SQLEvent['event_alarm'])) {
133:             $this->alarm = (int)$SQLEvent['event_alarm'];
134:         }
135:         if (isset($SQLEvent['event_alarm_methods'])) {
136:             $this->methods = $driver->convertFromDriver(unserialize($SQLEvent['event_alarm_methods']));
137:         }
138:         if (isset($SQLEvent['event_baseid'])) {
139:             $this->baseid = $SQLEvent['event_baseid'];
140:         }
141:         if (isset($SQLEvent['event_exceptionoriginaldate'])) {
142:             $this->exceptionoriginaldate = new Horde_Date($SQLEvent['event_exceptionoriginaldate']);
143:         }
144: 
145:         $this->initialized = true;
146:         $this->stored = true;
147:     }
148: 
149:     /**
150:      * Prepares this event to be saved to the backend.
151:      */
152:     public function toProperties()
153:     {
154:         $driver = $this->getDriver();
155:         $properties = array();
156: 
157:         /* Basic fields. */
158:         $properties['event_creator_id'] = $driver->convertToDriver($this->creator);
159:         $properties['event_title'] = $driver->convertToDriver($this->title);
160:         $properties['event_description'] = $driver->convertToDriver($this->description);
161:         $properties['event_location'] = $driver->convertToDriver($this->location);
162:         $properties['event_url'] = (string)$this->url;
163:         $properties['event_private'] = (int)$this->private;
164:         $properties['event_status'] = $this->status;
165:         $properties['event_attendees'] = serialize($driver->convertToDriver($this->attendees));
166:         $properties['event_resources'] = serialize($driver->convertToDriver($this->getResources()));
167:         $properties['event_modified'] = $_SERVER['REQUEST_TIME'];
168: 
169:         if ($this->isAllDay()) {
170:             $properties['event_start'] = $this->start->strftime('%Y-%m-%d %H:%M:%S');
171:             $properties['event_end'] = $this->end->strftime('%Y-%m-%d %H:%M:%S');
172:             $properties['event_allday'] = 1;
173:         } else {
174:             if ($driver->getParam('utc')) {
175:                 $start = clone $this->start;
176:                 $end = clone $this->end;
177:                 $start->setTimezone('UTC');
178:                 $end->setTimezone('UTC');
179:             } else {
180:                 $start = $this->start;
181:                 $end = $this->end;
182:             }
183:             $properties['event_start'] = $start->strftime('%Y-%m-%d %H:%M:%S');
184:             $properties['event_end'] = $end->strftime('%Y-%m-%d %H:%M:%S');
185:             $properties['event_allday'] = 0;
186:         }
187: 
188:         /* Alarm. */
189:         $properties['event_alarm'] = (int)$this->alarm;
190: 
191:         /* Alarm Notification Methods. */
192:         $properties['event_alarm_methods'] = serialize($driver->convertToDriver($this->methods));
193: 
194:         /* Recurrence. */
195:         if (!$this->recurs()) {
196:             $properties['event_recurtype'] = 0;
197:         } else {
198:             $recur = $this->recurrence->getRecurType();
199:             if ($this->recurrence->hasRecurEnd()) {
200:                 if ($driver->getParam('utc')) {
201:                     $recur_end = clone $this->recurrence->recurEnd;
202:                     $recur_end->setTimezone('UTC');
203:                 } else {
204:                     $recur_end = $this->recurrence->recurEnd;
205:                 }
206:             } else {
207:                 $recur_end = new Horde_Date(array('year' => 9999, 'month' => 12, 'mday' => 31, 'hour' => 23, 'min' => 59, 'sec' => 59));
208:             }
209: 
210:             $properties['event_recurtype'] = $recur;
211:             $properties['event_recurinterval'] = $this->recurrence->getRecurInterval();
212:             $properties['event_recurenddate'] = $recur_end->format('Y-m-d H:i:s');
213:             $properties['event_recurcount'] = $this->recurrence->getRecurCount();
214: 
215:             switch ($recur) {
216:             case Horde_Date_Recurrence::RECUR_WEEKLY:
217:                 $properties['event_recurdays'] = $this->recurrence->getRecurOnDays();
218:                 break;
219:             }
220:             $properties['event_exceptions'] = implode(',', $this->recurrence->getExceptions());
221:         }
222: 
223:         /* Exception information */
224:         if (!empty($this->baseid)) {
225:             $properties['event_baseid'] = $this->baseid;
226:             $properties['event_exceptionoriginaldate'] = $this->exceptionoriginaldate;
227:         }
228: 
229:         return $properties;
230:     }
231: 
232: }
233: 
API documentation generated by ApiGen