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 2004-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  Thomas Jarosch <thomas.jarosch@intra2net.com>
  9:  * @author  Gunnar Wrobel <wrobel@pardus.de>
 10:  * @author  Stuart Binge <omicron@mighty.co.za>
 11:  * @package Kronolith
 12:  */
 13: class Kronolith_Event_Kolab 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:         static $alarm;
 33: 
 34:         /* Set default alarm value. */
 35:         if (!isset($alarm) && isset($GLOBALS['prefs'])) {
 36:             $alarm = $GLOBALS['prefs']->getValue('default_alarm');
 37:         }
 38: 
 39:         $this->alarm = $alarm;
 40: 
 41:         parent::__construct($driver, $eventObject);
 42:     }
 43: 
 44:     /**
 45:      * Imports a backend specific event object.
 46:      *
 47:      * @param array $event  Backend specific event object that this object
 48:      *                      will represent.
 49:      */
 50:     public function fromDriver($event)
 51:     {
 52:         $this->id = $event['uid'];
 53:         $this->uid = $this->id;
 54: 
 55:         if (isset($event['summary'])) {
 56:             $this->title = $event['summary'];
 57:         }
 58:         if (isset($event['body'])) {
 59:             $this->description = $event['body'];
 60:         }
 61:         if (isset($event['location'])) {
 62:             $this->location = $event['location'];
 63:         }
 64: 
 65:         if (isset($event['sensitivity']) &&
 66:             ($event['sensitivity'] == 'private' || $event['sensitivity'] == 'confidential')) {
 67:             $this->private = true;
 68:         }
 69: 
 70:         if (isset($event['organizer']['smtp-address'])) {
 71:             if (Kronolith::isUserEmail($GLOBALS['registry']->getAuth(), $event['organizer']['smtp-address'])) {
 72:                 $this->creator = $GLOBALS['registry']->getAuth();
 73:             } else {
 74:                 $this->creator = $event['organizer']['smtp-address'];
 75:             }
 76:         }
 77: 
 78:         if (isset($event['alarm'])) {
 79:             $this->alarm = $event['alarm'];
 80:         }
 81: 
 82:         $this->start = new Horde_Date($event['start-date']);
 83:         $this->end = new Horde_Date($event['end-date']);
 84:         $this->durMin = ($this->end->timestamp() - $this->start->timestamp()) / 60;
 85: 
 86:         if (isset($event['show-time-as'])) {
 87:             switch ($event['show-time-as']) {
 88:                 case 'free':
 89:                     $this->status = Kronolith::STATUS_FREE;
 90:                     break;
 91: 
 92:                 case 'tentative':
 93:                     $this->status = Kronolith::STATUS_TENTATIVE;
 94:                     break;
 95: 
 96:                 case 'busy':
 97:                 case 'outofoffice':
 98:                 default:
 99:                     $this->status = Kronolith::STATUS_CONFIRMED;
100:             }
101:         } else {
102:             $this->status = Kronolith::STATUS_CONFIRMED;
103:         }
104: 
105:         // Recurrence
106:         if (isset($event['recurrence'])) {
107:             if (isset($event['recurrence']['exclusion'])) {
108:                 $exceptions = array();
109:                 foreach($event['recurrence']['exclusion'] as $exclusion) {
110:                     if (!empty($exclusion)) {
111:                         $exceptions[] = join('', explode('-', $exclusion));
112:                     }
113:                 }
114:                 $event['recurrence']['exceptions'] = $exceptions;
115:             }
116:             if (isset($event['recurrence']['complete'])) {
117:                 $completions = array();
118:                 foreach($event['recurrence']['complete'] as $complete) {
119:                     if (!empty($complete)) {
120:                         $completions[] = join('', explode('-', $complete));
121:                     }
122:                 }
123:                 $event['recurrence']['completions'] = $completions;
124:             }
125:             $this->recurrence = new Horde_Date_Recurrence($this->start);
126:             $this->recurrence->fromHash($event['recurrence']);
127:         }
128: 
129:         // Attendees
130:         $attendee_count = 0;
131:         if (!empty($event['attendee'])) {
132:             foreach($event['attendee'] as $attendee) {
133:                 $name = $attendee['display-name'];
134:                 $email = $attendee['smtp-address'];
135: 
136:                 $role = $attendee['role'];
137:                 switch ($role) {
138:                 case 'optional':
139:                     $role = Kronolith::PART_OPTIONAL;
140:                     break;
141: 
142:                 case 'resource':
143:                     $role = Kronolith::PART_NONE;
144:                     break;
145: 
146:                 case 'required':
147:                 default:
148:                     $role = Kronolith::PART_REQUIRED;
149:                 break;
150:                 }
151: 
152:                 $status = $attendee['status'];
153:                 switch ($status) {
154:                 case 'accepted':
155:                     $status = Kronolith::RESPONSE_ACCEPTED;
156:                     break;
157: 
158:                 case 'declined':
159:                     $status = Kronolith::RESPONSE_DECLINED;
160:                     break;
161: 
162:                 case 'tentative':
163:                     $status = Kronolith::RESPONSE_TENTATIVE;
164:                     break;
165: 
166:                 case 'none':
167:                 default:
168:                     $status = Kronolith::RESPONSE_NONE;
169:                     break;
170:                 }
171: 
172:                 // Attendees without an email address get added as incremented number
173:                 if (empty($email)) {
174:                     $email = $attendee_count;
175:                     $attendee_count++;
176:                 }
177: 
178:                 $this->addAttendee($email, $role, $status, $name);
179:             }
180:         }
181: 
182:         $this->initialized = true;
183:         $this->stored = true;
184:     }
185: 
186:     /**
187:      * Prepares this event to be saved to the backend.
188:      */
189:     public function toKolab()
190:     {
191:         $event = array();
192:         $event['uid'] = $this->uid;
193:         $event['summary'] = $this->title;
194:         $event['body']  = $this->description;
195:         $event['location'] = $this->location;
196:         $event['sensitivity'] = $this->private ? 'private' : 'public';
197: 
198:         // Only set organizer if this is a new event
199:         if ($this->_id == null) {
200:             $organizer = array(
201:                 'display-name' => Kronolith::getUserName($this->creator),
202:                 'smtp-address' => Kronolith::getUserEmail($this->creator)
203:             );
204:             $event['organizer'] = $organizer;
205:         }
206: 
207:         if ($this->alarm != 0) {
208:             $event['alarm'] = $this->alarm;
209:         }
210: 
211:         $event['start-date'] = $this->start->timestamp();
212:         $event['end-date'] = $this->end->timestamp();
213:         $event['_is_all_day'] = $this->isAllDay();
214: 
215:         switch ($this->status) {
216:         case Kronolith::STATUS_FREE:
217:         case Kronolith::STATUS_CANCELLED:
218:             $event['show-time-as'] = 'free';
219:             break;
220: 
221:         case Kronolith::STATUS_TENTATIVE:
222:             $event['show-time-as'] = 'tentative';
223:             break;
224: 
225:         // No mapping for outofoffice
226:         case Kronolith::STATUS_CONFIRMED:
227:         default:
228:             $event['show-time-as'] = 'busy';
229:         }
230: 
231:         // Recurrence
232:         if ($this->recurs()) {
233:             $event['recurrence'] = $this->recurrence->toHash();
234:             if (!empty($event['recurrence']['exceptions'])) {
235:                 $exclusions = array();
236:                 foreach($event['recurrence']['exceptions'] as $exclusion) {
237:                     if (!empty($exclusion)) {
238:                         $exclusions[] = vsprintf(
239:                             '%04d-%02d-%02d', sscanf($exclusion, '%04d%02d%02d')
240:                         );
241:                     }
242:                 }
243:                 $event['recurrence']['exclusion'] = $exclusions;
244:             }
245:             if (!empty($event['recurrence']['completions'])) {
246:                 $completions = array();
247:                 foreach($event['recurrence']['completions'] as $complete) {
248:                     if (!empty($complete)) {
249:                         $completions[] = vsprintf(
250:                             '%04d-%02d-%02d', sscanf($complete, '%04d%02d%02d')
251:                         );
252:                     }
253:                 }
254:                 $event['recurrence']['complete'] = $completions;
255:             }
256:         }
257: 
258:         // Attendees
259:         $event['attendee'] = array();
260:         foreach ($this->attendees as $email => $attendee) {
261:             $new_attendee = array();
262:             $new_attendee['display-name'] = $attendee['name'];
263: 
264:             // Attendee without an email address
265:             if (is_int($email)) {
266:                 $new_attendee['smtp-address'] = '';
267:             } else {
268:                 $new_attendee['smtp-address'] = $email;
269:             }
270: 
271:             switch ($attendee['attendance']) {
272:             case Kronolith::PART_OPTIONAL:
273:                 $new_attendee['role'] = 'optional';
274:                 break;
275: 
276:             case Kronolith::PART_NONE:
277:                 $new_attendee['role'] = 'resource';
278:                 break;
279: 
280:             case Kronolith::PART_REQUIRED:
281:             default:
282:                 $new_attendee['role'] = 'required';
283:                 break;
284:             }
285: 
286:             $new_attendee['request-response'] = '0';
287: 
288:             switch ($attendee['response']) {
289:             case Kronolith::RESPONSE_ACCEPTED:
290:                 $new_attendee['status'] = 'accepted';
291:                 break;
292: 
293:             case Kronolith::RESPONSE_DECLINED:
294:                 $new_attendee['status'] = 'declined';
295:                 break;
296: 
297:             case Kronolith::RESPONSE_TENTATIVE:
298:                 $new_attendee['status'] = 'tentative';
299:                 break;
300: 
301:             case Kronolith::RESPONSE_NONE:
302:             default:
303:                 $new_attendee['status'] = 'none';
304:                 break;
305:             }
306: 
307:             $event['attendee'][] = $new_attendee;
308:         }
309: 
310:         return $event;
311:     }
312: 
313: }
314: 
API documentation generated by ApiGen