diff options
author | Robin McCorkell <rmccorkell@owncloud.com> | 2015-09-13 19:38:22 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@owncloud.com> | 2015-09-13 19:38:22 +0100 |
commit | 0dc71813354407fad8fa1db113d75cad78dfc12f (patch) | |
tree | b34b739c2035808f08b8d92dac5ff1a40977b6ea /apps/files_external/service | |
parent | 2e7d50b7233dd812a0cca8bdc433fbfa41b8b31e (diff) | |
parent | 442f5269ef229afa09cbe1e06b2a73bb9656e8c4 (diff) | |
download | nextcloud-server-0dc71813354407fad8fa1db113d75cad78dfc12f.tar.gz nextcloud-server-0dc71813354407fad8fa1db113d75cad78dfc12f.zip |
Merge pull request #18441 from owncloud/ext-backends.advanced
Migrate advanced external storage backends to new registration API [part 3]
Diffstat (limited to 'apps/files_external/service')
-rw-r--r-- | apps/files_external/service/backendservice.php | 69 |
1 files changed, 12 insertions, 57 deletions
diff --git a/apps/files_external/service/backendservice.php b/apps/files_external/service/backendservice.php index 382834b4c19..70cb9291660 100644 --- a/apps/files_external/service/backendservice.php +++ b/apps/files_external/service/backendservice.php @@ -31,13 +31,17 @@ use \OCA\Files_External\Lib\Auth\AuthMechanism; */ class BackendService { - /** Visibility constants for VisibilityTrait */ - const VISIBILITY_NONE = 0; - const VISIBILITY_PERSONAL = 1; - const VISIBILITY_ADMIN = 2; - //const VISIBILITY_ALIENS = 4; + /** Permission constants for PermissionsTrait */ + const PERMISSION_NONE = 0; + const PERMISSION_MOUNT = 1; + const PERMISSION_CREATE = 2; + const PERMISSION_MODIFY = 4; - const VISIBILITY_DEFAULT = 3; // PERSONAL | ADMIN + const PERMISSION_DEFAULT = 7; // MOUNT | CREATE | MODIFY + + /** User contants */ + const USER_ADMIN = 'admin'; + const USER_PERSONAL = 'personal'; /** Priority constants for PriorityTrait */ const PRIORITY_DEFAULT = 100; @@ -81,7 +85,7 @@ class BackendService { */ public function registerBackend(Backend $backend) { if (!$this->isAllowedUserBackend($backend)) { - $backend->removeVisibility(BackendService::VISIBILITY_PERSONAL); + $backend->removePermission(self::USER_PERSONAL, self::PERMISSION_CREATE | self::PERMISSION_MOUNT); } foreach ($backend->getIdentifierAliases() as $alias) { $this->backends[$alias] = $backend; @@ -103,7 +107,7 @@ class BackendService { */ public function registerAuthMechanism(AuthMechanism $authMech) { if (!$this->isAllowedAuthMechanism($authMech)) { - $authMech->removeVisibility(BackendService::VISIBILITY_PERSONAL); + $authMech->removePermission(self::USER_PERSONAL, self::PERMISSION_CREATE | self::PERMISSION_MOUNT); } foreach ($authMech->getIdentifierAliases() as $alias) { $this->authMechanisms[$alias] = $authMech; @@ -145,30 +149,6 @@ class BackendService { } /** - * Get backends visible for $visibleFor - * - * @param int $visibleFor - * @return Backend[] - */ - public function getBackendsVisibleFor($visibleFor) { - return array_filter($this->getAvailableBackends(), function($backend) use ($visibleFor) { - return $backend->isVisibleFor($visibleFor); - }); - } - - /** - * Get backends allowed to be visible for $visibleFor - * - * @param int $visibleFor - * @return Backend[] - */ - public function getBackendsAllowedVisibleFor($visibleFor) { - return array_filter($this->getAvailableBackends(), function($backend) use ($visibleFor) { - return $backend->isAllowedVisibleFor($visibleFor); - }); - } - - /** * @param string $identifier * @return Backend|null */ @@ -206,31 +186,6 @@ class BackendService { } /** - * Get authentication mechanisms visible for $visibleFor - * - * @param int $visibleFor - * @return AuthMechanism[] - */ - public function getAuthMechanismsVisibleFor($visibleFor) { - return array_filter($this->getAuthMechanisms(), function($authMechanism) use ($visibleFor) { - return $authMechanism->isVisibleFor($visibleFor); - }); - } - - /** - * Get authentication mechanisms allowed to be visible for $visibleFor - * - * @param int $visibleFor - * @return AuthMechanism[] - */ - public function getAuthMechanismsAllowedVisibleFor($visibleFor) { - return array_filter($this->getAuthMechanisms(), function($authMechanism) use ($visibleFor) { - return $authMechanism->isAllowedVisibleFor($visibleFor); - }); - } - - - /** * @param string $identifier * @return AuthMechanism|null */ |