@@ -87,10 +87,10 @@ |
||
| 87 | 87 | * @return void |
| 88 | 88 | */ |
| 89 | 89 | public function propFind(PropFind $propFind, INode $node) { |
| 90 | - $propFind->handle('{DAV:}supportedlock', function () { |
|
| 90 | + $propFind->handle('{DAV:}supportedlock', function() { |
|
| 91 | 91 | return new SupportedLock(true); |
| 92 | 92 | }); |
| 93 | - $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) { |
|
| 93 | + $propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) { |
|
| 94 | 94 | return new LockDiscovery([]); |
| 95 | 95 | }); |
| 96 | 96 | } |
@@ -47,113 +47,113 @@ |
||
| 47 | 47 | * @package OCA\DAV\Connector\Sabre |
| 48 | 48 | */ |
| 49 | 49 | class FakeLockerPlugin extends ServerPlugin { |
| 50 | - /** @var \Sabre\DAV\Server */ |
|
| 51 | - private $server; |
|
| 50 | + /** @var \Sabre\DAV\Server */ |
|
| 51 | + private $server; |
|
| 52 | 52 | |
| 53 | - /** {@inheritDoc} */ |
|
| 54 | - public function initialize(\Sabre\DAV\Server $server) { |
|
| 55 | - $this->server = $server; |
|
| 56 | - $this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1); |
|
| 57 | - $this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1); |
|
| 58 | - $server->on('propFind', [$this, 'propFind']); |
|
| 59 | - $server->on('validateTokens', [$this, 'validateTokens']); |
|
| 60 | - } |
|
| 53 | + /** {@inheritDoc} */ |
|
| 54 | + public function initialize(\Sabre\DAV\Server $server) { |
|
| 55 | + $this->server = $server; |
|
| 56 | + $this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1); |
|
| 57 | + $this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1); |
|
| 58 | + $server->on('propFind', [$this, 'propFind']); |
|
| 59 | + $server->on('validateTokens', [$this, 'validateTokens']); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Indicate that we support LOCK and UNLOCK |
|
| 64 | - * |
|
| 65 | - * @param string $path |
|
| 66 | - * @return string[] |
|
| 67 | - */ |
|
| 68 | - public function getHTTPMethods($path) { |
|
| 69 | - return [ |
|
| 70 | - 'LOCK', |
|
| 71 | - 'UNLOCK', |
|
| 72 | - ]; |
|
| 73 | - } |
|
| 62 | + /** |
|
| 63 | + * Indicate that we support LOCK and UNLOCK |
|
| 64 | + * |
|
| 65 | + * @param string $path |
|
| 66 | + * @return string[] |
|
| 67 | + */ |
|
| 68 | + public function getHTTPMethods($path) { |
|
| 69 | + return [ |
|
| 70 | + 'LOCK', |
|
| 71 | + 'UNLOCK', |
|
| 72 | + ]; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Indicate that we support locking |
|
| 77 | - * |
|
| 78 | - * @return integer[] |
|
| 79 | - */ |
|
| 80 | - public function getFeatures() { |
|
| 81 | - return [2]; |
|
| 82 | - } |
|
| 75 | + /** |
|
| 76 | + * Indicate that we support locking |
|
| 77 | + * |
|
| 78 | + * @return integer[] |
|
| 79 | + */ |
|
| 80 | + public function getFeatures() { |
|
| 81 | + return [2]; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Return some dummy response for PROPFIND requests with regard to locking |
|
| 86 | - * |
|
| 87 | - * @param PropFind $propFind |
|
| 88 | - * @param INode $node |
|
| 89 | - * @return void |
|
| 90 | - */ |
|
| 91 | - public function propFind(PropFind $propFind, INode $node) { |
|
| 92 | - $propFind->handle('{DAV:}supportedlock', function () { |
|
| 93 | - return new SupportedLock(true); |
|
| 94 | - }); |
|
| 95 | - $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) { |
|
| 96 | - return new LockDiscovery([]); |
|
| 97 | - }); |
|
| 98 | - } |
|
| 84 | + /** |
|
| 85 | + * Return some dummy response for PROPFIND requests with regard to locking |
|
| 86 | + * |
|
| 87 | + * @param PropFind $propFind |
|
| 88 | + * @param INode $node |
|
| 89 | + * @return void |
|
| 90 | + */ |
|
| 91 | + public function propFind(PropFind $propFind, INode $node) { |
|
| 92 | + $propFind->handle('{DAV:}supportedlock', function () { |
|
| 93 | + return new SupportedLock(true); |
|
| 94 | + }); |
|
| 95 | + $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) { |
|
| 96 | + return new LockDiscovery([]); |
|
| 97 | + }); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Mark a locking token always as valid |
|
| 102 | - * |
|
| 103 | - * @param RequestInterface $request |
|
| 104 | - * @param array $conditions |
|
| 105 | - */ |
|
| 106 | - public function validateTokens(RequestInterface $request, &$conditions) { |
|
| 107 | - foreach ($conditions as &$fileCondition) { |
|
| 108 | - if (isset($fileCondition['tokens'])) { |
|
| 109 | - foreach ($fileCondition['tokens'] as &$token) { |
|
| 110 | - if (isset($token['token'])) { |
|
| 111 | - if (substr($token['token'], 0, 16) === 'opaquelocktoken:') { |
|
| 112 | - $token['validToken'] = true; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - } |
|
| 100 | + /** |
|
| 101 | + * Mark a locking token always as valid |
|
| 102 | + * |
|
| 103 | + * @param RequestInterface $request |
|
| 104 | + * @param array $conditions |
|
| 105 | + */ |
|
| 106 | + public function validateTokens(RequestInterface $request, &$conditions) { |
|
| 107 | + foreach ($conditions as &$fileCondition) { |
|
| 108 | + if (isset($fileCondition['tokens'])) { |
|
| 109 | + foreach ($fileCondition['tokens'] as &$token) { |
|
| 110 | + if (isset($token['token'])) { |
|
| 111 | + if (substr($token['token'], 0, 16) === 'opaquelocktoken:') { |
|
| 112 | + $token['validToken'] = true; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Fakes a successful LOCK |
|
| 122 | - * |
|
| 123 | - * @param RequestInterface $request |
|
| 124 | - * @param ResponseInterface $response |
|
| 125 | - * @return bool |
|
| 126 | - */ |
|
| 127 | - public function fakeLockProvider(RequestInterface $request, |
|
| 128 | - ResponseInterface $response) { |
|
| 129 | - $lockInfo = new LockInfo(); |
|
| 130 | - $lockInfo->token = md5($request->getPath()); |
|
| 131 | - $lockInfo->uri = $request->getPath(); |
|
| 132 | - $lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY; |
|
| 133 | - $lockInfo->timeout = 1800; |
|
| 120 | + /** |
|
| 121 | + * Fakes a successful LOCK |
|
| 122 | + * |
|
| 123 | + * @param RequestInterface $request |
|
| 124 | + * @param ResponseInterface $response |
|
| 125 | + * @return bool |
|
| 126 | + */ |
|
| 127 | + public function fakeLockProvider(RequestInterface $request, |
|
| 128 | + ResponseInterface $response) { |
|
| 129 | + $lockInfo = new LockInfo(); |
|
| 130 | + $lockInfo->token = md5($request->getPath()); |
|
| 131 | + $lockInfo->uri = $request->getPath(); |
|
| 132 | + $lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY; |
|
| 133 | + $lockInfo->timeout = 1800; |
|
| 134 | 134 | |
| 135 | - $body = $this->server->xml->write('{DAV:}prop', [ |
|
| 136 | - '{DAV:}lockdiscovery' => |
|
| 137 | - new LockDiscovery([$lockInfo]) |
|
| 138 | - ]); |
|
| 135 | + $body = $this->server->xml->write('{DAV:}prop', [ |
|
| 136 | + '{DAV:}lockdiscovery' => |
|
| 137 | + new LockDiscovery([$lockInfo]) |
|
| 138 | + ]); |
|
| 139 | 139 | |
| 140 | - $response->setStatus(200); |
|
| 141 | - $response->setBody($body); |
|
| 140 | + $response->setStatus(200); |
|
| 141 | + $response->setBody($body); |
|
| 142 | 142 | |
| 143 | - return false; |
|
| 144 | - } |
|
| 143 | + return false; |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - /** |
|
| 147 | - * Fakes a successful LOCK |
|
| 148 | - * |
|
| 149 | - * @param RequestInterface $request |
|
| 150 | - * @param ResponseInterface $response |
|
| 151 | - * @return bool |
|
| 152 | - */ |
|
| 153 | - public function fakeUnlockProvider(RequestInterface $request, |
|
| 154 | - ResponseInterface $response) { |
|
| 155 | - $response->setStatus(204); |
|
| 156 | - $response->setHeader('Content-Length', '0'); |
|
| 157 | - return false; |
|
| 158 | - } |
|
| 146 | + /** |
|
| 147 | + * Fakes a successful LOCK |
|
| 148 | + * |
|
| 149 | + * @param RequestInterface $request |
|
| 150 | + * @param ResponseInterface $response |
|
| 151 | + * @return bool |
|
| 152 | + */ |
|
| 153 | + public function fakeUnlockProvider(RequestInterface $request, |
|
| 154 | + ResponseInterface $response) { |
|
| 155 | + $response->setStatus(204); |
|
| 156 | + $response->setHeader('Content-Length', '0'); |
|
| 157 | + return false; |
|
| 158 | + } |
|
| 159 | 159 | } |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | */ |
| 65 | 65 | public function xmlSerialize(Writer $writer) { |
| 66 | 66 | foreach ($this->checksums as $checksum) { |
| 67 | - $writer->writeElement('{' . self::NS_OWNCLOUD . '}checksum', $checksum); |
|
| 67 | + $writer->writeElement('{'.self::NS_OWNCLOUD.'}checksum', $checksum); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -32,40 +32,40 @@ |
||
| 32 | 32 | * checksum name. |
| 33 | 33 | */ |
| 34 | 34 | class ChecksumList implements XmlSerializable { |
| 35 | - public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
| 35 | + public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
| 36 | 36 | |
| 37 | - /** @var string[] of TYPE:CHECKSUM */ |
|
| 38 | - private $checksums; |
|
| 37 | + /** @var string[] of TYPE:CHECKSUM */ |
|
| 38 | + private $checksums; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param string $checksum |
|
| 42 | - */ |
|
| 43 | - public function __construct($checksum) { |
|
| 44 | - $this->checksums = explode(',', $checksum); |
|
| 45 | - } |
|
| 40 | + /** |
|
| 41 | + * @param string $checksum |
|
| 42 | + */ |
|
| 43 | + public function __construct($checksum) { |
|
| 44 | + $this->checksums = explode(',', $checksum); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * The xmlSerialize metod is called during xml writing. |
|
| 49 | - * |
|
| 50 | - * Use the $writer argument to write its own xml serialization. |
|
| 51 | - * |
|
| 52 | - * An important note: do _not_ create a parent element. Any element |
|
| 53 | - * implementing XmlSerializble should only ever write what's considered |
|
| 54 | - * its 'inner xml'. |
|
| 55 | - * |
|
| 56 | - * The parent of the current element is responsible for writing a |
|
| 57 | - * containing element. |
|
| 58 | - * |
|
| 59 | - * This allows serializers to be re-used for different element names. |
|
| 60 | - * |
|
| 61 | - * If you are opening new elements, you must also close them again. |
|
| 62 | - * |
|
| 63 | - * @param Writer $writer |
|
| 64 | - * @return void |
|
| 65 | - */ |
|
| 66 | - public function xmlSerialize(Writer $writer) { |
|
| 67 | - foreach ($this->checksums as $checksum) { |
|
| 68 | - $writer->writeElement('{' . self::NS_OWNCLOUD . '}checksum', $checksum); |
|
| 69 | - } |
|
| 70 | - } |
|
| 47 | + /** |
|
| 48 | + * The xmlSerialize metod is called during xml writing. |
|
| 49 | + * |
|
| 50 | + * Use the $writer argument to write its own xml serialization. |
|
| 51 | + * |
|
| 52 | + * An important note: do _not_ create a parent element. Any element |
|
| 53 | + * implementing XmlSerializble should only ever write what's considered |
|
| 54 | + * its 'inner xml'. |
|
| 55 | + * |
|
| 56 | + * The parent of the current element is responsible for writing a |
|
| 57 | + * containing element. |
|
| 58 | + * |
|
| 59 | + * This allows serializers to be re-used for different element names. |
|
| 60 | + * |
|
| 61 | + * If you are opening new elements, you must also close them again. |
|
| 62 | + * |
|
| 63 | + * @param Writer $writer |
|
| 64 | + * @return void |
|
| 65 | + */ |
|
| 66 | + public function xmlSerialize(Writer $writer) { |
|
| 67 | + foreach ($this->checksums as $checksum) { |
|
| 68 | + $writer->writeElement('{' . self::NS_OWNCLOUD . '}checksum', $checksum); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | } |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | return null; |
| 72 | 72 | } |
| 73 | 73 | foreach ($tree as $elem) { |
| 74 | - if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') { |
|
| 75 | - $shareTypes[] = (int)$elem['value']; |
|
| 74 | + if ($elem['name'] === '{'.self::NS_OWNCLOUD.'}share-type') { |
|
| 75 | + $shareTypes[] = (int) $elem['value']; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | return new self($shareTypes); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function xmlSerialize(Writer $writer) { |
| 88 | 88 | foreach ($this->shareTypes as $shareType) { |
| 89 | - $writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType); |
|
| 89 | + $writer->writeElement('{'.self::NS_OWNCLOUD.'}share-type', $shareType); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -32,61 +32,61 @@ |
||
| 32 | 32 | * This property contains multiple "share-type" elements, each containing a share type. |
| 33 | 33 | */ |
| 34 | 34 | class ShareTypeList implements Element { |
| 35 | - public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
| 35 | + public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Share types |
|
| 39 | - * |
|
| 40 | - * @var int[] |
|
| 41 | - */ |
|
| 42 | - private $shareTypes; |
|
| 37 | + /** |
|
| 38 | + * Share types |
|
| 39 | + * |
|
| 40 | + * @var int[] |
|
| 41 | + */ |
|
| 42 | + private $shareTypes; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @param int[] $shareTypes |
|
| 46 | - */ |
|
| 47 | - public function __construct($shareTypes) { |
|
| 48 | - $this->shareTypes = $shareTypes; |
|
| 49 | - } |
|
| 44 | + /** |
|
| 45 | + * @param int[] $shareTypes |
|
| 46 | + */ |
|
| 47 | + public function __construct($shareTypes) { |
|
| 48 | + $this->shareTypes = $shareTypes; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Returns the share types |
|
| 53 | - * |
|
| 54 | - * @return int[] |
|
| 55 | - */ |
|
| 56 | - public function getShareTypes() { |
|
| 57 | - return $this->shareTypes; |
|
| 58 | - } |
|
| 51 | + /** |
|
| 52 | + * Returns the share types |
|
| 53 | + * |
|
| 54 | + * @return int[] |
|
| 55 | + */ |
|
| 56 | + public function getShareTypes() { |
|
| 57 | + return $this->shareTypes; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * The deserialize method is called during xml parsing. |
|
| 62 | - * |
|
| 63 | - * @param Reader $reader |
|
| 64 | - * @return mixed |
|
| 65 | - */ |
|
| 66 | - public static function xmlDeserialize(Reader $reader) { |
|
| 67 | - $shareTypes = []; |
|
| 60 | + /** |
|
| 61 | + * The deserialize method is called during xml parsing. |
|
| 62 | + * |
|
| 63 | + * @param Reader $reader |
|
| 64 | + * @return mixed |
|
| 65 | + */ |
|
| 66 | + public static function xmlDeserialize(Reader $reader) { |
|
| 67 | + $shareTypes = []; |
|
| 68 | 68 | |
| 69 | - $tree = $reader->parseInnerTree(); |
|
| 70 | - if ($tree === null) { |
|
| 71 | - return null; |
|
| 72 | - } |
|
| 73 | - foreach ($tree as $elem) { |
|
| 74 | - if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') { |
|
| 75 | - $shareTypes[] = (int)$elem['value']; |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - return new self($shareTypes); |
|
| 79 | - } |
|
| 69 | + $tree = $reader->parseInnerTree(); |
|
| 70 | + if ($tree === null) { |
|
| 71 | + return null; |
|
| 72 | + } |
|
| 73 | + foreach ($tree as $elem) { |
|
| 74 | + if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') { |
|
| 75 | + $shareTypes[] = (int)$elem['value']; |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + return new self($shareTypes); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * The xmlSerialize metod is called during xml writing. |
|
| 83 | - * |
|
| 84 | - * @param Writer $writer |
|
| 85 | - * @return void |
|
| 86 | - */ |
|
| 87 | - public function xmlSerialize(Writer $writer) { |
|
| 88 | - foreach ($this->shareTypes as $shareType) { |
|
| 89 | - $writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType); |
|
| 90 | - } |
|
| 91 | - } |
|
| 81 | + /** |
|
| 82 | + * The xmlSerialize metod is called during xml writing. |
|
| 83 | + * |
|
| 84 | + * @param Writer $writer |
|
| 85 | + * @return void |
|
| 86 | + */ |
|
| 87 | + public function xmlSerialize(Writer $writer) { |
|
| 88 | + foreach ($this->shareTypes as $shareType) { |
|
| 89 | + $writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | } |
@@ -108,7 +108,7 @@ |
||
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - throw new NotFound('Node with name \'' . $name . '\' could not be found'); |
|
| 111 | + throw new NotFound('Node with name \''.$name.'\' could not be found'); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -42,154 +42,154 @@ |
||
| 42 | 42 | |
| 43 | 43 | class CalendarHome extends \Sabre\CalDAV\CalendarHome { |
| 44 | 44 | |
| 45 | - /** @var \OCP\IL10N */ |
|
| 46 | - private $l10n; |
|
| 47 | - |
|
| 48 | - /** @var \OCP\IConfig */ |
|
| 49 | - private $config; |
|
| 50 | - |
|
| 51 | - /** @var PluginManager */ |
|
| 52 | - private $pluginManager; |
|
| 53 | - |
|
| 54 | - /** @var bool */ |
|
| 55 | - private $returnCachedSubscriptions = false; |
|
| 56 | - |
|
| 57 | - public function __construct(BackendInterface $caldavBackend, $principalInfo) { |
|
| 58 | - parent::__construct($caldavBackend, $principalInfo); |
|
| 59 | - $this->l10n = \OC::$server->getL10N('dav'); |
|
| 60 | - $this->config = \OC::$server->getConfig(); |
|
| 61 | - $this->pluginManager = new PluginManager( |
|
| 62 | - \OC::$server, |
|
| 63 | - \OC::$server->getAppManager() |
|
| 64 | - ); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @return BackendInterface |
|
| 69 | - */ |
|
| 70 | - public function getCalDAVBackend() { |
|
| 71 | - return $this->caldavBackend; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @inheritdoc |
|
| 76 | - */ |
|
| 77 | - public function createExtendedCollection($name, MkCol $mkCol) { |
|
| 78 | - $reservedNames = [BirthdayService::BIRTHDAY_CALENDAR_URI]; |
|
| 79 | - |
|
| 80 | - if (\in_array($name, $reservedNames, true) || ExternalCalendar::doesViolateReservedName($name)) { |
|
| 81 | - throw new MethodNotAllowed('The resource you tried to create has a reserved name'); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - parent::createExtendedCollection($name, $mkCol); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @inheritdoc |
|
| 89 | - */ |
|
| 90 | - public function getChildren() { |
|
| 91 | - $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); |
|
| 92 | - $objects = []; |
|
| 93 | - foreach ($calendars as $calendar) { |
|
| 94 | - $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if ($this->caldavBackend instanceof SchedulingSupport) { |
|
| 98 | - $objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']); |
|
| 99 | - $objects[] = new Outbox($this->config, $this->principalInfo['uri']); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - // We're adding a notifications node, if it's supported by the backend. |
|
| 103 | - if ($this->caldavBackend instanceof NotificationSupport) { |
|
| 104 | - $objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - // If the backend supports subscriptions, we'll add those as well, |
|
| 108 | - if ($this->caldavBackend instanceof SubscriptionSupport) { |
|
| 109 | - foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { |
|
| 110 | - if ($this->returnCachedSubscriptions) { |
|
| 111 | - $objects[] = new CachedSubscription($this->caldavBackend, $subscription); |
|
| 112 | - } else { |
|
| 113 | - $objects[] = new Subscription($this->caldavBackend, $subscription); |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) { |
|
| 119 | - /** @var ICalendarProvider $calendarPlugin */ |
|
| 120 | - $calendars = $calendarPlugin->fetchAllForCalendarHome($this->principalInfo['uri']); |
|
| 121 | - foreach ($calendars as $calendar) { |
|
| 122 | - $objects[] = $calendar; |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - return $objects; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @inheritdoc |
|
| 131 | - */ |
|
| 132 | - public function getChild($name) { |
|
| 133 | - // Special nodes |
|
| 134 | - if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) { |
|
| 135 | - return new Inbox($this->caldavBackend, $this->principalInfo['uri']); |
|
| 136 | - } |
|
| 137 | - if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) { |
|
| 138 | - return new Outbox($this->config, $this->principalInfo['uri']); |
|
| 139 | - } |
|
| 140 | - if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) { |
|
| 141 | - return new \Sabre\CalDAv\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - // Calendars |
|
| 145 | - foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) { |
|
| 146 | - if ($calendar['uri'] === $name) { |
|
| 147 | - return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config); |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - if ($this->caldavBackend instanceof SubscriptionSupport) { |
|
| 152 | - foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { |
|
| 153 | - if ($subscription['uri'] === $name) { |
|
| 154 | - if ($this->returnCachedSubscriptions) { |
|
| 155 | - return new CachedSubscription($this->caldavBackend, $subscription); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - return new Subscription($this->caldavBackend, $subscription); |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if (ExternalCalendar::isAppGeneratedCalendar($name)) { |
|
| 164 | - [$appId, $calendarUri] = ExternalCalendar::splitAppGeneratedCalendarUri($name); |
|
| 165 | - |
|
| 166 | - foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) { |
|
| 167 | - /** @var ICalendarProvider $calendarPlugin */ |
|
| 168 | - if ($calendarPlugin->getAppId() !== $appId) { |
|
| 169 | - continue; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - if ($calendarPlugin->hasCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri)) { |
|
| 173 | - return $calendarPlugin->getCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri); |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - throw new NotFound('Node with name \'' . $name . '\' could not be found'); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * @param array $filters |
|
| 183 | - * @param integer|null $limit |
|
| 184 | - * @param integer|null $offset |
|
| 185 | - */ |
|
| 186 | - public function calendarSearch(array $filters, $limit = null, $offset = null) { |
|
| 187 | - $principalUri = $this->principalInfo['uri']; |
|
| 188 | - return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - |
|
| 192 | - public function enableCachedSubscriptionsForThisRequest() { |
|
| 193 | - $this->returnCachedSubscriptions = true; |
|
| 194 | - } |
|
| 45 | + /** @var \OCP\IL10N */ |
|
| 46 | + private $l10n; |
|
| 47 | + |
|
| 48 | + /** @var \OCP\IConfig */ |
|
| 49 | + private $config; |
|
| 50 | + |
|
| 51 | + /** @var PluginManager */ |
|
| 52 | + private $pluginManager; |
|
| 53 | + |
|
| 54 | + /** @var bool */ |
|
| 55 | + private $returnCachedSubscriptions = false; |
|
| 56 | + |
|
| 57 | + public function __construct(BackendInterface $caldavBackend, $principalInfo) { |
|
| 58 | + parent::__construct($caldavBackend, $principalInfo); |
|
| 59 | + $this->l10n = \OC::$server->getL10N('dav'); |
|
| 60 | + $this->config = \OC::$server->getConfig(); |
|
| 61 | + $this->pluginManager = new PluginManager( |
|
| 62 | + \OC::$server, |
|
| 63 | + \OC::$server->getAppManager() |
|
| 64 | + ); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @return BackendInterface |
|
| 69 | + */ |
|
| 70 | + public function getCalDAVBackend() { |
|
| 71 | + return $this->caldavBackend; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @inheritdoc |
|
| 76 | + */ |
|
| 77 | + public function createExtendedCollection($name, MkCol $mkCol) { |
|
| 78 | + $reservedNames = [BirthdayService::BIRTHDAY_CALENDAR_URI]; |
|
| 79 | + |
|
| 80 | + if (\in_array($name, $reservedNames, true) || ExternalCalendar::doesViolateReservedName($name)) { |
|
| 81 | + throw new MethodNotAllowed('The resource you tried to create has a reserved name'); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + parent::createExtendedCollection($name, $mkCol); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @inheritdoc |
|
| 89 | + */ |
|
| 90 | + public function getChildren() { |
|
| 91 | + $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); |
|
| 92 | + $objects = []; |
|
| 93 | + foreach ($calendars as $calendar) { |
|
| 94 | + $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if ($this->caldavBackend instanceof SchedulingSupport) { |
|
| 98 | + $objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']); |
|
| 99 | + $objects[] = new Outbox($this->config, $this->principalInfo['uri']); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + // We're adding a notifications node, if it's supported by the backend. |
|
| 103 | + if ($this->caldavBackend instanceof NotificationSupport) { |
|
| 104 | + $objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + // If the backend supports subscriptions, we'll add those as well, |
|
| 108 | + if ($this->caldavBackend instanceof SubscriptionSupport) { |
|
| 109 | + foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { |
|
| 110 | + if ($this->returnCachedSubscriptions) { |
|
| 111 | + $objects[] = new CachedSubscription($this->caldavBackend, $subscription); |
|
| 112 | + } else { |
|
| 113 | + $objects[] = new Subscription($this->caldavBackend, $subscription); |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) { |
|
| 119 | + /** @var ICalendarProvider $calendarPlugin */ |
|
| 120 | + $calendars = $calendarPlugin->fetchAllForCalendarHome($this->principalInfo['uri']); |
|
| 121 | + foreach ($calendars as $calendar) { |
|
| 122 | + $objects[] = $calendar; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + return $objects; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @inheritdoc |
|
| 131 | + */ |
|
| 132 | + public function getChild($name) { |
|
| 133 | + // Special nodes |
|
| 134 | + if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) { |
|
| 135 | + return new Inbox($this->caldavBackend, $this->principalInfo['uri']); |
|
| 136 | + } |
|
| 137 | + if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) { |
|
| 138 | + return new Outbox($this->config, $this->principalInfo['uri']); |
|
| 139 | + } |
|
| 140 | + if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) { |
|
| 141 | + return new \Sabre\CalDAv\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + // Calendars |
|
| 145 | + foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) { |
|
| 146 | + if ($calendar['uri'] === $name) { |
|
| 147 | + return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config); |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + if ($this->caldavBackend instanceof SubscriptionSupport) { |
|
| 152 | + foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { |
|
| 153 | + if ($subscription['uri'] === $name) { |
|
| 154 | + if ($this->returnCachedSubscriptions) { |
|
| 155 | + return new CachedSubscription($this->caldavBackend, $subscription); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + return new Subscription($this->caldavBackend, $subscription); |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if (ExternalCalendar::isAppGeneratedCalendar($name)) { |
|
| 164 | + [$appId, $calendarUri] = ExternalCalendar::splitAppGeneratedCalendarUri($name); |
|
| 165 | + |
|
| 166 | + foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) { |
|
| 167 | + /** @var ICalendarProvider $calendarPlugin */ |
|
| 168 | + if ($calendarPlugin->getAppId() !== $appId) { |
|
| 169 | + continue; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + if ($calendarPlugin->hasCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri)) { |
|
| 173 | + return $calendarPlugin->getCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri); |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + throw new NotFound('Node with name \'' . $name . '\' could not be found'); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * @param array $filters |
|
| 183 | + * @param integer|null $limit |
|
| 184 | + * @param integer|null $offset |
|
| 185 | + */ |
|
| 186 | + public function calendarSearch(array $filters, $limit = null, $offset = null) { |
|
| 187 | + $principalUri = $this->principalInfo['uri']; |
|
| 188 | + return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + |
|
| 192 | + public function enableCachedSubscriptionsForThisRequest() { |
|
| 193 | + $this->returnCachedSubscriptions = true; |
|
| 194 | + } |
|
| 195 | 195 | } |
@@ -25,58 +25,58 @@ |
||
| 25 | 25 | |
| 26 | 26 | class Publisher implements XmlSerializable { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var string $publishUrl |
|
| 30 | - */ |
|
| 31 | - protected $publishUrl; |
|
| 28 | + /** |
|
| 29 | + * @var string $publishUrl |
|
| 30 | + */ |
|
| 31 | + protected $publishUrl; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var boolean $isPublished |
|
| 35 | - */ |
|
| 36 | - protected $isPublished; |
|
| 33 | + /** |
|
| 34 | + * @var boolean $isPublished |
|
| 35 | + */ |
|
| 36 | + protected $isPublished; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param string $publishUrl |
|
| 40 | - * @param boolean $isPublished |
|
| 41 | - */ |
|
| 42 | - public function __construct($publishUrl, $isPublished) { |
|
| 43 | - $this->publishUrl = $publishUrl; |
|
| 44 | - $this->isPublished = $isPublished; |
|
| 45 | - } |
|
| 38 | + /** |
|
| 39 | + * @param string $publishUrl |
|
| 40 | + * @param boolean $isPublished |
|
| 41 | + */ |
|
| 42 | + public function __construct($publishUrl, $isPublished) { |
|
| 43 | + $this->publishUrl = $publishUrl; |
|
| 44 | + $this->isPublished = $isPublished; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @return string |
|
| 49 | - */ |
|
| 50 | - public function getValue() { |
|
| 51 | - return $this->publishUrl; |
|
| 52 | - } |
|
| 47 | + /** |
|
| 48 | + * @return string |
|
| 49 | + */ |
|
| 50 | + public function getValue() { |
|
| 51 | + return $this->publishUrl; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * The xmlSerialize metod is called during xml writing. |
|
| 56 | - * |
|
| 57 | - * Use the $writer argument to write its own xml serialization. |
|
| 58 | - * |
|
| 59 | - * An important note: do _not_ create a parent element. Any element |
|
| 60 | - * implementing XmlSerializble should only ever write what's considered |
|
| 61 | - * its 'inner xml'. |
|
| 62 | - * |
|
| 63 | - * The parent of the current element is responsible for writing a |
|
| 64 | - * containing element. |
|
| 65 | - * |
|
| 66 | - * This allows serializers to be re-used for different element names. |
|
| 67 | - * |
|
| 68 | - * If you are opening new elements, you must also close them again. |
|
| 69 | - * |
|
| 70 | - * @param Writer $writer |
|
| 71 | - * @return void |
|
| 72 | - */ |
|
| 73 | - public function xmlSerialize(Writer $writer) { |
|
| 74 | - if (!$this->isPublished) { |
|
| 75 | - // for pre-publish-url |
|
| 76 | - $writer->write($this->publishUrl); |
|
| 77 | - } else { |
|
| 78 | - // for publish-url |
|
| 79 | - $writer->writeElement('{DAV:}href', $this->publishUrl); |
|
| 80 | - } |
|
| 81 | - } |
|
| 54 | + /** |
|
| 55 | + * The xmlSerialize metod is called during xml writing. |
|
| 56 | + * |
|
| 57 | + * Use the $writer argument to write its own xml serialization. |
|
| 58 | + * |
|
| 59 | + * An important note: do _not_ create a parent element. Any element |
|
| 60 | + * implementing XmlSerializble should only ever write what's considered |
|
| 61 | + * its 'inner xml'. |
|
| 62 | + * |
|
| 63 | + * The parent of the current element is responsible for writing a |
|
| 64 | + * containing element. |
|
| 65 | + * |
|
| 66 | + * This allows serializers to be re-used for different element names. |
|
| 67 | + * |
|
| 68 | + * If you are opening new elements, you must also close them again. |
|
| 69 | + * |
|
| 70 | + * @param Writer $writer |
|
| 71 | + * @return void |
|
| 72 | + */ |
|
| 73 | + public function xmlSerialize(Writer $writer) { |
|
| 74 | + if (!$this->isPublished) { |
|
| 75 | + // for pre-publish-url |
|
| 76 | + $writer->write($this->publishUrl); |
|
| 77 | + } else { |
|
| 78 | + // for publish-url |
|
| 79 | + $writer->writeElement('{DAV:}href', $this->publishUrl); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | } |
@@ -23,11 +23,11 @@ |
||
| 23 | 23 | |
| 24 | 24 | class PublicCalendarObject extends CalendarObject { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * public calendars are always shared |
|
| 28 | - * @return bool |
|
| 29 | - */ |
|
| 30 | - protected function isShared() { |
|
| 31 | - return true; |
|
| 32 | - } |
|
| 26 | + /** |
|
| 27 | + * public calendars are always shared |
|
| 28 | + * @return bool |
|
| 29 | + */ |
|
| 30 | + protected function isShared() { |
|
| 31 | + return true; |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -27,17 +27,17 @@ |
||
| 27 | 27 | |
| 28 | 28 | class SearchTermFilter implements XmlDeserializable { |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @param Reader $reader |
|
| 32 | - * @throws BadRequest |
|
| 33 | - * @return string |
|
| 34 | - */ |
|
| 35 | - public static function xmlDeserialize(Reader $reader) { |
|
| 36 | - $value = $reader->parseInnerTree(); |
|
| 37 | - if (!is_string($value)) { |
|
| 38 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value'); |
|
| 39 | - } |
|
| 30 | + /** |
|
| 31 | + * @param Reader $reader |
|
| 32 | + * @throws BadRequest |
|
| 33 | + * @return string |
|
| 34 | + */ |
|
| 35 | + public static function xmlDeserialize(Reader $reader) { |
|
| 36 | + $value = $reader->parseInnerTree(); |
|
| 37 | + if (!is_string($value)) { |
|
| 38 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value'); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - return $value; |
|
| 42 | - } |
|
| 41 | + return $value; |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | public static function xmlDeserialize(Reader $reader) { |
| 36 | 36 | $value = $reader->parseInnerTree(); |
| 37 | 37 | if (!is_string($value)) { |
| 38 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value'); |
|
| 38 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}search-term has illegal value'); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return $value; |
@@ -94,15 +94,15 @@ discard block |
||
| 94 | 94 | $tags = $this->tagManager->getTagsByIds([$tagId]); |
| 95 | 95 | $tag = current($tags); |
| 96 | 96 | if (!$this->tagManager->canUserSeeTag($tag, $this->user)) { |
| 97 | - throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign'); |
|
| 97 | + throw new PreconditionFailed('Tag with id '.$tagId.' does not exist, cannot assign'); |
|
| 98 | 98 | } |
| 99 | 99 | if (!$this->tagManager->canUserAssignTag($tag, $this->user)) { |
| 100 | - throw new Forbidden('No permission to assign tag ' . $tagId); |
|
| 100 | + throw new Forbidden('No permission to assign tag '.$tagId); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId); |
| 104 | 104 | } catch (TagNotFoundException $e) { |
| 105 | - throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign'); |
|
| 105 | + throw new PreconditionFailed('Tag with id '.$tagId.' does not exist, cannot assign'); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | return $this->makeNode($tag); |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | - throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId); |
|
| 122 | + throw new NotFound('Tag with id '.$tagId.' not present for object '.$this->objectId); |
|
| 123 | 123 | } catch (\InvalidArgumentException $e) { |
| 124 | 124 | throw new BadRequest('Invalid tag id', 0, $e); |
| 125 | 125 | } catch (TagNotFoundException $e) { |
| 126 | - throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e); |
|
| 126 | + throw new NotFound('Tag with id '.$tagId.' not found', 0, $e); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | $tags = $this->tagManager->getTagsByIds($tagIds); |
| 136 | 136 | |
| 137 | 137 | // filter out non-visible tags |
| 138 | - $tags = array_filter($tags, function ($tag) { |
|
| 138 | + $tags = array_filter($tags, function($tag) { |
|
| 139 | 139 | return $this->tagManager->canUserSeeTag($tag, $this->user); |
| 140 | 140 | }); |
| 141 | 141 | |
| 142 | - return array_values(array_map(function ($tag) { |
|
| 142 | + return array_values(array_map(function($tag) { |
|
| 143 | 143 | return $this->makeNode($tag); |
| 144 | 144 | }, $tags)); |
| 145 | 145 | } |
@@ -42,170 +42,170 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | class SystemTagsObjectMappingCollection implements ICollection { |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 48 | - private $objectId; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @var string |
|
| 52 | - */ |
|
| 53 | - private $objectType; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @var ISystemTagManager |
|
| 57 | - */ |
|
| 58 | - private $tagManager; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @var ISystemTagObjectMapper |
|
| 62 | - */ |
|
| 63 | - private $tagMapper; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * User |
|
| 67 | - * |
|
| 68 | - * @var IUser |
|
| 69 | - */ |
|
| 70 | - private $user; |
|
| 71 | - |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Constructor |
|
| 75 | - * |
|
| 76 | - * @param string $objectId object id |
|
| 77 | - * @param string $objectType object type |
|
| 78 | - * @param IUser $user user |
|
| 79 | - * @param ISystemTagManager $tagManager tag manager |
|
| 80 | - * @param ISystemTagObjectMapper $tagMapper tag mapper |
|
| 81 | - */ |
|
| 82 | - public function __construct( |
|
| 83 | - $objectId, |
|
| 84 | - $objectType, |
|
| 85 | - IUser $user, |
|
| 86 | - ISystemTagManager $tagManager, |
|
| 87 | - ISystemTagObjectMapper $tagMapper |
|
| 88 | - ) { |
|
| 89 | - $this->tagManager = $tagManager; |
|
| 90 | - $this->tagMapper = $tagMapper; |
|
| 91 | - $this->objectId = $objectId; |
|
| 92 | - $this->objectType = $objectType; |
|
| 93 | - $this->user = $user; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - public function createFile($name, $data = null) { |
|
| 97 | - $tagId = $name; |
|
| 98 | - try { |
|
| 99 | - $tags = $this->tagManager->getTagsByIds([$tagId]); |
|
| 100 | - $tag = current($tags); |
|
| 101 | - if (!$this->tagManager->canUserSeeTag($tag, $this->user)) { |
|
| 102 | - throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign'); |
|
| 103 | - } |
|
| 104 | - if (!$this->tagManager->canUserAssignTag($tag, $this->user)) { |
|
| 105 | - throw new Forbidden('No permission to assign tag ' . $tagId); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - $this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId); |
|
| 109 | - } catch (TagNotFoundException $e) { |
|
| 110 | - throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign'); |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - public function createDirectory($name) { |
|
| 115 | - throw new Forbidden('Permission denied to create collections'); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - public function getChild($tagId) { |
|
| 119 | - try { |
|
| 120 | - if ($this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true)) { |
|
| 121 | - $tag = $this->tagManager->getTagsByIds([$tagId]); |
|
| 122 | - $tag = current($tag); |
|
| 123 | - if ($this->tagManager->canUserSeeTag($tag, $this->user)) { |
|
| 124 | - return $this->makeNode($tag); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId); |
|
| 128 | - } catch (\InvalidArgumentException $e) { |
|
| 129 | - throw new BadRequest('Invalid tag id', 0, $e); |
|
| 130 | - } catch (TagNotFoundException $e) { |
|
| 131 | - throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e); |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - public function getChildren() { |
|
| 136 | - $tagIds = current($this->tagMapper->getTagIdsForObjects([$this->objectId], $this->objectType)); |
|
| 137 | - if (empty($tagIds)) { |
|
| 138 | - return []; |
|
| 139 | - } |
|
| 140 | - $tags = $this->tagManager->getTagsByIds($tagIds); |
|
| 141 | - |
|
| 142 | - // filter out non-visible tags |
|
| 143 | - $tags = array_filter($tags, function ($tag) { |
|
| 144 | - return $this->tagManager->canUserSeeTag($tag, $this->user); |
|
| 145 | - }); |
|
| 146 | - |
|
| 147 | - return array_values(array_map(function ($tag) { |
|
| 148 | - return $this->makeNode($tag); |
|
| 149 | - }, $tags)); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - public function childExists($tagId) { |
|
| 153 | - try { |
|
| 154 | - $result = $this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true); |
|
| 155 | - |
|
| 156 | - if ($result) { |
|
| 157 | - $tags = $this->tagManager->getTagsByIds([$tagId]); |
|
| 158 | - $tag = current($tags); |
|
| 159 | - if (!$this->tagManager->canUserSeeTag($tag, $this->user)) { |
|
| 160 | - return false; |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - return $result; |
|
| 165 | - } catch (\InvalidArgumentException $e) { |
|
| 166 | - throw new BadRequest('Invalid tag id', 0, $e); |
|
| 167 | - } catch (TagNotFoundException $e) { |
|
| 168 | - return false; |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - public function delete() { |
|
| 173 | - throw new Forbidden('Permission denied to delete this collection'); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - public function getName() { |
|
| 177 | - return $this->objectId; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - public function setName($name) { |
|
| 181 | - throw new Forbidden('Permission denied to rename this collection'); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * Returns the last modification time, as a unix timestamp |
|
| 186 | - * |
|
| 187 | - * @return int |
|
| 188 | - */ |
|
| 189 | - public function getLastModified() { |
|
| 190 | - return null; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * Create a sabre node for the mapping of the |
|
| 195 | - * given system tag to the collection's object |
|
| 196 | - * |
|
| 197 | - * @param ISystemTag $tag |
|
| 198 | - * |
|
| 199 | - * @return SystemTagMappingNode |
|
| 200 | - */ |
|
| 201 | - private function makeNode(ISystemTag $tag) { |
|
| 202 | - return new SystemTagMappingNode( |
|
| 203 | - $tag, |
|
| 204 | - $this->objectId, |
|
| 205 | - $this->objectType, |
|
| 206 | - $this->user, |
|
| 207 | - $this->tagManager, |
|
| 208 | - $this->tagMapper |
|
| 209 | - ); |
|
| 210 | - } |
|
| 45 | + /** |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | + private $objectId; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @var string |
|
| 52 | + */ |
|
| 53 | + private $objectType; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @var ISystemTagManager |
|
| 57 | + */ |
|
| 58 | + private $tagManager; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @var ISystemTagObjectMapper |
|
| 62 | + */ |
|
| 63 | + private $tagMapper; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * User |
|
| 67 | + * |
|
| 68 | + * @var IUser |
|
| 69 | + */ |
|
| 70 | + private $user; |
|
| 71 | + |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Constructor |
|
| 75 | + * |
|
| 76 | + * @param string $objectId object id |
|
| 77 | + * @param string $objectType object type |
|
| 78 | + * @param IUser $user user |
|
| 79 | + * @param ISystemTagManager $tagManager tag manager |
|
| 80 | + * @param ISystemTagObjectMapper $tagMapper tag mapper |
|
| 81 | + */ |
|
| 82 | + public function __construct( |
|
| 83 | + $objectId, |
|
| 84 | + $objectType, |
|
| 85 | + IUser $user, |
|
| 86 | + ISystemTagManager $tagManager, |
|
| 87 | + ISystemTagObjectMapper $tagMapper |
|
| 88 | + ) { |
|
| 89 | + $this->tagManager = $tagManager; |
|
| 90 | + $this->tagMapper = $tagMapper; |
|
| 91 | + $this->objectId = $objectId; |
|
| 92 | + $this->objectType = $objectType; |
|
| 93 | + $this->user = $user; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + public function createFile($name, $data = null) { |
|
| 97 | + $tagId = $name; |
|
| 98 | + try { |
|
| 99 | + $tags = $this->tagManager->getTagsByIds([$tagId]); |
|
| 100 | + $tag = current($tags); |
|
| 101 | + if (!$this->tagManager->canUserSeeTag($tag, $this->user)) { |
|
| 102 | + throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign'); |
|
| 103 | + } |
|
| 104 | + if (!$this->tagManager->canUserAssignTag($tag, $this->user)) { |
|
| 105 | + throw new Forbidden('No permission to assign tag ' . $tagId); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + $this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId); |
|
| 109 | + } catch (TagNotFoundException $e) { |
|
| 110 | + throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign'); |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + public function createDirectory($name) { |
|
| 115 | + throw new Forbidden('Permission denied to create collections'); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + public function getChild($tagId) { |
|
| 119 | + try { |
|
| 120 | + if ($this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true)) { |
|
| 121 | + $tag = $this->tagManager->getTagsByIds([$tagId]); |
|
| 122 | + $tag = current($tag); |
|
| 123 | + if ($this->tagManager->canUserSeeTag($tag, $this->user)) { |
|
| 124 | + return $this->makeNode($tag); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId); |
|
| 128 | + } catch (\InvalidArgumentException $e) { |
|
| 129 | + throw new BadRequest('Invalid tag id', 0, $e); |
|
| 130 | + } catch (TagNotFoundException $e) { |
|
| 131 | + throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + public function getChildren() { |
|
| 136 | + $tagIds = current($this->tagMapper->getTagIdsForObjects([$this->objectId], $this->objectType)); |
|
| 137 | + if (empty($tagIds)) { |
|
| 138 | + return []; |
|
| 139 | + } |
|
| 140 | + $tags = $this->tagManager->getTagsByIds($tagIds); |
|
| 141 | + |
|
| 142 | + // filter out non-visible tags |
|
| 143 | + $tags = array_filter($tags, function ($tag) { |
|
| 144 | + return $this->tagManager->canUserSeeTag($tag, $this->user); |
|
| 145 | + }); |
|
| 146 | + |
|
| 147 | + return array_values(array_map(function ($tag) { |
|
| 148 | + return $this->makeNode($tag); |
|
| 149 | + }, $tags)); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + public function childExists($tagId) { |
|
| 153 | + try { |
|
| 154 | + $result = $this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true); |
|
| 155 | + |
|
| 156 | + if ($result) { |
|
| 157 | + $tags = $this->tagManager->getTagsByIds([$tagId]); |
|
| 158 | + $tag = current($tags); |
|
| 159 | + if (!$this->tagManager->canUserSeeTag($tag, $this->user)) { |
|
| 160 | + return false; |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + return $result; |
|
| 165 | + } catch (\InvalidArgumentException $e) { |
|
| 166 | + throw new BadRequest('Invalid tag id', 0, $e); |
|
| 167 | + } catch (TagNotFoundException $e) { |
|
| 168 | + return false; |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + public function delete() { |
|
| 173 | + throw new Forbidden('Permission denied to delete this collection'); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + public function getName() { |
|
| 177 | + return $this->objectId; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + public function setName($name) { |
|
| 181 | + throw new Forbidden('Permission denied to rename this collection'); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * Returns the last modification time, as a unix timestamp |
|
| 186 | + * |
|
| 187 | + * @return int |
|
| 188 | + */ |
|
| 189 | + public function getLastModified() { |
|
| 190 | + return null; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Create a sabre node for the mapping of the |
|
| 195 | + * given system tag to the collection's object |
|
| 196 | + * |
|
| 197 | + * @param ISystemTag $tag |
|
| 198 | + * |
|
| 199 | + * @return SystemTagMappingNode |
|
| 200 | + */ |
|
| 201 | + private function makeNode(ISystemTag $tag) { |
|
| 202 | + return new SystemTagMappingNode( |
|
| 203 | + $tag, |
|
| 204 | + $this->objectId, |
|
| 205 | + $this->objectType, |
|
| 206 | + $this->user, |
|
| 207 | + $this->tagManager, |
|
| 208 | + $this->tagMapper |
|
| 209 | + ); |
|
| 210 | + } |
|
| 211 | 211 | } |
@@ -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 | } |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | $tag = $this->tagManager->getTagsByIds([$name]); |
| 105 | 105 | $tag = current($tag); |
| 106 | 106 | if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
| 107 | - throw new NotFound('Tag with id ' . $name . ' not found'); |
|
| 107 | + throw new NotFound('Tag with id '.$name.' not found'); |
|
| 108 | 108 | } |
| 109 | 109 | return $this->makeNode($tag); |
| 110 | 110 | } catch (\InvalidArgumentException $e) { |
| 111 | 111 | throw new BadRequest('Invalid tag id', 0, $e); |
| 112 | 112 | } catch (TagNotFoundException $e) { |
| 113 | - throw new NotFound('Tag with id ' . $name . ' not found', 0, $e); |
|
| 113 | + throw new NotFound('Tag with id '.$name.' not found', 0, $e); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $tags = $this->tagManager->getAllTags($visibilityFilter); |
| 124 | - return array_map(function ($tag) { |
|
| 124 | + return array_map(function($tag) { |
|
| 125 | 125 | return $this->makeNode($tag); |
| 126 | 126 | }, $tags); |
| 127 | 127 | } |