summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/connector/sabre/filesplugin.php8
-rw-r--r--apps/dav/lib/connector/sabre/node.php29
2 files changed, 33 insertions, 4 deletions
diff --git a/apps/dav/lib/connector/sabre/filesplugin.php b/apps/dav/lib/connector/sabre/filesplugin.php
index 686d0863f91..bd00a7c9930 100644
--- a/apps/dav/lib/connector/sabre/filesplugin.php
+++ b/apps/dav/lib/connector/sabre/filesplugin.php
@@ -236,6 +236,8 @@ class FilesPlugin extends ServerPlugin {
*/
public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) {
+ $httpRequest = $this->server->httpRequest;
+
if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
$propFind->handle(self::FILEID_PROPERTYNAME, function() use ($node) {
@@ -255,8 +257,10 @@ class FilesPlugin extends ServerPlugin {
return $perms;
});
- $propFind->handle(self::SHARE_PERMISSIONS_PROPERTYNAME, function() use ($node) {
- return $node->getSharePermissions();
+ $propFind->handle(self::SHARE_PERMISSIONS_PROPERTYNAME, function() use ($node, $httpRequest) {
+ return $node->getSharePermissions(
+ $httpRequest->getRawServerValue('PHP_AUTH_USER')
+ );
});
$propFind->handle(self::GETETAG_PROPERTYNAME, function() use ($node) {
diff --git a/apps/dav/lib/connector/sabre/node.php b/apps/dav/lib/connector/sabre/node.php
index eaba6713992..edb0ad82f41 100644
--- a/apps/dav/lib/connector/sabre/node.php
+++ b/apps/dav/lib/connector/sabre/node.php
@@ -32,6 +32,8 @@ namespace OCA\DAV\Connector\Sabre;
use OC\Files\Mount\MoveableMount;
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
+use OCP\Share\Exceptions\ShareNotFound;
+use OCP\Share\IManager;
abstract class Node implements \Sabre\DAV\INode {
@@ -61,15 +63,26 @@ abstract class Node implements \Sabre\DAV\INode {
protected $info;
/**
+ * @var IManager
+ */
+ protected $shareManager;
+
+ /**
* Sets up the node, expects a full path name
*
* @param \OC\Files\View $view
* @param \OCP\Files\FileInfo $info
+ * @param IManager $shareManager
*/
- public function __construct($view, $info) {
+ public function __construct($view, $info, IManager $shareManager = null) {
$this->fileView = $view;
$this->path = $this->fileView->getRelativePath($info->getPath());
$this->info = $info;
+ if ($shareManager) {
+ $this->shareManager = $shareManager;
+ } else {
+ $this->shareManager = \OC::$server->getShareManager();
+ }
}
protected function refreshInfo() {
@@ -215,9 +228,21 @@ abstract class Node implements \Sabre\DAV\INode {
}
/**
+ * @param string $user
* @return int
*/
- public function getSharePermissions() {
+ public function getSharePermissions($user) {
+
+ // check of we access a federated share
+ if ($user !== null) {
+ try {
+ $share = $this->shareManager->getShareByToken($user);
+ return $share->getPermissions();
+ } catch (ShareNotFound $e) {
+ // ignore
+ }
+ }
+
$storage = $this->info->getStorage();
$path = $this->info->getInternalPath();