diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-10-27 16:33:10 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-10-27 16:33:10 +0200 |
commit | 894d44e796bf99882383fcee42f754c5d9d6828b (patch) | |
tree | 848094d3e67f86a337b9be332108fe571334303c /3rdparty/Sabre/DAVACL/Plugin.php | |
parent | c1c76539cc2878c058de15892dd05d6dd8b4b9a5 (diff) | |
parent | b2b84f3a6f3c98005f80c6c7c558a33b4ea36193 (diff) | |
download | nextcloud-server-894d44e796bf99882383fcee42f754c5d9d6828b.tar.gz nextcloud-server-894d44e796bf99882383fcee42f754c5d9d6828b.zip |
Merge remote-tracking branch 'git://github.com/susinths/SabreDAV_1.7.1.git'
Conflicts:
lib/base.php
Diffstat (limited to '3rdparty/Sabre/DAVACL/Plugin.php')
-rw-r--r--[-rwxr-xr-x] | 3rdparty/Sabre/DAVACL/Plugin.php | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/3rdparty/Sabre/DAVACL/Plugin.php b/3rdparty/Sabre/DAVACL/Plugin.php index 5c828c6d97b..5b17c838475 100755..100644 --- a/3rdparty/Sabre/DAVACL/Plugin.php +++ b/3rdparty/Sabre/DAVACL/Plugin.php @@ -3,7 +3,7 @@ /** * SabreDAV ACL Plugin * - * This plugin provides funcitonality to enforce ACL permissions. + * This plugin provides functionality to enforce ACL permissions. * ACL is defined in RFC3744. * * In addition it also provides support for the {DAV:}current-user-principal @@ -102,11 +102,11 @@ class Sabre_DAVACL_Plugin extends Sabre_DAV_ServerPlugin { ); /** - * Any principal uri's added here, will automatically be added to the list - * of ACL's. They will effectively receive {DAV:}all privileges, as a + * Any principal uri's added here, will automatically be added to the list + * of ACL's. They will effectively receive {DAV:}all privileges, as a * protected privilege. - * - * @var array + * + * @var array */ public $adminPrincipals = array(); @@ -233,6 +233,7 @@ class Sabre_DAVACL_Plugin extends Sabre_DAV_ServerPlugin { $authPlugin = $this->server->getPlugin('auth'); if (is_null($authPlugin)) return null; + /** @var $authPlugin Sabre_DAV_Auth_Plugin */ $userName = $authPlugin->getCurrentUser(); if (!$userName) return null; @@ -242,6 +243,14 @@ class Sabre_DAVACL_Plugin extends Sabre_DAV_ServerPlugin { } /** + * This array holds a cache for all the principals that are associated with + * a single principal. + * + * @var array + */ + protected $currentUserPrincipalsCache = array(); + + /** * Returns a list of principals that's associated to the current * user, either directly or through group membership. * @@ -253,6 +262,11 @@ class Sabre_DAVACL_Plugin extends Sabre_DAV_ServerPlugin { if (is_null($currentUser)) return array(); + // First check our cache + if (isset($this->currentUserPrincipalsCache[$currentUser])) { + return $this->currentUserPrincipalsCache[$currentUser]; + } + $check = array($currentUser); $principals = array($currentUser); @@ -277,6 +291,9 @@ class Sabre_DAVACL_Plugin extends Sabre_DAV_ServerPlugin { } + // Store the result in the cache + $this->currentUserPrincipalsCache[$currentUser] = $principals; + return $principals; } @@ -771,7 +788,7 @@ class Sabre_DAVACL_Plugin extends Sabre_DAV_ServerPlugin { * @param array $requestedProperties * @param array $returnedProperties * @TODO really should be broken into multiple methods, or even a class. - * @return void + * @return bool */ public function beforeGetProperties($uri, Sabre_DAV_INode $node, &$requestedProperties, &$returnedProperties) { @@ -895,6 +912,18 @@ class Sabre_DAVACL_Plugin extends Sabre_DAV_ServerPlugin { $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() . '/'); + + } + + } + } /** @@ -928,6 +957,9 @@ class Sabre_DAVACL_Plugin extends Sabre_DAV_ServerPlugin { } $node->setGroupMemberSet($memberSet); + // We must also clear our cache, just in case + + $this->currentUserPrincipalsCache = array(); $result[200]['{DAV:}group-member-set'] = null; unset($propertyDelta['{DAV:}group-member-set']); @@ -935,7 +967,7 @@ class Sabre_DAVACL_Plugin extends Sabre_DAV_ServerPlugin { } /** - * This method handels HTTP REPORT requests + * This method handles HTTP REPORT requests * * @param string $reportName * @param DOMNode $dom @@ -1268,10 +1300,12 @@ class Sabre_DAVACL_Plugin extends Sabre_DAV_ServerPlugin { } $result = $this->principalSearch($searchProperties, $requestedProperties, $uri); - $xml = $this->server->generateMultiStatus($result); - $this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + $prefer = $this->server->getHTTPPRefer(); + $this->server->httpResponse->sendStatus(207); - $this->server->httpResponse->sendBody($xml); + $this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + $this->server->httpResponse->setHeader('Vary','Brief,Prefer'); + $this->server->httpResponse->sendBody($this->server->generateMultiStatus($result, $prefer['return-minimal'])); } |