protected function _addEventAttendee(Sabre_VObject_Component $_vevent, Calendar_Model_Event $_event) { if (version_compare($this->_version, '1.0b2', '>')) { parent::_addEventAttendee($_vevent, $_event); } else { // special handling for Lightning <= 1.0b2 // attendees get screwed up, if the CN contains commas Calendar_Model_Attender::resolveAttendee($_event->attendee, FALSE, $_event); foreach ($_event->attendee as $eventAttendee) { $attendeeEmail = $eventAttendee->getEmail(); if ($attendeeEmail) { $attendee = new Sabre_VObject_Property('ATTENDEE', (strpos($attendeeEmail, '@') !== false ? 'mailto:' : 'urn:uuid:') . $attendeeEmail); $attendee->add('CN', str_replace(',', null, $eventAttendee->getName())); $attendee->add('CUTYPE', Calendar_Convert_Event_VCalendar_Abstract::$cutypeMap[$eventAttendee->user_type]); $attendee->add('PARTSTAT', $eventAttendee->status); $attendee->add('ROLE', "{$eventAttendee->role}-PARTICIPANT"); $attendee->add('RSVP', 'FALSE'); if (strpos($attendeeEmail, '@') !== false) { $attendee->add('EMAIL', $attendeeEmail); } $_vevent->add($attendee); } } } }
/** * Updates the VCard-formatted object * * @param string $cardData * @return void */ public function put($cardData) { if (get_class($this->_converter) == 'Tasks_Convert_Task_VCalendar_Generic') { if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) { Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . " update by generic client not allowed. See Tasks_Convert_Task_VCalendar_Factory for supported clients."); } throw new Sabre\DAV\Exception\Forbidden('Update denied for unknow client'); } if (is_resource($cardData)) { $cardData = stream_get_contents($cardData); } // Converting to UTF-8, if needed $cardData = Sabre\DAV\StringUtil::ensureUTF8($cardData); #Sabre_CalDAV_ICalendarUtil::validateICalendarObject($cardData, array('VTODO', 'VFREEBUSY')); $vobject = Tasks_Convert_Task_VCalendar_Abstract::getVObject($cardData); foreach ($vobject->children() as $component) { if (isset($component->{'X-TINE20-CONTAINER'})) { $xContainerId = $component->{'X-TINE20-CONTAINER'}; break; } } // keep old record for reference $recordBeforeUpdate = clone $this->getRecord(); $task = $this->_converter->toTine20Model($vobject, $this->getRecord(), array(Tasks_Convert_Task_VCalendar_Abstract::OPTION_USE_SERVER_MODLOG => true)); // iCal does sends back an old value, because it does not refresh the vcalendar after // update. Therefor we must reapply the value of last_modified_time after the convert $task->last_modified_time = $recordBeforeUpdate->last_modified_time; $currentContainer = Tinebase_Container::getInstance()->getContainerById($this->getRecord()->container_id); //$ownAttendee = Calendar_Model_Attender::getOwnAttender($this->getRecord()->attendee); // task 'belongs' current user -> allow container move if ($currentContainer->isPersonalOf(Tinebase_Core::getUser())) { $task->container_id = $this->_container->getId(); } // client sends CalDAV task -> handle a container move /*else if (isset($xContainerId)) { if ($xContainerId == $currentContainer->getId()) { $task->container_id = $this->_container->getId(); } else { // @TODO allow organizer to move original cal when he edits the displaycal task? if ($ownAttendee && $this->_container->type == Tinebase_Model_Container::TYPE_PERSONAL) { $ownAttendee->displaycontainer_id = $this->_container->getId(); } } } */ // client sends task from iMIP invitation -> only allow displaycontainer move /*else { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " X-TINE20-CONTAINER not present -> restrict container moves"); if ($ownAttendee && $this->_container->type == Tinebase_Model_Container::TYPE_PERSONAL) { if ($ownAttendee->displaycontainer_id == $currentContainer->getId()) { $task->container_id = $this->_container->getId(); } $ownAttendee->displaycontainer_id = $this->_container->getId(); } }*/ self::enforceEventParameters($task); // don't allow update of alarms for non organizer if oganizer is Tine 2.0 user if ($task->organizer !== Tinebase_Core::getUser()->getId()) { $organizerContact = Addressbook_Controller_Contact::getInstance()->getContactByUserId($task->organizer, TRUE); // reset alarms if organizer is Tine 2.0 user if (!empty($organizerContact->account_id)) { $this->_resetAlarms($task, $recordBeforeUpdate); } } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " " . print_r($task->toArray(), true)); } try { $this->_task = Tasks_Controller_Task::getInstance()->update($task); } catch (Tinebase_Timemachine_Exception_ConcurrencyConflict $ttecc) { throw new Sabre\DAV\Exception\PreconditionFailed('An If-Match header was specified, but none of the specified the ETags matched.', 'If-Match'); } catch (Tinebase_Exception_AccessDenied $tead) { throw new Sabre\DAV\Exception\Forbidden('forbidden update'); } catch (Tinebase_Exception_NotFound $tenf) { throw new Sabre\DAV\Exception\PreconditionFailed('not found'); } catch (Exception $e) { Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . " " . $e); Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . " " . $cardData); Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . " " . print_r($task->toArray(), true)); throw new Sabre\DAV\Exception\PreconditionFailed($e->getMessage()); } return $this->getETag(); }