@@ -107,8 +107,8 @@ |
||
107 | 107 | protected function removeDeletedFiles($uid) { |
108 | 108 | \OC_Util::tearDownFS(); |
109 | 109 | \OC_Util::setupFS($uid); |
110 | - if ($this->rootFolder->nodeExists('/' . $uid . '/files_trashbin')) { |
|
111 | - $this->rootFolder->get('/' . $uid . '/files_trashbin')->delete(); |
|
110 | + if ($this->rootFolder->nodeExists('/'.$uid.'/files_trashbin')) { |
|
111 | + $this->rootFolder->get('/'.$uid.'/files_trashbin')->delete(); |
|
112 | 112 | $query = $this->dbConnection->getQueryBuilder(); |
113 | 113 | $query->delete('files_trash') |
114 | 114 | ->where($query->expr()->eq('user', $query->createParameter('uid'))) |
@@ -39,98 +39,98 @@ |
||
39 | 39 | |
40 | 40 | class CleanUp extends Command { |
41 | 41 | |
42 | - /** @var IUserManager */ |
|
43 | - protected $userManager; |
|
42 | + /** @var IUserManager */ |
|
43 | + protected $userManager; |
|
44 | 44 | |
45 | - /** @var IRootFolder */ |
|
46 | - protected $rootFolder; |
|
45 | + /** @var IRootFolder */ |
|
46 | + protected $rootFolder; |
|
47 | 47 | |
48 | - /** @var \OCP\IDBConnection */ |
|
49 | - protected $dbConnection; |
|
48 | + /** @var \OCP\IDBConnection */ |
|
49 | + protected $dbConnection; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param IRootFolder $rootFolder |
|
53 | - * @param IUserManager $userManager |
|
54 | - * @param IDBConnection $dbConnection |
|
55 | - */ |
|
56 | - public function __construct(IRootFolder $rootFolder, IUserManager $userManager, IDBConnection $dbConnection) { |
|
57 | - parent::__construct(); |
|
58 | - $this->userManager = $userManager; |
|
59 | - $this->rootFolder = $rootFolder; |
|
60 | - $this->dbConnection = $dbConnection; |
|
61 | - } |
|
51 | + /** |
|
52 | + * @param IRootFolder $rootFolder |
|
53 | + * @param IUserManager $userManager |
|
54 | + * @param IDBConnection $dbConnection |
|
55 | + */ |
|
56 | + public function __construct(IRootFolder $rootFolder, IUserManager $userManager, IDBConnection $dbConnection) { |
|
57 | + parent::__construct(); |
|
58 | + $this->userManager = $userManager; |
|
59 | + $this->rootFolder = $rootFolder; |
|
60 | + $this->dbConnection = $dbConnection; |
|
61 | + } |
|
62 | 62 | |
63 | - protected function configure() { |
|
64 | - $this |
|
65 | - ->setName('trashbin:cleanup') |
|
66 | - ->setDescription('Remove deleted files') |
|
67 | - ->addArgument( |
|
68 | - 'user_id', |
|
69 | - InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
|
70 | - 'remove deleted files of the given user(s)' |
|
71 | - ) |
|
72 | - ->addOption( |
|
73 | - 'all-users', |
|
74 | - null, |
|
75 | - InputOption::VALUE_NONE, |
|
76 | - 'run action on all users' |
|
77 | - ); |
|
78 | - } |
|
63 | + protected function configure() { |
|
64 | + $this |
|
65 | + ->setName('trashbin:cleanup') |
|
66 | + ->setDescription('Remove deleted files') |
|
67 | + ->addArgument( |
|
68 | + 'user_id', |
|
69 | + InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
|
70 | + 'remove deleted files of the given user(s)' |
|
71 | + ) |
|
72 | + ->addOption( |
|
73 | + 'all-users', |
|
74 | + null, |
|
75 | + InputOption::VALUE_NONE, |
|
76 | + 'run action on all users' |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
81 | - $users = $input->getArgument('user_id'); |
|
82 | - if ((!empty($users)) and ($input->getOption('all-users'))) { |
|
83 | - throw new InvalidOptionException('Either specify a user_id or --all-users'); |
|
84 | - } elseif (!empty($users)) { |
|
85 | - foreach ($users as $user) { |
|
86 | - if ($this->userManager->userExists($user)) { |
|
87 | - $output->writeln("Remove deleted files of <info>$user</info>"); |
|
88 | - $this->removeDeletedFiles($user); |
|
89 | - } else { |
|
90 | - $output->writeln("<error>Unknown user $user</error>"); |
|
91 | - return 1; |
|
92 | - } |
|
93 | - } |
|
94 | - } elseif ($input->getOption('all-users')) { |
|
95 | - $output->writeln('Remove deleted files for all users'); |
|
96 | - foreach ($this->userManager->getBackends() as $backend) { |
|
97 | - $name = get_class($backend); |
|
98 | - if ($backend instanceof IUserBackend) { |
|
99 | - $name = $backend->getBackendName(); |
|
100 | - } |
|
101 | - $output->writeln("Remove deleted files for users on backend <info>$name</info>"); |
|
102 | - $limit = 500; |
|
103 | - $offset = 0; |
|
104 | - do { |
|
105 | - $users = $backend->getUsers('', $limit, $offset); |
|
106 | - foreach ($users as $user) { |
|
107 | - $output->writeln(" <info>$user</info>"); |
|
108 | - $this->removeDeletedFiles($user); |
|
109 | - } |
|
110 | - $offset += $limit; |
|
111 | - } while (count($users) >= $limit); |
|
112 | - } |
|
113 | - } else { |
|
114 | - throw new InvalidOptionException('Either specify a user_id or --all-users'); |
|
115 | - } |
|
116 | - return 0; |
|
117 | - } |
|
80 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
81 | + $users = $input->getArgument('user_id'); |
|
82 | + if ((!empty($users)) and ($input->getOption('all-users'))) { |
|
83 | + throw new InvalidOptionException('Either specify a user_id or --all-users'); |
|
84 | + } elseif (!empty($users)) { |
|
85 | + foreach ($users as $user) { |
|
86 | + if ($this->userManager->userExists($user)) { |
|
87 | + $output->writeln("Remove deleted files of <info>$user</info>"); |
|
88 | + $this->removeDeletedFiles($user); |
|
89 | + } else { |
|
90 | + $output->writeln("<error>Unknown user $user</error>"); |
|
91 | + return 1; |
|
92 | + } |
|
93 | + } |
|
94 | + } elseif ($input->getOption('all-users')) { |
|
95 | + $output->writeln('Remove deleted files for all users'); |
|
96 | + foreach ($this->userManager->getBackends() as $backend) { |
|
97 | + $name = get_class($backend); |
|
98 | + if ($backend instanceof IUserBackend) { |
|
99 | + $name = $backend->getBackendName(); |
|
100 | + } |
|
101 | + $output->writeln("Remove deleted files for users on backend <info>$name</info>"); |
|
102 | + $limit = 500; |
|
103 | + $offset = 0; |
|
104 | + do { |
|
105 | + $users = $backend->getUsers('', $limit, $offset); |
|
106 | + foreach ($users as $user) { |
|
107 | + $output->writeln(" <info>$user</info>"); |
|
108 | + $this->removeDeletedFiles($user); |
|
109 | + } |
|
110 | + $offset += $limit; |
|
111 | + } while (count($users) >= $limit); |
|
112 | + } |
|
113 | + } else { |
|
114 | + throw new InvalidOptionException('Either specify a user_id or --all-users'); |
|
115 | + } |
|
116 | + return 0; |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * remove deleted files for the given user |
|
121 | - * |
|
122 | - * @param string $uid |
|
123 | - */ |
|
124 | - protected function removeDeletedFiles($uid) { |
|
125 | - \OC_Util::tearDownFS(); |
|
126 | - \OC_Util::setupFS($uid); |
|
127 | - if ($this->rootFolder->nodeExists('/' . $uid . '/files_trashbin')) { |
|
128 | - $this->rootFolder->get('/' . $uid . '/files_trashbin')->delete(); |
|
129 | - $query = $this->dbConnection->getQueryBuilder(); |
|
130 | - $query->delete('files_trash') |
|
131 | - ->where($query->expr()->eq('user', $query->createParameter('uid'))) |
|
132 | - ->setParameter('uid', $uid); |
|
133 | - $query->execute(); |
|
134 | - } |
|
135 | - } |
|
119 | + /** |
|
120 | + * remove deleted files for the given user |
|
121 | + * |
|
122 | + * @param string $uid |
|
123 | + */ |
|
124 | + protected function removeDeletedFiles($uid) { |
|
125 | + \OC_Util::tearDownFS(); |
|
126 | + \OC_Util::setupFS($uid); |
|
127 | + if ($this->rootFolder->nodeExists('/' . $uid . '/files_trashbin')) { |
|
128 | + $this->rootFolder->get('/' . $uid . '/files_trashbin')->delete(); |
|
129 | + $query = $this->dbConnection->getQueryBuilder(); |
|
130 | + $query->delete('files_trash') |
|
131 | + ->where($query->expr()->eq('user', $query->createParameter('uid'))) |
|
132 | + ->setParameter('uid', $uid); |
|
133 | + $query->execute(); |
|
134 | + } |
|
135 | + } |
|
136 | 136 | } |
@@ -33,17 +33,17 @@ |
||
33 | 33 | */ |
34 | 34 | class Capabilities implements ICapability { |
35 | 35 | |
36 | - /** |
|
37 | - * Return this classes capabilities |
|
38 | - * |
|
39 | - * @return array |
|
40 | - */ |
|
41 | - public function getCapabilities() { |
|
42 | - return [ |
|
43 | - 'files' => [ |
|
44 | - 'undelete' => true |
|
45 | - ] |
|
46 | - ]; |
|
47 | - } |
|
36 | + /** |
|
37 | + * Return this classes capabilities |
|
38 | + * |
|
39 | + * @return array |
|
40 | + */ |
|
41 | + public function getCapabilities() { |
|
42 | + return [ |
|
43 | + 'files' => [ |
|
44 | + 'undelete' => true |
|
45 | + ] |
|
46 | + ]; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | } |
@@ -34,23 +34,23 @@ |
||
34 | 34 | * ] |
35 | 35 | */ |
36 | 36 | class AlternativeHomeUserBackend extends \OC\User\Database { |
37 | - public function __construct() { |
|
38 | - parent::__construct(); |
|
39 | - } |
|
40 | - /** |
|
41 | - * get the user's home directory |
|
42 | - * @param string $uid the username |
|
43 | - * @return string|false |
|
44 | - */ |
|
45 | - public function getHome($uid) { |
|
46 | - if ($this->userExists($uid)) { |
|
47 | - // workaround to avoid killing the admin |
|
48 | - if ($uid !== 'admin') { |
|
49 | - $uid = md5($uid); |
|
50 | - } |
|
51 | - return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid; |
|
52 | - } |
|
37 | + public function __construct() { |
|
38 | + parent::__construct(); |
|
39 | + } |
|
40 | + /** |
|
41 | + * get the user's home directory |
|
42 | + * @param string $uid the username |
|
43 | + * @return string|false |
|
44 | + */ |
|
45 | + public function getHome($uid) { |
|
46 | + if ($this->userExists($uid)) { |
|
47 | + // workaround to avoid killing the admin |
|
48 | + if ($uid !== 'admin') { |
|
49 | + $uid = md5($uid); |
|
50 | + } |
|
51 | + return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid; |
|
52 | + } |
|
53 | 53 | |
54 | - return false; |
|
55 | - } |
|
54 | + return false; |
|
55 | + } |
|
56 | 56 | } |
@@ -48,7 +48,7 @@ |
||
48 | 48 | if ($uid !== 'admin') { |
49 | 49 | $uid = md5($uid); |
50 | 50 | } |
51 | - return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid; |
|
51 | + return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/'.$uid; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | return false; |
@@ -84,7 +84,7 @@ |
||
84 | 84 | */ |
85 | 85 | private function isRequestPublic(RequestInterface $request) { |
86 | 86 | $url = $request->getPath(); |
87 | - $matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) { |
|
87 | + $matchingUrls = array_filter($this->publicURLs, function($publicUrl) use ($url) { |
|
88 | 88 | return strpos($url, $publicUrl, 0) === 0; |
89 | 89 | }); |
90 | 90 | return !empty($matchingUrls); |
@@ -26,66 +26,66 @@ |
||
26 | 26 | |
27 | 27 | class PublicAuth implements BackendInterface { |
28 | 28 | |
29 | - /** @var string[] */ |
|
30 | - private $publicURLs; |
|
29 | + /** @var string[] */ |
|
30 | + private $publicURLs; |
|
31 | 31 | |
32 | - public function __construct() { |
|
33 | - $this->publicURLs = [ |
|
34 | - 'public-calendars', |
|
35 | - 'principals/system/public' |
|
36 | - ]; |
|
37 | - } |
|
32 | + public function __construct() { |
|
33 | + $this->publicURLs = [ |
|
34 | + 'public-calendars', |
|
35 | + 'principals/system/public' |
|
36 | + ]; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * When this method is called, the backend must check if authentication was |
|
41 | - * successful. |
|
42 | - * |
|
43 | - * The returned value must be one of the following |
|
44 | - * |
|
45 | - * [true, "principals/username"] |
|
46 | - * [false, "reason for failure"] |
|
47 | - * |
|
48 | - * If authentication was successful, it's expected that the authentication |
|
49 | - * backend returns a so-called principal url. |
|
50 | - * |
|
51 | - * Examples of a principal url: |
|
52 | - * |
|
53 | - * principals/admin |
|
54 | - * principals/user1 |
|
55 | - * principals/users/joe |
|
56 | - * principals/uid/123457 |
|
57 | - * |
|
58 | - * If you don't use WebDAV ACL (RFC3744) we recommend that you simply |
|
59 | - * return a string such as: |
|
60 | - * |
|
61 | - * principals/users/[username] |
|
62 | - * |
|
63 | - * @param RequestInterface $request |
|
64 | - * @param ResponseInterface $response |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - public function check(RequestInterface $request, ResponseInterface $response) { |
|
68 | - if ($this->isRequestPublic($request)) { |
|
69 | - return [true, "principals/system/public"]; |
|
70 | - } |
|
71 | - return [false, "No public access to this resource."]; |
|
72 | - } |
|
39 | + /** |
|
40 | + * When this method is called, the backend must check if authentication was |
|
41 | + * successful. |
|
42 | + * |
|
43 | + * The returned value must be one of the following |
|
44 | + * |
|
45 | + * [true, "principals/username"] |
|
46 | + * [false, "reason for failure"] |
|
47 | + * |
|
48 | + * If authentication was successful, it's expected that the authentication |
|
49 | + * backend returns a so-called principal url. |
|
50 | + * |
|
51 | + * Examples of a principal url: |
|
52 | + * |
|
53 | + * principals/admin |
|
54 | + * principals/user1 |
|
55 | + * principals/users/joe |
|
56 | + * principals/uid/123457 |
|
57 | + * |
|
58 | + * If you don't use WebDAV ACL (RFC3744) we recommend that you simply |
|
59 | + * return a string such as: |
|
60 | + * |
|
61 | + * principals/users/[username] |
|
62 | + * |
|
63 | + * @param RequestInterface $request |
|
64 | + * @param ResponseInterface $response |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + public function check(RequestInterface $request, ResponseInterface $response) { |
|
68 | + if ($this->isRequestPublic($request)) { |
|
69 | + return [true, "principals/system/public"]; |
|
70 | + } |
|
71 | + return [false, "No public access to this resource."]; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @inheritdoc |
|
76 | - */ |
|
77 | - public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
78 | - } |
|
74 | + /** |
|
75 | + * @inheritdoc |
|
76 | + */ |
|
77 | + public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @param RequestInterface $request |
|
82 | - * @return bool |
|
83 | - */ |
|
84 | - private function isRequestPublic(RequestInterface $request) { |
|
85 | - $url = $request->getPath(); |
|
86 | - $matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) { |
|
87 | - return strpos($url, $publicUrl, 0) === 0; |
|
88 | - }); |
|
89 | - return !empty($matchingUrls); |
|
90 | - } |
|
80 | + /** |
|
81 | + * @param RequestInterface $request |
|
82 | + * @return bool |
|
83 | + */ |
|
84 | + private function isRequestPublic(RequestInterface $request) { |
|
85 | + $url = $request->getPath(); |
|
86 | + $matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) { |
|
87 | + return strpos($url, $publicUrl, 0) === 0; |
|
88 | + }); |
|
89 | + return !empty($matchingUrls); |
|
90 | + } |
|
91 | 91 | } |
@@ -49,17 +49,17 @@ |
||
49 | 49 | * @param \DOMElement $errorNode |
50 | 50 | * @return void |
51 | 51 | */ |
52 | - public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) { |
|
52 | + public function serialize(\Sabre\DAV\Server $server, \DOMElement $errorNode) { |
|
53 | 53 | |
54 | 54 | // set ownCloud namespace |
55 | 55 | $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); |
56 | 56 | |
57 | 57 | // adding the retry node |
58 | - $error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true)); |
|
58 | + $error = $errorNode->ownerDocument->createElementNS('o:', 'o:retry', var_export($this->retry, true)); |
|
59 | 59 | $errorNode->appendChild($error); |
60 | 60 | |
61 | 61 | // adding the message node |
62 | - $error = $errorNode->ownerDocument->createElementNS('o:','o:reason', $this->getMessage()); |
|
62 | + $error = $errorNode->ownerDocument->createElementNS('o:', 'o:reason', $this->getMessage()); |
|
63 | 63 | $errorNode->appendChild($error); |
64 | 64 | } |
65 | 65 | } |
@@ -23,42 +23,42 @@ |
||
23 | 23 | namespace OCA\DAV\Connector\Sabre\Exception; |
24 | 24 | |
25 | 25 | class Forbidden extends \Sabre\DAV\Exception\Forbidden { |
26 | - public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
26 | + public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var bool |
|
30 | - */ |
|
31 | - private $retry; |
|
28 | + /** |
|
29 | + * @var bool |
|
30 | + */ |
|
31 | + private $retry; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param string $message |
|
35 | - * @param bool $retry |
|
36 | - * @param \Exception $previous |
|
37 | - */ |
|
38 | - public function __construct($message, $retry = false, \Exception $previous = null) { |
|
39 | - parent::__construct($message, 0, $previous); |
|
40 | - $this->retry = $retry; |
|
41 | - } |
|
33 | + /** |
|
34 | + * @param string $message |
|
35 | + * @param bool $retry |
|
36 | + * @param \Exception $previous |
|
37 | + */ |
|
38 | + public function __construct($message, $retry = false, \Exception $previous = null) { |
|
39 | + parent::__construct($message, 0, $previous); |
|
40 | + $this->retry = $retry; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * This method allows the exception to include additional information |
|
45 | - * into the WebDAV error response |
|
46 | - * |
|
47 | - * @param \Sabre\DAV\Server $server |
|
48 | - * @param \DOMElement $errorNode |
|
49 | - * @return void |
|
50 | - */ |
|
51 | - public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) { |
|
43 | + /** |
|
44 | + * This method allows the exception to include additional information |
|
45 | + * into the WebDAV error response |
|
46 | + * |
|
47 | + * @param \Sabre\DAV\Server $server |
|
48 | + * @param \DOMElement $errorNode |
|
49 | + * @return void |
|
50 | + */ |
|
51 | + public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) { |
|
52 | 52 | |
53 | - // set ownCloud namespace |
|
54 | - $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); |
|
53 | + // set ownCloud namespace |
|
54 | + $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); |
|
55 | 55 | |
56 | - // adding the retry node |
|
57 | - $error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true)); |
|
58 | - $errorNode->appendChild($error); |
|
56 | + // adding the retry node |
|
57 | + $error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true)); |
|
58 | + $errorNode->appendChild($error); |
|
59 | 59 | |
60 | - // adding the message node |
|
61 | - $error = $errorNode->ownerDocument->createElementNS('o:','o:reason', $this->getMessage()); |
|
62 | - $errorNode->appendChild($error); |
|
63 | - } |
|
60 | + // adding the message node |
|
61 | + $error = $errorNode->ownerDocument->createElementNS('o:','o:reason', $this->getMessage()); |
|
62 | + $errorNode->appendChild($error); |
|
63 | + } |
|
64 | 64 | } |
@@ -60,9 +60,9 @@ |
||
60 | 60 | |
61 | 61 | public function propFind(PropFind $propFind, INode $node) { |
62 | 62 | /* Overload current-user-principal */ |
63 | - $propFind->handle('{DAV:}current-user-principal', function () { |
|
63 | + $propFind->handle('{DAV:}current-user-principal', function() { |
|
64 | 64 | if ($url = parent::getCurrentUserPrincipal()) { |
65 | - return new Principal(Principal::HREF, $url . '/'); |
|
65 | + return new Principal(Principal::HREF, $url.'/'); |
|
66 | 66 | } else { |
67 | 67 | return new Principal(Principal::UNAUTHENTICATED); |
68 | 68 | } |
@@ -33,44 +33,44 @@ |
||
33 | 33 | |
34 | 34 | class LegacyDAVACL extends DavAclPlugin { |
35 | 35 | |
36 | - /** |
|
37 | - * @inheritdoc |
|
38 | - */ |
|
39 | - public function getCurrentUserPrincipals() { |
|
40 | - $principalV2 = $this->getCurrentUserPrincipal(); |
|
36 | + /** |
|
37 | + * @inheritdoc |
|
38 | + */ |
|
39 | + public function getCurrentUserPrincipals() { |
|
40 | + $principalV2 = $this->getCurrentUserPrincipal(); |
|
41 | 41 | |
42 | - if (is_null($principalV2)) { |
|
43 | - return []; |
|
44 | - } |
|
42 | + if (is_null($principalV2)) { |
|
43 | + return []; |
|
44 | + } |
|
45 | 45 | |
46 | - $principalV1 = $this->convertPrincipal($principalV2, false); |
|
47 | - return array_merge( |
|
48 | - [ |
|
49 | - $principalV2, |
|
50 | - $principalV1 |
|
51 | - ], |
|
52 | - $this->getPrincipalMembership($principalV1) |
|
53 | - ); |
|
54 | - } |
|
46 | + $principalV1 = $this->convertPrincipal($principalV2, false); |
|
47 | + return array_merge( |
|
48 | + [ |
|
49 | + $principalV2, |
|
50 | + $principalV1 |
|
51 | + ], |
|
52 | + $this->getPrincipalMembership($principalV1) |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | - private function convertPrincipal($principal, $toV2) { |
|
57 | - [, $name] = \Sabre\Uri\split($principal); |
|
58 | - if ($toV2) { |
|
59 | - return "principals/users/$name"; |
|
60 | - } |
|
61 | - return "principals/$name"; |
|
62 | - } |
|
56 | + private function convertPrincipal($principal, $toV2) { |
|
57 | + [, $name] = \Sabre\Uri\split($principal); |
|
58 | + if ($toV2) { |
|
59 | + return "principals/users/$name"; |
|
60 | + } |
|
61 | + return "principals/$name"; |
|
62 | + } |
|
63 | 63 | |
64 | - public function propFind(PropFind $propFind, INode $node) { |
|
65 | - /* Overload current-user-principal */ |
|
66 | - $propFind->handle('{DAV:}current-user-principal', function () { |
|
67 | - if ($url = parent::getCurrentUserPrincipal()) { |
|
68 | - return new Principal(Principal::HREF, $url . '/'); |
|
69 | - } else { |
|
70 | - return new Principal(Principal::UNAUTHENTICATED); |
|
71 | - } |
|
72 | - }); |
|
64 | + public function propFind(PropFind $propFind, INode $node) { |
|
65 | + /* Overload current-user-principal */ |
|
66 | + $propFind->handle('{DAV:}current-user-principal', function () { |
|
67 | + if ($url = parent::getCurrentUserPrincipal()) { |
|
68 | + return new Principal(Principal::HREF, $url . '/'); |
|
69 | + } else { |
|
70 | + return new Principal(Principal::UNAUTHENTICATED); |
|
71 | + } |
|
72 | + }); |
|
73 | 73 | |
74 | - return parent::propFind($propFind, $node); |
|
75 | - } |
|
74 | + return parent::propFind($propFind, $node); |
|
75 | + } |
|
76 | 76 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | protected function setSubjects(IEvent $event, $subject, array $parameters) { |
50 | 50 | $placeholders = $replacements = []; |
51 | 51 | foreach ($parameters as $placeholder => $parameter) { |
52 | - $placeholders[] = '{' . $placeholder . '}'; |
|
52 | + $placeholders[] = '{'.$placeholder.'}'; |
|
53 | 53 | $replacements[] = $parameter['name']; |
54 | 54 | } |
55 | 55 |
@@ -35,113 +35,113 @@ |
||
35 | 35 | |
36 | 36 | abstract class Base implements IProvider { |
37 | 37 | |
38 | - /** @var IUserManager */ |
|
39 | - protected $userManager; |
|
40 | - |
|
41 | - /** @var IGroupManager */ |
|
42 | - protected $groupManager; |
|
43 | - |
|
44 | - /** @var string[] */ |
|
45 | - protected $groupDisplayNames = []; |
|
46 | - |
|
47 | - /** @var IURLGenerator */ |
|
48 | - protected $url; |
|
49 | - |
|
50 | - /** |
|
51 | - * @param IUserManager $userManager |
|
52 | - * @param IGroupManager $groupManager |
|
53 | - * @param IURLGenerator $urlGenerator |
|
54 | - */ |
|
55 | - public function __construct(IUserManager $userManager, IGroupManager $groupManager, IURLGenerator $urlGenerator) { |
|
56 | - $this->userManager = $userManager; |
|
57 | - $this->groupManager = $groupManager; |
|
58 | - $this->url = $urlGenerator; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * @param IEvent $event |
|
63 | - * @param string $subject |
|
64 | - * @param array $parameters |
|
65 | - */ |
|
66 | - protected function setSubjects(IEvent $event, $subject, array $parameters) { |
|
67 | - $placeholders = $replacements = []; |
|
68 | - foreach ($parameters as $placeholder => $parameter) { |
|
69 | - $placeholders[] = '{' . $placeholder . '}'; |
|
70 | - $replacements[] = $parameter['name']; |
|
71 | - } |
|
72 | - |
|
73 | - $event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
74 | - ->setRichSubject($subject, $parameters); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * @param array $data |
|
79 | - * @param IL10N $l |
|
80 | - * @return array |
|
81 | - */ |
|
82 | - protected function generateCalendarParameter($data, IL10N $l) { |
|
83 | - if ($data['uri'] === CalDavBackend::PERSONAL_CALENDAR_URI && |
|
84 | - $data['name'] === CalDavBackend::PERSONAL_CALENDAR_NAME) { |
|
85 | - return [ |
|
86 | - 'type' => 'calendar', |
|
87 | - 'id' => $data['id'], |
|
88 | - 'name' => $l->t('Personal'), |
|
89 | - ]; |
|
90 | - } |
|
91 | - |
|
92 | - return [ |
|
93 | - 'type' => 'calendar', |
|
94 | - 'id' => $data['id'], |
|
95 | - 'name' => $data['name'], |
|
96 | - ]; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @param int $id |
|
101 | - * @param string $name |
|
102 | - * @return array |
|
103 | - */ |
|
104 | - protected function generateLegacyCalendarParameter($id, $name) { |
|
105 | - return [ |
|
106 | - 'type' => 'calendar', |
|
107 | - 'id' => $id, |
|
108 | - 'name' => $name, |
|
109 | - ]; |
|
110 | - } |
|
111 | - |
|
112 | - protected function generateUserParameter(string $uid): array { |
|
113 | - return [ |
|
114 | - 'type' => 'user', |
|
115 | - 'id' => $uid, |
|
116 | - 'name' => $this->userManager->getDisplayName($uid) ?? $uid, |
|
117 | - ]; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * @param string $gid |
|
122 | - * @return array |
|
123 | - */ |
|
124 | - protected function generateGroupParameter($gid) { |
|
125 | - if (!isset($this->groupDisplayNames[$gid])) { |
|
126 | - $this->groupDisplayNames[$gid] = $this->getGroupDisplayName($gid); |
|
127 | - } |
|
128 | - |
|
129 | - return [ |
|
130 | - 'type' => 'user-group', |
|
131 | - 'id' => $gid, |
|
132 | - 'name' => $this->groupDisplayNames[$gid], |
|
133 | - ]; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * @param string $gid |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - protected function getGroupDisplayName($gid) { |
|
141 | - $group = $this->groupManager->get($gid); |
|
142 | - if ($group instanceof IGroup) { |
|
143 | - return $group->getDisplayName(); |
|
144 | - } |
|
145 | - return $gid; |
|
146 | - } |
|
38 | + /** @var IUserManager */ |
|
39 | + protected $userManager; |
|
40 | + |
|
41 | + /** @var IGroupManager */ |
|
42 | + protected $groupManager; |
|
43 | + |
|
44 | + /** @var string[] */ |
|
45 | + protected $groupDisplayNames = []; |
|
46 | + |
|
47 | + /** @var IURLGenerator */ |
|
48 | + protected $url; |
|
49 | + |
|
50 | + /** |
|
51 | + * @param IUserManager $userManager |
|
52 | + * @param IGroupManager $groupManager |
|
53 | + * @param IURLGenerator $urlGenerator |
|
54 | + */ |
|
55 | + public function __construct(IUserManager $userManager, IGroupManager $groupManager, IURLGenerator $urlGenerator) { |
|
56 | + $this->userManager = $userManager; |
|
57 | + $this->groupManager = $groupManager; |
|
58 | + $this->url = $urlGenerator; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * @param IEvent $event |
|
63 | + * @param string $subject |
|
64 | + * @param array $parameters |
|
65 | + */ |
|
66 | + protected function setSubjects(IEvent $event, $subject, array $parameters) { |
|
67 | + $placeholders = $replacements = []; |
|
68 | + foreach ($parameters as $placeholder => $parameter) { |
|
69 | + $placeholders[] = '{' . $placeholder . '}'; |
|
70 | + $replacements[] = $parameter['name']; |
|
71 | + } |
|
72 | + |
|
73 | + $event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
74 | + ->setRichSubject($subject, $parameters); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * @param array $data |
|
79 | + * @param IL10N $l |
|
80 | + * @return array |
|
81 | + */ |
|
82 | + protected function generateCalendarParameter($data, IL10N $l) { |
|
83 | + if ($data['uri'] === CalDavBackend::PERSONAL_CALENDAR_URI && |
|
84 | + $data['name'] === CalDavBackend::PERSONAL_CALENDAR_NAME) { |
|
85 | + return [ |
|
86 | + 'type' => 'calendar', |
|
87 | + 'id' => $data['id'], |
|
88 | + 'name' => $l->t('Personal'), |
|
89 | + ]; |
|
90 | + } |
|
91 | + |
|
92 | + return [ |
|
93 | + 'type' => 'calendar', |
|
94 | + 'id' => $data['id'], |
|
95 | + 'name' => $data['name'], |
|
96 | + ]; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @param int $id |
|
101 | + * @param string $name |
|
102 | + * @return array |
|
103 | + */ |
|
104 | + protected function generateLegacyCalendarParameter($id, $name) { |
|
105 | + return [ |
|
106 | + 'type' => 'calendar', |
|
107 | + 'id' => $id, |
|
108 | + 'name' => $name, |
|
109 | + ]; |
|
110 | + } |
|
111 | + |
|
112 | + protected function generateUserParameter(string $uid): array { |
|
113 | + return [ |
|
114 | + 'type' => 'user', |
|
115 | + 'id' => $uid, |
|
116 | + 'name' => $this->userManager->getDisplayName($uid) ?? $uid, |
|
117 | + ]; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * @param string $gid |
|
122 | + * @return array |
|
123 | + */ |
|
124 | + protected function generateGroupParameter($gid) { |
|
125 | + if (!isset($this->groupDisplayNames[$gid])) { |
|
126 | + $this->groupDisplayNames[$gid] = $this->getGroupDisplayName($gid); |
|
127 | + } |
|
128 | + |
|
129 | + return [ |
|
130 | + 'type' => 'user-group', |
|
131 | + 'id' => $gid, |
|
132 | + 'name' => $this->groupDisplayNames[$gid], |
|
133 | + ]; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * @param string $gid |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + protected function getGroupDisplayName($gid) { |
|
141 | + $group = $this->groupManager->get($gid); |
|
142 | + if ($group instanceof IGroup) { |
|
143 | + return $group->getDisplayName(); |
|
144 | + } |
|
145 | + return $gid; |
|
146 | + } |
|
147 | 147 | } |
@@ -39,136 +39,136 @@ |
||
39 | 39 | */ |
40 | 40 | class SystemTagNode implements \Sabre\DAV\INode { |
41 | 41 | |
42 | - /** |
|
43 | - * @var ISystemTag |
|
44 | - */ |
|
45 | - protected $tag; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var ISystemTagManager |
|
49 | - */ |
|
50 | - protected $tagManager; |
|
51 | - |
|
52 | - /** |
|
53 | - * User |
|
54 | - * |
|
55 | - * @var IUser |
|
56 | - */ |
|
57 | - protected $user; |
|
58 | - |
|
59 | - /** |
|
60 | - * Whether to allow permissions for admins |
|
61 | - * |
|
62 | - * @var bool |
|
63 | - */ |
|
64 | - protected $isAdmin; |
|
65 | - |
|
66 | - /** |
|
67 | - * Sets up the node, expects a full path name |
|
68 | - * |
|
69 | - * @param ISystemTag $tag system tag |
|
70 | - * @param IUser $user user |
|
71 | - * @param bool $isAdmin whether to allow operations for admins |
|
72 | - * @param ISystemTagManager $tagManager tag manager |
|
73 | - */ |
|
74 | - public function __construct(ISystemTag $tag, IUser $user, $isAdmin, ISystemTagManager $tagManager) { |
|
75 | - $this->tag = $tag; |
|
76 | - $this->user = $user; |
|
77 | - $this->isAdmin = $isAdmin; |
|
78 | - $this->tagManager = $tagManager; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Returns the id of the tag |
|
83 | - * |
|
84 | - * @return string |
|
85 | - */ |
|
86 | - public function getName() { |
|
87 | - return $this->tag->getId(); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Returns the system tag represented by this node |
|
92 | - * |
|
93 | - * @return ISystemTag system tag |
|
94 | - */ |
|
95 | - public function getSystemTag() { |
|
96 | - return $this->tag; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Renames the node |
|
101 | - * |
|
102 | - * @param string $name The new name |
|
103 | - * |
|
104 | - * @throws MethodNotAllowed not allowed to rename node |
|
105 | - */ |
|
106 | - public function setName($name) { |
|
107 | - throw new MethodNotAllowed(); |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Update tag |
|
112 | - * |
|
113 | - * @param string $name new tag name |
|
114 | - * @param bool $userVisible user visible |
|
115 | - * @param bool $userAssignable user assignable |
|
116 | - * @throws NotFound whenever the given tag id does not exist |
|
117 | - * @throws Forbidden whenever there is no permission to update said tag |
|
118 | - * @throws Conflict whenever a tag already exists with the given attributes |
|
119 | - */ |
|
120 | - public function update($name, $userVisible, $userAssignable) { |
|
121 | - try { |
|
122 | - if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
|
123 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' does not exist'); |
|
124 | - } |
|
125 | - if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) { |
|
126 | - throw new Forbidden('No permission to update tag ' . $this->tag->getId()); |
|
127 | - } |
|
128 | - |
|
129 | - // only admin is able to change permissions, regular users can only rename |
|
130 | - if (!$this->isAdmin) { |
|
131 | - // only renaming is allowed for regular users |
|
132 | - if ($userVisible !== $this->tag->isUserVisible() |
|
133 | - || $userAssignable !== $this->tag->isUserAssignable() |
|
134 | - ) { |
|
135 | - throw new Forbidden('No permission to update permissions for tag ' . $this->tag->getId()); |
|
136 | - } |
|
137 | - } |
|
138 | - |
|
139 | - $this->tagManager->updateTag($this->tag->getId(), $name, $userVisible, $userAssignable); |
|
140 | - } catch (TagNotFoundException $e) { |
|
141 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' does not exist'); |
|
142 | - } catch (TagAlreadyExistsException $e) { |
|
143 | - throw new Conflict( |
|
144 | - 'Tag with the properties "' . $name . '", ' . |
|
145 | - $userVisible . ', ' . $userAssignable . ' already exists' |
|
146 | - ); |
|
147 | - } |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * Returns null, not supported |
|
152 | - * |
|
153 | - */ |
|
154 | - public function getLastModified() { |
|
155 | - return null; |
|
156 | - } |
|
157 | - |
|
158 | - public function delete() { |
|
159 | - try { |
|
160 | - if (!$this->isAdmin) { |
|
161 | - throw new Forbidden('No permission to delete tag ' . $this->tag->getId()); |
|
162 | - } |
|
163 | - |
|
164 | - if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
|
165 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found'); |
|
166 | - } |
|
167 | - |
|
168 | - $this->tagManager->deleteTags($this->tag->getId()); |
|
169 | - } catch (TagNotFoundException $e) { |
|
170 | - // can happen if concurrent deletion occurred |
|
171 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e); |
|
172 | - } |
|
173 | - } |
|
42 | + /** |
|
43 | + * @var ISystemTag |
|
44 | + */ |
|
45 | + protected $tag; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var ISystemTagManager |
|
49 | + */ |
|
50 | + protected $tagManager; |
|
51 | + |
|
52 | + /** |
|
53 | + * User |
|
54 | + * |
|
55 | + * @var IUser |
|
56 | + */ |
|
57 | + protected $user; |
|
58 | + |
|
59 | + /** |
|
60 | + * Whether to allow permissions for admins |
|
61 | + * |
|
62 | + * @var bool |
|
63 | + */ |
|
64 | + protected $isAdmin; |
|
65 | + |
|
66 | + /** |
|
67 | + * Sets up the node, expects a full path name |
|
68 | + * |
|
69 | + * @param ISystemTag $tag system tag |
|
70 | + * @param IUser $user user |
|
71 | + * @param bool $isAdmin whether to allow operations for admins |
|
72 | + * @param ISystemTagManager $tagManager tag manager |
|
73 | + */ |
|
74 | + public function __construct(ISystemTag $tag, IUser $user, $isAdmin, ISystemTagManager $tagManager) { |
|
75 | + $this->tag = $tag; |
|
76 | + $this->user = $user; |
|
77 | + $this->isAdmin = $isAdmin; |
|
78 | + $this->tagManager = $tagManager; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Returns the id of the tag |
|
83 | + * |
|
84 | + * @return string |
|
85 | + */ |
|
86 | + public function getName() { |
|
87 | + return $this->tag->getId(); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Returns the system tag represented by this node |
|
92 | + * |
|
93 | + * @return ISystemTag system tag |
|
94 | + */ |
|
95 | + public function getSystemTag() { |
|
96 | + return $this->tag; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Renames the node |
|
101 | + * |
|
102 | + * @param string $name The new name |
|
103 | + * |
|
104 | + * @throws MethodNotAllowed not allowed to rename node |
|
105 | + */ |
|
106 | + public function setName($name) { |
|
107 | + throw new MethodNotAllowed(); |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Update tag |
|
112 | + * |
|
113 | + * @param string $name new tag name |
|
114 | + * @param bool $userVisible user visible |
|
115 | + * @param bool $userAssignable user assignable |
|
116 | + * @throws NotFound whenever the given tag id does not exist |
|
117 | + * @throws Forbidden whenever there is no permission to update said tag |
|
118 | + * @throws Conflict whenever a tag already exists with the given attributes |
|
119 | + */ |
|
120 | + public function update($name, $userVisible, $userAssignable) { |
|
121 | + try { |
|
122 | + if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
|
123 | + throw new NotFound('Tag with id ' . $this->tag->getId() . ' does not exist'); |
|
124 | + } |
|
125 | + if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) { |
|
126 | + throw new Forbidden('No permission to update tag ' . $this->tag->getId()); |
|
127 | + } |
|
128 | + |
|
129 | + // only admin is able to change permissions, regular users can only rename |
|
130 | + if (!$this->isAdmin) { |
|
131 | + // only renaming is allowed for regular users |
|
132 | + if ($userVisible !== $this->tag->isUserVisible() |
|
133 | + || $userAssignable !== $this->tag->isUserAssignable() |
|
134 | + ) { |
|
135 | + throw new Forbidden('No permission to update permissions for tag ' . $this->tag->getId()); |
|
136 | + } |
|
137 | + } |
|
138 | + |
|
139 | + $this->tagManager->updateTag($this->tag->getId(), $name, $userVisible, $userAssignable); |
|
140 | + } catch (TagNotFoundException $e) { |
|
141 | + throw new NotFound('Tag with id ' . $this->tag->getId() . ' does not exist'); |
|
142 | + } catch (TagAlreadyExistsException $e) { |
|
143 | + throw new Conflict( |
|
144 | + 'Tag with the properties "' . $name . '", ' . |
|
145 | + $userVisible . ', ' . $userAssignable . ' already exists' |
|
146 | + ); |
|
147 | + } |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * Returns null, not supported |
|
152 | + * |
|
153 | + */ |
|
154 | + public function getLastModified() { |
|
155 | + return null; |
|
156 | + } |
|
157 | + |
|
158 | + public function delete() { |
|
159 | + try { |
|
160 | + if (!$this->isAdmin) { |
|
161 | + throw new Forbidden('No permission to delete tag ' . $this->tag->getId()); |
|
162 | + } |
|
163 | + |
|
164 | + if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
|
165 | + throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found'); |
|
166 | + } |
|
167 | + |
|
168 | + $this->tagManager->deleteTags($this->tag->getId()); |
|
169 | + } catch (TagNotFoundException $e) { |
|
170 | + // can happen if concurrent deletion occurred |
|
171 | + throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e); |
|
172 | + } |
|
173 | + } |
|
174 | 174 | } |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | public function update($name, $userVisible, $userAssignable) { |
121 | 121 | try { |
122 | 122 | if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
123 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' does not exist'); |
|
123 | + throw new NotFound('Tag with id '.$this->tag->getId().' does not exist'); |
|
124 | 124 | } |
125 | 125 | if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) { |
126 | - throw new Forbidden('No permission to update tag ' . $this->tag->getId()); |
|
126 | + throw new Forbidden('No permission to update tag '.$this->tag->getId()); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | // only admin is able to change permissions, regular users can only rename |
@@ -132,17 +132,17 @@ discard block |
||
132 | 132 | if ($userVisible !== $this->tag->isUserVisible() |
133 | 133 | || $userAssignable !== $this->tag->isUserAssignable() |
134 | 134 | ) { |
135 | - throw new Forbidden('No permission to update permissions for tag ' . $this->tag->getId()); |
|
135 | + throw new Forbidden('No permission to update permissions for tag '.$this->tag->getId()); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | 139 | $this->tagManager->updateTag($this->tag->getId(), $name, $userVisible, $userAssignable); |
140 | 140 | } catch (TagNotFoundException $e) { |
141 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' does not exist'); |
|
141 | + throw new NotFound('Tag with id '.$this->tag->getId().' does not exist'); |
|
142 | 142 | } catch (TagAlreadyExistsException $e) { |
143 | 143 | throw new Conflict( |
144 | - 'Tag with the properties "' . $name . '", ' . |
|
145 | - $userVisible . ', ' . $userAssignable . ' already exists' |
|
144 | + 'Tag with the properties "'.$name.'", '. |
|
145 | + $userVisible.', '.$userAssignable.' already exists' |
|
146 | 146 | ); |
147 | 147 | } |
148 | 148 | } |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | public function delete() { |
159 | 159 | try { |
160 | 160 | if (!$this->isAdmin) { |
161 | - throw new Forbidden('No permission to delete tag ' . $this->tag->getId()); |
|
161 | + throw new Forbidden('No permission to delete tag '.$this->tag->getId()); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
165 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found'); |
|
165 | + throw new NotFound('Tag with id '.$this->tag->getId().' not found'); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | $this->tagManager->deleteTags($this->tag->getId()); |
169 | 169 | } catch (TagNotFoundException $e) { |
170 | 170 | // can happen if concurrent deletion occurred |
171 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e); |
|
171 | + throw new NotFound('Tag with id '.$this->tag->getId().' not found', 0, $e); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
@@ -37,134 +37,134 @@ |
||
37 | 37 | * Mapping node for system tag to object id |
38 | 38 | */ |
39 | 39 | class SystemTagMappingNode implements \Sabre\DAV\INode { |
40 | - /** |
|
41 | - * @var ISystemTag |
|
42 | - */ |
|
43 | - protected $tag; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var string |
|
47 | - */ |
|
48 | - private $objectId; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var string |
|
52 | - */ |
|
53 | - private $objectType; |
|
54 | - |
|
55 | - /** |
|
56 | - * User |
|
57 | - * |
|
58 | - * @var IUser |
|
59 | - */ |
|
60 | - protected $user; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var ISystemTagManager |
|
64 | - */ |
|
65 | - protected $tagManager; |
|
66 | - |
|
67 | - /** |
|
68 | - * @var ISystemTagObjectMapper |
|
69 | - */ |
|
70 | - private $tagMapper; |
|
71 | - |
|
72 | - /** |
|
73 | - * Sets up the node, expects a full path name |
|
74 | - * |
|
75 | - * @param ISystemTag $tag system tag |
|
76 | - * @param string $objectId |
|
77 | - * @param string $objectType |
|
78 | - * @param IUser $user user |
|
79 | - * @param ISystemTagManager $tagManager |
|
80 | - * @param ISystemTagObjectMapper $tagMapper |
|
81 | - */ |
|
82 | - public function __construct( |
|
83 | - ISystemTag $tag, |
|
84 | - $objectId, |
|
85 | - $objectType, |
|
86 | - IUser $user, |
|
87 | - ISystemTagManager $tagManager, |
|
88 | - ISystemTagObjectMapper $tagMapper |
|
89 | - ) { |
|
90 | - $this->tag = $tag; |
|
91 | - $this->objectId = $objectId; |
|
92 | - $this->objectType = $objectType; |
|
93 | - $this->user = $user; |
|
94 | - $this->tagManager = $tagManager; |
|
95 | - $this->tagMapper = $tagMapper; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Returns the object id of the relationship |
|
100 | - * |
|
101 | - * @return string object id |
|
102 | - */ |
|
103 | - public function getObjectId() { |
|
104 | - return $this->objectId; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Returns the object type of the relationship |
|
109 | - * |
|
110 | - * @return string object type |
|
111 | - */ |
|
112 | - public function getObjectType() { |
|
113 | - return $this->objectType; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Returns the system tag represented by this node |
|
118 | - * |
|
119 | - * @return ISystemTag system tag |
|
120 | - */ |
|
121 | - public function getSystemTag() { |
|
122 | - return $this->tag; |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Returns the id of the tag |
|
127 | - * |
|
128 | - * @return string |
|
129 | - */ |
|
130 | - public function getName() { |
|
131 | - return $this->tag->getId(); |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * Renames the node |
|
136 | - * |
|
137 | - * @param string $name The new name |
|
138 | - * |
|
139 | - * @throws MethodNotAllowed not allowed to rename node |
|
140 | - */ |
|
141 | - public function setName($name) { |
|
142 | - throw new MethodNotAllowed(); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Returns null, not supported |
|
147 | - * |
|
148 | - */ |
|
149 | - public function getLastModified() { |
|
150 | - return null; |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * Delete tag to object association |
|
155 | - */ |
|
156 | - public function delete() { |
|
157 | - try { |
|
158 | - if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
|
159 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found'); |
|
160 | - } |
|
161 | - if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) { |
|
162 | - throw new Forbidden('No permission to unassign tag ' . $this->tag->getId()); |
|
163 | - } |
|
164 | - $this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId()); |
|
165 | - } catch (TagNotFoundException $e) { |
|
166 | - // can happen if concurrent deletion occurred |
|
167 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e); |
|
168 | - } |
|
169 | - } |
|
40 | + /** |
|
41 | + * @var ISystemTag |
|
42 | + */ |
|
43 | + protected $tag; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var string |
|
47 | + */ |
|
48 | + private $objectId; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var string |
|
52 | + */ |
|
53 | + private $objectType; |
|
54 | + |
|
55 | + /** |
|
56 | + * User |
|
57 | + * |
|
58 | + * @var IUser |
|
59 | + */ |
|
60 | + protected $user; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var ISystemTagManager |
|
64 | + */ |
|
65 | + protected $tagManager; |
|
66 | + |
|
67 | + /** |
|
68 | + * @var ISystemTagObjectMapper |
|
69 | + */ |
|
70 | + private $tagMapper; |
|
71 | + |
|
72 | + /** |
|
73 | + * Sets up the node, expects a full path name |
|
74 | + * |
|
75 | + * @param ISystemTag $tag system tag |
|
76 | + * @param string $objectId |
|
77 | + * @param string $objectType |
|
78 | + * @param IUser $user user |
|
79 | + * @param ISystemTagManager $tagManager |
|
80 | + * @param ISystemTagObjectMapper $tagMapper |
|
81 | + */ |
|
82 | + public function __construct( |
|
83 | + ISystemTag $tag, |
|
84 | + $objectId, |
|
85 | + $objectType, |
|
86 | + IUser $user, |
|
87 | + ISystemTagManager $tagManager, |
|
88 | + ISystemTagObjectMapper $tagMapper |
|
89 | + ) { |
|
90 | + $this->tag = $tag; |
|
91 | + $this->objectId = $objectId; |
|
92 | + $this->objectType = $objectType; |
|
93 | + $this->user = $user; |
|
94 | + $this->tagManager = $tagManager; |
|
95 | + $this->tagMapper = $tagMapper; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Returns the object id of the relationship |
|
100 | + * |
|
101 | + * @return string object id |
|
102 | + */ |
|
103 | + public function getObjectId() { |
|
104 | + return $this->objectId; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Returns the object type of the relationship |
|
109 | + * |
|
110 | + * @return string object type |
|
111 | + */ |
|
112 | + public function getObjectType() { |
|
113 | + return $this->objectType; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Returns the system tag represented by this node |
|
118 | + * |
|
119 | + * @return ISystemTag system tag |
|
120 | + */ |
|
121 | + public function getSystemTag() { |
|
122 | + return $this->tag; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Returns the id of the tag |
|
127 | + * |
|
128 | + * @return string |
|
129 | + */ |
|
130 | + public function getName() { |
|
131 | + return $this->tag->getId(); |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * Renames the node |
|
136 | + * |
|
137 | + * @param string $name The new name |
|
138 | + * |
|
139 | + * @throws MethodNotAllowed not allowed to rename node |
|
140 | + */ |
|
141 | + public function setName($name) { |
|
142 | + throw new MethodNotAllowed(); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Returns null, not supported |
|
147 | + * |
|
148 | + */ |
|
149 | + public function getLastModified() { |
|
150 | + return null; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * Delete tag to object association |
|
155 | + */ |
|
156 | + public function delete() { |
|
157 | + try { |
|
158 | + if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
|
159 | + throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found'); |
|
160 | + } |
|
161 | + if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) { |
|
162 | + throw new Forbidden('No permission to unassign tag ' . $this->tag->getId()); |
|
163 | + } |
|
164 | + $this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId()); |
|
165 | + } catch (TagNotFoundException $e) { |
|
166 | + // can happen if concurrent deletion occurred |
|
167 | + throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e); |
|
168 | + } |
|
169 | + } |
|
170 | 170 | } |
@@ -156,15 +156,15 @@ |
||
156 | 156 | public function delete() { |
157 | 157 | try { |
158 | 158 | if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
159 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found'); |
|
159 | + throw new NotFound('Tag with id '.$this->tag->getId().' not found'); |
|
160 | 160 | } |
161 | 161 | if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) { |
162 | - throw new Forbidden('No permission to unassign tag ' . $this->tag->getId()); |
|
162 | + throw new Forbidden('No permission to unassign tag '.$this->tag->getId()); |
|
163 | 163 | } |
164 | 164 | $this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId()); |
165 | 165 | } catch (TagNotFoundException $e) { |
166 | 166 | // can happen if concurrent deletion occurred |
167 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e); |
|
167 | + throw new NotFound('Tag with id '.$this->tag->getId().' not found', 0, $e); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | } |