/** * serialize * * @param Sabre_DAV_Server $server * @param DOMElement $dom * @return void */ public function serialize(Sabre_DAV_Server $server, DOMElement $dom) { $document = $dom->ownerDocument; $properties = $this->responseProperties; $xresponse = $document->createElement('d:response'); $dom->appendChild($xresponse); $uri = Sabre_DAV_URLUtil::encodePath($this->href); // Adding the baseurl to the beginning of the url $uri = $server->getBaseUri() . $uri; $xresponse->appendChild($document->createElement('d:href', $uri)); // The properties variable is an array containing properties, grouped by // HTTP status foreach ($properties as $httpStatus => $propertyGroup) { // The 'href' is also in this array, and it's special cased. // We will ignore it if ($httpStatus == 'href') { continue; } // If there are no properties in this group, we can also just carry on if (!count($propertyGroup)) { continue; } $xpropstat = $document->createElement('d:propstat'); $xresponse->appendChild($xpropstat); $xprop = $document->createElement('d:prop'); $xpropstat->appendChild($xprop); $nsList = $server->xmlNamespaces; foreach ($propertyGroup as $propertyName => $propertyValue) { $propName = null; preg_match('/^{([^}]*)}(.*)$/', $propertyName, $propName); // special case for empty namespaces if ($propName[1] == '') { $currentProperty = $document->createElement($propName[2]); $xprop->appendChild($currentProperty); $currentProperty->setAttribute('xmlns', ''); } else { if (!isset($nsList[$propName[1]])) { $nsList[$propName[1]] = 'x' . count($nsList); } // If the namespace was defined in the top-level xml namespaces, it means // there was already a namespace declaration, and we don't have to worry about it. if (isset($server->xmlNamespaces[$propName[1]])) { $currentProperty = $document->createElement($nsList[$propName[1]] . ':' . $propName[2]); } else { $currentProperty = $document->createElementNS($propName[1], $nsList[$propName[1]] . ':' . $propName[2]); } $xprop->appendChild($currentProperty); } if (is_scalar($propertyValue)) { $text = $document->createTextNode($propertyValue); $currentProperty->appendChild($text); } elseif ($propertyValue instanceof Sabre_DAV_PropertyInterface) { $propertyValue->serialize($server, $currentProperty); } elseif (!is_null($propertyValue)) { throw new Sabre_DAV_Exception('Unknown property value type: ' . gettype($propertyValue) . ' for property: ' . $propertyName); } } $xpropstat->appendChild($document->createElement('d:status', $server->httpResponse->getStatusMessage($httpStatus))); } }
/** * Generates the html directory index for a given url * * @param string $path * @return string */ public function generateDirectoryIndex($path) { $version = ''; if (Sabre_DAV_Server::$exposeVersion) { $version = Sabre_DAV_Version::VERSION . "-" . Sabre_DAV_Version::STABILITY; } $html = "<html>\n<head>\n <title>Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . $version . "</title>\n <style type=\"text/css\">\n body { Font-family: arial}\n h1 { font-size: 150% }\n </style>\n "; if ($this->enableAssets) { $html .= '<link rel="shortcut icon" href="' . $this->getAssetUrl('favicon.ico') . '" type="image/vnd.microsoft.icon" />'; } $html .= "</head>\n<body>\n <h1>Index for " . $this->escapeHTML($path) . "/</h1>\n <table>\n <tr><th width=\"24\"></th><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr>\n <tr><td colspan=\"5\"><hr /></td></tr>"; $files = $this->server->getPropertiesForPath($path, array('{DAV:}displayname', '{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified'), 1); $parent = $this->server->tree->getNodeForPath($path); if ($path) { list($parentUri) = Sabre_DAV_URLUtil::splitPath($path); $fullPath = Sabre_DAV_URLUtil::encodePath($this->server->getBaseUri() . $parentUri); $icon = $this->enableAssets ? '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl('icons/parent' . $this->iconExtension) . '" width="24" alt="Parent" /></a>' : ''; $html .= "<tr>\n <td>{$icon}</td>\n <td><a href=\"{$fullPath}\">..</a></td>\n <td>[parent]</td>\n <td></td>\n <td></td>\n </tr>"; } foreach ($files as $file) { // This is the current directory, we can skip it if (rtrim($file['href'], '/') == $path) { continue; } list(, $name) = Sabre_DAV_URLUtil::splitPath($file['href']); $type = null; if (isset($file[200]['{DAV:}resourcetype'])) { $type = $file[200]['{DAV:}resourcetype']->getValue(); // resourcetype can have multiple values if (!is_array($type)) { $type = array($type); } foreach ($type as $k => $v) { // Some name mapping is preferred switch ($v) { case '{DAV:}collection': $type[$k] = 'Collection'; break; case '{DAV:}principal': $type[$k] = 'Principal'; break; case '{urn:ietf:params:xml:ns:carddav}addressbook': $type[$k] = 'Addressbook'; break; case '{urn:ietf:params:xml:ns:caldav}calendar': $type[$k] = 'Calendar'; break; case '{urn:ietf:params:xml:ns:caldav}schedule-inbox': $type[$k] = 'Schedule Inbox'; break; case '{urn:ietf:params:xml:ns:caldav}schedule-outbox': $type[$k] = 'Schedule Outbox'; break; case '{http://calendarserver.org/ns/}calendar-proxy-read': $type[$k] = 'Proxy-Read'; break; case '{http://calendarserver.org/ns/}calendar-proxy-write': $type[$k] = 'Proxy-Write'; break; } } $type = implode(', ', $type); } // If no resourcetype was found, we attempt to use // the contenttype property if (!$type && isset($file[200]['{DAV:}getcontenttype'])) { $type = $file[200]['{DAV:}getcontenttype']; } if (!$type) { $type = 'Unknown'; } $size = isset($file[200]['{DAV:}getcontentlength']) ? (int) $file[200]['{DAV:}getcontentlength'] : ''; $lastmodified = isset($file[200]['{DAV:}getlastmodified']) ? $file[200]['{DAV:}getlastmodified']->getTime()->format(DateTime::ATOM) : ''; $fullPath = Sabre_DAV_URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path ? $path . '/' : '') . $name, '/')); $displayName = isset($file[200]['{DAV:}displayname']) ? $file[200]['{DAV:}displayname'] : $name; $displayName = $this->escapeHTML($displayName); $type = $this->escapeHTML($type); $icon = ''; if ($this->enableAssets) { $node = $this->server->tree->getNodeForPath(($path ? $path . '/' : '') . $name); foreach (array_reverse($this->iconMap) as $class => $iconName) { if ($node instanceof $class) { $icon = '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl($iconName . $this->iconExtension) . '" alt="" width="24" /></a>'; break; } } } $html .= "<tr>\n <td>{$icon}</td>\n <td><a href=\"{$fullPath}\">{$displayName}</a></td>\n <td>{$type}</td>\n <td>{$size}</td>\n <td>{$lastmodified}</td>\n </tr>"; } $html .= "<tr><td colspan=\"5\"><hr /></td></tr>"; $output = ''; if ($this->enablePost) { $this->server->broadcastEvent('onHTMLActionsPanel', array($parent, &$output)); } $html .= $output; $html .= "</table>\n <address>Generated by SabreDAV " . $version . " (c)2007-2013 <a href=\"http://code.google.com/p/sabredav/\">http://code.google.com/p/sabredav/</a></address>\n </body>\n </html>"; return $html; }
/** * Generates the html directory index for a given url * * @param string $path * @return string */ public function generateDirectoryIndex($path) { $html = "<html>\n<head>\n <title>Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . Sabre_DAV_Version::VERSION . "</title>\n <style type=\"text/css\"> body { Font-family: arial}</style>\n</head>\n<body>\n <h1>Index for " . $this->escapeHTML($path) . "/</h1>\n <table>\n <tr><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr>\n <tr><td colspan=\"4\"><hr /></td></tr>"; $files = $this->server->getPropertiesForPath($path, array('{DAV:}displayname', '{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified'), 1); $parent = $this->server->tree->getNodeForPath($path); if ($path) { list($parentUri) = Sabre_DAV_URLUtil::splitPath($path); $fullPath = Sabre_DAV_URLUtil::encodePath($this->server->getBaseUri() . $parentUri); $html .= "<tr>\n<td><a href=\"{$fullPath}\">..</a></td>\n<td>[parent]</td>\n<td></td>\n<td></td>\n</tr>"; } foreach ($files as $k => $file) { // This is the current directory, we can skip it if (rtrim($file['href'], '/') == $path) { continue; } list(, $name) = Sabre_DAV_URLUtil::splitPath($file['href']); $type = null; if (isset($file[200]['{DAV:}resourcetype'])) { $type = $file[200]['{DAV:}resourcetype']->getValue(); // resourcetype can have multiple values if (!is_array($type)) { $type = array($type); } foreach ($type as $k => $v) { // Some name mapping is preferred switch ($v) { case '{DAV:}collection': $type[$k] = 'Collection'; break; case '{DAV:}principal': $type[$k] = 'Principal'; break; case '{urn:ietf:params:xml:ns:carddav}addressbook': $type[$k] = 'Addressbook'; break; case '{urn:ietf:params:xml:ns:caldav}calendar': $type[$k] = 'Calendar'; break; } } $type = implode(', ', $type); } // If no resourcetype was found, we attempt to use // the contenttype property if (!$type && isset($file[200]['{DAV:}getcontenttype'])) { $type = $file[200]['{DAV:}getcontenttype']; } if (!$type) { $type = 'Unknown'; } $size = isset($file[200]['{DAV:}getcontentlength']) ? (int) $file[200]['{DAV:}getcontentlength'] : ''; $lastmodified = isset($file[200]['{DAV:}getlastmodified']) ? $file[200]['{DAV:}getlastmodified']->getTime()->format(DateTime::ATOM) : ''; $fullPath = Sabre_DAV_URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path ? $path . '/' : '') . $name, '/')); $displayName = isset($file[200]['{DAV:}displayname']) ? $file[200]['{DAV:}displayname'] : $name; $name = $this->escapeHTML($name); $displayName = $this->escapeHTML($displayName); $type = $this->escapeHTML($type); $html .= "<tr>\n<td><a href=\"{$fullPath}\">{$displayName}</a></td>\n<td>{$type}</td>\n<td>{$size}</td>\n<td>{$lastmodified}</td>\n</tr>"; } $html .= "<tr><td colspan=\"4\"><hr /></td></tr>"; if ($this->enablePost && $parent instanceof Sabre_DAV_ICollection) { $html .= '<tr><td><form method="post" action=""> <h3>Create new folder</h3> <input type="hidden" name="sabreAction" value="mkcol" /> Name: <input type="text" name="name" /><br /> <input type="submit" value="create" /> </form> <form method="post" action="" enctype="multipart/form-data"> <h3>Upload file</h3> <input type="hidden" name="sabreAction" value="put" /> Name (optional): <input type="text" name="name" /><br /> File: <input type="file" name="file" /><br /> <input type="submit" value="upload" /> </form> </td></tr>'; } $html .= "</table>\n <address>Generated by SabreDAV " . Sabre_DAV_Version::VERSION . "-" . Sabre_DAV_Version::STABILITY . " (c)2007-2012 <a href=\"http://code.google.com/p/sabredav/\">http://code.google.com/p/sabredav/</a></address>\n</body>\n</html>"; return $html; }
/** * Adds all CardDAV-specific properties * * @param string $path * @param Sabre_DAV_INode $node * @param array $requestedProperties * @param array $returnedProperties * @return void */ public function beforeGetProperties($path, Sabre_DAV_INode $node, array &$requestedProperties, array &$returnedProperties) { if ($node instanceof Sabre_DAVACL_IPrincipal) { // calendar-home-set property $addHome = '{' . self::NS_CARDDAV . '}addressbook-home-set'; if (in_array($addHome, $requestedProperties)) { $principalId = $node->getName(); $addressbookHomePath = self::ADDRESSBOOK_ROOT . '/' . $principalId . '/'; unset($requestedProperties[array_search($addHome, $requestedProperties)]); $returnedProperties[200][$addHome] = new Sabre_DAV_Property_Href(Sabre_DAV_URLUtil::encodePath($addressbookHomePath)); } $directories = '{' . self::NS_CARDDAV . '}directory-gateway'; if ($this->directories && in_array($directories, $requestedProperties)) { unset($requestedProperties[array_search($directories, $requestedProperties)]); $returnedProperties[200][$directories] = new Sabre_DAV_Property_HrefList($this->directories); } } if ($node instanceof Sabre_CardDAV_ICard) { // The address-data property is not supposed to be a 'real' // property, but in large chunks of the spec it does act as such. // Therefore we simply expose it as a property. $addressDataProp = '{' . self::NS_CARDDAV . '}address-data'; if (in_array($addressDataProp, $requestedProperties)) { unset($requestedProperties[$addressDataProp]); $val = $node->get(); if (is_resource($val)) { $val = stream_get_contents($val); } $returnedProperties[200][$addressDataProp] = $val; } } if ($node instanceof Sabre_CardDAV_UserAddressBooks) { $meCardProp = '{http://calendarserver.org/ns/}me-card'; if (in_array($meCardProp, $requestedProperties)) { $props = $this->server->getProperties($node->getOwner(), array('{http://sabredav.org/ns}vcard-url')); if (isset($props['{http://sabredav.org/ns}vcard-url'])) { $returnedProperties[200][$meCardProp] = new Sabre_DAV_Property_Href($props['{http://sabredav.org/ns}vcard-url']); $pos = array_search($meCardProp, $requestedProperties); unset($requestedProperties[$pos]); } } } }
/** * beforeGetProperties * * This method handler is invoked before any after properties for a * resource are fetched. This allows us to add in any CalDAV specific * properties. * * @param string $path * @param Sabre_DAV_INode $node * @param array $requestedProperties * @param array $returnedProperties * @return void */ public function beforeGetProperties($path, Sabre_DAV_INode $node, &$requestedProperties, &$returnedProperties) { if ($node instanceof Sabre_DAVACL_IPrincipal) { // calendar-home-set property $calHome = '{' . self::NS_CALDAV . '}calendar-home-set'; if (in_array($calHome, $requestedProperties)) { $principalId = $node->getName(); $calendarHomePath = self::CALENDAR_ROOT . '/' . $principalId . '/'; unset($requestedProperties[array_search($calHome, $requestedProperties)]); $returnedProperties[200][$calHome] = new Sabre_DAV_Property_Href(Sabre_DAV_URLUtil::encodePath($calendarHomePath)); } // schedule-outbox-URL property $scheduleProp = '{' . self::NS_CALDAV . '}schedule-outbox-URL'; if (in_array($scheduleProp, $requestedProperties)) { $principalId = $node->getName(); $outboxPath = self::CALENDAR_ROOT . '/' . $principalId . '/outbox'; unset($requestedProperties[array_search($scheduleProp, $requestedProperties)]); $returnedProperties[200][$scheduleProp] = new Sabre_DAV_Property_Href(Sabre_DAV_URLUtil::encodePath($outboxPath)); } // calendar-user-address-set property $calProp = '{' . self::NS_CALDAV . '}calendar-user-address-set'; if (in_array($calProp, $requestedProperties)) { $addresses = $node->getAlternateUriSet(); $addresses[] = Sabre_DAV_URLUtil::encodePath($this->server->getBaseUri() . $node->getPrincipalUrl() . '/'); unset($requestedProperties[array_search($calProp, $requestedProperties)]); $returnedProperties[200][$calProp] = new Sabre_DAV_Property_HrefList($addresses, false); } // These two properties are shortcuts for ical to easily find // other principals this principal has access to. $propRead = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for'; $propWrite = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for'; if (in_array($propRead, $requestedProperties) || in_array($propWrite, $requestedProperties)) { $aclPlugin = $this->server->getPlugin('acl'); $membership = $aclPlugin->getPrincipalMembership($path); $readList = array(); $writeList = array(); foreach ($membership as $group) { $groupNode = $this->server->tree->getNodeForPath($group); // If the node is either ap proxy-read or proxy-write // group, we grab the parent principal and add it to the // list. if ($groupNode instanceof Sabre_CalDAV_Principal_ProxyRead) { list($readList[]) = Sabre_DAV_URLUtil::encodePath(Sabre_DAV_URLUtil::splitPath($group)); } if ($groupNode instanceof Sabre_CalDAV_Principal_ProxyWrite) { list($writeList[]) = Sabre_DAV_URLUtil::encodePath(Sabre_DAV_URLUtil::splitPath($group)); } } if (in_array($propRead, $requestedProperties)) { unset($requestedProperties[$propRead]); $returnedProperties[200][$propRead] = new Sabre_DAV_Property_HrefList($readList); } if (in_array($propWrite, $requestedProperties)) { unset($requestedProperties[$propWrite]); $returnedProperties[200][$propWrite] = new Sabre_DAV_Property_HrefList($writeList); } } // notification-URL property $notificationUrl = '{' . self::NS_CALENDARSERVER . '}notification-URL'; if (($index = array_search($notificationUrl, $requestedProperties)) !== false) { $principalId = $node->getName(); $calendarHomePath = 'calendars/' . $principalId . '/notifications/'; unset($requestedProperties[$index]); $returnedProperties[200][$notificationUrl] = new Sabre_DAV_Property_Href(Sabre_DAV_URLUtil::encodePath($calendarHomePath)); } } // instanceof IPrincipal if ($node instanceof Sabre_CalDAV_Notifications_INode) { $propertyName = '{' . self::NS_CALENDARSERVER . '}notificationtype'; if (($index = array_search($propertyName, $requestedProperties)) !== false) { $returnedProperties[200][$propertyName] = $node->getNotificationType(); unset($requestedProperties[$index]); } } // instanceof Notifications_INode if ($node instanceof Sabre_CalDAV_ICalendarObject) { // The calendar-data property is not supposed to be a 'real' // property, but in large chunks of the spec it does act as such. // Therefore we simply expose it as a property. $calDataProp = '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}calendar-data'; if (in_array($calDataProp, $requestedProperties)) { unset($requestedProperties[$calDataProp]); $val = $node->get(); if (is_resource($val)) { $val = stream_get_contents($val); } // Taking out \r to not screw up the xml output $returnedProperties[200][$calDataProp] = str_replace("\r", "", $val); } } }
/** * This testcase was sent by a bug reporter * * @depends testDecode */ function testDecodeAccentsWindows7() { $str = '/webdav/%C3%A0fo%C3%B3'; $newStr = Sabre_DAV_URLUtil::decodePath($str); $this->assertEquals(strtolower($str), Sabre_DAV_URLUtil::encodePath($newStr)); }
/** * Rewriting for SabreDAV Browser plugin * * @param String $path * * @return String * * @see plugins/webdav/lib/Sabre/DAV/Browser/Sabre_DAV_Browser_Plugin#generateDirectoryIndex($path) */ public function generateDirectoryIndex($path) { $node = $this->server->tree->getNodeForPath($path); $class = get_class($node); echo $GLOBALS['HTML']->pv_header(array('title' => ' WebDAV : ' . $node->getName())); ob_start(); echo "<h3>" . $node->getName() . "</h3>"; echo ''; echo "<table>\n <tr><th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'name') . "</th><th>Type</th>"; if ($class == 'WebDAVFRS' && $node->userCanWrite()) { echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'delete') . "</th><th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'rename') . "</th>"; } if ($class == 'WebDAVFRSPackage') { echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'last_modified') . "</th>"; if ($node->userCanWrite()) { echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'delete') . "</th><th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'rename') . "</th>"; /*<th>".$GLOBALS['Language']->getText('plugin_webdav_html', 'move')."</th>";*/ } } if ($class == 'WebDAVFRSRelease') { echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'size') . "</th><th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'last_modified') . "</th>"; if ($node->userCanWrite()) { echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'delete') . "</th>"; /*<th>".$GLOBALS['Language']->getText('plugin_webdav_html', 'move')."</th>";*/ } } if ($class == 'WebDAVDocmanFolder') { echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'size') . "</th><th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'last_modified') . "</th>"; $docmanPermissionManager = $node->getUtils()->getDocmanPermissionsManager($node->getProject()); if ($node->getUtils()->isWriteEnabled() && $docmanPermissionManager->userCanWrite($node->getUser(), $node->getItem()->getId())) { echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'delete') . "</th><th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'rename') . "</th>"; } } echo "</tr><tr><td colspan=\"6\"><hr /></td></tr>"; $files = $this->server->getPropertiesForPath($path, array('{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified'), 1); if ($path) { list($parentUri) = Sabre_DAV_URLUtil::splitPath($path); $fullPath = Sabre_DAV_URLUtil::encodePath($this->server->getBaseUri() . $parentUri); echo "<tr><td><a href=\"{$fullPath}\">..</a></td></tr>"; } foreach ($files as $file) { // This is the current directory, we can skip it if (rtrim($file['href'], '/') == $path) { continue; } list(, $name) = Sabre_DAV_URLUtil::splitPath($file['href']); $type = null; if (isset($file[200]['{DAV:}resourcetype'])) { $type = $file[200]['{DAV:}resourcetype']->getValue(); // resourcetype can have multiple values if (!is_array($type)) { $type = array($type); } foreach ($type as $k => $v) { // Some name mapping is preferred if ($v == '{DAV:}collection') { $type[$k] = $GLOBALS["Language"]->getText("plugin_webdav_html", "directory"); } elseif ($v == '') { if (isset($file[200]['{DAV:}getcontenttype'])) { $type[$k] = $file[200]['{DAV:}getcontenttype']; } else { $type[$k] = $GLOBALS["Language"]->getText("plugin_webdav_html", "unknown"); } } } $type = implode(', ', $type); } $type = $this->escapeHTML($type); $size = isset($file[200]['{DAV:}getcontentlength']) ? (int) $file[200]['{DAV:}getcontentlength'] : ''; $lastmodified = isset($file[200]['{DAV:}getlastmodified']) ? $file[200]['{DAV:}getlastmodified']->getTime()->format(DATE_ATOM) : ''; $fullPath = '/' . trim($this->server->getBaseUri() . ($path ? $this->escapeHTML($path) . '/' : '') . $name, '/'); echo str_replace("%", "%25", "<tr><td><a href=\"{$fullPath}\">{$name}</a></td>"); echo "<td>{$type}</td>"; if ($class == 'WebDAVFRS' && $node->userCanWrite()) { $this->deleteForm($file); $this->renameForm($file); } if ($class == 'WebDAVFRSPackage') { echo "<td>{$lastmodified}</td>"; if ($node->userCanWrite()) { $this->deleteForm($file); $this->renameForm($file); $destinations = $this->getReleaseDestinations($file); //$this->moveForm($file, $destinations); } } if ($class == 'WebDAVFRSRelease') { echo "<td>{$size}</td>"; echo "<td>{$lastmodified}</td>"; if ($node->userCanWrite()) { $this->deleteForm($file); $destinations = $this->getFileDestinations($file); //$this->moveForm($file, $destinations); } } if ($class == 'WebDAVDocmanFolder') { echo "<td>{$size}</td>"; echo "<td>{$lastmodified}</td>"; $docmanPermissionManager = $node->getUtils()->getDocmanPermissionsManager($node->getProject()); if ($node->getUtils()->isWriteEnabled() && $docmanPermissionManager->userCanWrite($node->getUser(), $node->getItem()->getId())) { $this->deleteForm($file); $this->renameForm($file); } } echo "</tr>"; } echo "<tr><td colspan=\"6\"><hr /></td></tr>\n <tr><td>"; if ($this->enablePost) { if ($class == 'WebDAVFRS' && $node->userCanWrite()) { echo '<h4>' . $GLOBALS["Language"]->getText("plugin_webdav_html", "create_package") . ' :</h4>'; $this->mkcolForm(); } if ($class == 'WebDAVFRSPackage' && $node->userCanWrite()) { echo '<h4>' . $GLOBALS["Language"]->getText("plugin_webdav_html", "create_release") . ' :</h4>'; $this->mkcolForm(); } if ($class == 'WebDAVFRSRelease' && $node->userCanWrite()) { echo '<h4>' . $GLOBALS["Language"]->getText("plugin_webdav_html", "upload_file") . ' :</h4> <form method="post" action="" enctype="multipart/form-data"> <input type="hidden" name="action" value="put" /> ' . $GLOBALS["Language"]->getText("plugin_webdav_html", "name") . ' (' . $GLOBALS["Language"]->getText("plugin_webdav_html", "optional") . ') : <input type="text" name="name" /><br /> ' . $GLOBALS["Language"]->getText("plugin_webdav_html", "file") . ' : <input type="file" name="file" /> <button type="submit" style="background:white; border:0;" value="upload"><img src="https://' . $GLOBALS['sys_https_host'] . '/themes/Dawn/images/ic/tick.png"></button> </form>'; } if ($class == 'WebDAVDocmanFolder') { if ($node->getUtils()->isWriteEnabled() && $docmanPermissionManager->userCanWrite($node->getUser(), $node->getItem()->getId())) { echo '<h4>Create a new folder :</h4>'; $this->mkcolForm(); echo '<h4>' . $GLOBALS["Language"]->getText("plugin_webdav_html", "upload_file") . ' :</h4> <form method="post" action="" enctype="multipart/form-data"> <input type="hidden" name="action" value="put" /> ' . $GLOBALS["Language"]->getText("plugin_webdav_html", "name") . ' (' . $GLOBALS["Language"]->getText("plugin_webdav_html", "optional") . ') : <input type="text" name="name" /><br /> ' . $GLOBALS["Language"]->getText("plugin_webdav_html", "file") . ' : <input type="file" name="file" /> <button type="submit" style="background:white; border:0;" value="upload"><img src="https://' . $GLOBALS['sys_https_host'] . '/themes/Dawn/images/ic/tick.png"></button> </form>'; } } echo '</td></tr>'; } echo "</table>"; echo $GLOBALS['HTML']->pv_footer(array()); return ob_get_clean(); }
/** * Triggered before properties are looked up in specific nodes. * * @param string $uri * @param Sabre_DAV_INode $node * @param array $requestedProperties * @param array $returnedProperties * @TODO really should be broken into multiple methods, or even a class. * @return bool */ public function beforeGetProperties($uri, Sabre_DAV_INode $node, &$requestedProperties, &$returnedProperties) { // Checking the read permission if (!$this->checkPrivileges($uri, '{DAV:}read', self::R_PARENT, false)) { // User is not allowed to read properties if ($this->hideNodesFromListings) { return false; } // Marking all requested properties as '403'. foreach ($requestedProperties as $key => $requestedProperty) { unset($requestedProperties[$key]); $returnedProperties[403][$requestedProperty] = null; } return; } /* Adding principal properties */ if ($node instanceof Sabre_DAVACL_IPrincipal) { if (false !== ($index = array_search('{DAV:}alternate-URI-set', $requestedProperties))) { unset($requestedProperties[$index]); $returnedProperties[200]['{DAV:}alternate-URI-set'] = new Sabre_DAV_Property_HrefList($node->getAlternateUriSet()); } if (false !== ($index = array_search('{DAV:}principal-URL', $requestedProperties))) { unset($requestedProperties[$index]); $returnedProperties[200]['{DAV:}principal-URL'] = new Sabre_DAV_Property_Href(Sabre_DAV_URLUtil::encodePath($node->getPrincipalUrl()) . '/'); } if (false !== ($index = array_search('{DAV:}group-member-set', $requestedProperties))) { unset($requestedProperties[$index]); $returnedProperties[200]['{DAV:}group-member-set'] = new Sabre_DAV_Property_HrefList($node->getGroupMemberSet()); } if (false !== ($index = array_search('{DAV:}group-membership', $requestedProperties))) { unset($requestedProperties[$index]); $returnedProperties[200]['{DAV:}group-membership'] = new Sabre_DAV_Property_HrefList($node->getGroupMembership()); } if (false !== ($index = array_search('{DAV:}displayname', $requestedProperties))) { $returnedProperties[200]['{DAV:}displayname'] = $node->getDisplayName(); } } if (false !== ($index = array_search('{DAV:}principal-collection-set', $requestedProperties))) { unset($requestedProperties[$index]); $val = $this->principalCollectionSet; // Ensuring all collections end with a slash foreach ($val as $k => $v) { $val[$k] = $v . '/'; } $returnedProperties[200]['{DAV:}principal-collection-set'] = new Sabre_DAV_Property_HrefList($val); } if (false !== ($index = array_search('{DAV:}current-user-principal', $requestedProperties))) { unset($requestedProperties[$index]); if ($url = $this->getCurrentUserPrincipal()) { $returnedProperties[200]['{DAV:}current-user-principal'] = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::HREF, Sabre_DAV_URLUtil::encodePath($url) . '/'); } else { $returnedProperties[200]['{DAV:}current-user-principal'] = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::UNAUTHENTICATED); } } if (false !== ($index = array_search('{DAV:}supported-privilege-set', $requestedProperties))) { unset($requestedProperties[$index]); $returnedProperties[200]['{DAV:}supported-privilege-set'] = new Sabre_DAVACL_Property_SupportedPrivilegeSet($this->getSupportedPrivilegeSet($node)); } if (false !== ($index = array_search('{DAV:}current-user-privilege-set', $requestedProperties))) { if (!$this->checkPrivileges($uri, '{DAV:}read-current-user-privilege-set', self::R_PARENT, false)) { $returnedProperties[403]['{DAV:}current-user-privilege-set'] = null; unset($requestedProperties[$index]); } else { $val = $this->getCurrentUserPrivilegeSet($node); if (!is_null($val)) { unset($requestedProperties[$index]); $returnedProperties[200]['{DAV:}current-user-privilege-set'] = new Sabre_DAVACL_Property_CurrentUserPrivilegeSet($val); } } } /* The ACL property contains all the permissions */ if (false !== ($index = array_search('{DAV:}acl', $requestedProperties))) { if (!$this->checkPrivileges($uri, '{DAV:}read-acl', self::R_PARENT, false)) { unset($requestedProperties[$index]); $returnedProperties[403]['{DAV:}acl'] = null; } else { $acl = $this->getACL($node); if (!is_null($acl)) { unset($requestedProperties[$index]); $returnedProperties[200]['{DAV:}acl'] = new Sabre_DAVACL_Property_Acl($this->getACL($node)); } } } /* The acl-restrictions property contains information on how privileges * must behave. */ if (false !== ($index = array_search('{DAV:}acl-restrictions', $requestedProperties))) { unset($requestedProperties[$index]); $returnedProperties[200]['{DAV:}acl-restrictions'] = new Sabre_DAVACL_Property_AclRestrictions(); } /* Adding ACL properties */ if ($node instanceof Sabre_DAVACL_IACL) { if (false !== ($index = array_search('{DAV:}owner', $requestedProperties))) { unset($requestedProperties[$index]); $returnedProperties[200]['{DAV:}owner'] = new Sabre_DAV_Property_Href($node->getOwner() . '/'); } } }