/** * Updates properties on this node, * * The properties array uses the propertyName in clark-notation as key, * and the array value for the property value. In the case a property * should be deleted, the property value will be null. * * This method must be atomic. If one property cannot be changed, the * entire operation must fail. * * If the operation was successful, true can be returned. * If the operation failed, false can be returned. * * Deletion of a non-existant property is always succesful. * * Lastly, it is optional to return detailed information about any * failures. In this case an array should be returned with the following * structure: * * array( * 403 => array( * '{DAV:}displayname' => null, * ), * 424 => array( * '{DAV:}owner' => null, * ) * ) * * In this example it was forbidden to update {DAV:}displayname. * (403 Forbidden), which in turn also caused {DAV:}owner to fail * (424 Failed Dependency) because the request needs to be atomic. * * @param array $mutations * @return bool|array */ public function updateProperties($mutations) { if (!Tinebase_Core::getUser()->hasGrant($this->_container, Tinebase_Model_Grants::GRANT_ADMIN)) { throw new \Sabre\DAV\Exception\Forbidden('permission to update container denied'); } $result = array(200 => array(), 403 => array()); foreach ($mutations as $key => $value) { switch ($key) { case '{DAV:}displayname': if ($value === $this->_container->uuid || $value === $this->_container->getId()) { if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) { Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' It is not allowed to overwrite the name with the uuid/id'); } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r(array('useIdAsName' => $this->_useIdAsName, 'container' => $this->_container->toArray(), 'new value' => $value), true)); } } else { $this->_container->name = $value; } $result['200'][$key] = null; break; case '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}calendar-description': case '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}calendar-timezone': // fake success $result['200'][$key] = null; break; case '{http://apple.com/ns/ical/}calendar-color': $this->_container->color = substr($value, 0, 7); $result['200'][$key] = null; break; default: $result['403'][$key] = null; } } Tinebase_Container::getInstance()->update($this->_container); return $result; }