/** * Renames the node * * @throws Sabre\DAV\Exception\Forbidden * @param string $name The new name * @return void */ public function setName($name) { self::checkForbiddenFile($name); if (!Tinebase_Core::getUser()->hasGrant($this->_getContainer(), Tinebase_Model_Grants::GRANT_EDIT)) { throw new Sabre\DAV\Exception\Forbidden('Forbidden to rename file: ' . $this->_path); } list($dirname, $basename) = Sabre\DAV\URLUtil::splitPath($this->_path); Tinebase_FileSystem::getInstance()->rename($this->_path, $dirname . '/' . $name); }
/** * Returns the name of the node * * @return string */ public function getName() { if (count($this->_getPathParts()) === 2 && Tinebase_Helper::array_value(1, $this->_getPathParts()) !== Tinebase_Model_Container::TYPE_SHARED && !$this->_useIdAsName) { try { $contact = $this->_getContact(Tinebase_Helper::array_value(1, $this->_getPathParts())); $name = $contact->n_fileas; } catch (Tinebase_Exception_NotFound $tenf) { list(, $name) = Sabre\DAV\URLUtil::splitPath($this->_path); } } else { list(, $name) = Sabre\DAV\URLUtil::splitPath($this->_path); } return $name; }
/** * ACE reports for sogo integrator * * @param DOMDocument $dom * @throws Tinebase_Exception_InvalidArgument */ public function aclQueryReport(DOMDocument $dom, $uri) { list($parent, $containerId) = Sabre\DAV\URLUtil::splitPath($uri); // handle user-list $userlists = $dom->getElementsByTagNameNS(self::NS_INVERSE, 'user-list'); if ($userlists->length == 1) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' id container : ' . $containerId); } $grants = Tinebase_Container::getInstance()->getGrantsOfContainer($containerId); $domout = new DOMDocument('1.0', 'utf-8'); $domout->formatOutput = true; $userlist = $domout->createElement('user-list'); $domout->appendChild($userlist); foreach ($grants as &$value) { switch ($value['account_type']) { case Tinebase_Acl_Rights::ACCOUNT_TYPE_USER: try { $account = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $value['account_id'], 'Tinebase_Model_FullUser'); } catch (Tinebase_Exception_NotFound $e) { $account = Tinebase_User::getInstance()->getNonExistentUser(); } $userElement = $domout->createElement('user'); $userElement->appendChild(new DOMElement('id', $account->contact_id)); $userElement->appendChild(new DOMElement('displayName', $account->accountFullName)); $userElement->appendChild(new DOMElement('email', $account->accountEmailAddress)); $userlist->appendChild($userElement); break; case Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP: try { $group = Tinebase_Group::getInstance()->getGroupById($value['account_id']); } catch (Tinebase_Exception_Record_NotDefined $e) { $group = Tinebase_Group::getInstance()->getNonExistentGroup(); } $group = $group->toArray(); // @todo add xml for group break; case Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE: $userElement = $domout->createElement('user'); // @todo this is not an anonymous user, but all authenticated users $userElement->appendChild(new DOMElement('id', 'anonymous')); $userElement->appendChild(new DOMElement('displayName', 'Public User')); $userElement->appendChild(new DOMElement('email', 'anonymous')); $userlist->appendChild($userElement); break; default: throw new Tinebase_Exception_InvalidArgument('Unsupported accountType.'); break; } } $xmml = $domout->saveXML(); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' id container : ' . str_replace(array("\r\n", "\n", "\r", " "), '', $xmml)); } $this->server->httpResponse->sendStatus(207); $this->server->httpResponse->setHeader('Content-Type', 'text/xml; charset=utf-8'); $this->server->httpResponse->sendBody(str_replace(array("\r\n", "\n", "\r", " "), '', $xmml)); } // handle roles $roles = $dom->getElementsByTagNameNS(self::NS_INVERSE, 'roles'); if ($roles->length == 1) { $contact = $this->_resolveContactId($roles->item(0)->getAttribute('user')); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' contact id : ' . $contact->getId()); } $acls = Tinebase_Container::getInstance()->getGrantsOfAccount($contact->account_id, $containerId); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' id container : ' . print_r($acls, true)); } $domout = new DOMDocument('1.0', 'utf-8'); $domout->formatOutput = true; $role = $domout->createElement('roles'); $domout->appendChild($role); foreach ($acls as $acl => $value) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' fazendo acl : ' . $acl); } switch ($acl) { case Tinebase_Model_Grants::GRANT_READ: if ($value) { $role->appendChild(new DOMElement('ObjectViewer')); } break; case Tinebase_Model_Grants::GRANT_PRIVATE: if ($value) { $role->appendChild(new DOMElement('PrivateViewer')); } break; case Tinebase_Model_Grants::GRANT_EDIT: if ($value) { $role->appendChild(new DOMElement('ObjectEditor')); } break; case Tinebase_Model_Grants::GRANT_ADD: if ($value) { $role->appendChild(new DOMElement('ObjectCreator')); } break; case Tinebase_Model_Grants::GRANT_DELETE: if ($value) { $role->appendChild(new DOMElement('ObjectEraser')); } break; } } $xmml = $domout->saveXML(); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' id container : ' . str_replace(array("\r\n", "\n", "\r", " "), '', $xmml)); } $this->server->httpResponse->sendStatus(207); $this->server->httpResponse->setHeader('Content-Type', 'text/xml; charset=utf-8'); $this->server->httpResponse->sendBody(str_replace(array("\r\n", "\n", "\r", " "), '', $xmml)); } }
/** * Returns the name of the node. * * This is used to generate the url. * * @return string * * @todo DRY (@see Tinebase_Frontend_WebDAV_Node::getName()) */ function getName() { list(, $basename) = Sabre\DAV\URLUtil::splitPath($this->_path); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' name: ' . $basename); } return $basename; }
/** * Returns the list of properties * * @param array $requestedProperties * @return array */ public function getProperties($requestedProperties) { $pathParts = explode('/', trim($this->_path, '/')); Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' part count: ' . count($pathParts) . ' ' . print_r($pathParts, true)); $children = array(); list(, $basename) = Sabre\DAV\URLUtil::splitPath($this->_path); switch (count($pathParts)) { # path == /accountLoginName # list personal and shared folder case 1: $properties = array('{http://calendarserver.org/ns/}getctag' => 1, 'id' => $basename, 'uri' => $basename, '{DAV:}displayname' => $basename); break; } #Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .' path: ' . $this->_path . ' ' . print_r($requestedProperties, true)); #Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .' path: ' . $this->_path . ' ' . print_r($properties, true)); $response = array(); foreach ($requestedProperties as $prop) { switch ($prop) { case '{DAV:}owner': $response[$prop] = new Sabre\DAVACL\Property\Principal(Sabre\DAVACL\Property\Principal::HREF, 'principals/users/' . Tinebase_Core::getUser()->contact_id); break; case '{DAV:}getetag': $response[$prop] = $this->getETag(); break; default: if (isset($properties[$prop])) { $response[$prop] = $properties[$prop]; } break; } } Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' path: ' . $this->_path . ' ' . print_r($response, true)); return $response; }
/** * Returns the name of the node * * @return string */ public function getName() { list(, $name) = Sabre\DAV\URLUtil::splitPath($this->_path); return $name; }
/** * Returns the name of the node * * @return string */ public function getName() { if (count($this->_getPathParts()) === 2 && Tinebase_Helper::array_value(1, $this->_getPathParts()) !== Tinebase_Model_Container::TYPE_SHARED && !$this->_useIdAsName) { try { $user = $this->_getUser(Tinebase_Helper::array_value(1, $this->_getPathParts())); $name = $this->_useLoginAsFolderName() ? $user->accountLoginName : $user->accountDisplayName; } catch (Tinebase_Exception_NotFound $tenf) { list(, $name) = Sabre\DAV\URLUtil::splitPath($this->_path); } } else { list(, $name) = Sabre\DAV\URLUtil::splitPath($this->_path); } return $name; }