summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-03-23 11:03:55 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-03-23 11:03:55 +0100
commit24331be991e4485ae33bdd8c583c706e0c128990 (patch)
tree9cdbc4053fc376da9ae4a277346d13318ccfabf8
parente9d62741e89800b340b635cfe38265b90252c255 (diff)
parent164282c72ee8653df1a26e399ea3e87ee316af8d (diff)
downloadnextcloud-server-24331be991e4485ae33bdd8c583c706e0c128990.tar.gz
nextcloud-server-24331be991e4485ae33bdd8c583c706e0c128990.zip
Merge pull request #23431 from owncloud/use-dav-sabre-plugin-for-browser-2
Fix display of vcard and calendar object details page in browser plugin
-rw-r--r--apps/dav/lib/connector/sabre/filesplugin.php37
-rw-r--r--apps/dav/lib/connector/sabre/serverfactory.php3
-rw-r--r--apps/dav/lib/server.php3
3 files changed, 29 insertions, 14 deletions
diff --git a/apps/dav/lib/connector/sabre/filesplugin.php b/apps/dav/lib/connector/sabre/filesplugin.php
index e973b4e8682..fb2af554c68 100644
--- a/apps/dav/lib/connector/sabre/filesplugin.php
+++ b/apps/dav/lib/connector/sabre/filesplugin.php
@@ -27,10 +27,13 @@
namespace OCA\DAV\Connector\Sabre;
+use OC\Files\View;
+use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\IFile;
use \Sabre\DAV\PropFind;
use \Sabre\DAV\PropPatch;
+use Sabre\DAV\Tree;
use \Sabre\HTTP\RequestInterface;
use \Sabre\HTTP\ResponseInterface;
use OCP\Files\StorageNotAvailableException;
@@ -58,7 +61,7 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
private $server;
/**
- * @var \Sabre\DAV\Tree
+ * @var Tree
*/
private $tree;
@@ -71,21 +74,29 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
private $isPublic;
/**
- * @var \OC\Files\View
+ * @var View
*/
private $fileView;
/**
- * @param \Sabre\DAV\Tree $tree
- * @param \OC\Files\View $view
+ * @var bool
+ */
+ private $downloadAttachment;
+
+ /**
+ * @param Tree $tree
+ * @param View $view
* @param bool $isPublic
+ * @param bool $downloadAttachment
*/
- public function __construct(\Sabre\DAV\Tree $tree,
- \OC\Files\View $view,
- $isPublic = false) {
+ public function __construct(Tree $tree,
+ View $view,
+ $isPublic = false,
+ $downloadAttachment = true) {
$this->tree = $tree;
$this->fileView = $view;
$this->isPublic = $isPublic;
+ $this->downloadAttachment = $downloadAttachment;
}
/**
@@ -135,7 +146,7 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
* Plugin that checks if a move can actually be performed.
* @param string $source source path
* @param string $destination destination path
- * @throws \Sabre\DAV\Exception\Forbidden
+ * @throws Forbidden
*/
function checkMove($source, $destination) {
list($sourceDir,) = \Sabre\HTTP\URLUtil::splitPath($source);
@@ -145,11 +156,11 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
$sourceFileInfo = $this->fileView->getFileInfo($source);
if ($sourceFileInfo === false) {
- throw new \Sabre\DAV\Exception\NotFound($source . ' does not exist');
+ throw new NotFound($source . ' does not exist');
}
if (!$sourceFileInfo->isDeletable()) {
- throw new \Sabre\DAV\Exception\Forbidden($source . " cannot be deleted");
+ throw new Forbidden($source . " cannot be deleted");
}
}
}
@@ -192,7 +203,9 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
if (!($node instanceof IFile)) return;
// adds a 'Content-Disposition: attachment' header
- $response->addHeader('Content-Disposition', 'attachment');
+ if ($this->downloadAttachment) {
+ $response->addHeader('Content-Disposition', 'attachment');
+ }
if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
//Add OC-Checksum header
@@ -233,7 +246,7 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
});
$propFind->handle(self::GETETAG_PROPERTYNAME, function() use ($node) {
- return $node->getEtag();
+ return $node->getETag();
});
$propFind->handle(self::OWNER_ID_PROPERTYNAME, function() use ($node) {
diff --git a/apps/dav/lib/connector/sabre/serverfactory.php b/apps/dav/lib/connector/sabre/serverfactory.php
index 080f889ae71..8158db3e92a 100644
--- a/apps/dav/lib/connector/sabre/serverfactory.php
+++ b/apps/dav/lib/connector/sabre/serverfactory.php
@@ -132,7 +132,8 @@ class ServerFactory {
}
$objectTree->init($root, $view, $this->mountManager);
- $server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesPlugin($objectTree, $view));
+ $server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesPlugin($objectTree, $view, false,
+ !$this->config->getSystemValue('debug', false)));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view));
if($this->userSession->isLoggedIn()) {
diff --git a/apps/dav/lib/server.php b/apps/dav/lib/server.php
index f624137f316..e74292282a7 100644
--- a/apps/dav/lib/server.php
+++ b/apps/dav/lib/server.php
@@ -125,7 +125,8 @@ class Server {
$user = \OC::$server->getUserSession()->getUser();
if (!is_null($user)) {
$view = \OC\Files\Filesystem::getView();
- $this->server->addPlugin(new FilesPlugin($this->server->tree, $view));
+ $this->server->addPlugin(new FilesPlugin($this->server->tree, $view, false,
+ !\OC::$server->getConfig()->getSystemValue('debug', false)));
$this->server->addPlugin(
new \Sabre\DAV\PropertyStorage\Plugin(