Changeset View
Changeset View
Standalone View
Standalone View
lib/kolab_sync_data_calendar.php
Show First 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | // 'CHAIR' => self::ATTENDEE_TYPE_RESOURCE, | ||||
public function getEntry(Syncroton_Model_SyncCollection $collection, $serverId, $as_array = false) | public function getEntry(Syncroton_Model_SyncCollection $collection, $serverId, $as_array = false) | ||||
{ | { | ||||
$event = is_array($serverId) ? $serverId : $this->getObject($collection->collectionId, $serverId); | $event = is_array($serverId) ? $serverId : $this->getObject($collection->collectionId, $serverId); | ||||
$config = $this->getFolderConfig($event['_mailbox']); | $config = $this->getFolderConfig($event['_mailbox']); | ||||
$result = array(); | $result = array(); | ||||
// Timezone | // Timezone | ||||
// Kolab Format 3.0 and xCal does support timezone per-date, but ActiveSync allows | // Kolab Format 3.0 and xCal does support timezone per-date, but ActiveSync allows | ||||
// only one timezone per-event. We'll use timezone of the start date | // only one timezone per-event. We'll use timezone of the start date | ||||
machniak: I think we should rather throw an exception as we do e.g. in kolab_sync_data_contacts::getEntry… | |||||
Not Done Inline ActionsThe NULL will result in an exception when such exception is appropriate. vanmeeuwen: The NULL will result in an exception when such exception is appropriate. | |||||
if ($event['start'] instanceof DateTime) { | if ($event['start'] instanceof DateTime) { | ||||
$timezone = $event['start']->getTimezone(); | $timezone = $event['start']->getTimezone(); | ||||
if ($timezone && ($tz_name = $timezone->getName()) != 'UTC') { | if ($timezone && ($tz_name = $timezone->getName()) != 'UTC') { | ||||
$tzc = kolab_sync_timezone_converter::getInstance(); | $tzc = kolab_sync_timezone_converter::getInstance(); | ||||
if ($tz_name = $tzc->encodeTimezone($tz_name)) { | if ($tz_name = $tzc->encodeTimezone($tz_name)) { | ||||
$result['timezone'] = $tz_name; | $result['timezone'] = $tz_name; | ||||
▲ Show 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | public function toKolab(Syncroton_Model_IEntry $data, $folderid, $entry = null, $timezone = null) | ||||
$email = $data->organizerEmail; | $email = $data->organizerEmail; | ||||
if ($name || $email) { | if ($name || $email) { | ||||
$event['attendees'][] = array( | $event['attendees'][] = array( | ||||
'role' => 'ORGANIZER', | 'role' => 'ORGANIZER', | ||||
'name' => $name, | 'name' => $name, | ||||
'email' => $email, | 'email' => $email, | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
Not Done Inline ActionsI don't think we need this version check here. MeetingStatus is supported in older versions for top-level data. Do I miss something? machniak: I don't think we need this version check here. MeetingStatus is supported in older versions for… | |||||
Not Done Inline ActionsI don't know what this means:
vanmeeuwen: I don't know what this means:
> MeetingStatus is supported in older versions for top-level… | |||||
Not Done Inline ActionsThis does not make much sense to me. This will set the organizer status to DECLINED for events where the user is an attendee. I'd rather set the organizer status always to ACCEPTED. machniak: This does not make much sense to me. This will set the organizer status to DECLINED for events… | |||||
Not Done Inline ActionsNo, it'll only set the attendee's status to DECLINED if the overall meeting status is CANCELLED, and the attendee in question is also the organizer. vanmeeuwen: No, it'll only set the attendee's status to DECLINED if the overall meeting status is CANCELLED… | |||||
// Attendees | // Attendees | ||||
if (isset($data->attendees)) { | if (isset($data->attendees)) { | ||||
foreach ($data->attendees as $attendee) { | foreach ($data->attendees as $attendee) { | ||||
$role = false; | $role = false; | ||||
if (isset($attendee->attendeeType)) { | if (isset($attendee->attendeeType)) { | ||||
$role = array_search($attendee->attendeeType, $this->attendeeTypeMap); | $role = array_search($attendee->attendeeType, $this->attendeeTypeMap); | ||||
} | } | ||||
if ($role === false) { | if ($role === false) { | ||||
Show All 32 Lines | // 'CHAIR' => self::ATTENDEE_TYPE_RESOURCE, | ||||
* Set attendee status for meeting | * Set attendee status for meeting | ||||
* | * | ||||
* @param Syncroton_Model_MeetingResponse $request The meeting response | * @param Syncroton_Model_MeetingResponse $request The meeting response | ||||
* | * | ||||
* @return string ID of new calendar entry | * @return string ID of new calendar entry | ||||
*/ | */ | ||||
public function setAttendeeStatus(Syncroton_Model_MeetingResponse $request) | public function setAttendeeStatus(Syncroton_Model_MeetingResponse $request) | ||||
{ | { | ||||
/* | |||||
* The request actually involves an iTip request. | |||||
* | |||||
* - Get to the iTip, | |||||
* - Extract the event UID, | |||||
* - If not already an event in the user's calendar(s), create the event, | |||||
* - If already an event, update that event. | |||||
*/ | |||||
$object = $this->parseMessageId($request->requestId); | |||||
$message = new rcube_message($object['uid'], $object['foldername']); | |||||
// Parse the message | |||||
$libcal = libcalendaring::get_instance(); | |||||
$libcal->mail_message_load(array('object' => $message)); | |||||
$ical_objects = $libcal->get_mail_ical_objects(); | |||||
$uid = $ical_objects->objects[0]['uid']; | |||||
// Search the user's (event) folders | |||||
$folders = $this->listFolders(); | |||||
$serverIds = Array(); | |||||
foreach ($folders as $folder => $attrs) { | |||||
$serverIds[] = $this->serverId($uid, $attrs['imap_name']); | |||||
} | |||||
// Go search for a match | |||||
$existing_event = NULL; | |||||
foreach ($serverIds as $serverId) { | |||||
foreach ($folders as $folderid => $attrs) { | |||||
$existing_event = $this->getObject($folderid, $serverId); | |||||
if ($existing_event !== NULL) { | |||||
break; | |||||
} | |||||
} | |||||
if ($existing_event !== NULL) { | |||||
break; | |||||
} | |||||
} | |||||
/* | |||||
Consider; | |||||
- $existing_event->sensitivity (private, confidential, public) | |||||
- $existing_event->attendees[$x]->{role,rsvp,status} | |||||
- $request->userresponse | |||||
*/ | |||||
if ($existing_event !== NULL) { | |||||
// This is an existing event that needs updating | |||||
$this->log->debug("This is an existing event that needs updating"); | |||||
} else { | |||||
// This is a new event | |||||
$this->log->debug("This is a new event"); | |||||
} | |||||
// @TODO: not implemented | // @TODO: not implemented | ||||
throw new Syncroton_Exception_Status_MeetingResponse(Syncroton_Exception_Status_MeetingResponse::MEETING_ERROR); | throw new Syncroton_Exception_Status_MeetingResponse(Syncroton_Exception_Status_MeetingResponse::MEETING_ERROR); | ||||
} | } | ||||
/** | /** | ||||
* Returns filter query array according to specified ActiveSync FilterType | * Returns filter query array according to specified ActiveSync FilterType | ||||
* | * | ||||
* @param int $filter_type Filter type | * @param int $filter_type Filter type | ||||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | protected function eventCheck(Syncroton_Model_IEntry &$entry) | ||||
if ($entry->startTime < $now) { | if ($entry->startTime < $now) { | ||||
throw new Syncroton_Exception_Status_Sync(Syncroton_Exception_Status_Sync::INVALID_ITEM); | throw new Syncroton_Exception_Status_Sync(Syncroton_Exception_Status_Sync::INVALID_ITEM); | ||||
} | } | ||||
$rounded->add(new DateInterval($entry->allDayEvent ? 'P1D' : 'PT30M')); | $rounded->add(new DateInterval($entry->allDayEvent ? 'P1D' : 'PT30M')); | ||||
$entry->endTime = $rounded; | $entry->endTime = $rounded; | ||||
} | } | ||||
} | } | ||||
private function parseMessageId($entryid) | |||||
{ | |||||
// replyEmail/forwardEmail | |||||
if (is_array($entryid)) { | |||||
$entryid = $entryid['itemId']; | |||||
} | |||||
list($folderid, $uid) = explode('::', $entryid); | |||||
$foldername = $this->backend->folder_id2name($folderid, $this->device->deviceid); | |||||
if ($foldername === null || $foldername === false) { | |||||
// @TODO exception? | |||||
return null; | |||||
} | |||||
return array( | |||||
'uid' => $uid, | |||||
'folderid' => $folderid, | |||||
'foldername' => $foldername, | |||||
); | |||||
} | |||||
} | } |
I think we should rather throw an exception as we do e.g. in kolab_sync_data_contacts::getEntry(), Syncroton code can't handle NULL properly.