@@ -35,144 +35,144 @@ |
||
| 35 | 35 | |
| 36 | 36 | class SystemTagsByIdCollection implements ICollection { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var ISystemTagManager |
|
| 40 | - */ |
|
| 41 | - private $tagManager; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var IGroupManager |
|
| 45 | - */ |
|
| 46 | - private $groupManager; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var IUserSession |
|
| 50 | - */ |
|
| 51 | - private $userSession; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * SystemTagsByIdCollection constructor. |
|
| 55 | - * |
|
| 56 | - * @param ISystemTagManager $tagManager |
|
| 57 | - * @param IUserSession $userSession |
|
| 58 | - * @param IGroupManager $groupManager |
|
| 59 | - */ |
|
| 60 | - public function __construct( |
|
| 61 | - ISystemTagManager $tagManager, |
|
| 62 | - IUserSession $userSession, |
|
| 63 | - IGroupManager $groupManager |
|
| 64 | - ) { |
|
| 65 | - $this->tagManager = $tagManager; |
|
| 66 | - $this->userSession = $userSession; |
|
| 67 | - $this->groupManager = $groupManager; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Returns whether the currently logged in user is an administrator |
|
| 72 | - * |
|
| 73 | - * @return bool true if the user is an admin |
|
| 74 | - */ |
|
| 75 | - private function isAdmin() { |
|
| 76 | - $user = $this->userSession->getUser(); |
|
| 77 | - if ($user !== null) { |
|
| 78 | - return $this->groupManager->isAdmin($user->getUID()); |
|
| 79 | - } |
|
| 80 | - return false; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @param string $name |
|
| 85 | - * @param resource|string $data Initial payload |
|
| 86 | - * @throws Forbidden |
|
| 87 | - */ |
|
| 88 | - public function createFile($name, $data = null) { |
|
| 89 | - throw new Forbidden('Cannot create tags by id'); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @param string $name |
|
| 94 | - */ |
|
| 95 | - public function createDirectory($name) { |
|
| 96 | - throw new Forbidden('Permission denied to create collections'); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @param string $name |
|
| 101 | - */ |
|
| 102 | - public function getChild($name) { |
|
| 103 | - try { |
|
| 104 | - $tag = $this->tagManager->getTagsByIds([$name]); |
|
| 105 | - $tag = current($tag); |
|
| 106 | - if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
|
| 107 | - throw new NotFound('Tag with id ' . $name . ' not found'); |
|
| 108 | - } |
|
| 109 | - return $this->makeNode($tag); |
|
| 110 | - } catch (\InvalidArgumentException $e) { |
|
| 111 | - throw new BadRequest('Invalid tag id', 0, $e); |
|
| 112 | - } catch (TagNotFoundException $e) { |
|
| 113 | - throw new NotFound('Tag with id ' . $name . ' not found', 0, $e); |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - public function getChildren() { |
|
| 118 | - $visibilityFilter = true; |
|
| 119 | - if ($this->isAdmin()) { |
|
| 120 | - $visibilityFilter = null; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $tags = $this->tagManager->getAllTags($visibilityFilter); |
|
| 124 | - return array_map(function ($tag) { |
|
| 125 | - return $this->makeNode($tag); |
|
| 126 | - }, $tags); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @param string $name |
|
| 131 | - */ |
|
| 132 | - public function childExists($name) { |
|
| 133 | - try { |
|
| 134 | - $tag = $this->tagManager->getTagsByIds([$name]); |
|
| 135 | - $tag = current($tag); |
|
| 136 | - if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
|
| 137 | - return false; |
|
| 138 | - } |
|
| 139 | - return true; |
|
| 140 | - } catch (\InvalidArgumentException $e) { |
|
| 141 | - throw new BadRequest('Invalid tag id', 0, $e); |
|
| 142 | - } catch (TagNotFoundException $e) { |
|
| 143 | - return false; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - public function delete() { |
|
| 148 | - throw new Forbidden('Permission denied to delete this collection'); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - public function getName() { |
|
| 152 | - return 'systemtags'; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - public function setName($name) { |
|
| 156 | - throw new Forbidden('Permission denied to rename this collection'); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Returns the last modification time, as a unix timestamp |
|
| 161 | - * |
|
| 162 | - * @return int |
|
| 163 | - */ |
|
| 164 | - public function getLastModified() { |
|
| 165 | - return null; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Create a sabre node for the given system tag |
|
| 170 | - * |
|
| 171 | - * @param ISystemTag $tag |
|
| 172 | - * |
|
| 173 | - * @return SystemTagNode |
|
| 174 | - */ |
|
| 175 | - private function makeNode(ISystemTag $tag) { |
|
| 176 | - return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager); |
|
| 177 | - } |
|
| 38 | + /** |
|
| 39 | + * @var ISystemTagManager |
|
| 40 | + */ |
|
| 41 | + private $tagManager; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var IGroupManager |
|
| 45 | + */ |
|
| 46 | + private $groupManager; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var IUserSession |
|
| 50 | + */ |
|
| 51 | + private $userSession; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * SystemTagsByIdCollection constructor. |
|
| 55 | + * |
|
| 56 | + * @param ISystemTagManager $tagManager |
|
| 57 | + * @param IUserSession $userSession |
|
| 58 | + * @param IGroupManager $groupManager |
|
| 59 | + */ |
|
| 60 | + public function __construct( |
|
| 61 | + ISystemTagManager $tagManager, |
|
| 62 | + IUserSession $userSession, |
|
| 63 | + IGroupManager $groupManager |
|
| 64 | + ) { |
|
| 65 | + $this->tagManager = $tagManager; |
|
| 66 | + $this->userSession = $userSession; |
|
| 67 | + $this->groupManager = $groupManager; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Returns whether the currently logged in user is an administrator |
|
| 72 | + * |
|
| 73 | + * @return bool true if the user is an admin |
|
| 74 | + */ |
|
| 75 | + private function isAdmin() { |
|
| 76 | + $user = $this->userSession->getUser(); |
|
| 77 | + if ($user !== null) { |
|
| 78 | + return $this->groupManager->isAdmin($user->getUID()); |
|
| 79 | + } |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @param string $name |
|
| 85 | + * @param resource|string $data Initial payload |
|
| 86 | + * @throws Forbidden |
|
| 87 | + */ |
|
| 88 | + public function createFile($name, $data = null) { |
|
| 89 | + throw new Forbidden('Cannot create tags by id'); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @param string $name |
|
| 94 | + */ |
|
| 95 | + public function createDirectory($name) { |
|
| 96 | + throw new Forbidden('Permission denied to create collections'); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @param string $name |
|
| 101 | + */ |
|
| 102 | + public function getChild($name) { |
|
| 103 | + try { |
|
| 104 | + $tag = $this->tagManager->getTagsByIds([$name]); |
|
| 105 | + $tag = current($tag); |
|
| 106 | + if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
|
| 107 | + throw new NotFound('Tag with id ' . $name . ' not found'); |
|
| 108 | + } |
|
| 109 | + return $this->makeNode($tag); |
|
| 110 | + } catch (\InvalidArgumentException $e) { |
|
| 111 | + throw new BadRequest('Invalid tag id', 0, $e); |
|
| 112 | + } catch (TagNotFoundException $e) { |
|
| 113 | + throw new NotFound('Tag with id ' . $name . ' not found', 0, $e); |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + public function getChildren() { |
|
| 118 | + $visibilityFilter = true; |
|
| 119 | + if ($this->isAdmin()) { |
|
| 120 | + $visibilityFilter = null; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $tags = $this->tagManager->getAllTags($visibilityFilter); |
|
| 124 | + return array_map(function ($tag) { |
|
| 125 | + return $this->makeNode($tag); |
|
| 126 | + }, $tags); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @param string $name |
|
| 131 | + */ |
|
| 132 | + public function childExists($name) { |
|
| 133 | + try { |
|
| 134 | + $tag = $this->tagManager->getTagsByIds([$name]); |
|
| 135 | + $tag = current($tag); |
|
| 136 | + if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
|
| 137 | + return false; |
|
| 138 | + } |
|
| 139 | + return true; |
|
| 140 | + } catch (\InvalidArgumentException $e) { |
|
| 141 | + throw new BadRequest('Invalid tag id', 0, $e); |
|
| 142 | + } catch (TagNotFoundException $e) { |
|
| 143 | + return false; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + public function delete() { |
|
| 148 | + throw new Forbidden('Permission denied to delete this collection'); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + public function getName() { |
|
| 152 | + return 'systemtags'; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + public function setName($name) { |
|
| 156 | + throw new Forbidden('Permission denied to rename this collection'); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Returns the last modification time, as a unix timestamp |
|
| 161 | + * |
|
| 162 | + * @return int |
|
| 163 | + */ |
|
| 164 | + public function getLastModified() { |
|
| 165 | + return null; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Create a sabre node for the given system tag |
|
| 170 | + * |
|
| 171 | + * @param ISystemTag $tag |
|
| 172 | + * |
|
| 173 | + * @return SystemTagNode |
|
| 174 | + */ |
|
| 175 | + private function makeNode(ISystemTag $tag) { |
|
| 176 | + return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager); |
|
| 177 | + } |
|
| 178 | 178 | } |
@@ -36,87 +36,87 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class FutureFile implements \Sabre\DAV\IFile { |
| 38 | 38 | |
| 39 | - /** @var Directory */ |
|
| 40 | - private $root; |
|
| 41 | - /** @var string */ |
|
| 42 | - private $name; |
|
| 39 | + /** @var Directory */ |
|
| 40 | + private $root; |
|
| 41 | + /** @var string */ |
|
| 42 | + private $name; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @param Directory $root |
|
| 46 | - * @param string $name |
|
| 47 | - */ |
|
| 48 | - public function __construct(Directory $root, $name) { |
|
| 49 | - $this->root = $root; |
|
| 50 | - $this->name = $name; |
|
| 51 | - } |
|
| 44 | + /** |
|
| 45 | + * @param Directory $root |
|
| 46 | + * @param string $name |
|
| 47 | + */ |
|
| 48 | + public function __construct(Directory $root, $name) { |
|
| 49 | + $this->root = $root; |
|
| 50 | + $this->name = $name; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @inheritdoc |
|
| 55 | - */ |
|
| 56 | - public function put($data) { |
|
| 57 | - throw new Forbidden('Permission denied to put into this file'); |
|
| 58 | - } |
|
| 53 | + /** |
|
| 54 | + * @inheritdoc |
|
| 55 | + */ |
|
| 56 | + public function put($data) { |
|
| 57 | + throw new Forbidden('Permission denied to put into this file'); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @inheritdoc |
|
| 62 | - */ |
|
| 63 | - public function get() { |
|
| 64 | - $nodes = $this->root->getChildren(); |
|
| 65 | - return AssemblyStream::wrap($nodes); |
|
| 66 | - } |
|
| 60 | + /** |
|
| 61 | + * @inheritdoc |
|
| 62 | + */ |
|
| 63 | + public function get() { |
|
| 64 | + $nodes = $this->root->getChildren(); |
|
| 65 | + return AssemblyStream::wrap($nodes); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @inheritdoc |
|
| 70 | - */ |
|
| 71 | - public function getContentType() { |
|
| 72 | - return 'application/octet-stream'; |
|
| 73 | - } |
|
| 68 | + /** |
|
| 69 | + * @inheritdoc |
|
| 70 | + */ |
|
| 71 | + public function getContentType() { |
|
| 72 | + return 'application/octet-stream'; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @inheritdoc |
|
| 77 | - */ |
|
| 78 | - public function getETag() { |
|
| 79 | - return $this->root->getETag(); |
|
| 80 | - } |
|
| 75 | + /** |
|
| 76 | + * @inheritdoc |
|
| 77 | + */ |
|
| 78 | + public function getETag() { |
|
| 79 | + return $this->root->getETag(); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @inheritdoc |
|
| 84 | - */ |
|
| 85 | - public function getSize() { |
|
| 86 | - $children = $this->root->getChildren(); |
|
| 87 | - $sizes = array_map(function ($node) { |
|
| 88 | - /** @var IFile $node */ |
|
| 89 | - return $node->getSize(); |
|
| 90 | - }, $children); |
|
| 82 | + /** |
|
| 83 | + * @inheritdoc |
|
| 84 | + */ |
|
| 85 | + public function getSize() { |
|
| 86 | + $children = $this->root->getChildren(); |
|
| 87 | + $sizes = array_map(function ($node) { |
|
| 88 | + /** @var IFile $node */ |
|
| 89 | + return $node->getSize(); |
|
| 90 | + }, $children); |
|
| 91 | 91 | |
| 92 | - return array_sum($sizes); |
|
| 93 | - } |
|
| 92 | + return array_sum($sizes); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * @inheritdoc |
|
| 97 | - */ |
|
| 98 | - public function delete() { |
|
| 99 | - $this->root->delete(); |
|
| 100 | - } |
|
| 95 | + /** |
|
| 96 | + * @inheritdoc |
|
| 97 | + */ |
|
| 98 | + public function delete() { |
|
| 99 | + $this->root->delete(); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * @inheritdoc |
|
| 104 | - */ |
|
| 105 | - public function getName() { |
|
| 106 | - return $this->name; |
|
| 107 | - } |
|
| 102 | + /** |
|
| 103 | + * @inheritdoc |
|
| 104 | + */ |
|
| 105 | + public function getName() { |
|
| 106 | + return $this->name; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * @inheritdoc |
|
| 111 | - */ |
|
| 112 | - public function setName($name) { |
|
| 113 | - throw new Forbidden('Permission denied to rename this file'); |
|
| 114 | - } |
|
| 109 | + /** |
|
| 110 | + * @inheritdoc |
|
| 111 | + */ |
|
| 112 | + public function setName($name) { |
|
| 113 | + throw new Forbidden('Permission denied to rename this file'); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * @inheritdoc |
|
| 118 | - */ |
|
| 119 | - public function getLastModified() { |
|
| 120 | - return $this->root->getLastModified(); |
|
| 121 | - } |
|
| 116 | + /** |
|
| 117 | + * @inheritdoc |
|
| 118 | + */ |
|
| 119 | + public function getLastModified() { |
|
| 120 | + return $this->root->getLastModified(); |
|
| 121 | + } |
|
| 122 | 122 | } |
@@ -31,35 +31,35 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | class DeleteOrphanedSharesJob extends TimedJob { |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Default interval in minutes |
|
| 36 | - * |
|
| 37 | - * @var int $defaultIntervalMin |
|
| 38 | - **/ |
|
| 39 | - protected $defaultIntervalMin = 15; |
|
| 34 | + /** |
|
| 35 | + * Default interval in minutes |
|
| 36 | + * |
|
| 37 | + * @var int $defaultIntervalMin |
|
| 38 | + **/ |
|
| 39 | + protected $defaultIntervalMin = 15; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * sets the correct interval for this timed job |
|
| 43 | - */ |
|
| 44 | - public function __construct() { |
|
| 45 | - $this->interval = $this->defaultIntervalMin * 60; |
|
| 46 | - } |
|
| 41 | + /** |
|
| 42 | + * sets the correct interval for this timed job |
|
| 43 | + */ |
|
| 44 | + public function __construct() { |
|
| 45 | + $this->interval = $this->defaultIntervalMin * 60; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Makes the background job do its work |
|
| 50 | - * |
|
| 51 | - * @param array $argument unused argument |
|
| 52 | - */ |
|
| 53 | - public function run($argument) { |
|
| 54 | - $connection = \OC::$server->getDatabaseConnection(); |
|
| 55 | - $logger = \OC::$server->getLogger(); |
|
| 48 | + /** |
|
| 49 | + * Makes the background job do its work |
|
| 50 | + * |
|
| 51 | + * @param array $argument unused argument |
|
| 52 | + */ |
|
| 53 | + public function run($argument) { |
|
| 54 | + $connection = \OC::$server->getDatabaseConnection(); |
|
| 55 | + $logger = \OC::$server->getLogger(); |
|
| 56 | 56 | |
| 57 | - $sql = |
|
| 58 | - 'DELETE FROM `*PREFIX*share` ' . |
|
| 59 | - 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
| 60 | - 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
|
| 57 | + $sql = |
|
| 58 | + 'DELETE FROM `*PREFIX*share` ' . |
|
| 59 | + 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
| 60 | + 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
|
| 61 | 61 | |
| 62 | - $deletedEntries = $connection->executeUpdate($sql); |
|
| 63 | - $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']); |
|
| 64 | - } |
|
| 62 | + $deletedEntries = $connection->executeUpdate($sql); |
|
| 63 | + $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']); |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -29,31 +29,31 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | trait PriorityTrait { |
| 31 | 31 | |
| 32 | - /** @var int initial priority */ |
|
| 33 | - protected $priority = BackendService::PRIORITY_DEFAULT; |
|
| 32 | + /** @var int initial priority */ |
|
| 33 | + protected $priority = BackendService::PRIORITY_DEFAULT; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @return int |
|
| 37 | - */ |
|
| 38 | - public function getPriority() { |
|
| 39 | - return $this->priority; |
|
| 40 | - } |
|
| 35 | + /** |
|
| 36 | + * @return int |
|
| 37 | + */ |
|
| 38 | + public function getPriority() { |
|
| 39 | + return $this->priority; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @param int $priority |
|
| 44 | - * @return self |
|
| 45 | - */ |
|
| 46 | - public function setPriority($priority) { |
|
| 47 | - $this->priority = $priority; |
|
| 48 | - return $this; |
|
| 49 | - } |
|
| 42 | + /** |
|
| 43 | + * @param int $priority |
|
| 44 | + * @return self |
|
| 45 | + */ |
|
| 46 | + public function setPriority($priority) { |
|
| 47 | + $this->priority = $priority; |
|
| 48 | + return $this; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @param PriorityTrait $a |
|
| 53 | - * @param PriorityTrait $b |
|
| 54 | - * @return int |
|
| 55 | - */ |
|
| 56 | - public static function priorityCompare(PriorityTrait $a, PriorityTrait $b) { |
|
| 57 | - return ($a->getPriority() - $b->getPriority()); |
|
| 58 | - } |
|
| 51 | + /** |
|
| 52 | + * @param PriorityTrait $a |
|
| 53 | + * @param PriorityTrait $b |
|
| 54 | + * @return int |
|
| 55 | + */ |
|
| 56 | + public static function priorityCompare(PriorityTrait $a, PriorityTrait $b) { |
|
| 57 | + return ($a->getPriority() - $b->getPriority()); |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -36,101 +36,101 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | trait VisibilityTrait { |
| 38 | 38 | |
| 39 | - /** @var int visibility */ |
|
| 40 | - protected $visibility = BackendService::VISIBILITY_DEFAULT; |
|
| 39 | + /** @var int visibility */ |
|
| 40 | + protected $visibility = BackendService::VISIBILITY_DEFAULT; |
|
| 41 | 41 | |
| 42 | - /** @var int allowed visibilities */ |
|
| 43 | - protected $allowedVisibility = BackendService::VISIBILITY_DEFAULT; |
|
| 42 | + /** @var int allowed visibilities */ |
|
| 43 | + protected $allowedVisibility = BackendService::VISIBILITY_DEFAULT; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @return int |
|
| 47 | - */ |
|
| 48 | - public function getVisibility() { |
|
| 49 | - return $this->visibility; |
|
| 50 | - } |
|
| 45 | + /** |
|
| 46 | + * @return int |
|
| 47 | + */ |
|
| 48 | + public function getVisibility() { |
|
| 49 | + return $this->visibility; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Check if the backend is visible for a user type |
|
| 54 | - * |
|
| 55 | - * @param int $visibility |
|
| 56 | - * @return bool |
|
| 57 | - */ |
|
| 58 | - public function isVisibleFor($visibility) { |
|
| 59 | - if ($this->visibility & $visibility) { |
|
| 60 | - return true; |
|
| 61 | - } |
|
| 62 | - return false; |
|
| 63 | - } |
|
| 52 | + /** |
|
| 53 | + * Check if the backend is visible for a user type |
|
| 54 | + * |
|
| 55 | + * @param int $visibility |
|
| 56 | + * @return bool |
|
| 57 | + */ |
|
| 58 | + public function isVisibleFor($visibility) { |
|
| 59 | + if ($this->visibility & $visibility) { |
|
| 60 | + return true; |
|
| 61 | + } |
|
| 62 | + return false; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @param int $visibility |
|
| 67 | - * @return self |
|
| 68 | - */ |
|
| 69 | - public function setVisibility($visibility) { |
|
| 70 | - $this->visibility = $visibility; |
|
| 71 | - $this->allowedVisibility |= $visibility; |
|
| 72 | - return $this; |
|
| 73 | - } |
|
| 65 | + /** |
|
| 66 | + * @param int $visibility |
|
| 67 | + * @return self |
|
| 68 | + */ |
|
| 69 | + public function setVisibility($visibility) { |
|
| 70 | + $this->visibility = $visibility; |
|
| 71 | + $this->allowedVisibility |= $visibility; |
|
| 72 | + return $this; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @param int $visibility |
|
| 77 | - * @return self |
|
| 78 | - */ |
|
| 79 | - public function addVisibility($visibility) { |
|
| 80 | - return $this->setVisibility($this->visibility | $visibility); |
|
| 81 | - } |
|
| 75 | + /** |
|
| 76 | + * @param int $visibility |
|
| 77 | + * @return self |
|
| 78 | + */ |
|
| 79 | + public function addVisibility($visibility) { |
|
| 80 | + return $this->setVisibility($this->visibility | $visibility); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * @param int $visibility |
|
| 85 | - * @return self |
|
| 86 | - */ |
|
| 87 | - public function removeVisibility($visibility) { |
|
| 88 | - return $this->setVisibility($this->visibility & ~$visibility); |
|
| 89 | - } |
|
| 83 | + /** |
|
| 84 | + * @param int $visibility |
|
| 85 | + * @return self |
|
| 86 | + */ |
|
| 87 | + public function removeVisibility($visibility) { |
|
| 88 | + return $this->setVisibility($this->visibility & ~$visibility); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @return int |
|
| 93 | - */ |
|
| 94 | - public function getAllowedVisibility() { |
|
| 95 | - return $this->allowedVisibility; |
|
| 96 | - } |
|
| 91 | + /** |
|
| 92 | + * @return int |
|
| 93 | + */ |
|
| 94 | + public function getAllowedVisibility() { |
|
| 95 | + return $this->allowedVisibility; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Check if the backend is allowed to be visible for a user type |
|
| 100 | - * |
|
| 101 | - * @param int $allowedVisibility |
|
| 102 | - * @return bool |
|
| 103 | - */ |
|
| 104 | - public function isAllowedVisibleFor($allowedVisibility) { |
|
| 105 | - if ($this->allowedVisibility & $allowedVisibility) { |
|
| 106 | - return true; |
|
| 107 | - } |
|
| 108 | - return false; |
|
| 109 | - } |
|
| 98 | + /** |
|
| 99 | + * Check if the backend is allowed to be visible for a user type |
|
| 100 | + * |
|
| 101 | + * @param int $allowedVisibility |
|
| 102 | + * @return bool |
|
| 103 | + */ |
|
| 104 | + public function isAllowedVisibleFor($allowedVisibility) { |
|
| 105 | + if ($this->allowedVisibility & $allowedVisibility) { |
|
| 106 | + return true; |
|
| 107 | + } |
|
| 108 | + return false; |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * @param int $allowedVisibility |
|
| 113 | - * @return self |
|
| 114 | - */ |
|
| 115 | - public function setAllowedVisibility($allowedVisibility) { |
|
| 116 | - $this->allowedVisibility = $allowedVisibility; |
|
| 117 | - $this->visibility &= $allowedVisibility; |
|
| 118 | - return $this; |
|
| 119 | - } |
|
| 111 | + /** |
|
| 112 | + * @param int $allowedVisibility |
|
| 113 | + * @return self |
|
| 114 | + */ |
|
| 115 | + public function setAllowedVisibility($allowedVisibility) { |
|
| 116 | + $this->allowedVisibility = $allowedVisibility; |
|
| 117 | + $this->visibility &= $allowedVisibility; |
|
| 118 | + return $this; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * @param int $allowedVisibility |
|
| 123 | - * @return self |
|
| 124 | - */ |
|
| 125 | - public function addAllowedVisibility($allowedVisibility) { |
|
| 126 | - return $this->setAllowedVisibility($this->allowedVisibility | $allowedVisibility); |
|
| 127 | - } |
|
| 121 | + /** |
|
| 122 | + * @param int $allowedVisibility |
|
| 123 | + * @return self |
|
| 124 | + */ |
|
| 125 | + public function addAllowedVisibility($allowedVisibility) { |
|
| 126 | + return $this->setAllowedVisibility($this->allowedVisibility | $allowedVisibility); |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * @param int $allowedVisibility |
|
| 131 | - * @return self |
|
| 132 | - */ |
|
| 133 | - public function removeAllowedVisibility($allowedVisibility) { |
|
| 134 | - return $this->setAllowedVisibility($this->allowedVisibility & ~$allowedVisibility); |
|
| 135 | - } |
|
| 129 | + /** |
|
| 130 | + * @param int $allowedVisibility |
|
| 131 | + * @return self |
|
| 132 | + */ |
|
| 133 | + public function removeAllowedVisibility($allowedVisibility) { |
|
| 134 | + return $this->setAllowedVisibility($this->allowedVisibility & ~$allowedVisibility); |
|
| 135 | + } |
|
| 136 | 136 | } |
@@ -28,11 +28,11 @@ |
||
| 28 | 28 | * Builtin authentication mechanism, for legacy backends |
| 29 | 29 | */ |
| 30 | 30 | class Builtin extends AuthMechanism { |
| 31 | - public function __construct(IL10N $l) { |
|
| 32 | - $this |
|
| 33 | - ->setIdentifier('builtin::builtin') |
|
| 34 | - ->setScheme(self::SCHEME_BUILTIN) |
|
| 35 | - ->setText($l->t('Builtin')) |
|
| 36 | - ; |
|
| 37 | - } |
|
| 31 | + public function __construct(IL10N $l) { |
|
| 32 | + $this |
|
| 33 | + ->setIdentifier('builtin::builtin') |
|
| 34 | + ->setScheme(self::SCHEME_BUILTIN) |
|
| 35 | + ->setText($l->t('Builtin')) |
|
| 36 | + ; |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -28,11 +28,11 @@ |
||
| 28 | 28 | * Null authentication mechanism |
| 29 | 29 | */ |
| 30 | 30 | class NullMechanism extends AuthMechanism { |
| 31 | - public function __construct(IL10N $l) { |
|
| 32 | - $this |
|
| 33 | - ->setIdentifier('null::null') |
|
| 34 | - ->setScheme(self::SCHEME_NULL) |
|
| 35 | - ->setText($l->t('None')) |
|
| 36 | - ; |
|
| 37 | - } |
|
| 31 | + public function __construct(IL10N $l) { |
|
| 32 | + $this |
|
| 33 | + ->setIdentifier('null::null') |
|
| 34 | + ->setScheme(self::SCHEME_NULL) |
|
| 35 | + ->setText($l->t('None')) |
|
| 36 | + ; |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -29,40 +29,40 @@ |
||
| 29 | 29 | |
| 30 | 30 | class FedAuth extends AbstractBasic { |
| 31 | 31 | |
| 32 | - /** @var DbHandler */ |
|
| 33 | - private $db; |
|
| 32 | + /** @var DbHandler */ |
|
| 33 | + private $db; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * FedAuth constructor. |
|
| 37 | - * |
|
| 38 | - * @param DbHandler $db |
|
| 39 | - */ |
|
| 40 | - public function __construct(DbHandler $db) { |
|
| 41 | - $this->db = $db; |
|
| 42 | - $this->principalPrefix = 'principals/system/'; |
|
| 35 | + /** |
|
| 36 | + * FedAuth constructor. |
|
| 37 | + * |
|
| 38 | + * @param DbHandler $db |
|
| 39 | + */ |
|
| 40 | + public function __construct(DbHandler $db) { |
|
| 41 | + $this->db = $db; |
|
| 42 | + $this->principalPrefix = 'principals/system/'; |
|
| 43 | 43 | |
| 44 | - // setup realm |
|
| 45 | - $defaults = new \OCP\Defaults(); |
|
| 46 | - $this->realm = $defaults->getName(); |
|
| 47 | - } |
|
| 44 | + // setup realm |
|
| 45 | + $defaults = new \OCP\Defaults(); |
|
| 46 | + $this->realm = $defaults->getName(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Validates a username and password |
|
| 51 | - * |
|
| 52 | - * This method should return true or false depending on if login |
|
| 53 | - * succeeded. |
|
| 54 | - * |
|
| 55 | - * @param string $username |
|
| 56 | - * @param string $password |
|
| 57 | - * @return bool |
|
| 58 | - */ |
|
| 59 | - protected function validateUserPass($username, $password) { |
|
| 60 | - return $this->db->auth($username, $password); |
|
| 61 | - } |
|
| 49 | + /** |
|
| 50 | + * Validates a username and password |
|
| 51 | + * |
|
| 52 | + * This method should return true or false depending on if login |
|
| 53 | + * succeeded. |
|
| 54 | + * |
|
| 55 | + * @param string $username |
|
| 56 | + * @param string $password |
|
| 57 | + * @return bool |
|
| 58 | + */ |
|
| 59 | + protected function validateUserPass($username, $password) { |
|
| 60 | + return $this->db->auth($username, $password); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @inheritdoc |
|
| 65 | - */ |
|
| 66 | - public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
| 67 | - } |
|
| 63 | + /** |
|
| 64 | + * @inheritdoc |
|
| 65 | + */ |
|
| 66 | + public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -29,32 +29,32 @@ |
||
| 29 | 29 | |
| 30 | 30 | class LastUsedController extends Controller { |
| 31 | 31 | |
| 32 | - /** @var IConfig */ |
|
| 33 | - protected $config; |
|
| 32 | + /** @var IConfig */ |
|
| 33 | + protected $config; |
|
| 34 | 34 | |
| 35 | - /** @var IUserSession */ |
|
| 36 | - protected $userSession; |
|
| 35 | + /** @var IUserSession */ |
|
| 36 | + protected $userSession; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param string $appName |
|
| 40 | - * @param IRequest $request |
|
| 41 | - * @param IConfig $config |
|
| 42 | - * @param IUserSession $userSession |
|
| 43 | - */ |
|
| 44 | - public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession) { |
|
| 45 | - parent::__construct($appName, $request); |
|
| 46 | - $this->config = $config; |
|
| 47 | - $this->userSession = $userSession; |
|
| 48 | - } |
|
| 38 | + /** |
|
| 39 | + * @param string $appName |
|
| 40 | + * @param IRequest $request |
|
| 41 | + * @param IConfig $config |
|
| 42 | + * @param IUserSession $userSession |
|
| 43 | + */ |
|
| 44 | + public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession) { |
|
| 45 | + parent::__construct($appName, $request); |
|
| 46 | + $this->config = $config; |
|
| 47 | + $this->userSession = $userSession; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @NoAdminRequired |
|
| 52 | - */ |
|
| 53 | - public function getLastUsedTagIds() { |
|
| 54 | - $lastUsed = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'systemtags', 'last_used', '[]'); |
|
| 55 | - $tagIds = json_decode($lastUsed, true); |
|
| 56 | - return new DataResponse(array_map(function ($id) { |
|
| 57 | - return (string) $id; |
|
| 58 | - }, $tagIds)); |
|
| 59 | - } |
|
| 50 | + /** |
|
| 51 | + * @NoAdminRequired |
|
| 52 | + */ |
|
| 53 | + public function getLastUsedTagIds() { |
|
| 54 | + $lastUsed = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'systemtags', 'last_used', '[]'); |
|
| 55 | + $tagIds = json_decode($lastUsed, true); |
|
| 56 | + return new DataResponse(array_map(function ($id) { |
|
| 57 | + return (string) $id; |
|
| 58 | + }, $tagIds)); |
|
| 59 | + } |
|
| 60 | 60 | } |