@@ -27,57 +27,57 @@ |
||
| 27 | 27 | |
| 28 | 28 | class Manager implements \OCP\Calendar\Resource\IManager { |
| 29 | 29 | |
| 30 | - /** @var IBackend[] holds all registered resource backends */ |
|
| 31 | - private $backends; |
|
| 30 | + /** @var IBackend[] holds all registered resource backends */ |
|
| 31 | + private $backends; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Registers a resource backend |
|
| 35 | - * |
|
| 36 | - * @param IBackend $backend |
|
| 37 | - * @return void |
|
| 38 | - * @since 14.0.0 |
|
| 39 | - */ |
|
| 40 | - public function registerBackend(IBackend $backend) { |
|
| 41 | - $this->backends[$backend->getBackendIdentifier()] = $backend; |
|
| 42 | - } |
|
| 33 | + /** |
|
| 34 | + * Registers a resource backend |
|
| 35 | + * |
|
| 36 | + * @param IBackend $backend |
|
| 37 | + * @return void |
|
| 38 | + * @since 14.0.0 |
|
| 39 | + */ |
|
| 40 | + public function registerBackend(IBackend $backend) { |
|
| 41 | + $this->backends[$backend->getBackendIdentifier()] = $backend; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Unregisters a resource backend |
|
| 46 | - * |
|
| 47 | - * @param IBackend $backend |
|
| 48 | - * @return void |
|
| 49 | - * @since 14.0.0 |
|
| 50 | - */ |
|
| 51 | - public function unregisterBackend(IBackend $backend) { |
|
| 52 | - unset($this->backends[$backend->getBackendIdentifier()]); |
|
| 53 | - } |
|
| 44 | + /** |
|
| 45 | + * Unregisters a resource backend |
|
| 46 | + * |
|
| 47 | + * @param IBackend $backend |
|
| 48 | + * @return void |
|
| 49 | + * @since 14.0.0 |
|
| 50 | + */ |
|
| 51 | + public function unregisterBackend(IBackend $backend) { |
|
| 52 | + unset($this->backends[$backend->getBackendIdentifier()]); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @return IBackend[] |
|
| 57 | - * @since 14.0.0 |
|
| 58 | - */ |
|
| 59 | - public function getBackends():array { |
|
| 60 | - return array_values($this->backends); |
|
| 61 | - } |
|
| 55 | + /** |
|
| 56 | + * @return IBackend[] |
|
| 57 | + * @since 14.0.0 |
|
| 58 | + */ |
|
| 59 | + public function getBackends():array { |
|
| 60 | + return array_values($this->backends); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @param string $backendId |
|
| 65 | - * @return IBackend|null |
|
| 66 | - */ |
|
| 67 | - public function getBackend($backendId):IBackend { |
|
| 68 | - if (!isset($this->backends[$backendId])) { |
|
| 69 | - return null; |
|
| 70 | - } |
|
| 63 | + /** |
|
| 64 | + * @param string $backendId |
|
| 65 | + * @return IBackend|null |
|
| 66 | + */ |
|
| 67 | + public function getBackend($backendId):IBackend { |
|
| 68 | + if (!isset($this->backends[$backendId])) { |
|
| 69 | + return null; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - return $this->backends[$backendId]; |
|
| 73 | - } |
|
| 72 | + return $this->backends[$backendId]; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * removes all registered backend instances |
|
| 77 | - * @return void |
|
| 78 | - * @since 14.0.0 |
|
| 79 | - */ |
|
| 80 | - public function clear() { |
|
| 81 | - $this->backends = []; |
|
| 82 | - } |
|
| 75 | + /** |
|
| 76 | + * removes all registered backend instances |
|
| 77 | + * @return void |
|
| 78 | + * @since 14.0.0 |
|
| 79 | + */ |
|
| 80 | + public function clear() { |
|
| 81 | + $this->backends = []; |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -27,57 +27,57 @@ |
||
| 27 | 27 | |
| 28 | 28 | class Manager implements \OCP\Calendar\Room\IManager { |
| 29 | 29 | |
| 30 | - /** @var IBackend[] holds all registered resource backends */ |
|
| 31 | - private $backends; |
|
| 30 | + /** @var IBackend[] holds all registered resource backends */ |
|
| 31 | + private $backends; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Registers a resource backend |
|
| 35 | - * |
|
| 36 | - * @param IBackend $backend |
|
| 37 | - * @return void |
|
| 38 | - * @since 14.0.0 |
|
| 39 | - */ |
|
| 40 | - public function registerBackend(IBackend $backend) { |
|
| 41 | - $this->backends[$backend->getBackendIdentifier()] = $backend; |
|
| 42 | - } |
|
| 33 | + /** |
|
| 34 | + * Registers a resource backend |
|
| 35 | + * |
|
| 36 | + * @param IBackend $backend |
|
| 37 | + * @return void |
|
| 38 | + * @since 14.0.0 |
|
| 39 | + */ |
|
| 40 | + public function registerBackend(IBackend $backend) { |
|
| 41 | + $this->backends[$backend->getBackendIdentifier()] = $backend; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Unregisters a resource backend |
|
| 46 | - * |
|
| 47 | - * @param IBackend $backend |
|
| 48 | - * @return void |
|
| 49 | - * @since 14.0.0 |
|
| 50 | - */ |
|
| 51 | - public function unregisterBackend(IBackend $backend) { |
|
| 52 | - unset($this->backends[$backend->getBackendIdentifier()]); |
|
| 53 | - } |
|
| 44 | + /** |
|
| 45 | + * Unregisters a resource backend |
|
| 46 | + * |
|
| 47 | + * @param IBackend $backend |
|
| 48 | + * @return void |
|
| 49 | + * @since 14.0.0 |
|
| 50 | + */ |
|
| 51 | + public function unregisterBackend(IBackend $backend) { |
|
| 52 | + unset($this->backends[$backend->getBackendIdentifier()]); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @return IBackend[] |
|
| 57 | - * @since 14.0.0 |
|
| 58 | - */ |
|
| 59 | - public function getBackends():array { |
|
| 60 | - return array_values($this->backends); |
|
| 61 | - } |
|
| 55 | + /** |
|
| 56 | + * @return IBackend[] |
|
| 57 | + * @since 14.0.0 |
|
| 58 | + */ |
|
| 59 | + public function getBackends():array { |
|
| 60 | + return array_values($this->backends); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @param string $backendId |
|
| 65 | - * @return IBackend|null |
|
| 66 | - */ |
|
| 67 | - public function getBackend($backendId):IBackend { |
|
| 68 | - if (!isset($this->backends[$backendId])) { |
|
| 69 | - return null; |
|
| 70 | - } |
|
| 63 | + /** |
|
| 64 | + * @param string $backendId |
|
| 65 | + * @return IBackend|null |
|
| 66 | + */ |
|
| 67 | + public function getBackend($backendId):IBackend { |
|
| 68 | + if (!isset($this->backends[$backendId])) { |
|
| 69 | + return null; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - return $this->backends[$backendId]; |
|
| 73 | - } |
|
| 72 | + return $this->backends[$backendId]; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * removes all registered backend instances |
|
| 77 | - * @return void |
|
| 78 | - * @since 14.0.0 |
|
| 79 | - */ |
|
| 80 | - public function clear() { |
|
| 81 | - $this->backends = []; |
|
| 82 | - } |
|
| 75 | + /** |
|
| 76 | + * removes all registered backend instances |
|
| 77 | + * @return void |
|
| 78 | + * @since 14.0.0 |
|
| 79 | + */ |
|
| 80 | + public function clear() { |
|
| 81 | + $this->backends = []; |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -65,237 +65,237 @@ |
||
| 65 | 65 | |
| 66 | 66 | class Server { |
| 67 | 67 | |
| 68 | - /** @var IRequest */ |
|
| 69 | - private $request; |
|
| 68 | + /** @var IRequest */ |
|
| 69 | + private $request; |
|
| 70 | 70 | |
| 71 | - /** @var string */ |
|
| 72 | - private $baseUri; |
|
| 71 | + /** @var string */ |
|
| 72 | + private $baseUri; |
|
| 73 | 73 | |
| 74 | - /** @var Connector\Sabre\Server */ |
|
| 75 | - public $server; |
|
| 74 | + /** @var Connector\Sabre\Server */ |
|
| 75 | + public $server; |
|
| 76 | 76 | |
| 77 | - public function __construct(IRequest $request, $baseUri) { |
|
| 78 | - $this->request = $request; |
|
| 79 | - $this->baseUri = $baseUri; |
|
| 80 | - $logger = \OC::$server->getLogger(); |
|
| 81 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
| 77 | + public function __construct(IRequest $request, $baseUri) { |
|
| 78 | + $this->request = $request; |
|
| 79 | + $this->baseUri = $baseUri; |
|
| 80 | + $logger = \OC::$server->getLogger(); |
|
| 81 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
| 82 | 82 | |
| 83 | - $root = new RootCollection(); |
|
| 84 | - $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); |
|
| 83 | + $root = new RootCollection(); |
|
| 84 | + $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); |
|
| 85 | 85 | |
| 86 | - // Add maintenance plugin |
|
| 87 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
| 86 | + // Add maintenance plugin |
|
| 87 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
| 88 | 88 | |
| 89 | - // Backends |
|
| 90 | - $authBackend = new Auth( |
|
| 91 | - \OC::$server->getSession(), |
|
| 92 | - \OC::$server->getUserSession(), |
|
| 93 | - \OC::$server->getRequest(), |
|
| 94 | - \OC::$server->getTwoFactorAuthManager(), |
|
| 95 | - \OC::$server->getBruteForceThrottler() |
|
| 96 | - ); |
|
| 89 | + // Backends |
|
| 90 | + $authBackend = new Auth( |
|
| 91 | + \OC::$server->getSession(), |
|
| 92 | + \OC::$server->getUserSession(), |
|
| 93 | + \OC::$server->getRequest(), |
|
| 94 | + \OC::$server->getTwoFactorAuthManager(), |
|
| 95 | + \OC::$server->getBruteForceThrottler() |
|
| 96 | + ); |
|
| 97 | 97 | |
| 98 | - // Set URL explicitly due to reverse-proxy situations |
|
| 99 | - $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
| 100 | - $this->server->setBaseUri($this->baseUri); |
|
| 98 | + // Set URL explicitly due to reverse-proxy situations |
|
| 99 | + $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
| 100 | + $this->server->setBaseUri($this->baseUri); |
|
| 101 | 101 | |
| 102 | - $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
| 103 | - $this->server->addPlugin(new AnonymousOptionsPlugin()); |
|
| 104 | - $authPlugin = new Plugin(); |
|
| 105 | - $authPlugin->addBackend(new PublicAuth()); |
|
| 106 | - $this->server->addPlugin($authPlugin); |
|
| 102 | + $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
| 103 | + $this->server->addPlugin(new AnonymousOptionsPlugin()); |
|
| 104 | + $authPlugin = new Plugin(); |
|
| 105 | + $authPlugin->addBackend(new PublicAuth()); |
|
| 106 | + $this->server->addPlugin($authPlugin); |
|
| 107 | 107 | |
| 108 | - // allow setup of additional auth backends |
|
| 109 | - $event = new SabrePluginEvent($this->server); |
|
| 110 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
| 108 | + // allow setup of additional auth backends |
|
| 109 | + $event = new SabrePluginEvent($this->server); |
|
| 110 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
| 111 | 111 | |
| 112 | - $bearerAuthBackend = new BearerAuth( |
|
| 113 | - \OC::$server->getUserSession(), |
|
| 114 | - \OC::$server->getSession(), |
|
| 115 | - \OC::$server->getRequest() |
|
| 116 | - ); |
|
| 117 | - $authPlugin->addBackend($bearerAuthBackend); |
|
| 118 | - // because we are throwing exceptions this plugin has to be the last one |
|
| 119 | - $authPlugin->addBackend($authBackend); |
|
| 112 | + $bearerAuthBackend = new BearerAuth( |
|
| 113 | + \OC::$server->getUserSession(), |
|
| 114 | + \OC::$server->getSession(), |
|
| 115 | + \OC::$server->getRequest() |
|
| 116 | + ); |
|
| 117 | + $authPlugin->addBackend($bearerAuthBackend); |
|
| 118 | + // because we are throwing exceptions this plugin has to be the last one |
|
| 119 | + $authPlugin->addBackend($authBackend); |
|
| 120 | 120 | |
| 121 | - // debugging |
|
| 122 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 123 | - $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
| 124 | - } else { |
|
| 125 | - $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
| 126 | - } |
|
| 121 | + // debugging |
|
| 122 | + if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 123 | + $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
| 124 | + } else { |
|
| 125 | + $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
| 129 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
| 130 | - $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
| 128 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
| 129 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
| 130 | + $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
| 131 | 131 | |
| 132 | - // acl |
|
| 133 | - $acl = new DavAclPlugin(); |
|
| 134 | - $acl->principalCollectionSet = [ |
|
| 135 | - 'principals/users', 'principals/groups', |
|
| 136 | - 'principals/calendar-resources', |
|
| 137 | - 'principals/calendar-rooms', |
|
| 138 | - ]; |
|
| 139 | - $acl->defaultUsernamePath = 'principals/users'; |
|
| 140 | - $this->server->addPlugin($acl); |
|
| 132 | + // acl |
|
| 133 | + $acl = new DavAclPlugin(); |
|
| 134 | + $acl->principalCollectionSet = [ |
|
| 135 | + 'principals/users', 'principals/groups', |
|
| 136 | + 'principals/calendar-resources', |
|
| 137 | + 'principals/calendar-rooms', |
|
| 138 | + ]; |
|
| 139 | + $acl->defaultUsernamePath = 'principals/users'; |
|
| 140 | + $this->server->addPlugin($acl); |
|
| 141 | 141 | |
| 142 | - // calendar plugins |
|
| 143 | - if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) { |
|
| 144 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
| 145 | - $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
| 146 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
| 147 | - if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') { |
|
| 148 | - $this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class)); |
|
| 149 | - } |
|
| 150 | - $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
| 151 | - $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
| 152 | - $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
| 153 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
| 154 | - \OC::$server->getConfig(), |
|
| 155 | - \OC::$server->getURLGenerator() |
|
| 156 | - )); |
|
| 157 | - } |
|
| 142 | + // calendar plugins |
|
| 143 | + if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) { |
|
| 144 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
| 145 | + $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
| 146 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
| 147 | + if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') { |
|
| 148 | + $this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class)); |
|
| 149 | + } |
|
| 150 | + $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
| 151 | + $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
| 152 | + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
| 153 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
| 154 | + \OC::$server->getConfig(), |
|
| 155 | + \OC::$server->getURLGenerator() |
|
| 156 | + )); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - // addressbook plugins |
|
| 160 | - if ($this->requestIsForSubtree(['addressbooks', 'principals'])) { |
|
| 161 | - $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
| 162 | - $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
| 163 | - $this->server->addPlugin(new VCFExportPlugin()); |
|
| 164 | - $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); |
|
| 165 | - } |
|
| 159 | + // addressbook plugins |
|
| 160 | + if ($this->requestIsForSubtree(['addressbooks', 'principals'])) { |
|
| 161 | + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
| 162 | + $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
| 163 | + $this->server->addPlugin(new VCFExportPlugin()); |
|
| 164 | + $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - // system tags plugins |
|
| 168 | - $this->server->addPlugin(new SystemTagPlugin( |
|
| 169 | - \OC::$server->getSystemTagManager(), |
|
| 170 | - \OC::$server->getGroupManager(), |
|
| 171 | - \OC::$server->getUserSession() |
|
| 172 | - )); |
|
| 167 | + // system tags plugins |
|
| 168 | + $this->server->addPlugin(new SystemTagPlugin( |
|
| 169 | + \OC::$server->getSystemTagManager(), |
|
| 170 | + \OC::$server->getGroupManager(), |
|
| 171 | + \OC::$server->getUserSession() |
|
| 172 | + )); |
|
| 173 | 173 | |
| 174 | - // comments plugin |
|
| 175 | - $this->server->addPlugin(new CommentsPlugin( |
|
| 176 | - \OC::$server->getCommentsManager(), |
|
| 177 | - \OC::$server->getUserSession() |
|
| 178 | - )); |
|
| 174 | + // comments plugin |
|
| 175 | + $this->server->addPlugin(new CommentsPlugin( |
|
| 176 | + \OC::$server->getCommentsManager(), |
|
| 177 | + \OC::$server->getUserSession() |
|
| 178 | + )); |
|
| 179 | 179 | |
| 180 | - $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
| 181 | - $this->server->addPlugin(new ChunkingPlugin()); |
|
| 180 | + $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
| 181 | + $this->server->addPlugin(new ChunkingPlugin()); |
|
| 182 | 182 | |
| 183 | - // allow setup of additional plugins |
|
| 184 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
| 183 | + // allow setup of additional plugins |
|
| 184 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
| 185 | 185 | |
| 186 | - // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
| 187 | - // we do not provide locking we emulate it using a fake locking plugin. |
|
| 188 | - if($request->isUserAgent([ |
|
| 189 | - '/WebDAVFS/', |
|
| 190 | - '/OneNote/', |
|
| 191 | - '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
| 192 | - ])) { |
|
| 193 | - $this->server->addPlugin(new FakeLockerPlugin()); |
|
| 194 | - } |
|
| 186 | + // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
| 187 | + // we do not provide locking we emulate it using a fake locking plugin. |
|
| 188 | + if($request->isUserAgent([ |
|
| 189 | + '/WebDAVFS/', |
|
| 190 | + '/OneNote/', |
|
| 191 | + '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
| 192 | + ])) { |
|
| 193 | + $this->server->addPlugin(new FakeLockerPlugin()); |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
| 197 | - $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
| 198 | - } |
|
| 196 | + if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
| 197 | + $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - // wait with registering these until auth is handled and the filesystem is setup |
|
| 201 | - $this->server->on('beforeMethod', function () use ($root) { |
|
| 202 | - // custom properties plugin must be the last one |
|
| 203 | - $userSession = \OC::$server->getUserSession(); |
|
| 204 | - $user = $userSession->getUser(); |
|
| 205 | - if ($user !== null) { |
|
| 206 | - $view = \OC\Files\Filesystem::getView(); |
|
| 207 | - $this->server->addPlugin( |
|
| 208 | - new FilesPlugin( |
|
| 209 | - $this->server->tree, |
|
| 210 | - \OC::$server->getConfig(), |
|
| 211 | - $this->request, |
|
| 212 | - \OC::$server->getPreviewManager(), |
|
| 213 | - false, |
|
| 214 | - !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
| 215 | - ) |
|
| 216 | - ); |
|
| 200 | + // wait with registering these until auth is handled and the filesystem is setup |
|
| 201 | + $this->server->on('beforeMethod', function () use ($root) { |
|
| 202 | + // custom properties plugin must be the last one |
|
| 203 | + $userSession = \OC::$server->getUserSession(); |
|
| 204 | + $user = $userSession->getUser(); |
|
| 205 | + if ($user !== null) { |
|
| 206 | + $view = \OC\Files\Filesystem::getView(); |
|
| 207 | + $this->server->addPlugin( |
|
| 208 | + new FilesPlugin( |
|
| 209 | + $this->server->tree, |
|
| 210 | + \OC::$server->getConfig(), |
|
| 211 | + $this->request, |
|
| 212 | + \OC::$server->getPreviewManager(), |
|
| 213 | + false, |
|
| 214 | + !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
| 215 | + ) |
|
| 216 | + ); |
|
| 217 | 217 | |
| 218 | - $this->server->addPlugin( |
|
| 219 | - new \Sabre\DAV\PropertyStorage\Plugin( |
|
| 220 | - new CustomPropertiesBackend( |
|
| 221 | - $this->server->tree, |
|
| 222 | - \OC::$server->getDatabaseConnection(), |
|
| 223 | - \OC::$server->getUserSession()->getUser() |
|
| 224 | - ) |
|
| 225 | - ) |
|
| 226 | - ); |
|
| 227 | - if ($view !== null) { |
|
| 228 | - $this->server->addPlugin( |
|
| 229 | - new QuotaPlugin($view, false)); |
|
| 230 | - } |
|
| 231 | - $this->server->addPlugin( |
|
| 232 | - new TagsPlugin( |
|
| 233 | - $this->server->tree, \OC::$server->getTagManager() |
|
| 234 | - ) |
|
| 235 | - ); |
|
| 236 | - // TODO: switch to LazyUserFolder |
|
| 237 | - $userFolder = \OC::$server->getUserFolder(); |
|
| 238 | - $this->server->addPlugin(new SharesPlugin( |
|
| 239 | - $this->server->tree, |
|
| 240 | - $userSession, |
|
| 241 | - $userFolder, |
|
| 242 | - \OC::$server->getShareManager() |
|
| 243 | - )); |
|
| 244 | - $this->server->addPlugin(new CommentPropertiesPlugin( |
|
| 245 | - \OC::$server->getCommentsManager(), |
|
| 246 | - $userSession |
|
| 247 | - )); |
|
| 248 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
| 249 | - if ($view !== null) { |
|
| 250 | - $this->server->addPlugin(new FilesReportPlugin( |
|
| 251 | - $this->server->tree, |
|
| 252 | - $view, |
|
| 253 | - \OC::$server->getSystemTagManager(), |
|
| 254 | - \OC::$server->getSystemTagObjectMapper(), |
|
| 255 | - \OC::$server->getTagManager(), |
|
| 256 | - $userSession, |
|
| 257 | - \OC::$server->getGroupManager(), |
|
| 258 | - $userFolder |
|
| 259 | - )); |
|
| 260 | - $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
| 261 | - $this->server->tree, |
|
| 262 | - $user, |
|
| 263 | - \OC::$server->getRootFolder(), |
|
| 264 | - \OC::$server->getShareManager(), |
|
| 265 | - $view |
|
| 266 | - ))); |
|
| 267 | - } |
|
| 268 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin( |
|
| 269 | - \OC::$server->getConfig(), |
|
| 270 | - \OC::$server->query(BirthdayService::class) |
|
| 271 | - )); |
|
| 272 | - } |
|
| 218 | + $this->server->addPlugin( |
|
| 219 | + new \Sabre\DAV\PropertyStorage\Plugin( |
|
| 220 | + new CustomPropertiesBackend( |
|
| 221 | + $this->server->tree, |
|
| 222 | + \OC::$server->getDatabaseConnection(), |
|
| 223 | + \OC::$server->getUserSession()->getUser() |
|
| 224 | + ) |
|
| 225 | + ) |
|
| 226 | + ); |
|
| 227 | + if ($view !== null) { |
|
| 228 | + $this->server->addPlugin( |
|
| 229 | + new QuotaPlugin($view, false)); |
|
| 230 | + } |
|
| 231 | + $this->server->addPlugin( |
|
| 232 | + new TagsPlugin( |
|
| 233 | + $this->server->tree, \OC::$server->getTagManager() |
|
| 234 | + ) |
|
| 235 | + ); |
|
| 236 | + // TODO: switch to LazyUserFolder |
|
| 237 | + $userFolder = \OC::$server->getUserFolder(); |
|
| 238 | + $this->server->addPlugin(new SharesPlugin( |
|
| 239 | + $this->server->tree, |
|
| 240 | + $userSession, |
|
| 241 | + $userFolder, |
|
| 242 | + \OC::$server->getShareManager() |
|
| 243 | + )); |
|
| 244 | + $this->server->addPlugin(new CommentPropertiesPlugin( |
|
| 245 | + \OC::$server->getCommentsManager(), |
|
| 246 | + $userSession |
|
| 247 | + )); |
|
| 248 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
| 249 | + if ($view !== null) { |
|
| 250 | + $this->server->addPlugin(new FilesReportPlugin( |
|
| 251 | + $this->server->tree, |
|
| 252 | + $view, |
|
| 253 | + \OC::$server->getSystemTagManager(), |
|
| 254 | + \OC::$server->getSystemTagObjectMapper(), |
|
| 255 | + \OC::$server->getTagManager(), |
|
| 256 | + $userSession, |
|
| 257 | + \OC::$server->getGroupManager(), |
|
| 258 | + $userFolder |
|
| 259 | + )); |
|
| 260 | + $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
| 261 | + $this->server->tree, |
|
| 262 | + $user, |
|
| 263 | + \OC::$server->getRootFolder(), |
|
| 264 | + \OC::$server->getShareManager(), |
|
| 265 | + $view |
|
| 266 | + ))); |
|
| 267 | + } |
|
| 268 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin( |
|
| 269 | + \OC::$server->getConfig(), |
|
| 270 | + \OC::$server->query(BirthdayService::class) |
|
| 271 | + )); |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - // register plugins from apps |
|
| 275 | - $pluginManager = new PluginManager( |
|
| 276 | - \OC::$server, |
|
| 277 | - \OC::$server->getAppManager() |
|
| 278 | - ); |
|
| 279 | - foreach ($pluginManager->getAppPlugins() as $appPlugin) { |
|
| 280 | - $this->server->addPlugin($appPlugin); |
|
| 281 | - } |
|
| 282 | - foreach ($pluginManager->getAppCollections() as $appCollection) { |
|
| 283 | - $root->addChild($appCollection); |
|
| 284 | - } |
|
| 285 | - }); |
|
| 286 | - } |
|
| 274 | + // register plugins from apps |
|
| 275 | + $pluginManager = new PluginManager( |
|
| 276 | + \OC::$server, |
|
| 277 | + \OC::$server->getAppManager() |
|
| 278 | + ); |
|
| 279 | + foreach ($pluginManager->getAppPlugins() as $appPlugin) { |
|
| 280 | + $this->server->addPlugin($appPlugin); |
|
| 281 | + } |
|
| 282 | + foreach ($pluginManager->getAppCollections() as $appCollection) { |
|
| 283 | + $root->addChild($appCollection); |
|
| 284 | + } |
|
| 285 | + }); |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - public function exec() { |
|
| 289 | - $this->server->exec(); |
|
| 290 | - } |
|
| 288 | + public function exec() { |
|
| 289 | + $this->server->exec(); |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - private function requestIsForSubtree(array $subTrees): bool { |
|
| 293 | - foreach ($subTrees as $subTree) { |
|
| 294 | - $subTree = trim($subTree, ' /'); |
|
| 295 | - if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) { |
|
| 296 | - return true; |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - return false; |
|
| 300 | - } |
|
| 292 | + private function requestIsForSubtree(array $subTrees): bool { |
|
| 293 | + foreach ($subTrees as $subTree) { |
|
| 294 | + $subTree = trim($subTree, ' /'); |
|
| 295 | + if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) { |
|
| 296 | + return true; |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + return false; |
|
| 300 | + } |
|
| 301 | 301 | } |
@@ -24,18 +24,18 @@ |
||
| 24 | 24 | |
| 25 | 25 | class CalendarRoot extends \Sabre\CalDAV\CalendarRoot { |
| 26 | 26 | |
| 27 | - function getChildForPrincipal(array $principal) { |
|
| 28 | - return new CalendarHome($this->caldavBackend, $principal); |
|
| 29 | - } |
|
| 27 | + function getChildForPrincipal(array $principal) { |
|
| 28 | + return new CalendarHome($this->caldavBackend, $principal); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - function getName() { |
|
| 32 | - if ($this->principalPrefix === 'principals/calendar-resources' || |
|
| 33 | - $this->principalPrefix === 'principals/calendar-rooms') { |
|
| 34 | - $parts = explode('/', $this->principalPrefix); |
|
| 31 | + function getName() { |
|
| 32 | + if ($this->principalPrefix === 'principals/calendar-resources' || |
|
| 33 | + $this->principalPrefix === 'principals/calendar-rooms') { |
|
| 34 | + $parts = explode('/', $this->principalPrefix); |
|
| 35 | 35 | |
| 36 | - return $parts[1]; |
|
| 37 | - } |
|
| 36 | + return $parts[1]; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - return parent::getName(); |
|
| 40 | - } |
|
| 39 | + return parent::getName(); |
|
| 40 | + } |
|
| 41 | 41 | } |
| 42 | 42 | \ No newline at end of file |
@@ -73,2305 +73,2305 @@ |
||
| 73 | 73 | */ |
| 74 | 74 | class CalDavBackend extends AbstractBackend implements SyncSupport, SubscriptionSupport, SchedulingSupport { |
| 75 | 75 | |
| 76 | - const PERSONAL_CALENDAR_URI = 'personal'; |
|
| 77 | - const PERSONAL_CALENDAR_NAME = 'Personal'; |
|
| 78 | - |
|
| 79 | - const RESOURCE_BOOKING_CALENDAR_URI = 'calendar'; |
|
| 80 | - const RESOURCE_BOOKING_CALENDAR_NAME = 'Calendar'; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * We need to specify a max date, because we need to stop *somewhere* |
|
| 84 | - * |
|
| 85 | - * On 32 bit system the maximum for a signed integer is 2147483647, so |
|
| 86 | - * MAX_DATE cannot be higher than date('Y-m-d', 2147483647) which results |
|
| 87 | - * in 2038-01-19 to avoid problems when the date is converted |
|
| 88 | - * to a unix timestamp. |
|
| 89 | - */ |
|
| 90 | - const MAX_DATE = '2038-01-01'; |
|
| 91 | - |
|
| 92 | - const ACCESS_PUBLIC = 4; |
|
| 93 | - const CLASSIFICATION_PUBLIC = 0; |
|
| 94 | - const CLASSIFICATION_PRIVATE = 1; |
|
| 95 | - const CLASSIFICATION_CONFIDENTIAL = 2; |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * List of CalDAV properties, and how they map to database field names |
|
| 99 | - * Add your own properties by simply adding on to this array. |
|
| 100 | - * |
|
| 101 | - * Note that only string-based properties are supported here. |
|
| 102 | - * |
|
| 103 | - * @var array |
|
| 104 | - */ |
|
| 105 | - public $propertyMap = [ |
|
| 106 | - '{DAV:}displayname' => 'displayname', |
|
| 107 | - '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'description', |
|
| 108 | - '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => 'timezone', |
|
| 109 | - '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', |
|
| 110 | - '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', |
|
| 111 | - ]; |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * List of subscription properties, and how they map to database field names. |
|
| 115 | - * |
|
| 116 | - * @var array |
|
| 117 | - */ |
|
| 118 | - public $subscriptionPropertyMap = [ |
|
| 119 | - '{DAV:}displayname' => 'displayname', |
|
| 120 | - '{http://apple.com/ns/ical/}refreshrate' => 'refreshrate', |
|
| 121 | - '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', |
|
| 122 | - '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', |
|
| 123 | - '{http://calendarserver.org/ns/}subscribed-strip-todos' => 'striptodos', |
|
| 124 | - '{http://calendarserver.org/ns/}subscribed-strip-alarms' => 'stripalarms', |
|
| 125 | - '{http://calendarserver.org/ns/}subscribed-strip-attachments' => 'stripattachments', |
|
| 126 | - ]; |
|
| 127 | - |
|
| 128 | - /** @var array properties to index */ |
|
| 129 | - public static $indexProperties = ['CATEGORIES', 'COMMENT', 'DESCRIPTION', |
|
| 130 | - 'LOCATION', 'RESOURCES', 'STATUS', 'SUMMARY', 'ATTENDEE', 'CONTACT', |
|
| 131 | - 'ORGANIZER']; |
|
| 132 | - |
|
| 133 | - /** @var array parameters to index */ |
|
| 134 | - public static $indexParameters = [ |
|
| 135 | - 'ATTENDEE' => ['CN'], |
|
| 136 | - 'ORGANIZER' => ['CN'], |
|
| 137 | - ]; |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @var string[] Map of uid => display name |
|
| 141 | - */ |
|
| 142 | - protected $userDisplayNames; |
|
| 143 | - |
|
| 144 | - /** @var IDBConnection */ |
|
| 145 | - private $db; |
|
| 146 | - |
|
| 147 | - /** @var Backend */ |
|
| 148 | - private $sharingBackend; |
|
| 149 | - |
|
| 150 | - /** @var Principal */ |
|
| 151 | - private $principalBackend; |
|
| 152 | - |
|
| 153 | - /** @var IUserManager */ |
|
| 154 | - private $userManager; |
|
| 155 | - |
|
| 156 | - /** @var ISecureRandom */ |
|
| 157 | - private $random; |
|
| 158 | - |
|
| 159 | - /** @var ILogger */ |
|
| 160 | - private $logger; |
|
| 161 | - |
|
| 162 | - /** @var EventDispatcherInterface */ |
|
| 163 | - private $dispatcher; |
|
| 164 | - |
|
| 165 | - /** @var bool */ |
|
| 166 | - private $legacyEndpoint; |
|
| 167 | - |
|
| 168 | - /** @var string */ |
|
| 169 | - private $dbObjectPropertiesTable = 'calendarobjects_props'; |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * CalDavBackend constructor. |
|
| 173 | - * |
|
| 174 | - * @param IDBConnection $db |
|
| 175 | - * @param Principal $principalBackend |
|
| 176 | - * @param IUserManager $userManager |
|
| 177 | - * @param IGroupManager $groupManager |
|
| 178 | - * @param ISecureRandom $random |
|
| 179 | - * @param ILogger $logger |
|
| 180 | - * @param EventDispatcherInterface $dispatcher |
|
| 181 | - * @param bool $legacyEndpoint |
|
| 182 | - */ |
|
| 183 | - public function __construct(IDBConnection $db, |
|
| 184 | - Principal $principalBackend, |
|
| 185 | - IUserManager $userManager, |
|
| 186 | - IGroupManager $groupManager, |
|
| 187 | - ISecureRandom $random, |
|
| 188 | - ILogger $logger, |
|
| 189 | - EventDispatcherInterface $dispatcher, |
|
| 190 | - $legacyEndpoint = false) { |
|
| 191 | - $this->db = $db; |
|
| 192 | - $this->principalBackend = $principalBackend; |
|
| 193 | - $this->userManager = $userManager; |
|
| 194 | - $this->sharingBackend = new Backend($this->db, $this->userManager, $groupManager, $principalBackend, 'calendar'); |
|
| 195 | - $this->random = $random; |
|
| 196 | - $this->logger = $logger; |
|
| 197 | - $this->dispatcher = $dispatcher; |
|
| 198 | - $this->legacyEndpoint = $legacyEndpoint; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Return the number of calendars for a principal |
|
| 203 | - * |
|
| 204 | - * By default this excludes the automatically generated birthday calendar |
|
| 205 | - * |
|
| 206 | - * @param $principalUri |
|
| 207 | - * @param bool $excludeBirthday |
|
| 208 | - * @return int |
|
| 209 | - */ |
|
| 210 | - public function getCalendarsForUserCount($principalUri, $excludeBirthday = true) { |
|
| 211 | - $principalUri = $this->convertPrincipal($principalUri, true); |
|
| 212 | - $query = $this->db->getQueryBuilder(); |
|
| 213 | - $query->select($query->createFunction('COUNT(*)')) |
|
| 214 | - ->from('calendars') |
|
| 215 | - ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); |
|
| 216 | - |
|
| 217 | - if ($excludeBirthday) { |
|
| 218 | - $query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI))); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - return (int)$query->execute()->fetchColumn(); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * Returns a list of calendars for a principal. |
|
| 226 | - * |
|
| 227 | - * Every project is an array with the following keys: |
|
| 228 | - * * id, a unique id that will be used by other functions to modify the |
|
| 229 | - * calendar. This can be the same as the uri or a database key. |
|
| 230 | - * * uri, which the basename of the uri with which the calendar is |
|
| 231 | - * accessed. |
|
| 232 | - * * principaluri. The owner of the calendar. Almost always the same as |
|
| 233 | - * principalUri passed to this method. |
|
| 234 | - * |
|
| 235 | - * Furthermore it can contain webdav properties in clark notation. A very |
|
| 236 | - * common one is '{DAV:}displayname'. |
|
| 237 | - * |
|
| 238 | - * Many clients also require: |
|
| 239 | - * {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set |
|
| 240 | - * For this property, you can just return an instance of |
|
| 241 | - * Sabre\CalDAV\Property\SupportedCalendarComponentSet. |
|
| 242 | - * |
|
| 243 | - * If you return {http://sabredav.org/ns}read-only and set the value to 1, |
|
| 244 | - * ACL will automatically be put in read-only mode. |
|
| 245 | - * |
|
| 246 | - * @param string $principalUri |
|
| 247 | - * @return array |
|
| 248 | - */ |
|
| 249 | - function getCalendarsForUser($principalUri) { |
|
| 250 | - $principalUriOriginal = $principalUri; |
|
| 251 | - $principalUri = $this->convertPrincipal($principalUri, true); |
|
| 252 | - $fields = array_values($this->propertyMap); |
|
| 253 | - $fields[] = 'id'; |
|
| 254 | - $fields[] = 'uri'; |
|
| 255 | - $fields[] = 'synctoken'; |
|
| 256 | - $fields[] = 'components'; |
|
| 257 | - $fields[] = 'principaluri'; |
|
| 258 | - $fields[] = 'transparent'; |
|
| 259 | - |
|
| 260 | - // Making fields a comma-delimited list |
|
| 261 | - $query = $this->db->getQueryBuilder(); |
|
| 262 | - $query->select($fields)->from('calendars') |
|
| 263 | - ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
|
| 264 | - ->orderBy('calendarorder', 'ASC'); |
|
| 265 | - $stmt = $query->execute(); |
|
| 266 | - |
|
| 267 | - $calendars = []; |
|
| 268 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 269 | - |
|
| 270 | - $components = []; |
|
| 271 | - if ($row['components']) { |
|
| 272 | - $components = explode(',',$row['components']); |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - $calendar = [ |
|
| 276 | - 'id' => $row['id'], |
|
| 277 | - 'uri' => $row['uri'], |
|
| 278 | - 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 279 | - '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 280 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 281 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 282 | - '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 283 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint), |
|
| 284 | - ]; |
|
| 285 | - |
|
| 286 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 287 | - $calendar[$xmlName] = $row[$dbName]; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - $this->addOwnerPrincipal($calendar); |
|
| 291 | - |
|
| 292 | - if (!isset($calendars[$calendar['id']])) { |
|
| 293 | - $calendars[$calendar['id']] = $calendar; |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - $stmt->closeCursor(); |
|
| 298 | - |
|
| 299 | - // query for shared calendars |
|
| 300 | - $principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true); |
|
| 301 | - $principals = array_map(function($principal) { |
|
| 302 | - return urldecode($principal); |
|
| 303 | - }, $principals); |
|
| 304 | - $principals[]= $principalUri; |
|
| 305 | - |
|
| 306 | - $fields = array_values($this->propertyMap); |
|
| 307 | - $fields[] = 'a.id'; |
|
| 308 | - $fields[] = 'a.uri'; |
|
| 309 | - $fields[] = 'a.synctoken'; |
|
| 310 | - $fields[] = 'a.components'; |
|
| 311 | - $fields[] = 'a.principaluri'; |
|
| 312 | - $fields[] = 'a.transparent'; |
|
| 313 | - $fields[] = 's.access'; |
|
| 314 | - $query = $this->db->getQueryBuilder(); |
|
| 315 | - $result = $query->select($fields) |
|
| 316 | - ->from('dav_shares', 's') |
|
| 317 | - ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id')) |
|
| 318 | - ->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri'))) |
|
| 319 | - ->andWhere($query->expr()->eq('s.type', $query->createParameter('type'))) |
|
| 320 | - ->setParameter('type', 'calendar') |
|
| 321 | - ->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY) |
|
| 322 | - ->execute(); |
|
| 323 | - |
|
| 324 | - $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'; |
|
| 325 | - while($row = $result->fetch()) { |
|
| 326 | - if ($row['principaluri'] === $principalUri) { |
|
| 327 | - continue; |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - $readOnly = (int) $row['access'] === Backend::ACCESS_READ; |
|
| 331 | - if (isset($calendars[$row['id']])) { |
|
| 332 | - if ($readOnly) { |
|
| 333 | - // New share can not have more permissions then the old one. |
|
| 334 | - continue; |
|
| 335 | - } |
|
| 336 | - if (isset($calendars[$row['id']][$readOnlyPropertyName]) && |
|
| 337 | - $calendars[$row['id']][$readOnlyPropertyName] === 0) { |
|
| 338 | - // Old share is already read-write, no more permissions can be gained |
|
| 339 | - continue; |
|
| 340 | - } |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - list(, $name) = Uri\split($row['principaluri']); |
|
| 344 | - $uri = $row['uri'] . '_shared_by_' . $name; |
|
| 345 | - $row['displayname'] = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')'; |
|
| 346 | - $components = []; |
|
| 347 | - if ($row['components']) { |
|
| 348 | - $components = explode(',',$row['components']); |
|
| 349 | - } |
|
| 350 | - $calendar = [ |
|
| 351 | - 'id' => $row['id'], |
|
| 352 | - 'uri' => $uri, |
|
| 353 | - 'principaluri' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint), |
|
| 354 | - '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 355 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 356 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 357 | - '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp('transparent'), |
|
| 358 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 359 | - $readOnlyPropertyName => $readOnly, |
|
| 360 | - ]; |
|
| 361 | - |
|
| 362 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 363 | - $calendar[$xmlName] = $row[$dbName]; |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - $this->addOwnerPrincipal($calendar); |
|
| 367 | - |
|
| 368 | - $calendars[$calendar['id']] = $calendar; |
|
| 369 | - } |
|
| 370 | - $result->closeCursor(); |
|
| 371 | - |
|
| 372 | - return array_values($calendars); |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - public function getUsersOwnCalendars($principalUri) { |
|
| 376 | - $principalUri = $this->convertPrincipal($principalUri, true); |
|
| 377 | - $fields = array_values($this->propertyMap); |
|
| 378 | - $fields[] = 'id'; |
|
| 379 | - $fields[] = 'uri'; |
|
| 380 | - $fields[] = 'synctoken'; |
|
| 381 | - $fields[] = 'components'; |
|
| 382 | - $fields[] = 'principaluri'; |
|
| 383 | - $fields[] = 'transparent'; |
|
| 384 | - // Making fields a comma-delimited list |
|
| 385 | - $query = $this->db->getQueryBuilder(); |
|
| 386 | - $query->select($fields)->from('calendars') |
|
| 387 | - ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
|
| 388 | - ->orderBy('calendarorder', 'ASC'); |
|
| 389 | - $stmt = $query->execute(); |
|
| 390 | - $calendars = []; |
|
| 391 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 392 | - $components = []; |
|
| 393 | - if ($row['components']) { |
|
| 394 | - $components = explode(',',$row['components']); |
|
| 395 | - } |
|
| 396 | - $calendar = [ |
|
| 397 | - 'id' => $row['id'], |
|
| 398 | - 'uri' => $row['uri'], |
|
| 399 | - 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 400 | - '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 401 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 402 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 403 | - '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 404 | - ]; |
|
| 405 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 406 | - $calendar[$xmlName] = $row[$dbName]; |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - $this->addOwnerPrincipal($calendar); |
|
| 410 | - |
|
| 411 | - if (!isset($calendars[$calendar['id']])) { |
|
| 412 | - $calendars[$calendar['id']] = $calendar; |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - $stmt->closeCursor(); |
|
| 416 | - return array_values($calendars); |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - |
|
| 420 | - private function getUserDisplayName($uid) { |
|
| 421 | - if (!isset($this->userDisplayNames[$uid])) { |
|
| 422 | - $user = $this->userManager->get($uid); |
|
| 423 | - |
|
| 424 | - if ($user instanceof IUser) { |
|
| 425 | - $this->userDisplayNames[$uid] = $user->getDisplayName(); |
|
| 426 | - } else { |
|
| 427 | - $this->userDisplayNames[$uid] = $uid; |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - return $this->userDisplayNames[$uid]; |
|
| 432 | - } |
|
| 76 | + const PERSONAL_CALENDAR_URI = 'personal'; |
|
| 77 | + const PERSONAL_CALENDAR_NAME = 'Personal'; |
|
| 78 | + |
|
| 79 | + const RESOURCE_BOOKING_CALENDAR_URI = 'calendar'; |
|
| 80 | + const RESOURCE_BOOKING_CALENDAR_NAME = 'Calendar'; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * We need to specify a max date, because we need to stop *somewhere* |
|
| 84 | + * |
|
| 85 | + * On 32 bit system the maximum for a signed integer is 2147483647, so |
|
| 86 | + * MAX_DATE cannot be higher than date('Y-m-d', 2147483647) which results |
|
| 87 | + * in 2038-01-19 to avoid problems when the date is converted |
|
| 88 | + * to a unix timestamp. |
|
| 89 | + */ |
|
| 90 | + const MAX_DATE = '2038-01-01'; |
|
| 91 | + |
|
| 92 | + const ACCESS_PUBLIC = 4; |
|
| 93 | + const CLASSIFICATION_PUBLIC = 0; |
|
| 94 | + const CLASSIFICATION_PRIVATE = 1; |
|
| 95 | + const CLASSIFICATION_CONFIDENTIAL = 2; |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * List of CalDAV properties, and how they map to database field names |
|
| 99 | + * Add your own properties by simply adding on to this array. |
|
| 100 | + * |
|
| 101 | + * Note that only string-based properties are supported here. |
|
| 102 | + * |
|
| 103 | + * @var array |
|
| 104 | + */ |
|
| 105 | + public $propertyMap = [ |
|
| 106 | + '{DAV:}displayname' => 'displayname', |
|
| 107 | + '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'description', |
|
| 108 | + '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => 'timezone', |
|
| 109 | + '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', |
|
| 110 | + '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', |
|
| 111 | + ]; |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * List of subscription properties, and how they map to database field names. |
|
| 115 | + * |
|
| 116 | + * @var array |
|
| 117 | + */ |
|
| 118 | + public $subscriptionPropertyMap = [ |
|
| 119 | + '{DAV:}displayname' => 'displayname', |
|
| 120 | + '{http://apple.com/ns/ical/}refreshrate' => 'refreshrate', |
|
| 121 | + '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', |
|
| 122 | + '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', |
|
| 123 | + '{http://calendarserver.org/ns/}subscribed-strip-todos' => 'striptodos', |
|
| 124 | + '{http://calendarserver.org/ns/}subscribed-strip-alarms' => 'stripalarms', |
|
| 125 | + '{http://calendarserver.org/ns/}subscribed-strip-attachments' => 'stripattachments', |
|
| 126 | + ]; |
|
| 127 | + |
|
| 128 | + /** @var array properties to index */ |
|
| 129 | + public static $indexProperties = ['CATEGORIES', 'COMMENT', 'DESCRIPTION', |
|
| 130 | + 'LOCATION', 'RESOURCES', 'STATUS', 'SUMMARY', 'ATTENDEE', 'CONTACT', |
|
| 131 | + 'ORGANIZER']; |
|
| 132 | + |
|
| 133 | + /** @var array parameters to index */ |
|
| 134 | + public static $indexParameters = [ |
|
| 135 | + 'ATTENDEE' => ['CN'], |
|
| 136 | + 'ORGANIZER' => ['CN'], |
|
| 137 | + ]; |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @var string[] Map of uid => display name |
|
| 141 | + */ |
|
| 142 | + protected $userDisplayNames; |
|
| 143 | + |
|
| 144 | + /** @var IDBConnection */ |
|
| 145 | + private $db; |
|
| 146 | + |
|
| 147 | + /** @var Backend */ |
|
| 148 | + private $sharingBackend; |
|
| 149 | + |
|
| 150 | + /** @var Principal */ |
|
| 151 | + private $principalBackend; |
|
| 152 | + |
|
| 153 | + /** @var IUserManager */ |
|
| 154 | + private $userManager; |
|
| 155 | + |
|
| 156 | + /** @var ISecureRandom */ |
|
| 157 | + private $random; |
|
| 158 | + |
|
| 159 | + /** @var ILogger */ |
|
| 160 | + private $logger; |
|
| 161 | + |
|
| 162 | + /** @var EventDispatcherInterface */ |
|
| 163 | + private $dispatcher; |
|
| 164 | + |
|
| 165 | + /** @var bool */ |
|
| 166 | + private $legacyEndpoint; |
|
| 167 | + |
|
| 168 | + /** @var string */ |
|
| 169 | + private $dbObjectPropertiesTable = 'calendarobjects_props'; |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * CalDavBackend constructor. |
|
| 173 | + * |
|
| 174 | + * @param IDBConnection $db |
|
| 175 | + * @param Principal $principalBackend |
|
| 176 | + * @param IUserManager $userManager |
|
| 177 | + * @param IGroupManager $groupManager |
|
| 178 | + * @param ISecureRandom $random |
|
| 179 | + * @param ILogger $logger |
|
| 180 | + * @param EventDispatcherInterface $dispatcher |
|
| 181 | + * @param bool $legacyEndpoint |
|
| 182 | + */ |
|
| 183 | + public function __construct(IDBConnection $db, |
|
| 184 | + Principal $principalBackend, |
|
| 185 | + IUserManager $userManager, |
|
| 186 | + IGroupManager $groupManager, |
|
| 187 | + ISecureRandom $random, |
|
| 188 | + ILogger $logger, |
|
| 189 | + EventDispatcherInterface $dispatcher, |
|
| 190 | + $legacyEndpoint = false) { |
|
| 191 | + $this->db = $db; |
|
| 192 | + $this->principalBackend = $principalBackend; |
|
| 193 | + $this->userManager = $userManager; |
|
| 194 | + $this->sharingBackend = new Backend($this->db, $this->userManager, $groupManager, $principalBackend, 'calendar'); |
|
| 195 | + $this->random = $random; |
|
| 196 | + $this->logger = $logger; |
|
| 197 | + $this->dispatcher = $dispatcher; |
|
| 198 | + $this->legacyEndpoint = $legacyEndpoint; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Return the number of calendars for a principal |
|
| 203 | + * |
|
| 204 | + * By default this excludes the automatically generated birthday calendar |
|
| 205 | + * |
|
| 206 | + * @param $principalUri |
|
| 207 | + * @param bool $excludeBirthday |
|
| 208 | + * @return int |
|
| 209 | + */ |
|
| 210 | + public function getCalendarsForUserCount($principalUri, $excludeBirthday = true) { |
|
| 211 | + $principalUri = $this->convertPrincipal($principalUri, true); |
|
| 212 | + $query = $this->db->getQueryBuilder(); |
|
| 213 | + $query->select($query->createFunction('COUNT(*)')) |
|
| 214 | + ->from('calendars') |
|
| 215 | + ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); |
|
| 216 | + |
|
| 217 | + if ($excludeBirthday) { |
|
| 218 | + $query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI))); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + return (int)$query->execute()->fetchColumn(); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * Returns a list of calendars for a principal. |
|
| 226 | + * |
|
| 227 | + * Every project is an array with the following keys: |
|
| 228 | + * * id, a unique id that will be used by other functions to modify the |
|
| 229 | + * calendar. This can be the same as the uri or a database key. |
|
| 230 | + * * uri, which the basename of the uri with which the calendar is |
|
| 231 | + * accessed. |
|
| 232 | + * * principaluri. The owner of the calendar. Almost always the same as |
|
| 233 | + * principalUri passed to this method. |
|
| 234 | + * |
|
| 235 | + * Furthermore it can contain webdav properties in clark notation. A very |
|
| 236 | + * common one is '{DAV:}displayname'. |
|
| 237 | + * |
|
| 238 | + * Many clients also require: |
|
| 239 | + * {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set |
|
| 240 | + * For this property, you can just return an instance of |
|
| 241 | + * Sabre\CalDAV\Property\SupportedCalendarComponentSet. |
|
| 242 | + * |
|
| 243 | + * If you return {http://sabredav.org/ns}read-only and set the value to 1, |
|
| 244 | + * ACL will automatically be put in read-only mode. |
|
| 245 | + * |
|
| 246 | + * @param string $principalUri |
|
| 247 | + * @return array |
|
| 248 | + */ |
|
| 249 | + function getCalendarsForUser($principalUri) { |
|
| 250 | + $principalUriOriginal = $principalUri; |
|
| 251 | + $principalUri = $this->convertPrincipal($principalUri, true); |
|
| 252 | + $fields = array_values($this->propertyMap); |
|
| 253 | + $fields[] = 'id'; |
|
| 254 | + $fields[] = 'uri'; |
|
| 255 | + $fields[] = 'synctoken'; |
|
| 256 | + $fields[] = 'components'; |
|
| 257 | + $fields[] = 'principaluri'; |
|
| 258 | + $fields[] = 'transparent'; |
|
| 259 | + |
|
| 260 | + // Making fields a comma-delimited list |
|
| 261 | + $query = $this->db->getQueryBuilder(); |
|
| 262 | + $query->select($fields)->from('calendars') |
|
| 263 | + ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
|
| 264 | + ->orderBy('calendarorder', 'ASC'); |
|
| 265 | + $stmt = $query->execute(); |
|
| 266 | + |
|
| 267 | + $calendars = []; |
|
| 268 | + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 269 | + |
|
| 270 | + $components = []; |
|
| 271 | + if ($row['components']) { |
|
| 272 | + $components = explode(',',$row['components']); |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + $calendar = [ |
|
| 276 | + 'id' => $row['id'], |
|
| 277 | + 'uri' => $row['uri'], |
|
| 278 | + 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 279 | + '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 280 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 281 | + '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 282 | + '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 283 | + '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint), |
|
| 284 | + ]; |
|
| 285 | + |
|
| 286 | + foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 287 | + $calendar[$xmlName] = $row[$dbName]; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + $this->addOwnerPrincipal($calendar); |
|
| 291 | + |
|
| 292 | + if (!isset($calendars[$calendar['id']])) { |
|
| 293 | + $calendars[$calendar['id']] = $calendar; |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + $stmt->closeCursor(); |
|
| 298 | + |
|
| 299 | + // query for shared calendars |
|
| 300 | + $principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true); |
|
| 301 | + $principals = array_map(function($principal) { |
|
| 302 | + return urldecode($principal); |
|
| 303 | + }, $principals); |
|
| 304 | + $principals[]= $principalUri; |
|
| 305 | + |
|
| 306 | + $fields = array_values($this->propertyMap); |
|
| 307 | + $fields[] = 'a.id'; |
|
| 308 | + $fields[] = 'a.uri'; |
|
| 309 | + $fields[] = 'a.synctoken'; |
|
| 310 | + $fields[] = 'a.components'; |
|
| 311 | + $fields[] = 'a.principaluri'; |
|
| 312 | + $fields[] = 'a.transparent'; |
|
| 313 | + $fields[] = 's.access'; |
|
| 314 | + $query = $this->db->getQueryBuilder(); |
|
| 315 | + $result = $query->select($fields) |
|
| 316 | + ->from('dav_shares', 's') |
|
| 317 | + ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id')) |
|
| 318 | + ->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri'))) |
|
| 319 | + ->andWhere($query->expr()->eq('s.type', $query->createParameter('type'))) |
|
| 320 | + ->setParameter('type', 'calendar') |
|
| 321 | + ->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY) |
|
| 322 | + ->execute(); |
|
| 323 | + |
|
| 324 | + $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'; |
|
| 325 | + while($row = $result->fetch()) { |
|
| 326 | + if ($row['principaluri'] === $principalUri) { |
|
| 327 | + continue; |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + $readOnly = (int) $row['access'] === Backend::ACCESS_READ; |
|
| 331 | + if (isset($calendars[$row['id']])) { |
|
| 332 | + if ($readOnly) { |
|
| 333 | + // New share can not have more permissions then the old one. |
|
| 334 | + continue; |
|
| 335 | + } |
|
| 336 | + if (isset($calendars[$row['id']][$readOnlyPropertyName]) && |
|
| 337 | + $calendars[$row['id']][$readOnlyPropertyName] === 0) { |
|
| 338 | + // Old share is already read-write, no more permissions can be gained |
|
| 339 | + continue; |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + list(, $name) = Uri\split($row['principaluri']); |
|
| 344 | + $uri = $row['uri'] . '_shared_by_' . $name; |
|
| 345 | + $row['displayname'] = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')'; |
|
| 346 | + $components = []; |
|
| 347 | + if ($row['components']) { |
|
| 348 | + $components = explode(',',$row['components']); |
|
| 349 | + } |
|
| 350 | + $calendar = [ |
|
| 351 | + 'id' => $row['id'], |
|
| 352 | + 'uri' => $uri, |
|
| 353 | + 'principaluri' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint), |
|
| 354 | + '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 355 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 356 | + '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 357 | + '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp('transparent'), |
|
| 358 | + '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 359 | + $readOnlyPropertyName => $readOnly, |
|
| 360 | + ]; |
|
| 361 | + |
|
| 362 | + foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 363 | + $calendar[$xmlName] = $row[$dbName]; |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + $this->addOwnerPrincipal($calendar); |
|
| 367 | + |
|
| 368 | + $calendars[$calendar['id']] = $calendar; |
|
| 369 | + } |
|
| 370 | + $result->closeCursor(); |
|
| 371 | + |
|
| 372 | + return array_values($calendars); |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + public function getUsersOwnCalendars($principalUri) { |
|
| 376 | + $principalUri = $this->convertPrincipal($principalUri, true); |
|
| 377 | + $fields = array_values($this->propertyMap); |
|
| 378 | + $fields[] = 'id'; |
|
| 379 | + $fields[] = 'uri'; |
|
| 380 | + $fields[] = 'synctoken'; |
|
| 381 | + $fields[] = 'components'; |
|
| 382 | + $fields[] = 'principaluri'; |
|
| 383 | + $fields[] = 'transparent'; |
|
| 384 | + // Making fields a comma-delimited list |
|
| 385 | + $query = $this->db->getQueryBuilder(); |
|
| 386 | + $query->select($fields)->from('calendars') |
|
| 387 | + ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
|
| 388 | + ->orderBy('calendarorder', 'ASC'); |
|
| 389 | + $stmt = $query->execute(); |
|
| 390 | + $calendars = []; |
|
| 391 | + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 392 | + $components = []; |
|
| 393 | + if ($row['components']) { |
|
| 394 | + $components = explode(',',$row['components']); |
|
| 395 | + } |
|
| 396 | + $calendar = [ |
|
| 397 | + 'id' => $row['id'], |
|
| 398 | + 'uri' => $row['uri'], |
|
| 399 | + 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 400 | + '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 401 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 402 | + '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 403 | + '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 404 | + ]; |
|
| 405 | + foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 406 | + $calendar[$xmlName] = $row[$dbName]; |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + $this->addOwnerPrincipal($calendar); |
|
| 410 | + |
|
| 411 | + if (!isset($calendars[$calendar['id']])) { |
|
| 412 | + $calendars[$calendar['id']] = $calendar; |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + $stmt->closeCursor(); |
|
| 416 | + return array_values($calendars); |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + |
|
| 420 | + private function getUserDisplayName($uid) { |
|
| 421 | + if (!isset($this->userDisplayNames[$uid])) { |
|
| 422 | + $user = $this->userManager->get($uid); |
|
| 423 | + |
|
| 424 | + if ($user instanceof IUser) { |
|
| 425 | + $this->userDisplayNames[$uid] = $user->getDisplayName(); |
|
| 426 | + } else { |
|
| 427 | + $this->userDisplayNames[$uid] = $uid; |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + return $this->userDisplayNames[$uid]; |
|
| 432 | + } |
|
| 433 | 433 | |
| 434 | - /** |
|
| 435 | - * @return array |
|
| 436 | - */ |
|
| 437 | - public function getPublicCalendars() { |
|
| 438 | - $fields = array_values($this->propertyMap); |
|
| 439 | - $fields[] = 'a.id'; |
|
| 440 | - $fields[] = 'a.uri'; |
|
| 441 | - $fields[] = 'a.synctoken'; |
|
| 442 | - $fields[] = 'a.components'; |
|
| 443 | - $fields[] = 'a.principaluri'; |
|
| 444 | - $fields[] = 'a.transparent'; |
|
| 445 | - $fields[] = 's.access'; |
|
| 446 | - $fields[] = 's.publicuri'; |
|
| 447 | - $calendars = []; |
|
| 448 | - $query = $this->db->getQueryBuilder(); |
|
| 449 | - $result = $query->select($fields) |
|
| 450 | - ->from('dav_shares', 's') |
|
| 451 | - ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id')) |
|
| 452 | - ->where($query->expr()->in('s.access', $query->createNamedParameter(self::ACCESS_PUBLIC))) |
|
| 453 | - ->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar'))) |
|
| 454 | - ->execute(); |
|
| 455 | - |
|
| 456 | - while($row = $result->fetch()) { |
|
| 457 | - list(, $name) = Uri\split($row['principaluri']); |
|
| 458 | - $row['displayname'] = $row['displayname'] . "($name)"; |
|
| 459 | - $components = []; |
|
| 460 | - if ($row['components']) { |
|
| 461 | - $components = explode(',',$row['components']); |
|
| 462 | - } |
|
| 463 | - $calendar = [ |
|
| 464 | - 'id' => $row['id'], |
|
| 465 | - 'uri' => $row['publicuri'], |
|
| 466 | - 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 467 | - '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 468 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 469 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 470 | - '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 471 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint), |
|
| 472 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ, |
|
| 473 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC, |
|
| 474 | - ]; |
|
| 475 | - |
|
| 476 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 477 | - $calendar[$xmlName] = $row[$dbName]; |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - $this->addOwnerPrincipal($calendar); |
|
| 481 | - |
|
| 482 | - if (!isset($calendars[$calendar['id']])) { |
|
| 483 | - $calendars[$calendar['id']] = $calendar; |
|
| 484 | - } |
|
| 485 | - } |
|
| 486 | - $result->closeCursor(); |
|
| 487 | - |
|
| 488 | - return array_values($calendars); |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - /** |
|
| 492 | - * @param string $uri |
|
| 493 | - * @return array |
|
| 494 | - * @throws NotFound |
|
| 495 | - */ |
|
| 496 | - public function getPublicCalendar($uri) { |
|
| 497 | - $fields = array_values($this->propertyMap); |
|
| 498 | - $fields[] = 'a.id'; |
|
| 499 | - $fields[] = 'a.uri'; |
|
| 500 | - $fields[] = 'a.synctoken'; |
|
| 501 | - $fields[] = 'a.components'; |
|
| 502 | - $fields[] = 'a.principaluri'; |
|
| 503 | - $fields[] = 'a.transparent'; |
|
| 504 | - $fields[] = 's.access'; |
|
| 505 | - $fields[] = 's.publicuri'; |
|
| 506 | - $query = $this->db->getQueryBuilder(); |
|
| 507 | - $result = $query->select($fields) |
|
| 508 | - ->from('dav_shares', 's') |
|
| 509 | - ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id')) |
|
| 510 | - ->where($query->expr()->in('s.access', $query->createNamedParameter(self::ACCESS_PUBLIC))) |
|
| 511 | - ->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar'))) |
|
| 512 | - ->andWhere($query->expr()->eq('s.publicuri', $query->createNamedParameter($uri))) |
|
| 513 | - ->execute(); |
|
| 514 | - |
|
| 515 | - $row = $result->fetch(\PDO::FETCH_ASSOC); |
|
| 516 | - |
|
| 517 | - $result->closeCursor(); |
|
| 518 | - |
|
| 519 | - if ($row === false) { |
|
| 520 | - throw new NotFound('Node with name \'' . $uri . '\' could not be found'); |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - list(, $name) = Uri\split($row['principaluri']); |
|
| 524 | - $row['displayname'] = $row['displayname'] . ' ' . "($name)"; |
|
| 525 | - $components = []; |
|
| 526 | - if ($row['components']) { |
|
| 527 | - $components = explode(',',$row['components']); |
|
| 528 | - } |
|
| 529 | - $calendar = [ |
|
| 530 | - 'id' => $row['id'], |
|
| 531 | - 'uri' => $row['publicuri'], |
|
| 532 | - 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 533 | - '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 534 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 535 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 536 | - '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 537 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 538 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ, |
|
| 539 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC, |
|
| 540 | - ]; |
|
| 541 | - |
|
| 542 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 543 | - $calendar[$xmlName] = $row[$dbName]; |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - $this->addOwnerPrincipal($calendar); |
|
| 547 | - |
|
| 548 | - return $calendar; |
|
| 549 | - |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - /** |
|
| 553 | - * @param string $principal |
|
| 554 | - * @param string $uri |
|
| 555 | - * @return array|null |
|
| 556 | - */ |
|
| 557 | - public function getCalendarByUri($principal, $uri) { |
|
| 558 | - $fields = array_values($this->propertyMap); |
|
| 559 | - $fields[] = 'id'; |
|
| 560 | - $fields[] = 'uri'; |
|
| 561 | - $fields[] = 'synctoken'; |
|
| 562 | - $fields[] = 'components'; |
|
| 563 | - $fields[] = 'principaluri'; |
|
| 564 | - $fields[] = 'transparent'; |
|
| 565 | - |
|
| 566 | - // Making fields a comma-delimited list |
|
| 567 | - $query = $this->db->getQueryBuilder(); |
|
| 568 | - $query->select($fields)->from('calendars') |
|
| 569 | - ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) |
|
| 570 | - ->andWhere($query->expr()->eq('principaluri', $query->createNamedParameter($principal))) |
|
| 571 | - ->setMaxResults(1); |
|
| 572 | - $stmt = $query->execute(); |
|
| 573 | - |
|
| 574 | - $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
|
| 575 | - $stmt->closeCursor(); |
|
| 576 | - if ($row === false) { |
|
| 577 | - return null; |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - $components = []; |
|
| 581 | - if ($row['components']) { |
|
| 582 | - $components = explode(',',$row['components']); |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - $calendar = [ |
|
| 586 | - 'id' => $row['id'], |
|
| 587 | - 'uri' => $row['uri'], |
|
| 588 | - 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 589 | - '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 590 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 591 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 592 | - '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 593 | - ]; |
|
| 594 | - |
|
| 595 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 596 | - $calendar[$xmlName] = $row[$dbName]; |
|
| 597 | - } |
|
| 598 | - |
|
| 599 | - $this->addOwnerPrincipal($calendar); |
|
| 600 | - |
|
| 601 | - return $calendar; |
|
| 602 | - } |
|
| 603 | - |
|
| 604 | - public function getCalendarById($calendarId) { |
|
| 605 | - $fields = array_values($this->propertyMap); |
|
| 606 | - $fields[] = 'id'; |
|
| 607 | - $fields[] = 'uri'; |
|
| 608 | - $fields[] = 'synctoken'; |
|
| 609 | - $fields[] = 'components'; |
|
| 610 | - $fields[] = 'principaluri'; |
|
| 611 | - $fields[] = 'transparent'; |
|
| 612 | - |
|
| 613 | - // Making fields a comma-delimited list |
|
| 614 | - $query = $this->db->getQueryBuilder(); |
|
| 615 | - $query->select($fields)->from('calendars') |
|
| 616 | - ->where($query->expr()->eq('id', $query->createNamedParameter($calendarId))) |
|
| 617 | - ->setMaxResults(1); |
|
| 618 | - $stmt = $query->execute(); |
|
| 619 | - |
|
| 620 | - $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
|
| 621 | - $stmt->closeCursor(); |
|
| 622 | - if ($row === false) { |
|
| 623 | - return null; |
|
| 624 | - } |
|
| 625 | - |
|
| 626 | - $components = []; |
|
| 627 | - if ($row['components']) { |
|
| 628 | - $components = explode(',',$row['components']); |
|
| 629 | - } |
|
| 630 | - |
|
| 631 | - $calendar = [ |
|
| 632 | - 'id' => $row['id'], |
|
| 633 | - 'uri' => $row['uri'], |
|
| 634 | - 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 635 | - '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 636 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 637 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 638 | - '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 639 | - ]; |
|
| 640 | - |
|
| 641 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 642 | - $calendar[$xmlName] = $row[$dbName]; |
|
| 643 | - } |
|
| 644 | - |
|
| 645 | - $this->addOwnerPrincipal($calendar); |
|
| 646 | - |
|
| 647 | - return $calendar; |
|
| 648 | - } |
|
| 649 | - |
|
| 650 | - /** |
|
| 651 | - * Creates a new calendar for a principal. |
|
| 652 | - * |
|
| 653 | - * If the creation was a success, an id must be returned that can be used to reference |
|
| 654 | - * this calendar in other methods, such as updateCalendar. |
|
| 655 | - * |
|
| 656 | - * @param string $principalUri |
|
| 657 | - * @param string $calendarUri |
|
| 658 | - * @param array $properties |
|
| 659 | - * @return int |
|
| 660 | - * @suppress SqlInjectionChecker |
|
| 661 | - */ |
|
| 662 | - function createCalendar($principalUri, $calendarUri, array $properties) { |
|
| 663 | - $values = [ |
|
| 664 | - 'principaluri' => $this->convertPrincipal($principalUri, true), |
|
| 665 | - 'uri' => $calendarUri, |
|
| 666 | - 'synctoken' => 1, |
|
| 667 | - 'transparent' => 0, |
|
| 668 | - 'components' => 'VEVENT,VTODO', |
|
| 669 | - 'displayname' => $calendarUri |
|
| 670 | - ]; |
|
| 671 | - |
|
| 672 | - // Default value |
|
| 673 | - $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; |
|
| 674 | - if (isset($properties[$sccs])) { |
|
| 675 | - if (!($properties[$sccs] instanceof SupportedCalendarComponentSet)) { |
|
| 676 | - throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet'); |
|
| 677 | - } |
|
| 678 | - $values['components'] = implode(',',$properties[$sccs]->getValue()); |
|
| 679 | - } |
|
| 680 | - $transp = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp'; |
|
| 681 | - if (isset($properties[$transp])) { |
|
| 682 | - $values['transparent'] = (int) ($properties[$transp]->getValue() === 'transparent'); |
|
| 683 | - } |
|
| 684 | - |
|
| 685 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 686 | - if (isset($properties[$xmlName])) { |
|
| 687 | - $values[$dbName] = $properties[$xmlName]; |
|
| 688 | - } |
|
| 689 | - } |
|
| 690 | - |
|
| 691 | - $query = $this->db->getQueryBuilder(); |
|
| 692 | - $query->insert('calendars'); |
|
| 693 | - foreach($values as $column => $value) { |
|
| 694 | - $query->setValue($column, $query->createNamedParameter($value)); |
|
| 695 | - } |
|
| 696 | - $query->execute(); |
|
| 697 | - $calendarId = $query->getLastInsertId(); |
|
| 698 | - |
|
| 699 | - $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', new GenericEvent( |
|
| 700 | - '\OCA\DAV\CalDAV\CalDavBackend::createCalendar', |
|
| 701 | - [ |
|
| 702 | - 'calendarId' => $calendarId, |
|
| 703 | - 'calendarData' => $this->getCalendarById($calendarId), |
|
| 704 | - ])); |
|
| 705 | - |
|
| 706 | - return $calendarId; |
|
| 707 | - } |
|
| 708 | - |
|
| 709 | - /** |
|
| 710 | - * Updates properties for a calendar. |
|
| 711 | - * |
|
| 712 | - * The list of mutations is stored in a Sabre\DAV\PropPatch object. |
|
| 713 | - * To do the actual updates, you must tell this object which properties |
|
| 714 | - * you're going to process with the handle() method. |
|
| 715 | - * |
|
| 716 | - * Calling the handle method is like telling the PropPatch object "I |
|
| 717 | - * promise I can handle updating this property". |
|
| 718 | - * |
|
| 719 | - * Read the PropPatch documentation for more info and examples. |
|
| 720 | - * |
|
| 721 | - * @param mixed $calendarId |
|
| 722 | - * @param PropPatch $propPatch |
|
| 723 | - * @return void |
|
| 724 | - */ |
|
| 725 | - function updateCalendar($calendarId, PropPatch $propPatch) { |
|
| 726 | - $supportedProperties = array_keys($this->propertyMap); |
|
| 727 | - $supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp'; |
|
| 728 | - |
|
| 729 | - /** |
|
| 730 | - * @suppress SqlInjectionChecker |
|
| 731 | - */ |
|
| 732 | - $propPatch->handle($supportedProperties, function($mutations) use ($calendarId) { |
|
| 733 | - $newValues = []; |
|
| 734 | - foreach ($mutations as $propertyName => $propertyValue) { |
|
| 735 | - |
|
| 736 | - switch ($propertyName) { |
|
| 737 | - case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' : |
|
| 738 | - $fieldName = 'transparent'; |
|
| 739 | - $newValues[$fieldName] = (int) ($propertyValue->getValue() === 'transparent'); |
|
| 740 | - break; |
|
| 741 | - default : |
|
| 742 | - $fieldName = $this->propertyMap[$propertyName]; |
|
| 743 | - $newValues[$fieldName] = $propertyValue; |
|
| 744 | - break; |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - } |
|
| 748 | - $query = $this->db->getQueryBuilder(); |
|
| 749 | - $query->update('calendars'); |
|
| 750 | - foreach ($newValues as $fieldName => $value) { |
|
| 751 | - $query->set($fieldName, $query->createNamedParameter($value)); |
|
| 752 | - } |
|
| 753 | - $query->where($query->expr()->eq('id', $query->createNamedParameter($calendarId))); |
|
| 754 | - $query->execute(); |
|
| 755 | - |
|
| 756 | - $this->addChange($calendarId, "", 2); |
|
| 757 | - |
|
| 758 | - $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', new GenericEvent( |
|
| 759 | - '\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', |
|
| 760 | - [ |
|
| 761 | - 'calendarId' => $calendarId, |
|
| 762 | - 'calendarData' => $this->getCalendarById($calendarId), |
|
| 763 | - 'shares' => $this->getShares($calendarId), |
|
| 764 | - 'propertyMutations' => $mutations, |
|
| 765 | - ])); |
|
| 766 | - |
|
| 767 | - return true; |
|
| 768 | - }); |
|
| 769 | - } |
|
| 770 | - |
|
| 771 | - /** |
|
| 772 | - * Delete a calendar and all it's objects |
|
| 773 | - * |
|
| 774 | - * @param mixed $calendarId |
|
| 775 | - * @return void |
|
| 776 | - */ |
|
| 777 | - function deleteCalendar($calendarId) { |
|
| 778 | - $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', new GenericEvent( |
|
| 779 | - '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', |
|
| 780 | - [ |
|
| 781 | - 'calendarId' => $calendarId, |
|
| 782 | - 'calendarData' => $this->getCalendarById($calendarId), |
|
| 783 | - 'shares' => $this->getShares($calendarId), |
|
| 784 | - ])); |
|
| 785 | - |
|
| 786 | - $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ?'); |
|
| 787 | - $stmt->execute([$calendarId]); |
|
| 788 | - |
|
| 789 | - $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendars` WHERE `id` = ?'); |
|
| 790 | - $stmt->execute([$calendarId]); |
|
| 791 | - |
|
| 792 | - $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarchanges` WHERE `calendarid` = ?'); |
|
| 793 | - $stmt->execute([$calendarId]); |
|
| 794 | - |
|
| 795 | - $this->sharingBackend->deleteAllShares($calendarId); |
|
| 796 | - |
|
| 797 | - $query = $this->db->getQueryBuilder(); |
|
| 798 | - $query->delete($this->dbObjectPropertiesTable) |
|
| 799 | - ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))) |
|
| 800 | - ->execute(); |
|
| 801 | - } |
|
| 802 | - |
|
| 803 | - /** |
|
| 804 | - * Delete all of an user's shares |
|
| 805 | - * |
|
| 806 | - * @param string $principaluri |
|
| 807 | - * @return void |
|
| 808 | - */ |
|
| 809 | - function deleteAllSharesByUser($principaluri) { |
|
| 810 | - $this->sharingBackend->deleteAllSharesByUser($principaluri); |
|
| 811 | - } |
|
| 812 | - |
|
| 813 | - /** |
|
| 814 | - * Returns all calendar objects within a calendar. |
|
| 815 | - * |
|
| 816 | - * Every item contains an array with the following keys: |
|
| 817 | - * * calendardata - The iCalendar-compatible calendar data |
|
| 818 | - * * uri - a unique key which will be used to construct the uri. This can |
|
| 819 | - * be any arbitrary string, but making sure it ends with '.ics' is a |
|
| 820 | - * good idea. This is only the basename, or filename, not the full |
|
| 821 | - * path. |
|
| 822 | - * * lastmodified - a timestamp of the last modification time |
|
| 823 | - * * etag - An arbitrary string, surrounded by double-quotes. (e.g.: |
|
| 824 | - * '"abcdef"') |
|
| 825 | - * * size - The size of the calendar objects, in bytes. |
|
| 826 | - * * component - optional, a string containing the type of object, such |
|
| 827 | - * as 'vevent' or 'vtodo'. If specified, this will be used to populate |
|
| 828 | - * the Content-Type header. |
|
| 829 | - * |
|
| 830 | - * Note that the etag is optional, but it's highly encouraged to return for |
|
| 831 | - * speed reasons. |
|
| 832 | - * |
|
| 833 | - * The calendardata is also optional. If it's not returned |
|
| 834 | - * 'getCalendarObject' will be called later, which *is* expected to return |
|
| 835 | - * calendardata. |
|
| 836 | - * |
|
| 837 | - * If neither etag or size are specified, the calendardata will be |
|
| 838 | - * used/fetched to determine these numbers. If both are specified the |
|
| 839 | - * amount of times this is needed is reduced by a great degree. |
|
| 840 | - * |
|
| 841 | - * @param mixed $calendarId |
|
| 842 | - * @return array |
|
| 843 | - */ |
|
| 844 | - function getCalendarObjects($calendarId) { |
|
| 845 | - $query = $this->db->getQueryBuilder(); |
|
| 846 | - $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'componenttype', 'classification']) |
|
| 847 | - ->from('calendarobjects') |
|
| 848 | - ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))); |
|
| 849 | - $stmt = $query->execute(); |
|
| 850 | - |
|
| 851 | - $result = []; |
|
| 852 | - foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { |
|
| 853 | - $result[] = [ |
|
| 854 | - 'id' => $row['id'], |
|
| 855 | - 'uri' => $row['uri'], |
|
| 856 | - 'lastmodified' => $row['lastmodified'], |
|
| 857 | - 'etag' => '"' . $row['etag'] . '"', |
|
| 858 | - 'calendarid' => $row['calendarid'], |
|
| 859 | - 'size' => (int)$row['size'], |
|
| 860 | - 'component' => strtolower($row['componenttype']), |
|
| 861 | - 'classification'=> (int)$row['classification'] |
|
| 862 | - ]; |
|
| 863 | - } |
|
| 864 | - |
|
| 865 | - return $result; |
|
| 866 | - } |
|
| 867 | - |
|
| 868 | - /** |
|
| 869 | - * Returns information from a single calendar object, based on it's object |
|
| 870 | - * uri. |
|
| 871 | - * |
|
| 872 | - * The object uri is only the basename, or filename and not a full path. |
|
| 873 | - * |
|
| 874 | - * The returned array must have the same keys as getCalendarObjects. The |
|
| 875 | - * 'calendardata' object is required here though, while it's not required |
|
| 876 | - * for getCalendarObjects. |
|
| 877 | - * |
|
| 878 | - * This method must return null if the object did not exist. |
|
| 879 | - * |
|
| 880 | - * @param mixed $calendarId |
|
| 881 | - * @param string $objectUri |
|
| 882 | - * @return array|null |
|
| 883 | - */ |
|
| 884 | - function getCalendarObject($calendarId, $objectUri) { |
|
| 885 | - |
|
| 886 | - $query = $this->db->getQueryBuilder(); |
|
| 887 | - $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification']) |
|
| 888 | - ->from('calendarobjects') |
|
| 889 | - ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))) |
|
| 890 | - ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri))); |
|
| 891 | - $stmt = $query->execute(); |
|
| 892 | - $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
|
| 893 | - |
|
| 894 | - if(!$row) return null; |
|
| 895 | - |
|
| 896 | - return [ |
|
| 897 | - 'id' => $row['id'], |
|
| 898 | - 'uri' => $row['uri'], |
|
| 899 | - 'lastmodified' => $row['lastmodified'], |
|
| 900 | - 'etag' => '"' . $row['etag'] . '"', |
|
| 901 | - 'calendarid' => $row['calendarid'], |
|
| 902 | - 'size' => (int)$row['size'], |
|
| 903 | - 'calendardata' => $this->readBlob($row['calendardata']), |
|
| 904 | - 'component' => strtolower($row['componenttype']), |
|
| 905 | - 'classification'=> (int)$row['classification'] |
|
| 906 | - ]; |
|
| 907 | - } |
|
| 908 | - |
|
| 909 | - /** |
|
| 910 | - * Returns a list of calendar objects. |
|
| 911 | - * |
|
| 912 | - * This method should work identical to getCalendarObject, but instead |
|
| 913 | - * return all the calendar objects in the list as an array. |
|
| 914 | - * |
|
| 915 | - * If the backend supports this, it may allow for some speed-ups. |
|
| 916 | - * |
|
| 917 | - * @param mixed $calendarId |
|
| 918 | - * @param string[] $uris |
|
| 919 | - * @return array |
|
| 920 | - */ |
|
| 921 | - function getMultipleCalendarObjects($calendarId, array $uris) { |
|
| 922 | - if (empty($uris)) { |
|
| 923 | - return []; |
|
| 924 | - } |
|
| 925 | - |
|
| 926 | - $chunks = array_chunk($uris, 100); |
|
| 927 | - $objects = []; |
|
| 928 | - |
|
| 929 | - $query = $this->db->getQueryBuilder(); |
|
| 930 | - $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification']) |
|
| 931 | - ->from('calendarobjects') |
|
| 932 | - ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))) |
|
| 933 | - ->andWhere($query->expr()->in('uri', $query->createParameter('uri'))); |
|
| 934 | - |
|
| 935 | - foreach ($chunks as $uris) { |
|
| 936 | - $query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY); |
|
| 937 | - $result = $query->execute(); |
|
| 938 | - |
|
| 939 | - while ($row = $result->fetch()) { |
|
| 940 | - $objects[] = [ |
|
| 941 | - 'id' => $row['id'], |
|
| 942 | - 'uri' => $row['uri'], |
|
| 943 | - 'lastmodified' => $row['lastmodified'], |
|
| 944 | - 'etag' => '"' . $row['etag'] . '"', |
|
| 945 | - 'calendarid' => $row['calendarid'], |
|
| 946 | - 'size' => (int)$row['size'], |
|
| 947 | - 'calendardata' => $this->readBlob($row['calendardata']), |
|
| 948 | - 'component' => strtolower($row['componenttype']), |
|
| 949 | - 'classification' => (int)$row['classification'] |
|
| 950 | - ]; |
|
| 951 | - } |
|
| 952 | - $result->closeCursor(); |
|
| 953 | - } |
|
| 954 | - return $objects; |
|
| 955 | - } |
|
| 956 | - |
|
| 957 | - /** |
|
| 958 | - * Creates a new calendar object. |
|
| 959 | - * |
|
| 960 | - * The object uri is only the basename, or filename and not a full path. |
|
| 961 | - * |
|
| 962 | - * It is possible return an etag from this function, which will be used in |
|
| 963 | - * the response to this PUT request. Note that the ETag must be surrounded |
|
| 964 | - * by double-quotes. |
|
| 965 | - * |
|
| 966 | - * However, you should only really return this ETag if you don't mangle the |
|
| 967 | - * calendar-data. If the result of a subsequent GET to this object is not |
|
| 968 | - * the exact same as this request body, you should omit the ETag. |
|
| 969 | - * |
|
| 970 | - * @param mixed $calendarId |
|
| 971 | - * @param string $objectUri |
|
| 972 | - * @param string $calendarData |
|
| 973 | - * @return string |
|
| 974 | - */ |
|
| 975 | - function createCalendarObject($calendarId, $objectUri, $calendarData) { |
|
| 976 | - $extraData = $this->getDenormalizedData($calendarData); |
|
| 977 | - |
|
| 978 | - $q = $this->db->getQueryBuilder(); |
|
| 979 | - $q->select($q->createFunction('COUNT(*)')) |
|
| 980 | - ->from('calendarobjects') |
|
| 981 | - ->where($q->expr()->eq('calendarid', $q->createNamedParameter($calendarId))) |
|
| 982 | - ->andWhere($q->expr()->eq('uid', $q->createNamedParameter($extraData['uid']))); |
|
| 983 | - |
|
| 984 | - $result = $q->execute(); |
|
| 985 | - $count = (int) $result->fetchColumn(); |
|
| 986 | - $result->closeCursor(); |
|
| 987 | - |
|
| 988 | - if ($count !== 0) { |
|
| 989 | - throw new \Sabre\DAV\Exception\BadRequest('Calendar object with uid already exists in this calendar collection.'); |
|
| 990 | - } |
|
| 991 | - |
|
| 992 | - $query = $this->db->getQueryBuilder(); |
|
| 993 | - $query->insert('calendarobjects') |
|
| 994 | - ->values([ |
|
| 995 | - 'calendarid' => $query->createNamedParameter($calendarId), |
|
| 996 | - 'uri' => $query->createNamedParameter($objectUri), |
|
| 997 | - 'calendardata' => $query->createNamedParameter($calendarData, IQueryBuilder::PARAM_LOB), |
|
| 998 | - 'lastmodified' => $query->createNamedParameter(time()), |
|
| 999 | - 'etag' => $query->createNamedParameter($extraData['etag']), |
|
| 1000 | - 'size' => $query->createNamedParameter($extraData['size']), |
|
| 1001 | - 'componenttype' => $query->createNamedParameter($extraData['componentType']), |
|
| 1002 | - 'firstoccurence' => $query->createNamedParameter($extraData['firstOccurence']), |
|
| 1003 | - 'lastoccurence' => $query->createNamedParameter($extraData['lastOccurence']), |
|
| 1004 | - 'classification' => $query->createNamedParameter($extraData['classification']), |
|
| 1005 | - 'uid' => $query->createNamedParameter($extraData['uid']), |
|
| 1006 | - ]) |
|
| 1007 | - ->execute(); |
|
| 1008 | - |
|
| 1009 | - $this->updateProperties($calendarId, $objectUri, $calendarData); |
|
| 1010 | - |
|
| 1011 | - $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', new GenericEvent( |
|
| 1012 | - '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', |
|
| 1013 | - [ |
|
| 1014 | - 'calendarId' => $calendarId, |
|
| 1015 | - 'calendarData' => $this->getCalendarById($calendarId), |
|
| 1016 | - 'shares' => $this->getShares($calendarId), |
|
| 1017 | - 'objectData' => $this->getCalendarObject($calendarId, $objectUri), |
|
| 1018 | - ] |
|
| 1019 | - )); |
|
| 1020 | - $this->addChange($calendarId, $objectUri, 1); |
|
| 1021 | - |
|
| 1022 | - return '"' . $extraData['etag'] . '"'; |
|
| 1023 | - } |
|
| 1024 | - |
|
| 1025 | - /** |
|
| 1026 | - * Updates an existing calendarobject, based on it's uri. |
|
| 1027 | - * |
|
| 1028 | - * The object uri is only the basename, or filename and not a full path. |
|
| 1029 | - * |
|
| 1030 | - * It is possible return an etag from this function, which will be used in |
|
| 1031 | - * the response to this PUT request. Note that the ETag must be surrounded |
|
| 1032 | - * by double-quotes. |
|
| 1033 | - * |
|
| 1034 | - * However, you should only really return this ETag if you don't mangle the |
|
| 1035 | - * calendar-data. If the result of a subsequent GET to this object is not |
|
| 1036 | - * the exact same as this request body, you should omit the ETag. |
|
| 1037 | - * |
|
| 1038 | - * @param mixed $calendarId |
|
| 1039 | - * @param string $objectUri |
|
| 1040 | - * @param string $calendarData |
|
| 1041 | - * @return string |
|
| 1042 | - */ |
|
| 1043 | - function updateCalendarObject($calendarId, $objectUri, $calendarData) { |
|
| 1044 | - $extraData = $this->getDenormalizedData($calendarData); |
|
| 1045 | - |
|
| 1046 | - $query = $this->db->getQueryBuilder(); |
|
| 1047 | - $query->update('calendarobjects') |
|
| 1048 | - ->set('calendardata', $query->createNamedParameter($calendarData, IQueryBuilder::PARAM_LOB)) |
|
| 1049 | - ->set('lastmodified', $query->createNamedParameter(time())) |
|
| 1050 | - ->set('etag', $query->createNamedParameter($extraData['etag'])) |
|
| 1051 | - ->set('size', $query->createNamedParameter($extraData['size'])) |
|
| 1052 | - ->set('componenttype', $query->createNamedParameter($extraData['componentType'])) |
|
| 1053 | - ->set('firstoccurence', $query->createNamedParameter($extraData['firstOccurence'])) |
|
| 1054 | - ->set('lastoccurence', $query->createNamedParameter($extraData['lastOccurence'])) |
|
| 1055 | - ->set('classification', $query->createNamedParameter($extraData['classification'])) |
|
| 1056 | - ->set('uid', $query->createNamedParameter($extraData['uid'])) |
|
| 1057 | - ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))) |
|
| 1058 | - ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri))) |
|
| 1059 | - ->execute(); |
|
| 1060 | - |
|
| 1061 | - $this->updateProperties($calendarId, $objectUri, $calendarData); |
|
| 1062 | - |
|
| 1063 | - $data = $this->getCalendarObject($calendarId, $objectUri); |
|
| 1064 | - if (is_array($data)) { |
|
| 1065 | - $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', new GenericEvent( |
|
| 1066 | - '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', |
|
| 1067 | - [ |
|
| 1068 | - 'calendarId' => $calendarId, |
|
| 1069 | - 'calendarData' => $this->getCalendarById($calendarId), |
|
| 1070 | - 'shares' => $this->getShares($calendarId), |
|
| 1071 | - 'objectData' => $data, |
|
| 1072 | - ] |
|
| 1073 | - )); |
|
| 1074 | - } |
|
| 1075 | - $this->addChange($calendarId, $objectUri, 2); |
|
| 1076 | - |
|
| 1077 | - return '"' . $extraData['etag'] . '"'; |
|
| 1078 | - } |
|
| 1079 | - |
|
| 1080 | - /** |
|
| 1081 | - * @param int $calendarObjectId |
|
| 1082 | - * @param int $classification |
|
| 1083 | - */ |
|
| 1084 | - public function setClassification($calendarObjectId, $classification) { |
|
| 1085 | - if (!in_array($classification, [ |
|
| 1086 | - self::CLASSIFICATION_PUBLIC, self::CLASSIFICATION_PRIVATE, self::CLASSIFICATION_CONFIDENTIAL |
|
| 1087 | - ])) { |
|
| 1088 | - throw new \InvalidArgumentException(); |
|
| 1089 | - } |
|
| 1090 | - $query = $this->db->getQueryBuilder(); |
|
| 1091 | - $query->update('calendarobjects') |
|
| 1092 | - ->set('classification', $query->createNamedParameter($classification)) |
|
| 1093 | - ->where($query->expr()->eq('id', $query->createNamedParameter($calendarObjectId))) |
|
| 1094 | - ->execute(); |
|
| 1095 | - } |
|
| 1096 | - |
|
| 1097 | - /** |
|
| 1098 | - * Deletes an existing calendar object. |
|
| 1099 | - * |
|
| 1100 | - * The object uri is only the basename, or filename and not a full path. |
|
| 1101 | - * |
|
| 1102 | - * @param mixed $calendarId |
|
| 1103 | - * @param string $objectUri |
|
| 1104 | - * @return void |
|
| 1105 | - */ |
|
| 1106 | - function deleteCalendarObject($calendarId, $objectUri) { |
|
| 1107 | - $data = $this->getCalendarObject($calendarId, $objectUri); |
|
| 1108 | - if (is_array($data)) { |
|
| 1109 | - $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', new GenericEvent( |
|
| 1110 | - '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', |
|
| 1111 | - [ |
|
| 1112 | - 'calendarId' => $calendarId, |
|
| 1113 | - 'calendarData' => $this->getCalendarById($calendarId), |
|
| 1114 | - 'shares' => $this->getShares($calendarId), |
|
| 1115 | - 'objectData' => $data, |
|
| 1116 | - ] |
|
| 1117 | - )); |
|
| 1118 | - } |
|
| 1119 | - |
|
| 1120 | - $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ? AND `uri` = ?'); |
|
| 1121 | - $stmt->execute([$calendarId, $objectUri]); |
|
| 1122 | - |
|
| 1123 | - $this->purgeProperties($calendarId, $data['id']); |
|
| 1124 | - |
|
| 1125 | - $this->addChange($calendarId, $objectUri, 3); |
|
| 1126 | - } |
|
| 1127 | - |
|
| 1128 | - /** |
|
| 1129 | - * Performs a calendar-query on the contents of this calendar. |
|
| 1130 | - * |
|
| 1131 | - * The calendar-query is defined in RFC4791 : CalDAV. Using the |
|
| 1132 | - * calendar-query it is possible for a client to request a specific set of |
|
| 1133 | - * object, based on contents of iCalendar properties, date-ranges and |
|
| 1134 | - * iCalendar component types (VTODO, VEVENT). |
|
| 1135 | - * |
|
| 1136 | - * This method should just return a list of (relative) urls that match this |
|
| 1137 | - * query. |
|
| 1138 | - * |
|
| 1139 | - * The list of filters are specified as an array. The exact array is |
|
| 1140 | - * documented by Sabre\CalDAV\CalendarQueryParser. |
|
| 1141 | - * |
|
| 1142 | - * Note that it is extremely likely that getCalendarObject for every path |
|
| 1143 | - * returned from this method will be called almost immediately after. You |
|
| 1144 | - * may want to anticipate this to speed up these requests. |
|
| 1145 | - * |
|
| 1146 | - * This method provides a default implementation, which parses *all* the |
|
| 1147 | - * iCalendar objects in the specified calendar. |
|
| 1148 | - * |
|
| 1149 | - * This default may well be good enough for personal use, and calendars |
|
| 1150 | - * that aren't very large. But if you anticipate high usage, big calendars |
|
| 1151 | - * or high loads, you are strongly advised to optimize certain paths. |
|
| 1152 | - * |
|
| 1153 | - * The best way to do so is override this method and to optimize |
|
| 1154 | - * specifically for 'common filters'. |
|
| 1155 | - * |
|
| 1156 | - * Requests that are extremely common are: |
|
| 1157 | - * * requests for just VEVENTS |
|
| 1158 | - * * requests for just VTODO |
|
| 1159 | - * * requests with a time-range-filter on either VEVENT or VTODO. |
|
| 1160 | - * |
|
| 1161 | - * ..and combinations of these requests. It may not be worth it to try to |
|
| 1162 | - * handle every possible situation and just rely on the (relatively |
|
| 1163 | - * easy to use) CalendarQueryValidator to handle the rest. |
|
| 1164 | - * |
|
| 1165 | - * Note that especially time-range-filters may be difficult to parse. A |
|
| 1166 | - * time-range filter specified on a VEVENT must for instance also handle |
|
| 1167 | - * recurrence rules correctly. |
|
| 1168 | - * A good example of how to interprete all these filters can also simply |
|
| 1169 | - * be found in Sabre\CalDAV\CalendarQueryFilter. This class is as correct |
|
| 1170 | - * as possible, so it gives you a good idea on what type of stuff you need |
|
| 1171 | - * to think of. |
|
| 1172 | - * |
|
| 1173 | - * @param mixed $calendarId |
|
| 1174 | - * @param array $filters |
|
| 1175 | - * @return array |
|
| 1176 | - */ |
|
| 1177 | - function calendarQuery($calendarId, array $filters) { |
|
| 1178 | - $componentType = null; |
|
| 1179 | - $requirePostFilter = true; |
|
| 1180 | - $timeRange = null; |
|
| 1181 | - |
|
| 1182 | - // if no filters were specified, we don't need to filter after a query |
|
| 1183 | - if (!$filters['prop-filters'] && !$filters['comp-filters']) { |
|
| 1184 | - $requirePostFilter = false; |
|
| 1185 | - } |
|
| 1186 | - |
|
| 1187 | - // Figuring out if there's a component filter |
|
| 1188 | - if (count($filters['comp-filters']) > 0 && !$filters['comp-filters'][0]['is-not-defined']) { |
|
| 1189 | - $componentType = $filters['comp-filters'][0]['name']; |
|
| 1190 | - |
|
| 1191 | - // Checking if we need post-filters |
|
| 1192 | - if (!$filters['prop-filters'] && !$filters['comp-filters'][0]['comp-filters'] && !$filters['comp-filters'][0]['time-range'] && !$filters['comp-filters'][0]['prop-filters']) { |
|
| 1193 | - $requirePostFilter = false; |
|
| 1194 | - } |
|
| 1195 | - // There was a time-range filter |
|
| 1196 | - if ($componentType === 'VEVENT' && isset($filters['comp-filters'][0]['time-range'])) { |
|
| 1197 | - $timeRange = $filters['comp-filters'][0]['time-range']; |
|
| 1198 | - |
|
| 1199 | - // If start time OR the end time is not specified, we can do a |
|
| 1200 | - // 100% accurate mysql query. |
|
| 1201 | - if (!$filters['prop-filters'] && !$filters['comp-filters'][0]['comp-filters'] && !$filters['comp-filters'][0]['prop-filters'] && (!$timeRange['start'] || !$timeRange['end'])) { |
|
| 1202 | - $requirePostFilter = false; |
|
| 1203 | - } |
|
| 1204 | - } |
|
| 1205 | - |
|
| 1206 | - } |
|
| 1207 | - $columns = ['uri']; |
|
| 1208 | - if ($requirePostFilter) { |
|
| 1209 | - $columns = ['uri', 'calendardata']; |
|
| 1210 | - } |
|
| 1211 | - $query = $this->db->getQueryBuilder(); |
|
| 1212 | - $query->select($columns) |
|
| 1213 | - ->from('calendarobjects') |
|
| 1214 | - ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))); |
|
| 1215 | - |
|
| 1216 | - if ($componentType) { |
|
| 1217 | - $query->andWhere($query->expr()->eq('componenttype', $query->createNamedParameter($componentType))); |
|
| 1218 | - } |
|
| 1219 | - |
|
| 1220 | - if ($timeRange && $timeRange['start']) { |
|
| 1221 | - $query->andWhere($query->expr()->gt('lastoccurence', $query->createNamedParameter($timeRange['start']->getTimeStamp()))); |
|
| 1222 | - } |
|
| 1223 | - if ($timeRange && $timeRange['end']) { |
|
| 1224 | - $query->andWhere($query->expr()->lt('firstoccurence', $query->createNamedParameter($timeRange['end']->getTimeStamp()))); |
|
| 1225 | - } |
|
| 1226 | - |
|
| 1227 | - $stmt = $query->execute(); |
|
| 1228 | - |
|
| 1229 | - $result = []; |
|
| 1230 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 1231 | - if ($requirePostFilter) { |
|
| 1232 | - // validateFilterForObject will parse the calendar data |
|
| 1233 | - // catch parsing errors |
|
| 1234 | - try { |
|
| 1235 | - $matches = $this->validateFilterForObject($row, $filters); |
|
| 1236 | - } catch(ParseException $ex) { |
|
| 1237 | - $this->logger->logException($ex, [ |
|
| 1238 | - 'app' => 'dav', |
|
| 1239 | - 'message' => 'Caught parsing exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri'] |
|
| 1240 | - ]); |
|
| 1241 | - continue; |
|
| 1242 | - } catch (InvalidDataException $ex) { |
|
| 1243 | - $this->logger->logException($ex, [ |
|
| 1244 | - 'app' => 'dav', |
|
| 1245 | - 'message' => 'Caught invalid data exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri'] |
|
| 1246 | - ]); |
|
| 1247 | - continue; |
|
| 1248 | - } |
|
| 1249 | - |
|
| 1250 | - if (!$matches) { |
|
| 1251 | - continue; |
|
| 1252 | - } |
|
| 1253 | - } |
|
| 1254 | - $result[] = $row['uri']; |
|
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - return $result; |
|
| 1258 | - } |
|
| 1259 | - |
|
| 1260 | - /** |
|
| 1261 | - * custom Nextcloud search extension for CalDAV |
|
| 1262 | - * |
|
| 1263 | - * @param string $principalUri |
|
| 1264 | - * @param array $filters |
|
| 1265 | - * @param integer|null $limit |
|
| 1266 | - * @param integer|null $offset |
|
| 1267 | - * @return array |
|
| 1268 | - */ |
|
| 1269 | - public function calendarSearch($principalUri, array $filters, $limit=null, $offset=null) { |
|
| 1270 | - $calendars = $this->getCalendarsForUser($principalUri); |
|
| 1271 | - $ownCalendars = []; |
|
| 1272 | - $sharedCalendars = []; |
|
| 1273 | - |
|
| 1274 | - $uriMapper = []; |
|
| 1275 | - |
|
| 1276 | - foreach($calendars as $calendar) { |
|
| 1277 | - if ($calendar['{http://owncloud.org/ns}owner-principal'] === $principalUri) { |
|
| 1278 | - $ownCalendars[] = $calendar['id']; |
|
| 1279 | - } else { |
|
| 1280 | - $sharedCalendars[] = $calendar['id']; |
|
| 1281 | - } |
|
| 1282 | - $uriMapper[$calendar['id']] = $calendar['uri']; |
|
| 1283 | - } |
|
| 1284 | - if (count($ownCalendars) === 0 && count($sharedCalendars) === 0) { |
|
| 1285 | - return []; |
|
| 1286 | - } |
|
| 1287 | - |
|
| 1288 | - $query = $this->db->getQueryBuilder(); |
|
| 1289 | - // Calendar id expressions |
|
| 1290 | - $calendarExpressions = []; |
|
| 1291 | - foreach($ownCalendars as $id) { |
|
| 1292 | - $calendarExpressions[] = $query->expr() |
|
| 1293 | - ->eq('c.calendarid', $query->createNamedParameter($id)); |
|
| 1294 | - } |
|
| 1295 | - foreach($sharedCalendars as $id) { |
|
| 1296 | - $calendarExpressions[] = $query->expr()->andX( |
|
| 1297 | - $query->expr()->eq('c.calendarid', |
|
| 1298 | - $query->createNamedParameter($id)), |
|
| 1299 | - $query->expr()->eq('c.classification', |
|
| 1300 | - $query->createNamedParameter(self::CLASSIFICATION_PUBLIC)) |
|
| 1301 | - ); |
|
| 1302 | - } |
|
| 1303 | - |
|
| 1304 | - if (count($calendarExpressions) === 1) { |
|
| 1305 | - $calExpr = $calendarExpressions[0]; |
|
| 1306 | - } else { |
|
| 1307 | - $calExpr = call_user_func_array([$query->expr(), 'orX'], $calendarExpressions); |
|
| 1308 | - } |
|
| 1309 | - |
|
| 1310 | - // Component expressions |
|
| 1311 | - $compExpressions = []; |
|
| 1312 | - foreach($filters['comps'] as $comp) { |
|
| 1313 | - $compExpressions[] = $query->expr() |
|
| 1314 | - ->eq('c.componenttype', $query->createNamedParameter($comp)); |
|
| 1315 | - } |
|
| 1316 | - |
|
| 1317 | - if (count($compExpressions) === 1) { |
|
| 1318 | - $compExpr = $compExpressions[0]; |
|
| 1319 | - } else { |
|
| 1320 | - $compExpr = call_user_func_array([$query->expr(), 'orX'], $compExpressions); |
|
| 1321 | - } |
|
| 1322 | - |
|
| 1323 | - if (!isset($filters['props'])) { |
|
| 1324 | - $filters['props'] = []; |
|
| 1325 | - } |
|
| 1326 | - if (!isset($filters['params'])) { |
|
| 1327 | - $filters['params'] = []; |
|
| 1328 | - } |
|
| 1329 | - |
|
| 1330 | - $propParamExpressions = []; |
|
| 1331 | - foreach($filters['props'] as $prop) { |
|
| 1332 | - $propParamExpressions[] = $query->expr()->andX( |
|
| 1333 | - $query->expr()->eq('i.name', $query->createNamedParameter($prop)), |
|
| 1334 | - $query->expr()->isNull('i.parameter') |
|
| 1335 | - ); |
|
| 1336 | - } |
|
| 1337 | - foreach($filters['params'] as $param) { |
|
| 1338 | - $propParamExpressions[] = $query->expr()->andX( |
|
| 1339 | - $query->expr()->eq('i.name', $query->createNamedParameter($param['property'])), |
|
| 1340 | - $query->expr()->eq('i.parameter', $query->createNamedParameter($param['parameter'])) |
|
| 1341 | - ); |
|
| 1342 | - } |
|
| 1343 | - |
|
| 1344 | - if (count($propParamExpressions) === 1) { |
|
| 1345 | - $propParamExpr = $propParamExpressions[0]; |
|
| 1346 | - } else { |
|
| 1347 | - $propParamExpr = call_user_func_array([$query->expr(), 'orX'], $propParamExpressions); |
|
| 1348 | - } |
|
| 1349 | - |
|
| 1350 | - $query->select(['c.calendarid', 'c.uri']) |
|
| 1351 | - ->from($this->dbObjectPropertiesTable, 'i') |
|
| 1352 | - ->join('i', 'calendarobjects', 'c', $query->expr()->eq('i.objectid', 'c.id')) |
|
| 1353 | - ->where($calExpr) |
|
| 1354 | - ->andWhere($compExpr) |
|
| 1355 | - ->andWhere($propParamExpr) |
|
| 1356 | - ->andWhere($query->expr()->iLike('i.value', |
|
| 1357 | - $query->createNamedParameter('%'.$this->db->escapeLikeParameter($filters['search-term']).'%'))); |
|
| 1358 | - |
|
| 1359 | - if ($offset) { |
|
| 1360 | - $query->setFirstResult($offset); |
|
| 1361 | - } |
|
| 1362 | - if ($limit) { |
|
| 1363 | - $query->setMaxResults($limit); |
|
| 1364 | - } |
|
| 1365 | - |
|
| 1366 | - $stmt = $query->execute(); |
|
| 1367 | - |
|
| 1368 | - $result = []; |
|
| 1369 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 1370 | - $path = $uriMapper[$row['calendarid']] . '/' . $row['uri']; |
|
| 1371 | - if (!in_array($path, $result)) { |
|
| 1372 | - $result[] = $path; |
|
| 1373 | - } |
|
| 1374 | - } |
|
| 1375 | - |
|
| 1376 | - return $result; |
|
| 1377 | - } |
|
| 1378 | - |
|
| 1379 | - /** |
|
| 1380 | - * used for Nextcloud's calendar API |
|
| 1381 | - * |
|
| 1382 | - * @param array $calendarInfo |
|
| 1383 | - * @param string $pattern |
|
| 1384 | - * @param array $searchProperties |
|
| 1385 | - * @param array $options |
|
| 1386 | - * @param integer|null $limit |
|
| 1387 | - * @param integer|null $offset |
|
| 1388 | - * |
|
| 1389 | - * @return array |
|
| 1390 | - */ |
|
| 1391 | - public function search(array $calendarInfo, $pattern, array $searchProperties, |
|
| 1392 | - array $options, $limit, $offset) { |
|
| 1393 | - $outerQuery = $this->db->getQueryBuilder(); |
|
| 1394 | - $innerQuery = $this->db->getQueryBuilder(); |
|
| 1395 | - |
|
| 1396 | - $innerQuery->selectDistinct('op.objectid') |
|
| 1397 | - ->from($this->dbObjectPropertiesTable, 'op') |
|
| 1398 | - ->andWhere($innerQuery->expr()->eq('op.calendarid', |
|
| 1399 | - $outerQuery->createNamedParameter($calendarInfo['id']))); |
|
| 1400 | - |
|
| 1401 | - // only return public items for shared calendars for now |
|
| 1402 | - if ($calendarInfo['principaluri'] !== $calendarInfo['{http://owncloud.org/ns}owner-principal']) { |
|
| 1403 | - $innerQuery->andWhere($innerQuery->expr()->eq('c.classification', |
|
| 1404 | - $outerQuery->createNamedParameter(self::CLASSIFICATION_PUBLIC))); |
|
| 1405 | - } |
|
| 1406 | - |
|
| 1407 | - $or = $innerQuery->expr()->orX(); |
|
| 1408 | - foreach($searchProperties as $searchProperty) { |
|
| 1409 | - $or->add($innerQuery->expr()->eq('op.name', |
|
| 1410 | - $outerQuery->createNamedParameter($searchProperty))); |
|
| 1411 | - } |
|
| 1412 | - $innerQuery->andWhere($or); |
|
| 1413 | - |
|
| 1414 | - if ($pattern !== '') { |
|
| 1415 | - $innerQuery->andWhere($innerQuery->expr()->iLike('op.value', |
|
| 1416 | - $outerQuery->createNamedParameter('%' . |
|
| 1417 | - $this->db->escapeLikeParameter($pattern) . '%'))); |
|
| 1418 | - } |
|
| 1419 | - |
|
| 1420 | - $outerQuery->select('c.id', 'c.calendardata', 'c.componenttype', 'c.uid', 'c.uri') |
|
| 1421 | - ->from('calendarobjects', 'c'); |
|
| 1422 | - |
|
| 1423 | - if (isset($options['timerange'])) { |
|
| 1424 | - if (isset($options['timerange']['start'])) { |
|
| 1425 | - $outerQuery->andWhere($outerQuery->expr()->gt('lastoccurence', |
|
| 1426 | - $outerQuery->createNamedParameter($options['timerange']['start']->getTimeStamp))); |
|
| 1427 | - |
|
| 1428 | - } |
|
| 1429 | - if (isset($options['timerange']['end'])) { |
|
| 1430 | - $outerQuery->andWhere($outerQuery->expr()->lt('firstoccurence', |
|
| 1431 | - $outerQuery->createNamedParameter($options['timerange']['end']->getTimeStamp))); |
|
| 1432 | - } |
|
| 1433 | - } |
|
| 1434 | - |
|
| 1435 | - if (isset($options['types'])) { |
|
| 1436 | - $or = $outerQuery->expr()->orX(); |
|
| 1437 | - foreach($options['types'] as $type) { |
|
| 1438 | - $or->add($outerQuery->expr()->eq('componenttype', |
|
| 1439 | - $outerQuery->createNamedParameter($type))); |
|
| 1440 | - } |
|
| 1441 | - $outerQuery->andWhere($or); |
|
| 1442 | - } |
|
| 1443 | - |
|
| 1444 | - $outerQuery->andWhere($outerQuery->expr()->in('c.id', |
|
| 1445 | - $outerQuery->createFunction($innerQuery->getSQL()))); |
|
| 1446 | - |
|
| 1447 | - if ($offset) { |
|
| 1448 | - $outerQuery->setFirstResult($offset); |
|
| 1449 | - } |
|
| 1450 | - if ($limit) { |
|
| 1451 | - $outerQuery->setMaxResults($limit); |
|
| 1452 | - } |
|
| 1453 | - |
|
| 1454 | - $result = $outerQuery->execute(); |
|
| 1455 | - $calendarObjects = $result->fetchAll(); |
|
| 1456 | - |
|
| 1457 | - return array_map(function($o) { |
|
| 1458 | - $calendarData = Reader::read($o['calendardata']); |
|
| 1459 | - $comps = $calendarData->getComponents(); |
|
| 1460 | - $objects = []; |
|
| 1461 | - $timezones = []; |
|
| 1462 | - foreach($comps as $comp) { |
|
| 1463 | - if ($comp instanceof VTimeZone) { |
|
| 1464 | - $timezones[] = $comp; |
|
| 1465 | - } else { |
|
| 1466 | - $objects[] = $comp; |
|
| 1467 | - } |
|
| 1468 | - } |
|
| 1469 | - |
|
| 1470 | - return [ |
|
| 1471 | - 'id' => $o['id'], |
|
| 1472 | - 'type' => $o['componenttype'], |
|
| 1473 | - 'uid' => $o['uid'], |
|
| 1474 | - 'uri' => $o['uri'], |
|
| 1475 | - 'objects' => array_map(function($c) { |
|
| 1476 | - return $this->transformSearchData($c); |
|
| 1477 | - }, $objects), |
|
| 1478 | - 'timezones' => array_map(function($c) { |
|
| 1479 | - return $this->transformSearchData($c); |
|
| 1480 | - }, $timezones), |
|
| 1481 | - ]; |
|
| 1482 | - }, $calendarObjects); |
|
| 1483 | - } |
|
| 1484 | - |
|
| 1485 | - /** |
|
| 1486 | - * @param Component $comp |
|
| 1487 | - * @return array |
|
| 1488 | - */ |
|
| 1489 | - private function transformSearchData(Component $comp) { |
|
| 1490 | - $data = []; |
|
| 1491 | - /** @var Component[] $subComponents */ |
|
| 1492 | - $subComponents = $comp->getComponents(); |
|
| 1493 | - /** @var Property[] $properties */ |
|
| 1494 | - $properties = array_filter($comp->children(), function($c) { |
|
| 1495 | - return $c instanceof Property; |
|
| 1496 | - }); |
|
| 1497 | - $validationRules = $comp->getValidationRules(); |
|
| 1498 | - |
|
| 1499 | - foreach($subComponents as $subComponent) { |
|
| 1500 | - $name = $subComponent->name; |
|
| 1501 | - if (!isset($data[$name])) { |
|
| 1502 | - $data[$name] = []; |
|
| 1503 | - } |
|
| 1504 | - $data[$name][] = $this->transformSearchData($subComponent); |
|
| 1505 | - } |
|
| 1506 | - |
|
| 1507 | - foreach($properties as $property) { |
|
| 1508 | - $name = $property->name; |
|
| 1509 | - if (!isset($validationRules[$name])) { |
|
| 1510 | - $validationRules[$name] = '*'; |
|
| 1511 | - } |
|
| 1512 | - |
|
| 1513 | - $rule = $validationRules[$property->name]; |
|
| 1514 | - if ($rule === '+' || $rule === '*') { // multiple |
|
| 1515 | - if (!isset($data[$name])) { |
|
| 1516 | - $data[$name] = []; |
|
| 1517 | - } |
|
| 1518 | - |
|
| 1519 | - $data[$name][] = $this->transformSearchProperty($property); |
|
| 1520 | - } else { // once |
|
| 1521 | - $data[$name] = $this->transformSearchProperty($property); |
|
| 1522 | - } |
|
| 1523 | - } |
|
| 1524 | - |
|
| 1525 | - return $data; |
|
| 1526 | - } |
|
| 1527 | - |
|
| 1528 | - /** |
|
| 1529 | - * @param Property $prop |
|
| 1530 | - * @return array |
|
| 1531 | - */ |
|
| 1532 | - private function transformSearchProperty(Property $prop) { |
|
| 1533 | - // No need to check Date, as it extends DateTime |
|
| 1534 | - if ($prop instanceof Property\ICalendar\DateTime) { |
|
| 1535 | - $value = $prop->getDateTime(); |
|
| 1536 | - } else { |
|
| 1537 | - $value = $prop->getValue(); |
|
| 1538 | - } |
|
| 1539 | - |
|
| 1540 | - return [ |
|
| 1541 | - $value, |
|
| 1542 | - $prop->parameters() |
|
| 1543 | - ]; |
|
| 1544 | - } |
|
| 1545 | - |
|
| 1546 | - /** |
|
| 1547 | - * Searches through all of a users calendars and calendar objects to find |
|
| 1548 | - * an object with a specific UID. |
|
| 1549 | - * |
|
| 1550 | - * This method should return the path to this object, relative to the |
|
| 1551 | - * calendar home, so this path usually only contains two parts: |
|
| 1552 | - * |
|
| 1553 | - * calendarpath/objectpath.ics |
|
| 1554 | - * |
|
| 1555 | - * If the uid is not found, return null. |
|
| 1556 | - * |
|
| 1557 | - * This method should only consider * objects that the principal owns, so |
|
| 1558 | - * any calendars owned by other principals that also appear in this |
|
| 1559 | - * collection should be ignored. |
|
| 1560 | - * |
|
| 1561 | - * @param string $principalUri |
|
| 1562 | - * @param string $uid |
|
| 1563 | - * @return string|null |
|
| 1564 | - */ |
|
| 1565 | - function getCalendarObjectByUID($principalUri, $uid) { |
|
| 1566 | - |
|
| 1567 | - $query = $this->db->getQueryBuilder(); |
|
| 1568 | - $query->selectAlias('c.uri', 'calendaruri')->selectAlias('co.uri', 'objecturi') |
|
| 1569 | - ->from('calendarobjects', 'co') |
|
| 1570 | - ->leftJoin('co', 'calendars', 'c', $query->expr()->eq('co.calendarid', 'c.id')) |
|
| 1571 | - ->where($query->expr()->eq('c.principaluri', $query->createNamedParameter($principalUri))) |
|
| 1572 | - ->andWhere($query->expr()->eq('co.uid', $query->createNamedParameter($uid))); |
|
| 1573 | - |
|
| 1574 | - $stmt = $query->execute(); |
|
| 1575 | - |
|
| 1576 | - if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 1577 | - return $row['calendaruri'] . '/' . $row['objecturi']; |
|
| 1578 | - } |
|
| 1579 | - |
|
| 1580 | - return null; |
|
| 1581 | - } |
|
| 1582 | - |
|
| 1583 | - /** |
|
| 1584 | - * The getChanges method returns all the changes that have happened, since |
|
| 1585 | - * the specified syncToken in the specified calendar. |
|
| 1586 | - * |
|
| 1587 | - * This function should return an array, such as the following: |
|
| 1588 | - * |
|
| 1589 | - * [ |
|
| 1590 | - * 'syncToken' => 'The current synctoken', |
|
| 1591 | - * 'added' => [ |
|
| 1592 | - * 'new.txt', |
|
| 1593 | - * ], |
|
| 1594 | - * 'modified' => [ |
|
| 1595 | - * 'modified.txt', |
|
| 1596 | - * ], |
|
| 1597 | - * 'deleted' => [ |
|
| 1598 | - * 'foo.php.bak', |
|
| 1599 | - * 'old.txt' |
|
| 1600 | - * ] |
|
| 1601 | - * ); |
|
| 1602 | - * |
|
| 1603 | - * The returned syncToken property should reflect the *current* syncToken |
|
| 1604 | - * of the calendar, as reported in the {http://sabredav.org/ns}sync-token |
|
| 1605 | - * property This is * needed here too, to ensure the operation is atomic. |
|
| 1606 | - * |
|
| 1607 | - * If the $syncToken argument is specified as null, this is an initial |
|
| 1608 | - * sync, and all members should be reported. |
|
| 1609 | - * |
|
| 1610 | - * The modified property is an array of nodenames that have changed since |
|
| 1611 | - * the last token. |
|
| 1612 | - * |
|
| 1613 | - * The deleted property is an array with nodenames, that have been deleted |
|
| 1614 | - * from collection. |
|
| 1615 | - * |
|
| 1616 | - * The $syncLevel argument is basically the 'depth' of the report. If it's |
|
| 1617 | - * 1, you only have to report changes that happened only directly in |
|
| 1618 | - * immediate descendants. If it's 2, it should also include changes from |
|
| 1619 | - * the nodes below the child collections. (grandchildren) |
|
| 1620 | - * |
|
| 1621 | - * The $limit argument allows a client to specify how many results should |
|
| 1622 | - * be returned at most. If the limit is not specified, it should be treated |
|
| 1623 | - * as infinite. |
|
| 1624 | - * |
|
| 1625 | - * If the limit (infinite or not) is higher than you're willing to return, |
|
| 1626 | - * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception. |
|
| 1627 | - * |
|
| 1628 | - * If the syncToken is expired (due to data cleanup) or unknown, you must |
|
| 1629 | - * return null. |
|
| 1630 | - * |
|
| 1631 | - * The limit is 'suggestive'. You are free to ignore it. |
|
| 1632 | - * |
|
| 1633 | - * @param string $calendarId |
|
| 1634 | - * @param string $syncToken |
|
| 1635 | - * @param int $syncLevel |
|
| 1636 | - * @param int $limit |
|
| 1637 | - * @return array |
|
| 1638 | - */ |
|
| 1639 | - function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) { |
|
| 1640 | - // Current synctoken |
|
| 1641 | - $stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*calendars` WHERE `id` = ?'); |
|
| 1642 | - $stmt->execute([ $calendarId ]); |
|
| 1643 | - $currentToken = $stmt->fetchColumn(0); |
|
| 1644 | - |
|
| 1645 | - if (is_null($currentToken)) { |
|
| 1646 | - return null; |
|
| 1647 | - } |
|
| 1648 | - |
|
| 1649 | - $result = [ |
|
| 1650 | - 'syncToken' => $currentToken, |
|
| 1651 | - 'added' => [], |
|
| 1652 | - 'modified' => [], |
|
| 1653 | - 'deleted' => [], |
|
| 1654 | - ]; |
|
| 1655 | - |
|
| 1656 | - if ($syncToken) { |
|
| 1657 | - |
|
| 1658 | - $query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? ORDER BY `synctoken`"; |
|
| 1659 | - if ($limit>0) { |
|
| 1660 | - $query.= " LIMIT " . (int)$limit; |
|
| 1661 | - } |
|
| 1662 | - |
|
| 1663 | - // Fetching all changes |
|
| 1664 | - $stmt = $this->db->prepare($query); |
|
| 1665 | - $stmt->execute([$syncToken, $currentToken, $calendarId]); |
|
| 1666 | - |
|
| 1667 | - $changes = []; |
|
| 1668 | - |
|
| 1669 | - // This loop ensures that any duplicates are overwritten, only the |
|
| 1670 | - // last change on a node is relevant. |
|
| 1671 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 1672 | - |
|
| 1673 | - $changes[$row['uri']] = $row['operation']; |
|
| 1674 | - |
|
| 1675 | - } |
|
| 1676 | - |
|
| 1677 | - foreach($changes as $uri => $operation) { |
|
| 1678 | - |
|
| 1679 | - switch($operation) { |
|
| 1680 | - case 1 : |
|
| 1681 | - $result['added'][] = $uri; |
|
| 1682 | - break; |
|
| 1683 | - case 2 : |
|
| 1684 | - $result['modified'][] = $uri; |
|
| 1685 | - break; |
|
| 1686 | - case 3 : |
|
| 1687 | - $result['deleted'][] = $uri; |
|
| 1688 | - break; |
|
| 1689 | - } |
|
| 1690 | - |
|
| 1691 | - } |
|
| 1692 | - } else { |
|
| 1693 | - // No synctoken supplied, this is the initial sync. |
|
| 1694 | - $query = "SELECT `uri` FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ?"; |
|
| 1695 | - $stmt = $this->db->prepare($query); |
|
| 1696 | - $stmt->execute([$calendarId]); |
|
| 1697 | - |
|
| 1698 | - $result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN); |
|
| 1699 | - } |
|
| 1700 | - return $result; |
|
| 1701 | - |
|
| 1702 | - } |
|
| 1703 | - |
|
| 1704 | - /** |
|
| 1705 | - * Returns a list of subscriptions for a principal. |
|
| 1706 | - * |
|
| 1707 | - * Every subscription is an array with the following keys: |
|
| 1708 | - * * id, a unique id that will be used by other functions to modify the |
|
| 1709 | - * subscription. This can be the same as the uri or a database key. |
|
| 1710 | - * * uri. This is just the 'base uri' or 'filename' of the subscription. |
|
| 1711 | - * * principaluri. The owner of the subscription. Almost always the same as |
|
| 1712 | - * principalUri passed to this method. |
|
| 1713 | - * |
|
| 1714 | - * Furthermore, all the subscription info must be returned too: |
|
| 1715 | - * |
|
| 1716 | - * 1. {DAV:}displayname |
|
| 1717 | - * 2. {http://apple.com/ns/ical/}refreshrate |
|
| 1718 | - * 3. {http://calendarserver.org/ns/}subscribed-strip-todos (omit if todos |
|
| 1719 | - * should not be stripped). |
|
| 1720 | - * 4. {http://calendarserver.org/ns/}subscribed-strip-alarms (omit if alarms |
|
| 1721 | - * should not be stripped). |
|
| 1722 | - * 5. {http://calendarserver.org/ns/}subscribed-strip-attachments (omit if |
|
| 1723 | - * attachments should not be stripped). |
|
| 1724 | - * 6. {http://calendarserver.org/ns/}source (Must be a |
|
| 1725 | - * Sabre\DAV\Property\Href). |
|
| 1726 | - * 7. {http://apple.com/ns/ical/}calendar-color |
|
| 1727 | - * 8. {http://apple.com/ns/ical/}calendar-order |
|
| 1728 | - * 9. {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set |
|
| 1729 | - * (should just be an instance of |
|
| 1730 | - * Sabre\CalDAV\Property\SupportedCalendarComponentSet, with a bunch of |
|
| 1731 | - * default components). |
|
| 1732 | - * |
|
| 1733 | - * @param string $principalUri |
|
| 1734 | - * @return array |
|
| 1735 | - */ |
|
| 1736 | - function getSubscriptionsForUser($principalUri) { |
|
| 1737 | - $fields = array_values($this->subscriptionPropertyMap); |
|
| 1738 | - $fields[] = 'id'; |
|
| 1739 | - $fields[] = 'uri'; |
|
| 1740 | - $fields[] = 'source'; |
|
| 1741 | - $fields[] = 'principaluri'; |
|
| 1742 | - $fields[] = 'lastmodified'; |
|
| 1743 | - |
|
| 1744 | - $query = $this->db->getQueryBuilder(); |
|
| 1745 | - $query->select($fields) |
|
| 1746 | - ->from('calendarsubscriptions') |
|
| 1747 | - ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
|
| 1748 | - ->orderBy('calendarorder', 'asc'); |
|
| 1749 | - $stmt =$query->execute(); |
|
| 1750 | - |
|
| 1751 | - $subscriptions = []; |
|
| 1752 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 1753 | - |
|
| 1754 | - $subscription = [ |
|
| 1755 | - 'id' => $row['id'], |
|
| 1756 | - 'uri' => $row['uri'], |
|
| 1757 | - 'principaluri' => $row['principaluri'], |
|
| 1758 | - 'source' => $row['source'], |
|
| 1759 | - 'lastmodified' => $row['lastmodified'], |
|
| 1760 | - |
|
| 1761 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']), |
|
| 1762 | - ]; |
|
| 1763 | - |
|
| 1764 | - foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) { |
|
| 1765 | - if (!is_null($row[$dbName])) { |
|
| 1766 | - $subscription[$xmlName] = $row[$dbName]; |
|
| 1767 | - } |
|
| 1768 | - } |
|
| 1769 | - |
|
| 1770 | - $subscriptions[] = $subscription; |
|
| 1771 | - |
|
| 1772 | - } |
|
| 1773 | - |
|
| 1774 | - return $subscriptions; |
|
| 1775 | - } |
|
| 1776 | - |
|
| 1777 | - /** |
|
| 1778 | - * Creates a new subscription for a principal. |
|
| 1779 | - * |
|
| 1780 | - * If the creation was a success, an id must be returned that can be used to reference |
|
| 1781 | - * this subscription in other methods, such as updateSubscription. |
|
| 1782 | - * |
|
| 1783 | - * @param string $principalUri |
|
| 1784 | - * @param string $uri |
|
| 1785 | - * @param array $properties |
|
| 1786 | - * @return mixed |
|
| 1787 | - */ |
|
| 1788 | - function createSubscription($principalUri, $uri, array $properties) { |
|
| 1789 | - |
|
| 1790 | - if (!isset($properties['{http://calendarserver.org/ns/}source'])) { |
|
| 1791 | - throw new Forbidden('The {http://calendarserver.org/ns/}source property is required when creating subscriptions'); |
|
| 1792 | - } |
|
| 1793 | - |
|
| 1794 | - $values = [ |
|
| 1795 | - 'principaluri' => $principalUri, |
|
| 1796 | - 'uri' => $uri, |
|
| 1797 | - 'source' => $properties['{http://calendarserver.org/ns/}source']->getHref(), |
|
| 1798 | - 'lastmodified' => time(), |
|
| 1799 | - ]; |
|
| 1800 | - |
|
| 1801 | - $propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments']; |
|
| 1802 | - |
|
| 1803 | - foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) { |
|
| 1804 | - if (array_key_exists($xmlName, $properties)) { |
|
| 1805 | - $values[$dbName] = $properties[$xmlName]; |
|
| 1806 | - if (in_array($dbName, $propertiesBoolean)) { |
|
| 1807 | - $values[$dbName] = true; |
|
| 1808 | - } |
|
| 1809 | - } |
|
| 1810 | - } |
|
| 1811 | - |
|
| 1812 | - $valuesToInsert = array(); |
|
| 1813 | - |
|
| 1814 | - $query = $this->db->getQueryBuilder(); |
|
| 1815 | - |
|
| 1816 | - foreach (array_keys($values) as $name) { |
|
| 1817 | - $valuesToInsert[$name] = $query->createNamedParameter($values[$name]); |
|
| 1818 | - } |
|
| 1819 | - |
|
| 1820 | - $query->insert('calendarsubscriptions') |
|
| 1821 | - ->values($valuesToInsert) |
|
| 1822 | - ->execute(); |
|
| 1823 | - |
|
| 1824 | - return $this->db->lastInsertId('*PREFIX*calendarsubscriptions'); |
|
| 1825 | - } |
|
| 1826 | - |
|
| 1827 | - /** |
|
| 1828 | - * Updates a subscription |
|
| 1829 | - * |
|
| 1830 | - * The list of mutations is stored in a Sabre\DAV\PropPatch object. |
|
| 1831 | - * To do the actual updates, you must tell this object which properties |
|
| 1832 | - * you're going to process with the handle() method. |
|
| 1833 | - * |
|
| 1834 | - * Calling the handle method is like telling the PropPatch object "I |
|
| 1835 | - * promise I can handle updating this property". |
|
| 1836 | - * |
|
| 1837 | - * Read the PropPatch documentation for more info and examples. |
|
| 1838 | - * |
|
| 1839 | - * @param mixed $subscriptionId |
|
| 1840 | - * @param PropPatch $propPatch |
|
| 1841 | - * @return void |
|
| 1842 | - */ |
|
| 1843 | - function updateSubscription($subscriptionId, PropPatch $propPatch) { |
|
| 1844 | - $supportedProperties = array_keys($this->subscriptionPropertyMap); |
|
| 1845 | - $supportedProperties[] = '{http://calendarserver.org/ns/}source'; |
|
| 1846 | - |
|
| 1847 | - /** |
|
| 1848 | - * @suppress SqlInjectionChecker |
|
| 1849 | - */ |
|
| 1850 | - $propPatch->handle($supportedProperties, function($mutations) use ($subscriptionId) { |
|
| 1851 | - |
|
| 1852 | - $newValues = []; |
|
| 1853 | - |
|
| 1854 | - foreach($mutations as $propertyName=>$propertyValue) { |
|
| 1855 | - if ($propertyName === '{http://calendarserver.org/ns/}source') { |
|
| 1856 | - $newValues['source'] = $propertyValue->getHref(); |
|
| 1857 | - } else { |
|
| 1858 | - $fieldName = $this->subscriptionPropertyMap[$propertyName]; |
|
| 1859 | - $newValues[$fieldName] = $propertyValue; |
|
| 1860 | - } |
|
| 1861 | - } |
|
| 1862 | - |
|
| 1863 | - $query = $this->db->getQueryBuilder(); |
|
| 1864 | - $query->update('calendarsubscriptions') |
|
| 1865 | - ->set('lastmodified', $query->createNamedParameter(time())); |
|
| 1866 | - foreach($newValues as $fieldName=>$value) { |
|
| 1867 | - $query->set($fieldName, $query->createNamedParameter($value)); |
|
| 1868 | - } |
|
| 1869 | - $query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId))) |
|
| 1870 | - ->execute(); |
|
| 1871 | - |
|
| 1872 | - return true; |
|
| 1873 | - |
|
| 1874 | - }); |
|
| 1875 | - } |
|
| 1876 | - |
|
| 1877 | - /** |
|
| 1878 | - * Deletes a subscription. |
|
| 1879 | - * |
|
| 1880 | - * @param mixed $subscriptionId |
|
| 1881 | - * @return void |
|
| 1882 | - */ |
|
| 1883 | - function deleteSubscription($subscriptionId) { |
|
| 1884 | - $query = $this->db->getQueryBuilder(); |
|
| 1885 | - $query->delete('calendarsubscriptions') |
|
| 1886 | - ->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId))) |
|
| 1887 | - ->execute(); |
|
| 1888 | - } |
|
| 1889 | - |
|
| 1890 | - /** |
|
| 1891 | - * Returns a single scheduling object for the inbox collection. |
|
| 1892 | - * |
|
| 1893 | - * The returned array should contain the following elements: |
|
| 1894 | - * * uri - A unique basename for the object. This will be used to |
|
| 1895 | - * construct a full uri. |
|
| 1896 | - * * calendardata - The iCalendar object |
|
| 1897 | - * * lastmodified - The last modification date. Can be an int for a unix |
|
| 1898 | - * timestamp, or a PHP DateTime object. |
|
| 1899 | - * * etag - A unique token that must change if the object changed. |
|
| 1900 | - * * size - The size of the object, in bytes. |
|
| 1901 | - * |
|
| 1902 | - * @param string $principalUri |
|
| 1903 | - * @param string $objectUri |
|
| 1904 | - * @return array |
|
| 1905 | - */ |
|
| 1906 | - function getSchedulingObject($principalUri, $objectUri) { |
|
| 1907 | - $query = $this->db->getQueryBuilder(); |
|
| 1908 | - $stmt = $query->select(['uri', 'calendardata', 'lastmodified', 'etag', 'size']) |
|
| 1909 | - ->from('schedulingobjects') |
|
| 1910 | - ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
|
| 1911 | - ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri))) |
|
| 1912 | - ->execute(); |
|
| 1913 | - |
|
| 1914 | - $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
|
| 1915 | - |
|
| 1916 | - if(!$row) { |
|
| 1917 | - return null; |
|
| 1918 | - } |
|
| 1919 | - |
|
| 1920 | - return [ |
|
| 1921 | - 'uri' => $row['uri'], |
|
| 1922 | - 'calendardata' => $row['calendardata'], |
|
| 1923 | - 'lastmodified' => $row['lastmodified'], |
|
| 1924 | - 'etag' => '"' . $row['etag'] . '"', |
|
| 1925 | - 'size' => (int)$row['size'], |
|
| 1926 | - ]; |
|
| 1927 | - } |
|
| 1928 | - |
|
| 1929 | - /** |
|
| 1930 | - * Returns all scheduling objects for the inbox collection. |
|
| 1931 | - * |
|
| 1932 | - * These objects should be returned as an array. Every item in the array |
|
| 1933 | - * should follow the same structure as returned from getSchedulingObject. |
|
| 1934 | - * |
|
| 1935 | - * The main difference is that 'calendardata' is optional. |
|
| 1936 | - * |
|
| 1937 | - * @param string $principalUri |
|
| 1938 | - * @return array |
|
| 1939 | - */ |
|
| 1940 | - function getSchedulingObjects($principalUri) { |
|
| 1941 | - $query = $this->db->getQueryBuilder(); |
|
| 1942 | - $stmt = $query->select(['uri', 'calendardata', 'lastmodified', 'etag', 'size']) |
|
| 1943 | - ->from('schedulingobjects') |
|
| 1944 | - ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
|
| 1945 | - ->execute(); |
|
| 1946 | - |
|
| 1947 | - $result = []; |
|
| 1948 | - foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { |
|
| 1949 | - $result[] = [ |
|
| 1950 | - 'calendardata' => $row['calendardata'], |
|
| 1951 | - 'uri' => $row['uri'], |
|
| 1952 | - 'lastmodified' => $row['lastmodified'], |
|
| 1953 | - 'etag' => '"' . $row['etag'] . '"', |
|
| 1954 | - 'size' => (int)$row['size'], |
|
| 1955 | - ]; |
|
| 1956 | - } |
|
| 1957 | - |
|
| 1958 | - return $result; |
|
| 1959 | - } |
|
| 1960 | - |
|
| 1961 | - /** |
|
| 1962 | - * Deletes a scheduling object from the inbox collection. |
|
| 1963 | - * |
|
| 1964 | - * @param string $principalUri |
|
| 1965 | - * @param string $objectUri |
|
| 1966 | - * @return void |
|
| 1967 | - */ |
|
| 1968 | - function deleteSchedulingObject($principalUri, $objectUri) { |
|
| 1969 | - $query = $this->db->getQueryBuilder(); |
|
| 1970 | - $query->delete('schedulingobjects') |
|
| 1971 | - ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
|
| 1972 | - ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri))) |
|
| 1973 | - ->execute(); |
|
| 1974 | - } |
|
| 1975 | - |
|
| 1976 | - /** |
|
| 1977 | - * Creates a new scheduling object. This should land in a users' inbox. |
|
| 1978 | - * |
|
| 1979 | - * @param string $principalUri |
|
| 1980 | - * @param string $objectUri |
|
| 1981 | - * @param string $objectData |
|
| 1982 | - * @return void |
|
| 1983 | - */ |
|
| 1984 | - function createSchedulingObject($principalUri, $objectUri, $objectData) { |
|
| 1985 | - $query = $this->db->getQueryBuilder(); |
|
| 1986 | - $query->insert('schedulingobjects') |
|
| 1987 | - ->values([ |
|
| 1988 | - 'principaluri' => $query->createNamedParameter($principalUri), |
|
| 1989 | - 'calendardata' => $query->createNamedParameter($objectData), |
|
| 1990 | - 'uri' => $query->createNamedParameter($objectUri), |
|
| 1991 | - 'lastmodified' => $query->createNamedParameter(time()), |
|
| 1992 | - 'etag' => $query->createNamedParameter(md5($objectData)), |
|
| 1993 | - 'size' => $query->createNamedParameter(strlen($objectData)) |
|
| 1994 | - ]) |
|
| 1995 | - ->execute(); |
|
| 1996 | - } |
|
| 1997 | - |
|
| 1998 | - /** |
|
| 1999 | - * Adds a change record to the calendarchanges table. |
|
| 2000 | - * |
|
| 2001 | - * @param mixed $calendarId |
|
| 2002 | - * @param string $objectUri |
|
| 2003 | - * @param int $operation 1 = add, 2 = modify, 3 = delete. |
|
| 2004 | - * @return void |
|
| 2005 | - */ |
|
| 2006 | - protected function addChange($calendarId, $objectUri, $operation) { |
|
| 2007 | - |
|
| 2008 | - $stmt = $this->db->prepare('INSERT INTO `*PREFIX*calendarchanges` (`uri`, `synctoken`, `calendarid`, `operation`) SELECT ?, `synctoken`, ?, ? FROM `*PREFIX*calendars` WHERE `id` = ?'); |
|
| 2009 | - $stmt->execute([ |
|
| 2010 | - $objectUri, |
|
| 2011 | - $calendarId, |
|
| 2012 | - $operation, |
|
| 2013 | - $calendarId |
|
| 2014 | - ]); |
|
| 2015 | - $stmt = $this->db->prepare('UPDATE `*PREFIX*calendars` SET `synctoken` = `synctoken` + 1 WHERE `id` = ?'); |
|
| 2016 | - $stmt->execute([ |
|
| 2017 | - $calendarId |
|
| 2018 | - ]); |
|
| 2019 | - |
|
| 2020 | - } |
|
| 2021 | - |
|
| 2022 | - /** |
|
| 2023 | - * Parses some information from calendar objects, used for optimized |
|
| 2024 | - * calendar-queries. |
|
| 2025 | - * |
|
| 2026 | - * Returns an array with the following keys: |
|
| 2027 | - * * etag - An md5 checksum of the object without the quotes. |
|
| 2028 | - * * size - Size of the object in bytes |
|
| 2029 | - * * componentType - VEVENT, VTODO or VJOURNAL |
|
| 2030 | - * * firstOccurence |
|
| 2031 | - * * lastOccurence |
|
| 2032 | - * * uid - value of the UID property |
|
| 2033 | - * |
|
| 2034 | - * @param string $calendarData |
|
| 2035 | - * @return array |
|
| 2036 | - */ |
|
| 2037 | - public function getDenormalizedData($calendarData) { |
|
| 2038 | - |
|
| 2039 | - $vObject = Reader::read($calendarData); |
|
| 2040 | - $componentType = null; |
|
| 2041 | - $component = null; |
|
| 2042 | - $firstOccurrence = null; |
|
| 2043 | - $lastOccurrence = null; |
|
| 2044 | - $uid = null; |
|
| 2045 | - $classification = self::CLASSIFICATION_PUBLIC; |
|
| 2046 | - foreach($vObject->getComponents() as $component) { |
|
| 2047 | - if ($component->name!=='VTIMEZONE') { |
|
| 2048 | - $componentType = $component->name; |
|
| 2049 | - $uid = (string)$component->UID; |
|
| 2050 | - break; |
|
| 2051 | - } |
|
| 2052 | - } |
|
| 2053 | - if (!$componentType) { |
|
| 2054 | - throw new \Sabre\DAV\Exception\BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component'); |
|
| 2055 | - } |
|
| 2056 | - if ($componentType === 'VEVENT' && $component->DTSTART) { |
|
| 2057 | - $firstOccurrence = $component->DTSTART->getDateTime()->getTimeStamp(); |
|
| 2058 | - // Finding the last occurrence is a bit harder |
|
| 2059 | - if (!isset($component->RRULE)) { |
|
| 2060 | - if (isset($component->DTEND)) { |
|
| 2061 | - $lastOccurrence = $component->DTEND->getDateTime()->getTimeStamp(); |
|
| 2062 | - } elseif (isset($component->DURATION)) { |
|
| 2063 | - $endDate = clone $component->DTSTART->getDateTime(); |
|
| 2064 | - $endDate->add(DateTimeParser::parse($component->DURATION->getValue())); |
|
| 2065 | - $lastOccurrence = $endDate->getTimeStamp(); |
|
| 2066 | - } elseif (!$component->DTSTART->hasTime()) { |
|
| 2067 | - $endDate = clone $component->DTSTART->getDateTime(); |
|
| 2068 | - $endDate->modify('+1 day'); |
|
| 2069 | - $lastOccurrence = $endDate->getTimeStamp(); |
|
| 2070 | - } else { |
|
| 2071 | - $lastOccurrence = $firstOccurrence; |
|
| 2072 | - } |
|
| 2073 | - } else { |
|
| 2074 | - $it = new EventIterator($vObject, (string)$component->UID); |
|
| 2075 | - $maxDate = new \DateTime(self::MAX_DATE); |
|
| 2076 | - if ($it->isInfinite()) { |
|
| 2077 | - $lastOccurrence = $maxDate->getTimestamp(); |
|
| 2078 | - } else { |
|
| 2079 | - $end = $it->getDtEnd(); |
|
| 2080 | - while($it->valid() && $end < $maxDate) { |
|
| 2081 | - $end = $it->getDtEnd(); |
|
| 2082 | - $it->next(); |
|
| 2083 | - |
|
| 2084 | - } |
|
| 2085 | - $lastOccurrence = $end->getTimestamp(); |
|
| 2086 | - } |
|
| 2087 | - |
|
| 2088 | - } |
|
| 2089 | - } |
|
| 2090 | - |
|
| 2091 | - if ($component->CLASS) { |
|
| 2092 | - $classification = CalDavBackend::CLASSIFICATION_PRIVATE; |
|
| 2093 | - switch ($component->CLASS->getValue()) { |
|
| 2094 | - case 'PUBLIC': |
|
| 2095 | - $classification = CalDavBackend::CLASSIFICATION_PUBLIC; |
|
| 2096 | - break; |
|
| 2097 | - case 'CONFIDENTIAL': |
|
| 2098 | - $classification = CalDavBackend::CLASSIFICATION_CONFIDENTIAL; |
|
| 2099 | - break; |
|
| 2100 | - } |
|
| 2101 | - } |
|
| 2102 | - return [ |
|
| 2103 | - 'etag' => md5($calendarData), |
|
| 2104 | - 'size' => strlen($calendarData), |
|
| 2105 | - 'componentType' => $componentType, |
|
| 2106 | - 'firstOccurence' => is_null($firstOccurrence) ? null : max(0, $firstOccurrence), |
|
| 2107 | - 'lastOccurence' => $lastOccurrence, |
|
| 2108 | - 'uid' => $uid, |
|
| 2109 | - 'classification' => $classification |
|
| 2110 | - ]; |
|
| 2111 | - |
|
| 2112 | - } |
|
| 2113 | - |
|
| 2114 | - private function readBlob($cardData) { |
|
| 2115 | - if (is_resource($cardData)) { |
|
| 2116 | - return stream_get_contents($cardData); |
|
| 2117 | - } |
|
| 2118 | - |
|
| 2119 | - return $cardData; |
|
| 2120 | - } |
|
| 2121 | - |
|
| 2122 | - /** |
|
| 2123 | - * @param IShareable $shareable |
|
| 2124 | - * @param array $add |
|
| 2125 | - * @param array $remove |
|
| 2126 | - */ |
|
| 2127 | - public function updateShares($shareable, $add, $remove) { |
|
| 2128 | - $calendarId = $shareable->getResourceId(); |
|
| 2129 | - $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateShares', new GenericEvent( |
|
| 2130 | - '\OCA\DAV\CalDAV\CalDavBackend::updateShares', |
|
| 2131 | - [ |
|
| 2132 | - 'calendarId' => $calendarId, |
|
| 2133 | - 'calendarData' => $this->getCalendarById($calendarId), |
|
| 2134 | - 'shares' => $this->getShares($calendarId), |
|
| 2135 | - 'add' => $add, |
|
| 2136 | - 'remove' => $remove, |
|
| 2137 | - ])); |
|
| 2138 | - $this->sharingBackend->updateShares($shareable, $add, $remove); |
|
| 2139 | - } |
|
| 2140 | - |
|
| 2141 | - /** |
|
| 2142 | - * @param int $resourceId |
|
| 2143 | - * @return array |
|
| 2144 | - */ |
|
| 2145 | - public function getShares($resourceId) { |
|
| 2146 | - return $this->sharingBackend->getShares($resourceId); |
|
| 2147 | - } |
|
| 2148 | - |
|
| 2149 | - /** |
|
| 2150 | - * @param boolean $value |
|
| 2151 | - * @param \OCA\DAV\CalDAV\Calendar $calendar |
|
| 2152 | - * @return string|null |
|
| 2153 | - */ |
|
| 2154 | - public function setPublishStatus($value, $calendar) { |
|
| 2155 | - |
|
| 2156 | - $calendarId = $calendar->getResourceId(); |
|
| 2157 | - $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::publishCalendar', new GenericEvent( |
|
| 2158 | - '\OCA\DAV\CalDAV\CalDavBackend::updateShares', |
|
| 2159 | - [ |
|
| 2160 | - 'calendarId' => $calendarId, |
|
| 2161 | - 'calendarData' => $this->getCalendarById($calendarId), |
|
| 2162 | - 'public' => $value, |
|
| 2163 | - ])); |
|
| 2164 | - |
|
| 2165 | - $query = $this->db->getQueryBuilder(); |
|
| 2166 | - if ($value) { |
|
| 2167 | - $publicUri = $this->random->generate(16, ISecureRandom::CHAR_HUMAN_READABLE); |
|
| 2168 | - $query->insert('dav_shares') |
|
| 2169 | - ->values([ |
|
| 2170 | - 'principaluri' => $query->createNamedParameter($calendar->getPrincipalURI()), |
|
| 2171 | - 'type' => $query->createNamedParameter('calendar'), |
|
| 2172 | - 'access' => $query->createNamedParameter(self::ACCESS_PUBLIC), |
|
| 2173 | - 'resourceid' => $query->createNamedParameter($calendar->getResourceId()), |
|
| 2174 | - 'publicuri' => $query->createNamedParameter($publicUri) |
|
| 2175 | - ]); |
|
| 2176 | - $query->execute(); |
|
| 2177 | - return $publicUri; |
|
| 2178 | - } |
|
| 2179 | - $query->delete('dav_shares') |
|
| 2180 | - ->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId()))) |
|
| 2181 | - ->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC))); |
|
| 2182 | - $query->execute(); |
|
| 2183 | - return null; |
|
| 2184 | - } |
|
| 2185 | - |
|
| 2186 | - /** |
|
| 2187 | - * @param \OCA\DAV\CalDAV\Calendar $calendar |
|
| 2188 | - * @return mixed |
|
| 2189 | - */ |
|
| 2190 | - public function getPublishStatus($calendar) { |
|
| 2191 | - $query = $this->db->getQueryBuilder(); |
|
| 2192 | - $result = $query->select('publicuri') |
|
| 2193 | - ->from('dav_shares') |
|
| 2194 | - ->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId()))) |
|
| 2195 | - ->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC))) |
|
| 2196 | - ->execute(); |
|
| 2197 | - |
|
| 2198 | - $row = $result->fetch(); |
|
| 2199 | - $result->closeCursor(); |
|
| 2200 | - return $row ? reset($row) : false; |
|
| 2201 | - } |
|
| 2202 | - |
|
| 2203 | - /** |
|
| 2204 | - * @param int $resourceId |
|
| 2205 | - * @param array $acl |
|
| 2206 | - * @return array |
|
| 2207 | - */ |
|
| 2208 | - public function applyShareAcl($resourceId, $acl) { |
|
| 2209 | - return $this->sharingBackend->applyShareAcl($resourceId, $acl); |
|
| 2210 | - } |
|
| 2211 | - |
|
| 2212 | - |
|
| 2213 | - |
|
| 2214 | - /** |
|
| 2215 | - * update properties table |
|
| 2216 | - * |
|
| 2217 | - * @param int $calendarId |
|
| 2218 | - * @param string $objectUri |
|
| 2219 | - * @param string $calendarData |
|
| 2220 | - */ |
|
| 2221 | - public function updateProperties($calendarId, $objectUri, $calendarData) { |
|
| 2222 | - $objectId = $this->getCalendarObjectId($calendarId, $objectUri); |
|
| 2223 | - |
|
| 2224 | - try { |
|
| 2225 | - $vCalendar = $this->readCalendarData($calendarData); |
|
| 2226 | - } catch (\Exception $ex) { |
|
| 2227 | - return; |
|
| 2228 | - } |
|
| 2229 | - |
|
| 2230 | - $this->purgeProperties($calendarId, $objectId); |
|
| 2231 | - |
|
| 2232 | - $query = $this->db->getQueryBuilder(); |
|
| 2233 | - $query->insert($this->dbObjectPropertiesTable) |
|
| 2234 | - ->values( |
|
| 2235 | - [ |
|
| 2236 | - 'calendarid' => $query->createNamedParameter($calendarId), |
|
| 2237 | - 'objectid' => $query->createNamedParameter($objectId), |
|
| 2238 | - 'name' => $query->createParameter('name'), |
|
| 2239 | - 'parameter' => $query->createParameter('parameter'), |
|
| 2240 | - 'value' => $query->createParameter('value'), |
|
| 2241 | - ] |
|
| 2242 | - ); |
|
| 2243 | - |
|
| 2244 | - $indexComponents = ['VEVENT', 'VJOURNAL', 'VTODO']; |
|
| 2245 | - foreach ($vCalendar->getComponents() as $component) { |
|
| 2246 | - if (!in_array($component->name, $indexComponents)) { |
|
| 2247 | - continue; |
|
| 2248 | - } |
|
| 2249 | - |
|
| 2250 | - foreach ($component->children() as $property) { |
|
| 2251 | - if (in_array($property->name, self::$indexProperties)) { |
|
| 2252 | - $value = $property->getValue(); |
|
| 2253 | - // is this a shitty db? |
|
| 2254 | - if (!$this->db->supports4ByteText()) { |
|
| 2255 | - $value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value); |
|
| 2256 | - } |
|
| 2257 | - $value = mb_substr($value, 0, 254); |
|
| 2258 | - |
|
| 2259 | - $query->setParameter('name', $property->name); |
|
| 2260 | - $query->setParameter('parameter', null); |
|
| 2261 | - $query->setParameter('value', $value); |
|
| 2262 | - $query->execute(); |
|
| 2263 | - } |
|
| 2264 | - |
|
| 2265 | - if (array_key_exists($property->name, self::$indexParameters)) { |
|
| 2266 | - $parameters = $property->parameters(); |
|
| 2267 | - $indexedParametersForProperty = self::$indexParameters[$property->name]; |
|
| 2268 | - |
|
| 2269 | - foreach ($parameters as $key => $value) { |
|
| 2270 | - if (in_array($key, $indexedParametersForProperty)) { |
|
| 2271 | - // is this a shitty db? |
|
| 2272 | - if ($this->db->supports4ByteText()) { |
|
| 2273 | - $value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value); |
|
| 2274 | - } |
|
| 2275 | - $value = mb_substr($value, 0, 254); |
|
| 2276 | - |
|
| 2277 | - $query->setParameter('name', $property->name); |
|
| 2278 | - $query->setParameter('parameter', substr($key, 0, 254)); |
|
| 2279 | - $query->setParameter('value', substr($value, 0, 254)); |
|
| 2280 | - $query->execute(); |
|
| 2281 | - } |
|
| 2282 | - } |
|
| 2283 | - } |
|
| 2284 | - } |
|
| 2285 | - } |
|
| 2286 | - } |
|
| 2287 | - |
|
| 2288 | - /** |
|
| 2289 | - * deletes all birthday calendars |
|
| 2290 | - */ |
|
| 2291 | - public function deleteAllBirthdayCalendars() { |
|
| 2292 | - $query = $this->db->getQueryBuilder(); |
|
| 2293 | - $result = $query->select(['id'])->from('calendars') |
|
| 2294 | - ->where($query->expr()->eq('uri', |
|
| 2295 | - $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI))) |
|
| 2296 | - ->execute(); |
|
| 2297 | - |
|
| 2298 | - $ids = $result->fetchAll(); |
|
| 2299 | - foreach($ids as $id) { |
|
| 2300 | - $this->deleteCalendar($id['id']); |
|
| 2301 | - } |
|
| 2302 | - } |
|
| 2303 | - |
|
| 2304 | - /** |
|
| 2305 | - * read VCalendar data into a VCalendar object |
|
| 2306 | - * |
|
| 2307 | - * @param string $objectData |
|
| 2308 | - * @return VCalendar |
|
| 2309 | - */ |
|
| 2310 | - protected function readCalendarData($objectData) { |
|
| 2311 | - return Reader::read($objectData); |
|
| 2312 | - } |
|
| 2313 | - |
|
| 2314 | - /** |
|
| 2315 | - * delete all properties from a given calendar object |
|
| 2316 | - * |
|
| 2317 | - * @param int $calendarId |
|
| 2318 | - * @param int $objectId |
|
| 2319 | - */ |
|
| 2320 | - protected function purgeProperties($calendarId, $objectId) { |
|
| 2321 | - $query = $this->db->getQueryBuilder(); |
|
| 2322 | - $query->delete($this->dbObjectPropertiesTable) |
|
| 2323 | - ->where($query->expr()->eq('objectid', $query->createNamedParameter($objectId))) |
|
| 2324 | - ->andWhere($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))); |
|
| 2325 | - $query->execute(); |
|
| 2326 | - } |
|
| 2327 | - |
|
| 2328 | - /** |
|
| 2329 | - * get ID from a given calendar object |
|
| 2330 | - * |
|
| 2331 | - * @param int $calendarId |
|
| 2332 | - * @param string $uri |
|
| 2333 | - * @return int |
|
| 2334 | - */ |
|
| 2335 | - protected function getCalendarObjectId($calendarId, $uri) { |
|
| 2336 | - $query = $this->db->getQueryBuilder(); |
|
| 2337 | - $query->select('id')->from('calendarobjects') |
|
| 2338 | - ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) |
|
| 2339 | - ->andWhere($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))); |
|
| 2340 | - |
|
| 2341 | - $result = $query->execute(); |
|
| 2342 | - $objectIds = $result->fetch(); |
|
| 2343 | - $result->closeCursor(); |
|
| 2344 | - |
|
| 2345 | - if (!isset($objectIds['id'])) { |
|
| 2346 | - throw new \InvalidArgumentException('Calendarobject does not exists: ' . $uri); |
|
| 2347 | - } |
|
| 2348 | - |
|
| 2349 | - return (int)$objectIds['id']; |
|
| 2350 | - } |
|
| 2351 | - |
|
| 2352 | - private function convertPrincipal($principalUri, $toV2) { |
|
| 2353 | - if ($this->principalBackend->getPrincipalPrefix() === 'principals') { |
|
| 2354 | - list(, $name) = Uri\split($principalUri); |
|
| 2355 | - if ($toV2 === true) { |
|
| 2356 | - return "principals/users/$name"; |
|
| 2357 | - } |
|
| 2358 | - return "principals/$name"; |
|
| 2359 | - } |
|
| 2360 | - return $principalUri; |
|
| 2361 | - } |
|
| 2362 | - |
|
| 2363 | - private function addOwnerPrincipal(&$calendarInfo) { |
|
| 2364 | - $ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'; |
|
| 2365 | - $displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'; |
|
| 2366 | - if (isset($calendarInfo[$ownerPrincipalKey])) { |
|
| 2367 | - $uri = $calendarInfo[$ownerPrincipalKey]; |
|
| 2368 | - } else { |
|
| 2369 | - $uri = $calendarInfo['principaluri']; |
|
| 2370 | - } |
|
| 2371 | - |
|
| 2372 | - $principalInformation = $this->principalBackend->getPrincipalByPath($uri); |
|
| 2373 | - if (isset($principalInformation['{DAV:}displayname'])) { |
|
| 2374 | - $calendarInfo[$displaynameKey] = $principalInformation['{DAV:}displayname']; |
|
| 2375 | - } |
|
| 2376 | - } |
|
| 434 | + /** |
|
| 435 | + * @return array |
|
| 436 | + */ |
|
| 437 | + public function getPublicCalendars() { |
|
| 438 | + $fields = array_values($this->propertyMap); |
|
| 439 | + $fields[] = 'a.id'; |
|
| 440 | + $fields[] = 'a.uri'; |
|
| 441 | + $fields[] = 'a.synctoken'; |
|
| 442 | + $fields[] = 'a.components'; |
|
| 443 | + $fields[] = 'a.principaluri'; |
|
| 444 | + $fields[] = 'a.transparent'; |
|
| 445 | + $fields[] = 's.access'; |
|
| 446 | + $fields[] = 's.publicuri'; |
|
| 447 | + $calendars = []; |
|
| 448 | + $query = $this->db->getQueryBuilder(); |
|
| 449 | + $result = $query->select($fields) |
|
| 450 | + ->from('dav_shares', 's') |
|
| 451 | + ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id')) |
|
| 452 | + ->where($query->expr()->in('s.access', $query->createNamedParameter(self::ACCESS_PUBLIC))) |
|
| 453 | + ->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar'))) |
|
| 454 | + ->execute(); |
|
| 455 | + |
|
| 456 | + while($row = $result->fetch()) { |
|
| 457 | + list(, $name) = Uri\split($row['principaluri']); |
|
| 458 | + $row['displayname'] = $row['displayname'] . "($name)"; |
|
| 459 | + $components = []; |
|
| 460 | + if ($row['components']) { |
|
| 461 | + $components = explode(',',$row['components']); |
|
| 462 | + } |
|
| 463 | + $calendar = [ |
|
| 464 | + 'id' => $row['id'], |
|
| 465 | + 'uri' => $row['publicuri'], |
|
| 466 | + 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 467 | + '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 468 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 469 | + '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 470 | + '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 471 | + '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint), |
|
| 472 | + '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ, |
|
| 473 | + '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC, |
|
| 474 | + ]; |
|
| 475 | + |
|
| 476 | + foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 477 | + $calendar[$xmlName] = $row[$dbName]; |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + $this->addOwnerPrincipal($calendar); |
|
| 481 | + |
|
| 482 | + if (!isset($calendars[$calendar['id']])) { |
|
| 483 | + $calendars[$calendar['id']] = $calendar; |
|
| 484 | + } |
|
| 485 | + } |
|
| 486 | + $result->closeCursor(); |
|
| 487 | + |
|
| 488 | + return array_values($calendars); |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + /** |
|
| 492 | + * @param string $uri |
|
| 493 | + * @return array |
|
| 494 | + * @throws NotFound |
|
| 495 | + */ |
|
| 496 | + public function getPublicCalendar($uri) { |
|
| 497 | + $fields = array_values($this->propertyMap); |
|
| 498 | + $fields[] = 'a.id'; |
|
| 499 | + $fields[] = 'a.uri'; |
|
| 500 | + $fields[] = 'a.synctoken'; |
|
| 501 | + $fields[] = 'a.components'; |
|
| 502 | + $fields[] = 'a.principaluri'; |
|
| 503 | + $fields[] = 'a.transparent'; |
|
| 504 | + $fields[] = 's.access'; |
|
| 505 | + $fields[] = 's.publicuri'; |
|
| 506 | + $query = $this->db->getQueryBuilder(); |
|
| 507 | + $result = $query->select($fields) |
|
| 508 | + ->from('dav_shares', 's') |
|
| 509 | + ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id')) |
|
| 510 | + ->where($query->expr()->in('s.access', $query->createNamedParameter(self::ACCESS_PUBLIC))) |
|
| 511 | + ->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar'))) |
|
| 512 | + ->andWhere($query->expr()->eq('s.publicuri', $query->createNamedParameter($uri))) |
|
| 513 | + ->execute(); |
|
| 514 | + |
|
| 515 | + $row = $result->fetch(\PDO::FETCH_ASSOC); |
|
| 516 | + |
|
| 517 | + $result->closeCursor(); |
|
| 518 | + |
|
| 519 | + if ($row === false) { |
|
| 520 | + throw new NotFound('Node with name \'' . $uri . '\' could not be found'); |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + list(, $name) = Uri\split($row['principaluri']); |
|
| 524 | + $row['displayname'] = $row['displayname'] . ' ' . "($name)"; |
|
| 525 | + $components = []; |
|
| 526 | + if ($row['components']) { |
|
| 527 | + $components = explode(',',$row['components']); |
|
| 528 | + } |
|
| 529 | + $calendar = [ |
|
| 530 | + 'id' => $row['id'], |
|
| 531 | + 'uri' => $row['publicuri'], |
|
| 532 | + 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 533 | + '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 534 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 535 | + '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 536 | + '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 537 | + '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 538 | + '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ, |
|
| 539 | + '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC, |
|
| 540 | + ]; |
|
| 541 | + |
|
| 542 | + foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 543 | + $calendar[$xmlName] = $row[$dbName]; |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + $this->addOwnerPrincipal($calendar); |
|
| 547 | + |
|
| 548 | + return $calendar; |
|
| 549 | + |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + /** |
|
| 553 | + * @param string $principal |
|
| 554 | + * @param string $uri |
|
| 555 | + * @return array|null |
|
| 556 | + */ |
|
| 557 | + public function getCalendarByUri($principal, $uri) { |
|
| 558 | + $fields = array_values($this->propertyMap); |
|
| 559 | + $fields[] = 'id'; |
|
| 560 | + $fields[] = 'uri'; |
|
| 561 | + $fields[] = 'synctoken'; |
|
| 562 | + $fields[] = 'components'; |
|
| 563 | + $fields[] = 'principaluri'; |
|
| 564 | + $fields[] = 'transparent'; |
|
| 565 | + |
|
| 566 | + // Making fields a comma-delimited list |
|
| 567 | + $query = $this->db->getQueryBuilder(); |
|
| 568 | + $query->select($fields)->from('calendars') |
|
| 569 | + ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) |
|
| 570 | + ->andWhere($query->expr()->eq('principaluri', $query->createNamedParameter($principal))) |
|
| 571 | + ->setMaxResults(1); |
|
| 572 | + $stmt = $query->execute(); |
|
| 573 | + |
|
| 574 | + $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
|
| 575 | + $stmt->closeCursor(); |
|
| 576 | + if ($row === false) { |
|
| 577 | + return null; |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + $components = []; |
|
| 581 | + if ($row['components']) { |
|
| 582 | + $components = explode(',',$row['components']); |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + $calendar = [ |
|
| 586 | + 'id' => $row['id'], |
|
| 587 | + 'uri' => $row['uri'], |
|
| 588 | + 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 589 | + '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 590 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 591 | + '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 592 | + '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 593 | + ]; |
|
| 594 | + |
|
| 595 | + foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 596 | + $calendar[$xmlName] = $row[$dbName]; |
|
| 597 | + } |
|
| 598 | + |
|
| 599 | + $this->addOwnerPrincipal($calendar); |
|
| 600 | + |
|
| 601 | + return $calendar; |
|
| 602 | + } |
|
| 603 | + |
|
| 604 | + public function getCalendarById($calendarId) { |
|
| 605 | + $fields = array_values($this->propertyMap); |
|
| 606 | + $fields[] = 'id'; |
|
| 607 | + $fields[] = 'uri'; |
|
| 608 | + $fields[] = 'synctoken'; |
|
| 609 | + $fields[] = 'components'; |
|
| 610 | + $fields[] = 'principaluri'; |
|
| 611 | + $fields[] = 'transparent'; |
|
| 612 | + |
|
| 613 | + // Making fields a comma-delimited list |
|
| 614 | + $query = $this->db->getQueryBuilder(); |
|
| 615 | + $query->select($fields)->from('calendars') |
|
| 616 | + ->where($query->expr()->eq('id', $query->createNamedParameter($calendarId))) |
|
| 617 | + ->setMaxResults(1); |
|
| 618 | + $stmt = $query->execute(); |
|
| 619 | + |
|
| 620 | + $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
|
| 621 | + $stmt->closeCursor(); |
|
| 622 | + if ($row === false) { |
|
| 623 | + return null; |
|
| 624 | + } |
|
| 625 | + |
|
| 626 | + $components = []; |
|
| 627 | + if ($row['components']) { |
|
| 628 | + $components = explode(',',$row['components']); |
|
| 629 | + } |
|
| 630 | + |
|
| 631 | + $calendar = [ |
|
| 632 | + 'id' => $row['id'], |
|
| 633 | + 'uri' => $row['uri'], |
|
| 634 | + 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), |
|
| 635 | + '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 636 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 637 | + '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 638 | + '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 639 | + ]; |
|
| 640 | + |
|
| 641 | + foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 642 | + $calendar[$xmlName] = $row[$dbName]; |
|
| 643 | + } |
|
| 644 | + |
|
| 645 | + $this->addOwnerPrincipal($calendar); |
|
| 646 | + |
|
| 647 | + return $calendar; |
|
| 648 | + } |
|
| 649 | + |
|
| 650 | + /** |
|
| 651 | + * Creates a new calendar for a principal. |
|
| 652 | + * |
|
| 653 | + * If the creation was a success, an id must be returned that can be used to reference |
|
| 654 | + * this calendar in other methods, such as updateCalendar. |
|
| 655 | + * |
|
| 656 | + * @param string $principalUri |
|
| 657 | + * @param string $calendarUri |
|
| 658 | + * @param array $properties |
|
| 659 | + * @return int |
|
| 660 | + * @suppress SqlInjectionChecker |
|
| 661 | + */ |
|
| 662 | + function createCalendar($principalUri, $calendarUri, array $properties) { |
|
| 663 | + $values = [ |
|
| 664 | + 'principaluri' => $this->convertPrincipal($principalUri, true), |
|
| 665 | + 'uri' => $calendarUri, |
|
| 666 | + 'synctoken' => 1, |
|
| 667 | + 'transparent' => 0, |
|
| 668 | + 'components' => 'VEVENT,VTODO', |
|
| 669 | + 'displayname' => $calendarUri |
|
| 670 | + ]; |
|
| 671 | + |
|
| 672 | + // Default value |
|
| 673 | + $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; |
|
| 674 | + if (isset($properties[$sccs])) { |
|
| 675 | + if (!($properties[$sccs] instanceof SupportedCalendarComponentSet)) { |
|
| 676 | + throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet'); |
|
| 677 | + } |
|
| 678 | + $values['components'] = implode(',',$properties[$sccs]->getValue()); |
|
| 679 | + } |
|
| 680 | + $transp = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp'; |
|
| 681 | + if (isset($properties[$transp])) { |
|
| 682 | + $values['transparent'] = (int) ($properties[$transp]->getValue() === 'transparent'); |
|
| 683 | + } |
|
| 684 | + |
|
| 685 | + foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 686 | + if (isset($properties[$xmlName])) { |
|
| 687 | + $values[$dbName] = $properties[$xmlName]; |
|
| 688 | + } |
|
| 689 | + } |
|
| 690 | + |
|
| 691 | + $query = $this->db->getQueryBuilder(); |
|
| 692 | + $query->insert('calendars'); |
|
| 693 | + foreach($values as $column => $value) { |
|
| 694 | + $query->setValue($column, $query->createNamedParameter($value)); |
|
| 695 | + } |
|
| 696 | + $query->execute(); |
|
| 697 | + $calendarId = $query->getLastInsertId(); |
|
| 698 | + |
|
| 699 | + $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', new GenericEvent( |
|
| 700 | + '\OCA\DAV\CalDAV\CalDavBackend::createCalendar', |
|
| 701 | + [ |
|
| 702 | + 'calendarId' => $calendarId, |
|
| 703 | + 'calendarData' => $this->getCalendarById($calendarId), |
|
| 704 | + ])); |
|
| 705 | + |
|
| 706 | + return $calendarId; |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + /** |
|
| 710 | + * Updates properties for a calendar. |
|
| 711 | + * |
|
| 712 | + * The list of mutations is stored in a Sabre\DAV\PropPatch object. |
|
| 713 | + * To do the actual updates, you must tell this object which properties |
|
| 714 | + * you're going to process with the handle() method. |
|
| 715 | + * |
|
| 716 | + * Calling the handle method is like telling the PropPatch object "I |
|
| 717 | + * promise I can handle updating this property". |
|
| 718 | + * |
|
| 719 | + * Read the PropPatch documentation for more info and examples. |
|
| 720 | + * |
|
| 721 | + * @param mixed $calendarId |
|
| 722 | + * @param PropPatch $propPatch |
|
| 723 | + * @return void |
|
| 724 | + */ |
|
| 725 | + function updateCalendar($calendarId, PropPatch $propPatch) { |
|
| 726 | + $supportedProperties = array_keys($this->propertyMap); |
|
| 727 | + $supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp'; |
|
| 728 | + |
|
| 729 | + /** |
|
| 730 | + * @suppress SqlInjectionChecker |
|
| 731 | + */ |
|
| 732 | + $propPatch->handle($supportedProperties, function($mutations) use ($calendarId) { |
|
| 733 | + $newValues = []; |
|
| 734 | + foreach ($mutations as $propertyName => $propertyValue) { |
|
| 735 | + |
|
| 736 | + switch ($propertyName) { |
|
| 737 | + case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' : |
|
| 738 | + $fieldName = 'transparent'; |
|
| 739 | + $newValues[$fieldName] = (int) ($propertyValue->getValue() === 'transparent'); |
|
| 740 | + break; |
|
| 741 | + default : |
|
| 742 | + $fieldName = $this->propertyMap[$propertyName]; |
|
| 743 | + $newValues[$fieldName] = $propertyValue; |
|
| 744 | + break; |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + } |
|
| 748 | + $query = $this->db->getQueryBuilder(); |
|
| 749 | + $query->update('calendars'); |
|
| 750 | + foreach ($newValues as $fieldName => $value) { |
|
| 751 | + $query->set($fieldName, $query->createNamedParameter($value)); |
|
| 752 | + } |
|
| 753 | + $query->where($query->expr()->eq('id', $query->createNamedParameter($calendarId))); |
|
| 754 | + $query->execute(); |
|
| 755 | + |
|
| 756 | + $this->addChange($calendarId, "", 2); |
|
| 757 | + |
|
| 758 | + $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', new GenericEvent( |
|
| 759 | + '\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', |
|
| 760 | + [ |
|
| 761 | + 'calendarId' => $calendarId, |
|
| 762 | + 'calendarData' => $this->getCalendarById($calendarId), |
|
| 763 | + 'shares' => $this->getShares($calendarId), |
|
| 764 | + 'propertyMutations' => $mutations, |
|
| 765 | + ])); |
|
| 766 | + |
|
| 767 | + return true; |
|
| 768 | + }); |
|
| 769 | + } |
|
| 770 | + |
|
| 771 | + /** |
|
| 772 | + * Delete a calendar and all it's objects |
|
| 773 | + * |
|
| 774 | + * @param mixed $calendarId |
|
| 775 | + * @return void |
|
| 776 | + */ |
|
| 777 | + function deleteCalendar($calendarId) { |
|
| 778 | + $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', new GenericEvent( |
|
| 779 | + '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', |
|
| 780 | + [ |
|
| 781 | + 'calendarId' => $calendarId, |
|
| 782 | + 'calendarData' => $this->getCalendarById($calendarId), |
|
| 783 | + 'shares' => $this->getShares($calendarId), |
|
| 784 | + ])); |
|
| 785 | + |
|
| 786 | + $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ?'); |
|
| 787 | + $stmt->execute([$calendarId]); |
|
| 788 | + |
|
| 789 | + $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendars` WHERE `id` = ?'); |
|
| 790 | + $stmt->execute([$calendarId]); |
|
| 791 | + |
|
| 792 | + $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarchanges` WHERE `calendarid` = ?'); |
|
| 793 | + $stmt->execute([$calendarId]); |
|
| 794 | + |
|
| 795 | + $this->sharingBackend->deleteAllShares($calendarId); |
|
| 796 | + |
|
| 797 | + $query = $this->db->getQueryBuilder(); |
|
| 798 | + $query->delete($this->dbObjectPropertiesTable) |
|
| 799 | + ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))) |
|
| 800 | + ->execute(); |
|
| 801 | + } |
|
| 802 | + |
|
| 803 | + /** |
|
| 804 | + * Delete all of an user's shares |
|
| 805 | + * |
|
| 806 | + * @param string $principaluri |
|
| 807 | + * @return void |
|
| 808 | + */ |
|
| 809 | + function deleteAllSharesByUser($principaluri) { |
|
| 810 | + $this->sharingBackend->deleteAllSharesByUser($principaluri); |
|
| 811 | + } |
|
| 812 | + |
|
| 813 | + /** |
|
| 814 | + * Returns all calendar objects within a calendar. |
|
| 815 | + * |
|
| 816 | + * Every item contains an array with the following keys: |
|
| 817 | + * * calendardata - The iCalendar-compatible calendar data |
|
| 818 | + * * uri - a unique key which will be used to construct the uri. This can |
|
| 819 | + * be any arbitrary string, but making sure it ends with '.ics' is a |
|
| 820 | + * good idea. This is only the basename, or filename, not the full |
|
| 821 | + * path. |
|
| 822 | + * * lastmodified - a timestamp of the last modification time |
|
| 823 | + * * etag - An arbitrary string, surrounded by double-quotes. (e.g.: |
|
| 824 | + * '"abcdef"') |
|
| 825 | + * * size - The size of the calendar objects, in bytes. |
|
| 826 | + * * component - optional, a string containing the type of object, such |
|
| 827 | + * as 'vevent' or 'vtodo'. If specified, this will be used to populate |
|
| 828 | + * the Content-Type header. |
|
| 829 | + * |
|
| 830 | + * Note that the etag is optional, but it's highly encouraged to return for |
|
| 831 | + * speed reasons. |
|
| 832 | + * |
|
| 833 | + * The calendardata is also optional. If it's not returned |
|
| 834 | + * 'getCalendarObject' will be called later, which *is* expected to return |
|
| 835 | + * calendardata. |
|
| 836 | + * |
|
| 837 | + * If neither etag or size are specified, the calendardata will be |
|
| 838 | + * used/fetched to determine these numbers. If both are specified the |
|
| 839 | + * amount of times this is needed is reduced by a great degree. |
|
| 840 | + * |
|
| 841 | + * @param mixed $calendarId |
|
| 842 | + * @return array |
|
| 843 | + */ |
|
| 844 | + function getCalendarObjects($calendarId) { |
|
| 845 | + $query = $this->db->getQueryBuilder(); |
|
| 846 | + $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'componenttype', 'classification']) |
|
| 847 | + ->from('calendarobjects') |
|
| 848 | + ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))); |
|
| 849 | + $stmt = $query->execute(); |
|
| 850 | + |
|
| 851 | + $result = []; |
|
| 852 | + foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { |
|
| 853 | + $result[] = [ |
|
| 854 | + 'id' => $row['id'], |
|
| 855 | + 'uri' => $row['uri'], |
|
| 856 | + 'lastmodified' => $row['lastmodified'], |
|
| 857 | + 'etag' => '"' . $row['etag'] . '"', |
|
| 858 | + 'calendarid' => $row['calendarid'], |
|
| 859 | + 'size' => (int)$row['size'], |
|
| 860 | + 'component' => strtolower($row['componenttype']), |
|
| 861 | + 'classification'=> (int)$row['classification'] |
|
| 862 | + ]; |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + return $result; |
|
| 866 | + } |
|
| 867 | + |
|
| 868 | + /** |
|
| 869 | + * Returns information from a single calendar object, based on it's object |
|
| 870 | + * uri. |
|
| 871 | + * |
|
| 872 | + * The object uri is only the basename, or filename and not a full path. |
|
| 873 | + * |
|
| 874 | + * The returned array must have the same keys as getCalendarObjects. The |
|
| 875 | + * 'calendardata' object is required here though, while it's not required |
|
| 876 | + * for getCalendarObjects. |
|
| 877 | + * |
|
| 878 | + * This method must return null if the object did not exist. |
|
| 879 | + * |
|
| 880 | + * @param mixed $calendarId |
|
| 881 | + * @param string $objectUri |
|
| 882 | + * @return array|null |
|
| 883 | + */ |
|
| 884 | + function getCalendarObject($calendarId, $objectUri) { |
|
| 885 | + |
|
| 886 | + $query = $this->db->getQueryBuilder(); |
|
| 887 | + $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification']) |
|
| 888 | + ->from('calendarobjects') |
|
| 889 | + ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))) |
|
| 890 | + ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri))); |
|
| 891 | + $stmt = $query->execute(); |
|
| 892 | + $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
|
| 893 | + |
|
| 894 | + if(!$row) return null; |
|
| 895 | + |
|
| 896 | + return [ |
|
| 897 | + 'id' => $row['id'], |
|
| 898 | + 'uri' => $row['uri'], |
|
| 899 | + 'lastmodified' => $row['lastmodified'], |
|
| 900 | + 'etag' => '"' . $row['etag'] . '"', |
|
| 901 | + 'calendarid' => $row['calendarid'], |
|
| 902 | + 'size' => (int)$row['size'], |
|
| 903 | + 'calendardata' => $this->readBlob($row['calendardata']), |
|
| 904 | + 'component' => strtolower($row['componenttype']), |
|
| 905 | + 'classification'=> (int)$row['classification'] |
|
| 906 | + ]; |
|
| 907 | + } |
|
| 908 | + |
|
| 909 | + /** |
|
| 910 | + * Returns a list of calendar objects. |
|
| 911 | + * |
|
| 912 | + * This method should work identical to getCalendarObject, but instead |
|
| 913 | + * return all the calendar objects in the list as an array. |
|
| 914 | + * |
|
| 915 | + * If the backend supports this, it may allow for some speed-ups. |
|
| 916 | + * |
|
| 917 | + * @param mixed $calendarId |
|
| 918 | + * @param string[] $uris |
|
| 919 | + * @return array |
|
| 920 | + */ |
|
| 921 | + function getMultipleCalendarObjects($calendarId, array $uris) { |
|
| 922 | + if (empty($uris)) { |
|
| 923 | + return []; |
|
| 924 | + } |
|
| 925 | + |
|
| 926 | + $chunks = array_chunk($uris, 100); |
|
| 927 | + $objects = []; |
|
| 928 | + |
|
| 929 | + $query = $this->db->getQueryBuilder(); |
|
| 930 | + $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification']) |
|
| 931 | + ->from('calendarobjects') |
|
| 932 | + ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))) |
|
| 933 | + ->andWhere($query->expr()->in('uri', $query->createParameter('uri'))); |
|
| 934 | + |
|
| 935 | + foreach ($chunks as $uris) { |
|
| 936 | + $query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY); |
|
| 937 | + $result = $query->execute(); |
|
| 938 | + |
|
| 939 | + while ($row = $result->fetch()) { |
|
| 940 | + $objects[] = [ |
|
| 941 | + 'id' => $row['id'], |
|
| 942 | + 'uri' => $row['uri'], |
|
| 943 | + 'lastmodified' => $row['lastmodified'], |
|
| 944 | + 'etag' => '"' . $row['etag'] . '"', |
|
| 945 | + 'calendarid' => $row['calendarid'], |
|
| 946 | + 'size' => (int)$row['size'], |
|
| 947 | + 'calendardata' => $this->readBlob($row['calendardata']), |
|
| 948 | + 'component' => strtolower($row['componenttype']), |
|
| 949 | + 'classification' => (int)$row['classification'] |
|
| 950 | + ]; |
|
| 951 | + } |
|
| 952 | + $result->closeCursor(); |
|
| 953 | + } |
|
| 954 | + return $objects; |
|
| 955 | + } |
|
| 956 | + |
|
| 957 | + /** |
|
| 958 | + * Creates a new calendar object. |
|
| 959 | + * |
|
| 960 | + * The object uri is only the basename, or filename and not a full path. |
|
| 961 | + * |
|
| 962 | + * It is possible return an etag from this function, which will be used in |
|
| 963 | + * the response to this PUT request. Note that the ETag must be surrounded |
|
| 964 | + * by double-quotes. |
|
| 965 | + * |
|
| 966 | + * However, you should only really return this ETag if you don't mangle the |
|
| 967 | + * calendar-data. If the result of a subsequent GET to this object is not |
|
| 968 | + * the exact same as this request body, you should omit the ETag. |
|
| 969 | + * |
|
| 970 | + * @param mixed $calendarId |
|
| 971 | + * @param string $objectUri |
|
| 972 | + * @param string $calendarData |
|
| 973 | + * @return string |
|
| 974 | + */ |
|
| 975 | + function createCalendarObject($calendarId, $objectUri, $calendarData) { |
|
| 976 | + $extraData = $this->getDenormalizedData($calendarData); |
|
| 977 | + |
|
| 978 | + $q = $this->db->getQueryBuilder(); |
|
| 979 | + $q->select($q->createFunction('COUNT(*)')) |
|
| 980 | + ->from('calendarobjects') |
|
| 981 | + ->where($q->expr()->eq('calendarid', $q->createNamedParameter($calendarId))) |
|
| 982 | + ->andWhere($q->expr()->eq('uid', $q->createNamedParameter($extraData['uid']))); |
|
| 983 | + |
|
| 984 | + $result = $q->execute(); |
|
| 985 | + $count = (int) $result->fetchColumn(); |
|
| 986 | + $result->closeCursor(); |
|
| 987 | + |
|
| 988 | + if ($count !== 0) { |
|
| 989 | + throw new \Sabre\DAV\Exception\BadRequest('Calendar object with uid already exists in this calendar collection.'); |
|
| 990 | + } |
|
| 991 | + |
|
| 992 | + $query = $this->db->getQueryBuilder(); |
|
| 993 | + $query->insert('calendarobjects') |
|
| 994 | + ->values([ |
|
| 995 | + 'calendarid' => $query->createNamedParameter($calendarId), |
|
| 996 | + 'uri' => $query->createNamedParameter($objectUri), |
|
| 997 | + 'calendardata' => $query->createNamedParameter($calendarData, IQueryBuilder::PARAM_LOB), |
|
| 998 | + 'lastmodified' => $query->createNamedParameter(time()), |
|
| 999 | + 'etag' => $query->createNamedParameter($extraData['etag']), |
|
| 1000 | + 'size' => $query->createNamedParameter($extraData['size']), |
|
| 1001 | + 'componenttype' => $query->createNamedParameter($extraData['componentType']), |
|
| 1002 | + 'firstoccurence' => $query->createNamedParameter($extraData['firstOccurence']), |
|
| 1003 | + 'lastoccurence' => $query->createNamedParameter($extraData['lastOccurence']), |
|
| 1004 | + 'classification' => $query->createNamedParameter($extraData['classification']), |
|
| 1005 | + 'uid' => $query->createNamedParameter($extraData['uid']), |
|
| 1006 | + ]) |
|
| 1007 | + ->execute(); |
|
| 1008 | + |
|
| 1009 | + $this->updateProperties($calendarId, $objectUri, $calendarData); |
|
| 1010 | + |
|
| 1011 | + $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', new GenericEvent( |
|
| 1012 | + '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', |
|
| 1013 | + [ |
|
| 1014 | + 'calendarId' => $calendarId, |
|
| 1015 | + 'calendarData' => $this->getCalendarById($calendarId), |
|
| 1016 | + 'shares' => $this->getShares($calendarId), |
|
| 1017 | + 'objectData' => $this->getCalendarObject($calendarId, $objectUri), |
|
| 1018 | + ] |
|
| 1019 | + )); |
|
| 1020 | + $this->addChange($calendarId, $objectUri, 1); |
|
| 1021 | + |
|
| 1022 | + return '"' . $extraData['etag'] . '"'; |
|
| 1023 | + } |
|
| 1024 | + |
|
| 1025 | + /** |
|
| 1026 | + * Updates an existing calendarobject, based on it's uri. |
|
| 1027 | + * |
|
| 1028 | + * The object uri is only the basename, or filename and not a full path. |
|
| 1029 | + * |
|
| 1030 | + * It is possible return an etag from this function, which will be used in |
|
| 1031 | + * the response to this PUT request. Note that the ETag must be surrounded |
|
| 1032 | + * by double-quotes. |
|
| 1033 | + * |
|
| 1034 | + * However, you should only really return this ETag if you don't mangle the |
|
| 1035 | + * calendar-data. If the result of a subsequent GET to this object is not |
|
| 1036 | + * the exact same as this request body, you should omit the ETag. |
|
| 1037 | + * |
|
| 1038 | + * @param mixed $calendarId |
|
| 1039 | + * @param string $objectUri |
|
| 1040 | + * @param string $calendarData |
|
| 1041 | + * @return string |
|
| 1042 | + */ |
|
| 1043 | + function updateCalendarObject($calendarId, $objectUri, $calendarData) { |
|
| 1044 | + $extraData = $this->getDenormalizedData($calendarData); |
|
| 1045 | + |
|
| 1046 | + $query = $this->db->getQueryBuilder(); |
|
| 1047 | + $query->update('calendarobjects') |
|
| 1048 | + ->set('calendardata', $query->createNamedParameter($calendarData, IQueryBuilder::PARAM_LOB)) |
|
| 1049 | + ->set('lastmodified', $query->createNamedParameter(time())) |
|
| 1050 | + ->set('etag', $query->createNamedParameter($extraData['etag'])) |
|
| 1051 | + ->set('size', $query->createNamedParameter($extraData['size'])) |
|
| 1052 | + ->set('componenttype', $query->createNamedParameter($extraData['componentType'])) |
|
| 1053 | + ->set('firstoccurence', $query->createNamedParameter($extraData['firstOccurence'])) |
|
| 1054 | + ->set('lastoccurence', $query->createNamedParameter($extraData['lastOccurence'])) |
|
| 1055 | + ->set('classification', $query->createNamedParameter($extraData['classification'])) |
|
| 1056 | + ->set('uid', $query->createNamedParameter($extraData['uid'])) |
|
| 1057 | + ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))) |
|
| 1058 | + ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri))) |
|
| 1059 | + ->execute(); |
|
| 1060 | + |
|
| 1061 | + $this->updateProperties($calendarId, $objectUri, $calendarData); |
|
| 1062 | + |
|
| 1063 | + $data = $this->getCalendarObject($calendarId, $objectUri); |
|
| 1064 | + if (is_array($data)) { |
|
| 1065 | + $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', new GenericEvent( |
|
| 1066 | + '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', |
|
| 1067 | + [ |
|
| 1068 | + 'calendarId' => $calendarId, |
|
| 1069 | + 'calendarData' => $this->getCalendarById($calendarId), |
|
| 1070 | + 'shares' => $this->getShares($calendarId), |
|
| 1071 | + 'objectData' => $data, |
|
| 1072 | + ] |
|
| 1073 | + )); |
|
| 1074 | + } |
|
| 1075 | + $this->addChange($calendarId, $objectUri, 2); |
|
| 1076 | + |
|
| 1077 | + return '"' . $extraData['etag'] . '"'; |
|
| 1078 | + } |
|
| 1079 | + |
|
| 1080 | + /** |
|
| 1081 | + * @param int $calendarObjectId |
|
| 1082 | + * @param int $classification |
|
| 1083 | + */ |
|
| 1084 | + public function setClassification($calendarObjectId, $classification) { |
|
| 1085 | + if (!in_array($classification, [ |
|
| 1086 | + self::CLASSIFICATION_PUBLIC, self::CLASSIFICATION_PRIVATE, self::CLASSIFICATION_CONFIDENTIAL |
|
| 1087 | + ])) { |
|
| 1088 | + throw new \InvalidArgumentException(); |
|
| 1089 | + } |
|
| 1090 | + $query = $this->db->getQueryBuilder(); |
|
| 1091 | + $query->update('calendarobjects') |
|
| 1092 | + ->set('classification', $query->createNamedParameter($classification)) |
|
| 1093 | + ->where($query->expr()->eq('id', $query->createNamedParameter($calendarObjectId))) |
|
| 1094 | + ->execute(); |
|
| 1095 | + } |
|
| 1096 | + |
|
| 1097 | + /** |
|
| 1098 | + * Deletes an existing calendar object. |
|
| 1099 | + * |
|
| 1100 | + * The object uri is only the basename, or filename and not a full path. |
|
| 1101 | + * |
|
| 1102 | + * @param mixed $calendarId |
|
| 1103 | + * @param string $objectUri |
|
| 1104 | + * @return void |
|
| 1105 | + */ |
|
| 1106 | + function deleteCalendarObject($calendarId, $objectUri) { |
|
| 1107 | + $data = $this->getCalendarObject($calendarId, $objectUri); |
|
| 1108 | + if (is_array($data)) { |
|
| 1109 | + $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', new GenericEvent( |
|
| 1110 | + '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', |
|
| 1111 | + [ |
|
| 1112 | + 'calendarId' => $calendarId, |
|
| 1113 | + 'calendarData' => $this->getCalendarById($calendarId), |
|
| 1114 | + 'shares' => $this->getShares($calendarId), |
|
| 1115 | + 'objectData' => $data, |
|
| 1116 | + ] |
|
| 1117 | + )); |
|
| 1118 | + } |
|
| 1119 | + |
|
| 1120 | + $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ? AND `uri` = ?'); |
|
| 1121 | + $stmt->execute([$calendarId, $objectUri]); |
|
| 1122 | + |
|
| 1123 | + $this->purgeProperties($calendarId, $data['id']); |
|
| 1124 | + |
|
| 1125 | + $this->addChange($calendarId, $objectUri, 3); |
|
| 1126 | + } |
|
| 1127 | + |
|
| 1128 | + /** |
|
| 1129 | + * Performs a calendar-query on the contents of this calendar. |
|
| 1130 | + * |
|
| 1131 | + * The calendar-query is defined in RFC4791 : CalDAV. Using the |
|
| 1132 | + * calendar-query it is possible for a client to request a specific set of |
|
| 1133 | + * object, based on contents of iCalendar properties, date-ranges and |
|
| 1134 | + * iCalendar component types (VTODO, VEVENT). |
|
| 1135 | + * |
|
| 1136 | + * This method should just return a list of (relative) urls that match this |
|
| 1137 | + * query. |
|
| 1138 | + * |
|
| 1139 | + * The list of filters are specified as an array. The exact array is |
|
| 1140 | + * documented by Sabre\CalDAV\CalendarQueryParser. |
|
| 1141 | + * |
|
| 1142 | + * Note that it is extremely likely that getCalendarObject for every path |
|
| 1143 | + * returned from this method will be called almost immediately after. You |
|
| 1144 | + * may want to anticipate this to speed up these requests. |
|
| 1145 | + * |
|
| 1146 | + * This method provides a default implementation, which parses *all* the |
|
| 1147 | + * iCalendar objects in the specified calendar. |
|
| 1148 | + * |
|
| 1149 | + * This default may well be good enough for personal use, and calendars |
|
| 1150 | + * that aren't very large. But if you anticipate high usage, big calendars |
|
| 1151 | + * or high loads, you are strongly advised to optimize certain paths. |
|
| 1152 | + * |
|
| 1153 | + * The best way to do so is override this method and to optimize |
|
| 1154 | + * specifically for 'common filters'. |
|
| 1155 | + * |
|
| 1156 | + * Requests that are extremely common are: |
|
| 1157 | + * * requests for just VEVENTS |
|
| 1158 | + * * requests for just VTODO |
|
| 1159 | + * * requests with a time-range-filter on either VEVENT or VTODO. |
|
| 1160 | + * |
|
| 1161 | + * ..and combinations of these requests. It may not be worth it to try to |
|
| 1162 | + * handle every possible situation and just rely on the (relatively |
|
| 1163 | + * easy to use) CalendarQueryValidator to handle the rest. |
|
| 1164 | + * |
|
| 1165 | + * Note that especially time-range-filters may be difficult to parse. A |
|
| 1166 | + * time-range filter specified on a VEVENT must for instance also handle |
|
| 1167 | + * recurrence rules correctly. |
|
| 1168 | + * A good example of how to interprete all these filters can also simply |
|
| 1169 | + * be found in Sabre\CalDAV\CalendarQueryFilter. This class is as correct |
|
| 1170 | + * as possible, so it gives you a good idea on what type of stuff you need |
|
| 1171 | + * to think of. |
|
| 1172 | + * |
|
| 1173 | + * @param mixed $calendarId |
|
| 1174 | + * @param array $filters |
|
| 1175 | + * @return array |
|
| 1176 | + */ |
|
| 1177 | + function calendarQuery($calendarId, array $filters) { |
|
| 1178 | + $componentType = null; |
|
| 1179 | + $requirePostFilter = true; |
|
| 1180 | + $timeRange = null; |
|
| 1181 | + |
|
| 1182 | + // if no filters were specified, we don't need to filter after a query |
|
| 1183 | + if (!$filters['prop-filters'] && !$filters['comp-filters']) { |
|
| 1184 | + $requirePostFilter = false; |
|
| 1185 | + } |
|
| 1186 | + |
|
| 1187 | + // Figuring out if there's a component filter |
|
| 1188 | + if (count($filters['comp-filters']) > 0 && !$filters['comp-filters'][0]['is-not-defined']) { |
|
| 1189 | + $componentType = $filters['comp-filters'][0]['name']; |
|
| 1190 | + |
|
| 1191 | + // Checking if we need post-filters |
|
| 1192 | + if (!$filters['prop-filters'] && !$filters['comp-filters'][0]['comp-filters'] && !$filters['comp-filters'][0]['time-range'] && !$filters['comp-filters'][0]['prop-filters']) { |
|
| 1193 | + $requirePostFilter = false; |
|
| 1194 | + } |
|
| 1195 | + // There was a time-range filter |
|
| 1196 | + if ($componentType === 'VEVENT' && isset($filters['comp-filters'][0]['time-range'])) { |
|
| 1197 | + $timeRange = $filters['comp-filters'][0]['time-range']; |
|
| 1198 | + |
|
| 1199 | + // If start time OR the end time is not specified, we can do a |
|
| 1200 | + // 100% accurate mysql query. |
|
| 1201 | + if (!$filters['prop-filters'] && !$filters['comp-filters'][0]['comp-filters'] && !$filters['comp-filters'][0]['prop-filters'] && (!$timeRange['start'] || !$timeRange['end'])) { |
|
| 1202 | + $requirePostFilter = false; |
|
| 1203 | + } |
|
| 1204 | + } |
|
| 1205 | + |
|
| 1206 | + } |
|
| 1207 | + $columns = ['uri']; |
|
| 1208 | + if ($requirePostFilter) { |
|
| 1209 | + $columns = ['uri', 'calendardata']; |
|
| 1210 | + } |
|
| 1211 | + $query = $this->db->getQueryBuilder(); |
|
| 1212 | + $query->select($columns) |
|
| 1213 | + ->from('calendarobjects') |
|
| 1214 | + ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))); |
|
| 1215 | + |
|
| 1216 | + if ($componentType) { |
|
| 1217 | + $query->andWhere($query->expr()->eq('componenttype', $query->createNamedParameter($componentType))); |
|
| 1218 | + } |
|
| 1219 | + |
|
| 1220 | + if ($timeRange && $timeRange['start']) { |
|
| 1221 | + $query->andWhere($query->expr()->gt('lastoccurence', $query->createNamedParameter($timeRange['start']->getTimeStamp()))); |
|
| 1222 | + } |
|
| 1223 | + if ($timeRange && $timeRange['end']) { |
|
| 1224 | + $query->andWhere($query->expr()->lt('firstoccurence', $query->createNamedParameter($timeRange['end']->getTimeStamp()))); |
|
| 1225 | + } |
|
| 1226 | + |
|
| 1227 | + $stmt = $query->execute(); |
|
| 1228 | + |
|
| 1229 | + $result = []; |
|
| 1230 | + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 1231 | + if ($requirePostFilter) { |
|
| 1232 | + // validateFilterForObject will parse the calendar data |
|
| 1233 | + // catch parsing errors |
|
| 1234 | + try { |
|
| 1235 | + $matches = $this->validateFilterForObject($row, $filters); |
|
| 1236 | + } catch(ParseException $ex) { |
|
| 1237 | + $this->logger->logException($ex, [ |
|
| 1238 | + 'app' => 'dav', |
|
| 1239 | + 'message' => 'Caught parsing exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri'] |
|
| 1240 | + ]); |
|
| 1241 | + continue; |
|
| 1242 | + } catch (InvalidDataException $ex) { |
|
| 1243 | + $this->logger->logException($ex, [ |
|
| 1244 | + 'app' => 'dav', |
|
| 1245 | + 'message' => 'Caught invalid data exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri'] |
|
| 1246 | + ]); |
|
| 1247 | + continue; |
|
| 1248 | + } |
|
| 1249 | + |
|
| 1250 | + if (!$matches) { |
|
| 1251 | + continue; |
|
| 1252 | + } |
|
| 1253 | + } |
|
| 1254 | + $result[] = $row['uri']; |
|
| 1255 | + } |
|
| 1256 | + |
|
| 1257 | + return $result; |
|
| 1258 | + } |
|
| 1259 | + |
|
| 1260 | + /** |
|
| 1261 | + * custom Nextcloud search extension for CalDAV |
|
| 1262 | + * |
|
| 1263 | + * @param string $principalUri |
|
| 1264 | + * @param array $filters |
|
| 1265 | + * @param integer|null $limit |
|
| 1266 | + * @param integer|null $offset |
|
| 1267 | + * @return array |
|
| 1268 | + */ |
|
| 1269 | + public function calendarSearch($principalUri, array $filters, $limit=null, $offset=null) { |
|
| 1270 | + $calendars = $this->getCalendarsForUser($principalUri); |
|
| 1271 | + $ownCalendars = []; |
|
| 1272 | + $sharedCalendars = []; |
|
| 1273 | + |
|
| 1274 | + $uriMapper = []; |
|
| 1275 | + |
|
| 1276 | + foreach($calendars as $calendar) { |
|
| 1277 | + if ($calendar['{http://owncloud.org/ns}owner-principal'] === $principalUri) { |
|
| 1278 | + $ownCalendars[] = $calendar['id']; |
|
| 1279 | + } else { |
|
| 1280 | + $sharedCalendars[] = $calendar['id']; |
|
| 1281 | + } |
|
| 1282 | + $uriMapper[$calendar['id']] = $calendar['uri']; |
|
| 1283 | + } |
|
| 1284 | + if (count($ownCalendars) === 0 && count($sharedCalendars) === 0) { |
|
| 1285 | + return []; |
|
| 1286 | + } |
|
| 1287 | + |
|
| 1288 | + $query = $this->db->getQueryBuilder(); |
|
| 1289 | + // Calendar id expressions |
|
| 1290 | + $calendarExpressions = []; |
|
| 1291 | + foreach($ownCalendars as $id) { |
|
| 1292 | + $calendarExpressions[] = $query->expr() |
|
| 1293 | + ->eq('c.calendarid', $query->createNamedParameter($id)); |
|
| 1294 | + } |
|
| 1295 | + foreach($sharedCalendars as $id) { |
|
| 1296 | + $calendarExpressions[] = $query->expr()->andX( |
|
| 1297 | + $query->expr()->eq('c.calendarid', |
|
| 1298 | + $query->createNamedParameter($id)), |
|
| 1299 | + $query->expr()->eq('c.classification', |
|
| 1300 | + $query->createNamedParameter(self::CLASSIFICATION_PUBLIC)) |
|
| 1301 | + ); |
|
| 1302 | + } |
|
| 1303 | + |
|
| 1304 | + if (count($calendarExpressions) === 1) { |
|
| 1305 | + $calExpr = $calendarExpressions[0]; |
|
| 1306 | + } else { |
|
| 1307 | + $calExpr = call_user_func_array([$query->expr(), 'orX'], $calendarExpressions); |
|
| 1308 | + } |
|
| 1309 | + |
|
| 1310 | + // Component expressions |
|
| 1311 | + $compExpressions = []; |
|
| 1312 | + foreach($filters['comps'] as $comp) { |
|
| 1313 | + $compExpressions[] = $query->expr() |
|
| 1314 | + ->eq('c.componenttype', $query->createNamedParameter($comp)); |
|
| 1315 | + } |
|
| 1316 | + |
|
| 1317 | + if (count($compExpressions) === 1) { |
|
| 1318 | + $compExpr = $compExpressions[0]; |
|
| 1319 | + } else { |
|
| 1320 | + $compExpr = call_user_func_array([$query->expr(), 'orX'], $compExpressions); |
|
| 1321 | + } |
|
| 1322 | + |
|
| 1323 | + if (!isset($filters['props'])) { |
|
| 1324 | + $filters['props'] = []; |
|
| 1325 | + } |
|
| 1326 | + if (!isset($filters['params'])) { |
|
| 1327 | + $filters['params'] = []; |
|
| 1328 | + } |
|
| 1329 | + |
|
| 1330 | + $propParamExpressions = []; |
|
| 1331 | + foreach($filters['props'] as $prop) { |
|
| 1332 | + $propParamExpressions[] = $query->expr()->andX( |
|
| 1333 | + $query->expr()->eq('i.name', $query->createNamedParameter($prop)), |
|
| 1334 | + $query->expr()->isNull('i.parameter') |
|
| 1335 | + ); |
|
| 1336 | + } |
|
| 1337 | + foreach($filters['params'] as $param) { |
|
| 1338 | + $propParamExpressions[] = $query->expr()->andX( |
|
| 1339 | + $query->expr()->eq('i.name', $query->createNamedParameter($param['property'])), |
|
| 1340 | + $query->expr()->eq('i.parameter', $query->createNamedParameter($param['parameter'])) |
|
| 1341 | + ); |
|
| 1342 | + } |
|
| 1343 | + |
|
| 1344 | + if (count($propParamExpressions) === 1) { |
|
| 1345 | + $propParamExpr = $propParamExpressions[0]; |
|
| 1346 | + } else { |
|
| 1347 | + $propParamExpr = call_user_func_array([$query->expr(), 'orX'], $propParamExpressions); |
|
| 1348 | + } |
|
| 1349 | + |
|
| 1350 | + $query->select(['c.calendarid', 'c.uri']) |
|
| 1351 | + ->from($this->dbObjectPropertiesTable, 'i') |
|
| 1352 | + ->join('i', 'calendarobjects', 'c', $query->expr()->eq('i.objectid', 'c.id')) |
|
| 1353 | + ->where($calExpr) |
|
| 1354 | + ->andWhere($compExpr) |
|
| 1355 | + ->andWhere($propParamExpr) |
|
| 1356 | + ->andWhere($query->expr()->iLike('i.value', |
|
| 1357 | + $query->createNamedParameter('%'.$this->db->escapeLikeParameter($filters['search-term']).'%'))); |
|
| 1358 | + |
|
| 1359 | + if ($offset) { |
|
| 1360 | + $query->setFirstResult($offset); |
|
| 1361 | + } |
|
| 1362 | + if ($limit) { |
|
| 1363 | + $query->setMaxResults($limit); |
|
| 1364 | + } |
|
| 1365 | + |
|
| 1366 | + $stmt = $query->execute(); |
|
| 1367 | + |
|
| 1368 | + $result = []; |
|
| 1369 | + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 1370 | + $path = $uriMapper[$row['calendarid']] . '/' . $row['uri']; |
|
| 1371 | + if (!in_array($path, $result)) { |
|
| 1372 | + $result[] = $path; |
|
| 1373 | + } |
|
| 1374 | + } |
|
| 1375 | + |
|
| 1376 | + return $result; |
|
| 1377 | + } |
|
| 1378 | + |
|
| 1379 | + /** |
|
| 1380 | + * used for Nextcloud's calendar API |
|
| 1381 | + * |
|
| 1382 | + * @param array $calendarInfo |
|
| 1383 | + * @param string $pattern |
|
| 1384 | + * @param array $searchProperties |
|
| 1385 | + * @param array $options |
|
| 1386 | + * @param integer|null $limit |
|
| 1387 | + * @param integer|null $offset |
|
| 1388 | + * |
|
| 1389 | + * @return array |
|
| 1390 | + */ |
|
| 1391 | + public function search(array $calendarInfo, $pattern, array $searchProperties, |
|
| 1392 | + array $options, $limit, $offset) { |
|
| 1393 | + $outerQuery = $this->db->getQueryBuilder(); |
|
| 1394 | + $innerQuery = $this->db->getQueryBuilder(); |
|
| 1395 | + |
|
| 1396 | + $innerQuery->selectDistinct('op.objectid') |
|
| 1397 | + ->from($this->dbObjectPropertiesTable, 'op') |
|
| 1398 | + ->andWhere($innerQuery->expr()->eq('op.calendarid', |
|
| 1399 | + $outerQuery->createNamedParameter($calendarInfo['id']))); |
|
| 1400 | + |
|
| 1401 | + // only return public items for shared calendars for now |
|
| 1402 | + if ($calendarInfo['principaluri'] !== $calendarInfo['{http://owncloud.org/ns}owner-principal']) { |
|
| 1403 | + $innerQuery->andWhere($innerQuery->expr()->eq('c.classification', |
|
| 1404 | + $outerQuery->createNamedParameter(self::CLASSIFICATION_PUBLIC))); |
|
| 1405 | + } |
|
| 1406 | + |
|
| 1407 | + $or = $innerQuery->expr()->orX(); |
|
| 1408 | + foreach($searchProperties as $searchProperty) { |
|
| 1409 | + $or->add($innerQuery->expr()->eq('op.name', |
|
| 1410 | + $outerQuery->createNamedParameter($searchProperty))); |
|
| 1411 | + } |
|
| 1412 | + $innerQuery->andWhere($or); |
|
| 1413 | + |
|
| 1414 | + if ($pattern !== '') { |
|
| 1415 | + $innerQuery->andWhere($innerQuery->expr()->iLike('op.value', |
|
| 1416 | + $outerQuery->createNamedParameter('%' . |
|
| 1417 | + $this->db->escapeLikeParameter($pattern) . '%'))); |
|
| 1418 | + } |
|
| 1419 | + |
|
| 1420 | + $outerQuery->select('c.id', 'c.calendardata', 'c.componenttype', 'c.uid', 'c.uri') |
|
| 1421 | + ->from('calendarobjects', 'c'); |
|
| 1422 | + |
|
| 1423 | + if (isset($options['timerange'])) { |
|
| 1424 | + if (isset($options['timerange']['start'])) { |
|
| 1425 | + $outerQuery->andWhere($outerQuery->expr()->gt('lastoccurence', |
|
| 1426 | + $outerQuery->createNamedParameter($options['timerange']['start']->getTimeStamp))); |
|
| 1427 | + |
|
| 1428 | + } |
|
| 1429 | + if (isset($options['timerange']['end'])) { |
|
| 1430 | + $outerQuery->andWhere($outerQuery->expr()->lt('firstoccurence', |
|
| 1431 | + $outerQuery->createNamedParameter($options['timerange']['end']->getTimeStamp))); |
|
| 1432 | + } |
|
| 1433 | + } |
|
| 1434 | + |
|
| 1435 | + if (isset($options['types'])) { |
|
| 1436 | + $or = $outerQuery->expr()->orX(); |
|
| 1437 | + foreach($options['types'] as $type) { |
|
| 1438 | + $or->add($outerQuery->expr()->eq('componenttype', |
|
| 1439 | + $outerQuery->createNamedParameter($type))); |
|
| 1440 | + } |
|
| 1441 | + $outerQuery->andWhere($or); |
|
| 1442 | + } |
|
| 1443 | + |
|
| 1444 | + $outerQuery->andWhere($outerQuery->expr()->in('c.id', |
|
| 1445 | + $outerQuery->createFunction($innerQuery->getSQL()))); |
|
| 1446 | + |
|
| 1447 | + if ($offset) { |
|
| 1448 | + $outerQuery->setFirstResult($offset); |
|
| 1449 | + } |
|
| 1450 | + if ($limit) { |
|
| 1451 | + $outerQuery->setMaxResults($limit); |
|
| 1452 | + } |
|
| 1453 | + |
|
| 1454 | + $result = $outerQuery->execute(); |
|
| 1455 | + $calendarObjects = $result->fetchAll(); |
|
| 1456 | + |
|
| 1457 | + return array_map(function($o) { |
|
| 1458 | + $calendarData = Reader::read($o['calendardata']); |
|
| 1459 | + $comps = $calendarData->getComponents(); |
|
| 1460 | + $objects = []; |
|
| 1461 | + $timezones = []; |
|
| 1462 | + foreach($comps as $comp) { |
|
| 1463 | + if ($comp instanceof VTimeZone) { |
|
| 1464 | + $timezones[] = $comp; |
|
| 1465 | + } else { |
|
| 1466 | + $objects[] = $comp; |
|
| 1467 | + } |
|
| 1468 | + } |
|
| 1469 | + |
|
| 1470 | + return [ |
|
| 1471 | + 'id' => $o['id'], |
|
| 1472 | + 'type' => $o['componenttype'], |
|
| 1473 | + 'uid' => $o['uid'], |
|
| 1474 | + 'uri' => $o['uri'], |
|
| 1475 | + 'objects' => array_map(function($c) { |
|
| 1476 | + return $this->transformSearchData($c); |
|
| 1477 | + }, $objects), |
|
| 1478 | + 'timezones' => array_map(function($c) { |
|
| 1479 | + return $this->transformSearchData($c); |
|
| 1480 | + }, $timezones), |
|
| 1481 | + ]; |
|
| 1482 | + }, $calendarObjects); |
|
| 1483 | + } |
|
| 1484 | + |
|
| 1485 | + /** |
|
| 1486 | + * @param Component $comp |
|
| 1487 | + * @return array |
|
| 1488 | + */ |
|
| 1489 | + private function transformSearchData(Component $comp) { |
|
| 1490 | + $data = []; |
|
| 1491 | + /** @var Component[] $subComponents */ |
|
| 1492 | + $subComponents = $comp->getComponents(); |
|
| 1493 | + /** @var Property[] $properties */ |
|
| 1494 | + $properties = array_filter($comp->children(), function($c) { |
|
| 1495 | + return $c instanceof Property; |
|
| 1496 | + }); |
|
| 1497 | + $validationRules = $comp->getValidationRules(); |
|
| 1498 | + |
|
| 1499 | + foreach($subComponents as $subComponent) { |
|
| 1500 | + $name = $subComponent->name; |
|
| 1501 | + if (!isset($data[$name])) { |
|
| 1502 | + $data[$name] = []; |
|
| 1503 | + } |
|
| 1504 | + $data[$name][] = $this->transformSearchData($subComponent); |
|
| 1505 | + } |
|
| 1506 | + |
|
| 1507 | + foreach($properties as $property) { |
|
| 1508 | + $name = $property->name; |
|
| 1509 | + if (!isset($validationRules[$name])) { |
|
| 1510 | + $validationRules[$name] = '*'; |
|
| 1511 | + } |
|
| 1512 | + |
|
| 1513 | + $rule = $validationRules[$property->name]; |
|
| 1514 | + if ($rule === '+' || $rule === '*') { // multiple |
|
| 1515 | + if (!isset($data[$name])) { |
|
| 1516 | + $data[$name] = []; |
|
| 1517 | + } |
|
| 1518 | + |
|
| 1519 | + $data[$name][] = $this->transformSearchProperty($property); |
|
| 1520 | + } else { // once |
|
| 1521 | + $data[$name] = $this->transformSearchProperty($property); |
|
| 1522 | + } |
|
| 1523 | + } |
|
| 1524 | + |
|
| 1525 | + return $data; |
|
| 1526 | + } |
|
| 1527 | + |
|
| 1528 | + /** |
|
| 1529 | + * @param Property $prop |
|
| 1530 | + * @return array |
|
| 1531 | + */ |
|
| 1532 | + private function transformSearchProperty(Property $prop) { |
|
| 1533 | + // No need to check Date, as it extends DateTime |
|
| 1534 | + if ($prop instanceof Property\ICalendar\DateTime) { |
|
| 1535 | + $value = $prop->getDateTime(); |
|
| 1536 | + } else { |
|
| 1537 | + $value = $prop->getValue(); |
|
| 1538 | + } |
|
| 1539 | + |
|
| 1540 | + return [ |
|
| 1541 | + $value, |
|
| 1542 | + $prop->parameters() |
|
| 1543 | + ]; |
|
| 1544 | + } |
|
| 1545 | + |
|
| 1546 | + /** |
|
| 1547 | + * Searches through all of a users calendars and calendar objects to find |
|
| 1548 | + * an object with a specific UID. |
|
| 1549 | + * |
|
| 1550 | + * This method should return the path to this object, relative to the |
|
| 1551 | + * calendar home, so this path usually only contains two parts: |
|
| 1552 | + * |
|
| 1553 | + * calendarpath/objectpath.ics |
|
| 1554 | + * |
|
| 1555 | + * If the uid is not found, return null. |
|
| 1556 | + * |
|
| 1557 | + * This method should only consider * objects that the principal owns, so |
|
| 1558 | + * any calendars owned by other principals that also appear in this |
|
| 1559 | + * collection should be ignored. |
|
| 1560 | + * |
|
| 1561 | + * @param string $principalUri |
|
| 1562 | + * @param string $uid |
|
| 1563 | + * @return string|null |
|
| 1564 | + */ |
|
| 1565 | + function getCalendarObjectByUID($principalUri, $uid) { |
|
| 1566 | + |
|
| 1567 | + $query = $this->db->getQueryBuilder(); |
|
| 1568 | + $query->selectAlias('c.uri', 'calendaruri')->selectAlias('co.uri', 'objecturi') |
|
| 1569 | + ->from('calendarobjects', 'co') |
|
| 1570 | + ->leftJoin('co', 'calendars', 'c', $query->expr()->eq('co.calendarid', 'c.id')) |
|
| 1571 | + ->where($query->expr()->eq('c.principaluri', $query->createNamedParameter($principalUri))) |
|
| 1572 | + ->andWhere($query->expr()->eq('co.uid', $query->createNamedParameter($uid))); |
|
| 1573 | + |
|
| 1574 | + $stmt = $query->execute(); |
|
| 1575 | + |
|
| 1576 | + if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 1577 | + return $row['calendaruri'] . '/' . $row['objecturi']; |
|
| 1578 | + } |
|
| 1579 | + |
|
| 1580 | + return null; |
|
| 1581 | + } |
|
| 1582 | + |
|
| 1583 | + /** |
|
| 1584 | + * The getChanges method returns all the changes that have happened, since |
|
| 1585 | + * the specified syncToken in the specified calendar. |
|
| 1586 | + * |
|
| 1587 | + * This function should return an array, such as the following: |
|
| 1588 | + * |
|
| 1589 | + * [ |
|
| 1590 | + * 'syncToken' => 'The current synctoken', |
|
| 1591 | + * 'added' => [ |
|
| 1592 | + * 'new.txt', |
|
| 1593 | + * ], |
|
| 1594 | + * 'modified' => [ |
|
| 1595 | + * 'modified.txt', |
|
| 1596 | + * ], |
|
| 1597 | + * 'deleted' => [ |
|
| 1598 | + * 'foo.php.bak', |
|
| 1599 | + * 'old.txt' |
|
| 1600 | + * ] |
|
| 1601 | + * ); |
|
| 1602 | + * |
|
| 1603 | + * The returned syncToken property should reflect the *current* syncToken |
|
| 1604 | + * of the calendar, as reported in the {http://sabredav.org/ns}sync-token |
|
| 1605 | + * property This is * needed here too, to ensure the operation is atomic. |
|
| 1606 | + * |
|
| 1607 | + * If the $syncToken argument is specified as null, this is an initial |
|
| 1608 | + * sync, and all members should be reported. |
|
| 1609 | + * |
|
| 1610 | + * The modified property is an array of nodenames that have changed since |
|
| 1611 | + * the last token. |
|
| 1612 | + * |
|
| 1613 | + * The deleted property is an array with nodenames, that have been deleted |
|
| 1614 | + * from collection. |
|
| 1615 | + * |
|
| 1616 | + * The $syncLevel argument is basically the 'depth' of the report. If it's |
|
| 1617 | + * 1, you only have to report changes that happened only directly in |
|
| 1618 | + * immediate descendants. If it's 2, it should also include changes from |
|
| 1619 | + * the nodes below the child collections. (grandchildren) |
|
| 1620 | + * |
|
| 1621 | + * The $limit argument allows a client to specify how many results should |
|
| 1622 | + * be returned at most. If the limit is not specified, it should be treated |
|
| 1623 | + * as infinite. |
|
| 1624 | + * |
|
| 1625 | + * If the limit (infinite or not) is higher than you're willing to return, |
|
| 1626 | + * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception. |
|
| 1627 | + * |
|
| 1628 | + * If the syncToken is expired (due to data cleanup) or unknown, you must |
|
| 1629 | + * return null. |
|
| 1630 | + * |
|
| 1631 | + * The limit is 'suggestive'. You are free to ignore it. |
|
| 1632 | + * |
|
| 1633 | + * @param string $calendarId |
|
| 1634 | + * @param string $syncToken |
|
| 1635 | + * @param int $syncLevel |
|
| 1636 | + * @param int $limit |
|
| 1637 | + * @return array |
|
| 1638 | + */ |
|
| 1639 | + function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) { |
|
| 1640 | + // Current synctoken |
|
| 1641 | + $stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*calendars` WHERE `id` = ?'); |
|
| 1642 | + $stmt->execute([ $calendarId ]); |
|
| 1643 | + $currentToken = $stmt->fetchColumn(0); |
|
| 1644 | + |
|
| 1645 | + if (is_null($currentToken)) { |
|
| 1646 | + return null; |
|
| 1647 | + } |
|
| 1648 | + |
|
| 1649 | + $result = [ |
|
| 1650 | + 'syncToken' => $currentToken, |
|
| 1651 | + 'added' => [], |
|
| 1652 | + 'modified' => [], |
|
| 1653 | + 'deleted' => [], |
|
| 1654 | + ]; |
|
| 1655 | + |
|
| 1656 | + if ($syncToken) { |
|
| 1657 | + |
|
| 1658 | + $query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? ORDER BY `synctoken`"; |
|
| 1659 | + if ($limit>0) { |
|
| 1660 | + $query.= " LIMIT " . (int)$limit; |
|
| 1661 | + } |
|
| 1662 | + |
|
| 1663 | + // Fetching all changes |
|
| 1664 | + $stmt = $this->db->prepare($query); |
|
| 1665 | + $stmt->execute([$syncToken, $currentToken, $calendarId]); |
|
| 1666 | + |
|
| 1667 | + $changes = []; |
|
| 1668 | + |
|
| 1669 | + // This loop ensures that any duplicates are overwritten, only the |
|
| 1670 | + // last change on a node is relevant. |
|
| 1671 | + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 1672 | + |
|
| 1673 | + $changes[$row['uri']] = $row['operation']; |
|
| 1674 | + |
|
| 1675 | + } |
|
| 1676 | + |
|
| 1677 | + foreach($changes as $uri => $operation) { |
|
| 1678 | + |
|
| 1679 | + switch($operation) { |
|
| 1680 | + case 1 : |
|
| 1681 | + $result['added'][] = $uri; |
|
| 1682 | + break; |
|
| 1683 | + case 2 : |
|
| 1684 | + $result['modified'][] = $uri; |
|
| 1685 | + break; |
|
| 1686 | + case 3 : |
|
| 1687 | + $result['deleted'][] = $uri; |
|
| 1688 | + break; |
|
| 1689 | + } |
|
| 1690 | + |
|
| 1691 | + } |
|
| 1692 | + } else { |
|
| 1693 | + // No synctoken supplied, this is the initial sync. |
|
| 1694 | + $query = "SELECT `uri` FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ?"; |
|
| 1695 | + $stmt = $this->db->prepare($query); |
|
| 1696 | + $stmt->execute([$calendarId]); |
|
| 1697 | + |
|
| 1698 | + $result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN); |
|
| 1699 | + } |
|
| 1700 | + return $result; |
|
| 1701 | + |
|
| 1702 | + } |
|
| 1703 | + |
|
| 1704 | + /** |
|
| 1705 | + * Returns a list of subscriptions for a principal. |
|
| 1706 | + * |
|
| 1707 | + * Every subscription is an array with the following keys: |
|
| 1708 | + * * id, a unique id that will be used by other functions to modify the |
|
| 1709 | + * subscription. This can be the same as the uri or a database key. |
|
| 1710 | + * * uri. This is just the 'base uri' or 'filename' of the subscription. |
|
| 1711 | + * * principaluri. The owner of the subscription. Almost always the same as |
|
| 1712 | + * principalUri passed to this method. |
|
| 1713 | + * |
|
| 1714 | + * Furthermore, all the subscription info must be returned too: |
|
| 1715 | + * |
|
| 1716 | + * 1. {DAV:}displayname |
|
| 1717 | + * 2. {http://apple.com/ns/ical/}refreshrate |
|
| 1718 | + * 3. {http://calendarserver.org/ns/}subscribed-strip-todos (omit if todos |
|
| 1719 | + * should not be stripped). |
|
| 1720 | + * 4. {http://calendarserver.org/ns/}subscribed-strip-alarms (omit if alarms |
|
| 1721 | + * should not be stripped). |
|
| 1722 | + * 5. {http://calendarserver.org/ns/}subscribed-strip-attachments (omit if |
|
| 1723 | + * attachments should not be stripped). |
|
| 1724 | + * 6. {http://calendarserver.org/ns/}source (Must be a |
|
| 1725 | + * Sabre\DAV\Property\Href). |
|
| 1726 | + * 7. {http://apple.com/ns/ical/}calendar-color |
|
| 1727 | + * 8. {http://apple.com/ns/ical/}calendar-order |
|
| 1728 | + * 9. {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set |
|
| 1729 | + * (should just be an instance of |
|
| 1730 | + * Sabre\CalDAV\Property\SupportedCalendarComponentSet, with a bunch of |
|
| 1731 | + * default components). |
|
| 1732 | + * |
|
| 1733 | + * @param string $principalUri |
|
| 1734 | + * @return array |
|
| 1735 | + */ |
|
| 1736 | + function getSubscriptionsForUser($principalUri) { |
|
| 1737 | + $fields = array_values($this->subscriptionPropertyMap); |
|
| 1738 | + $fields[] = 'id'; |
|
| 1739 | + $fields[] = 'uri'; |
|
| 1740 | + $fields[] = 'source'; |
|
| 1741 | + $fields[] = 'principaluri'; |
|
| 1742 | + $fields[] = 'lastmodified'; |
|
| 1743 | + |
|
| 1744 | + $query = $this->db->getQueryBuilder(); |
|
| 1745 | + $query->select($fields) |
|
| 1746 | + ->from('calendarsubscriptions') |
|
| 1747 | + ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
|
| 1748 | + ->orderBy('calendarorder', 'asc'); |
|
| 1749 | + $stmt =$query->execute(); |
|
| 1750 | + |
|
| 1751 | + $subscriptions = []; |
|
| 1752 | + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 1753 | + |
|
| 1754 | + $subscription = [ |
|
| 1755 | + 'id' => $row['id'], |
|
| 1756 | + 'uri' => $row['uri'], |
|
| 1757 | + 'principaluri' => $row['principaluri'], |
|
| 1758 | + 'source' => $row['source'], |
|
| 1759 | + 'lastmodified' => $row['lastmodified'], |
|
| 1760 | + |
|
| 1761 | + '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']), |
|
| 1762 | + ]; |
|
| 1763 | + |
|
| 1764 | + foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) { |
|
| 1765 | + if (!is_null($row[$dbName])) { |
|
| 1766 | + $subscription[$xmlName] = $row[$dbName]; |
|
| 1767 | + } |
|
| 1768 | + } |
|
| 1769 | + |
|
| 1770 | + $subscriptions[] = $subscription; |
|
| 1771 | + |
|
| 1772 | + } |
|
| 1773 | + |
|
| 1774 | + return $subscriptions; |
|
| 1775 | + } |
|
| 1776 | + |
|
| 1777 | + /** |
|
| 1778 | + * Creates a new subscription for a principal. |
|
| 1779 | + * |
|
| 1780 | + * If the creation was a success, an id must be returned that can be used to reference |
|
| 1781 | + * this subscription in other methods, such as updateSubscription. |
|
| 1782 | + * |
|
| 1783 | + * @param string $principalUri |
|
| 1784 | + * @param string $uri |
|
| 1785 | + * @param array $properties |
|
| 1786 | + * @return mixed |
|
| 1787 | + */ |
|
| 1788 | + function createSubscription($principalUri, $uri, array $properties) { |
|
| 1789 | + |
|
| 1790 | + if (!isset($properties['{http://calendarserver.org/ns/}source'])) { |
|
| 1791 | + throw new Forbidden('The {http://calendarserver.org/ns/}source property is required when creating subscriptions'); |
|
| 1792 | + } |
|
| 1793 | + |
|
| 1794 | + $values = [ |
|
| 1795 | + 'principaluri' => $principalUri, |
|
| 1796 | + 'uri' => $uri, |
|
| 1797 | + 'source' => $properties['{http://calendarserver.org/ns/}source']->getHref(), |
|
| 1798 | + 'lastmodified' => time(), |
|
| 1799 | + ]; |
|
| 1800 | + |
|
| 1801 | + $propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments']; |
|
| 1802 | + |
|
| 1803 | + foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) { |
|
| 1804 | + if (array_key_exists($xmlName, $properties)) { |
|
| 1805 | + $values[$dbName] = $properties[$xmlName]; |
|
| 1806 | + if (in_array($dbName, $propertiesBoolean)) { |
|
| 1807 | + $values[$dbName] = true; |
|
| 1808 | + } |
|
| 1809 | + } |
|
| 1810 | + } |
|
| 1811 | + |
|
| 1812 | + $valuesToInsert = array(); |
|
| 1813 | + |
|
| 1814 | + $query = $this->db->getQueryBuilder(); |
|
| 1815 | + |
|
| 1816 | + foreach (array_keys($values) as $name) { |
|
| 1817 | + $valuesToInsert[$name] = $query->createNamedParameter($values[$name]); |
|
| 1818 | + } |
|
| 1819 | + |
|
| 1820 | + $query->insert('calendarsubscriptions') |
|
| 1821 | + ->values($valuesToInsert) |
|
| 1822 | + ->execute(); |
|
| 1823 | + |
|
| 1824 | + return $this->db->lastInsertId('*PREFIX*calendarsubscriptions'); |
|
| 1825 | + } |
|
| 1826 | + |
|
| 1827 | + /** |
|
| 1828 | + * Updates a subscription |
|
| 1829 | + * |
|
| 1830 | + * The list of mutations is stored in a Sabre\DAV\PropPatch object. |
|
| 1831 | + * To do the actual updates, you must tell this object which properties |
|
| 1832 | + * you're going to process with the handle() method. |
|
| 1833 | + * |
|
| 1834 | + * Calling the handle method is like telling the PropPatch object "I |
|
| 1835 | + * promise I can handle updating this property". |
|
| 1836 | + * |
|
| 1837 | + * Read the PropPatch documentation for more info and examples. |
|
| 1838 | + * |
|
| 1839 | + * @param mixed $subscriptionId |
|
| 1840 | + * @param PropPatch $propPatch |
|
| 1841 | + * @return void |
|
| 1842 | + */ |
|
| 1843 | + function updateSubscription($subscriptionId, PropPatch $propPatch) { |
|
| 1844 | + $supportedProperties = array_keys($this->subscriptionPropertyMap); |
|
| 1845 | + $supportedProperties[] = '{http://calendarserver.org/ns/}source'; |
|
| 1846 | + |
|
| 1847 | + /** |
|
| 1848 | + * @suppress SqlInjectionChecker |
|
| 1849 | + */ |
|
| 1850 | + $propPatch->handle($supportedProperties, function($mutations) use ($subscriptionId) { |
|
| 1851 | + |
|
| 1852 | + $newValues = []; |
|
| 1853 | + |
|
| 1854 | + foreach($mutations as $propertyName=>$propertyValue) { |
|
| 1855 | + if ($propertyName === '{http://calendarserver.org/ns/}source') { |
|
| 1856 | + $newValues['source'] = $propertyValue->getHref(); |
|
| 1857 | + } else { |
|
| 1858 | + $fieldName = $this->subscriptionPropertyMap[$propertyName]; |
|
| 1859 | + $newValues[$fieldName] = $propertyValue; |
|
| 1860 | + } |
|
| 1861 | + } |
|
| 1862 | + |
|
| 1863 | + $query = $this->db->getQueryBuilder(); |
|
| 1864 | + $query->update('calendarsubscriptions') |
|
| 1865 | + ->set('lastmodified', $query->createNamedParameter(time())); |
|
| 1866 | + foreach($newValues as $fieldName=>$value) { |
|
| 1867 | + $query->set($fieldName, $query->createNamedParameter($value)); |
|
| 1868 | + } |
|
| 1869 | + $query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId))) |
|
| 1870 | + ->execute(); |
|
| 1871 | + |
|
| 1872 | + return true; |
|
| 1873 | + |
|
| 1874 | + }); |
|
| 1875 | + } |
|
| 1876 | + |
|
| 1877 | + /** |
|
| 1878 | + * Deletes a subscription. |
|
| 1879 | + * |
|
| 1880 | + * @param mixed $subscriptionId |
|
| 1881 | + * @return void |
|
| 1882 | + */ |
|
| 1883 | + function deleteSubscription($subscriptionId) { |
|
| 1884 | + $query = $this->db->getQueryBuilder(); |
|
| 1885 | + $query->delete('calendarsubscriptions') |
|
| 1886 | + ->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId))) |
|
| 1887 | + ->execute(); |
|
| 1888 | + } |
|
| 1889 | + |
|
| 1890 | + /** |
|
| 1891 | + * Returns a single scheduling object for the inbox collection. |
|
| 1892 | + * |
|
| 1893 | + * The returned array should contain the following elements: |
|
| 1894 | + * * uri - A unique basename for the object. This will be used to |
|
| 1895 | + * construct a full uri. |
|
| 1896 | + * * calendardata - The iCalendar object |
|
| 1897 | + * * lastmodified - The last modification date. Can be an int for a unix |
|
| 1898 | + * timestamp, or a PHP DateTime object. |
|
| 1899 | + * * etag - A unique token that must change if the object changed. |
|
| 1900 | + * * size - The size of the object, in bytes. |
|
| 1901 | + * |
|
| 1902 | + * @param string $principalUri |
|
| 1903 | + * @param string $objectUri |
|
| 1904 | + * @return array |
|
| 1905 | + */ |
|
| 1906 | + function getSchedulingObject($principalUri, $objectUri) { |
|
| 1907 | + $query = $this->db->getQueryBuilder(); |
|
| 1908 | + $stmt = $query->select(['uri', 'calendardata', 'lastmodified', 'etag', 'size']) |
|
| 1909 | + ->from('schedulingobjects') |
|
| 1910 | + ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
|
| 1911 | + ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri))) |
|
| 1912 | + ->execute(); |
|
| 1913 | + |
|
| 1914 | + $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
|
| 1915 | + |
|
| 1916 | + if(!$row) { |
|
| 1917 | + return null; |
|
| 1918 | + } |
|
| 1919 | + |
|
| 1920 | + return [ |
|
| 1921 | + 'uri' => $row['uri'], |
|
| 1922 | + 'calendardata' => $row['calendardata'], |
|
| 1923 | + 'lastmodified' => $row['lastmodified'], |
|
| 1924 | + 'etag' => '"' . $row['etag'] . '"', |
|
| 1925 | + 'size' => (int)$row['size'], |
|
| 1926 | + ]; |
|
| 1927 | + } |
|
| 1928 | + |
|
| 1929 | + /** |
|
| 1930 | + * Returns all scheduling objects for the inbox collection. |
|
| 1931 | + * |
|
| 1932 | + * These objects should be returned as an array. Every item in the array |
|
| 1933 | + * should follow the same structure as returned from getSchedulingObject. |
|
| 1934 | + * |
|
| 1935 | + * The main difference is that 'calendardata' is optional. |
|
| 1936 | + * |
|
| 1937 | + * @param string $principalUri |
|
| 1938 | + * @return array |
|
| 1939 | + */ |
|
| 1940 | + function getSchedulingObjects($principalUri) { |
|
| 1941 | + $query = $this->db->getQueryBuilder(); |
|
| 1942 | + $stmt = $query->select(['uri', 'calendardata', 'lastmodified', 'etag', 'size']) |
|
| 1943 | + ->from('schedulingobjects') |
|
| 1944 | + ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
|
| 1945 | + ->execute(); |
|
| 1946 | + |
|
| 1947 | + $result = []; |
|
| 1948 | + foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { |
|
| 1949 | + $result[] = [ |
|
| 1950 | + 'calendardata' => $row['calendardata'], |
|
| 1951 | + 'uri' => $row['uri'], |
|
| 1952 | + 'lastmodified' => $row['lastmodified'], |
|
| 1953 | + 'etag' => '"' . $row['etag'] . '"', |
|
| 1954 | + 'size' => (int)$row['size'], |
|
| 1955 | + ]; |
|
| 1956 | + } |
|
| 1957 | + |
|
| 1958 | + return $result; |
|
| 1959 | + } |
|
| 1960 | + |
|
| 1961 | + /** |
|
| 1962 | + * Deletes a scheduling object from the inbox collection. |
|
| 1963 | + * |
|
| 1964 | + * @param string $principalUri |
|
| 1965 | + * @param string $objectUri |
|
| 1966 | + * @return void |
|
| 1967 | + */ |
|
| 1968 | + function deleteSchedulingObject($principalUri, $objectUri) { |
|
| 1969 | + $query = $this->db->getQueryBuilder(); |
|
| 1970 | + $query->delete('schedulingobjects') |
|
| 1971 | + ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
|
| 1972 | + ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri))) |
|
| 1973 | + ->execute(); |
|
| 1974 | + } |
|
| 1975 | + |
|
| 1976 | + /** |
|
| 1977 | + * Creates a new scheduling object. This should land in a users' inbox. |
|
| 1978 | + * |
|
| 1979 | + * @param string $principalUri |
|
| 1980 | + * @param string $objectUri |
|
| 1981 | + * @param string $objectData |
|
| 1982 | + * @return void |
|
| 1983 | + */ |
|
| 1984 | + function createSchedulingObject($principalUri, $objectUri, $objectData) { |
|
| 1985 | + $query = $this->db->getQueryBuilder(); |
|
| 1986 | + $query->insert('schedulingobjects') |
|
| 1987 | + ->values([ |
|
| 1988 | + 'principaluri' => $query->createNamedParameter($principalUri), |
|
| 1989 | + 'calendardata' => $query->createNamedParameter($objectData), |
|
| 1990 | + 'uri' => $query->createNamedParameter($objectUri), |
|
| 1991 | + 'lastmodified' => $query->createNamedParameter(time()), |
|
| 1992 | + 'etag' => $query->createNamedParameter(md5($objectData)), |
|
| 1993 | + 'size' => $query->createNamedParameter(strlen($objectData)) |
|
| 1994 | + ]) |
|
| 1995 | + ->execute(); |
|
| 1996 | + } |
|
| 1997 | + |
|
| 1998 | + /** |
|
| 1999 | + * Adds a change record to the calendarchanges table. |
|
| 2000 | + * |
|
| 2001 | + * @param mixed $calendarId |
|
| 2002 | + * @param string $objectUri |
|
| 2003 | + * @param int $operation 1 = add, 2 = modify, 3 = delete. |
|
| 2004 | + * @return void |
|
| 2005 | + */ |
|
| 2006 | + protected function addChange($calendarId, $objectUri, $operation) { |
|
| 2007 | + |
|
| 2008 | + $stmt = $this->db->prepare('INSERT INTO `*PREFIX*calendarchanges` (`uri`, `synctoken`, `calendarid`, `operation`) SELECT ?, `synctoken`, ?, ? FROM `*PREFIX*calendars` WHERE `id` = ?'); |
|
| 2009 | + $stmt->execute([ |
|
| 2010 | + $objectUri, |
|
| 2011 | + $calendarId, |
|
| 2012 | + $operation, |
|
| 2013 | + $calendarId |
|
| 2014 | + ]); |
|
| 2015 | + $stmt = $this->db->prepare('UPDATE `*PREFIX*calendars` SET `synctoken` = `synctoken` + 1 WHERE `id` = ?'); |
|
| 2016 | + $stmt->execute([ |
|
| 2017 | + $calendarId |
|
| 2018 | + ]); |
|
| 2019 | + |
|
| 2020 | + } |
|
| 2021 | + |
|
| 2022 | + /** |
|
| 2023 | + * Parses some information from calendar objects, used for optimized |
|
| 2024 | + * calendar-queries. |
|
| 2025 | + * |
|
| 2026 | + * Returns an array with the following keys: |
|
| 2027 | + * * etag - An md5 checksum of the object without the quotes. |
|
| 2028 | + * * size - Size of the object in bytes |
|
| 2029 | + * * componentType - VEVENT, VTODO or VJOURNAL |
|
| 2030 | + * * firstOccurence |
|
| 2031 | + * * lastOccurence |
|
| 2032 | + * * uid - value of the UID property |
|
| 2033 | + * |
|
| 2034 | + * @param string $calendarData |
|
| 2035 | + * @return array |
|
| 2036 | + */ |
|
| 2037 | + public function getDenormalizedData($calendarData) { |
|
| 2038 | + |
|
| 2039 | + $vObject = Reader::read($calendarData); |
|
| 2040 | + $componentType = null; |
|
| 2041 | + $component = null; |
|
| 2042 | + $firstOccurrence = null; |
|
| 2043 | + $lastOccurrence = null; |
|
| 2044 | + $uid = null; |
|
| 2045 | + $classification = self::CLASSIFICATION_PUBLIC; |
|
| 2046 | + foreach($vObject->getComponents() as $component) { |
|
| 2047 | + if ($component->name!=='VTIMEZONE') { |
|
| 2048 | + $componentType = $component->name; |
|
| 2049 | + $uid = (string)$component->UID; |
|
| 2050 | + break; |
|
| 2051 | + } |
|
| 2052 | + } |
|
| 2053 | + if (!$componentType) { |
|
| 2054 | + throw new \Sabre\DAV\Exception\BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component'); |
|
| 2055 | + } |
|
| 2056 | + if ($componentType === 'VEVENT' && $component->DTSTART) { |
|
| 2057 | + $firstOccurrence = $component->DTSTART->getDateTime()->getTimeStamp(); |
|
| 2058 | + // Finding the last occurrence is a bit harder |
|
| 2059 | + if (!isset($component->RRULE)) { |
|
| 2060 | + if (isset($component->DTEND)) { |
|
| 2061 | + $lastOccurrence = $component->DTEND->getDateTime()->getTimeStamp(); |
|
| 2062 | + } elseif (isset($component->DURATION)) { |
|
| 2063 | + $endDate = clone $component->DTSTART->getDateTime(); |
|
| 2064 | + $endDate->add(DateTimeParser::parse($component->DURATION->getValue())); |
|
| 2065 | + $lastOccurrence = $endDate->getTimeStamp(); |
|
| 2066 | + } elseif (!$component->DTSTART->hasTime()) { |
|
| 2067 | + $endDate = clone $component->DTSTART->getDateTime(); |
|
| 2068 | + $endDate->modify('+1 day'); |
|
| 2069 | + $lastOccurrence = $endDate->getTimeStamp(); |
|
| 2070 | + } else { |
|
| 2071 | + $lastOccurrence = $firstOccurrence; |
|
| 2072 | + } |
|
| 2073 | + } else { |
|
| 2074 | + $it = new EventIterator($vObject, (string)$component->UID); |
|
| 2075 | + $maxDate = new \DateTime(self::MAX_DATE); |
|
| 2076 | + if ($it->isInfinite()) { |
|
| 2077 | + $lastOccurrence = $maxDate->getTimestamp(); |
|
| 2078 | + } else { |
|
| 2079 | + $end = $it->getDtEnd(); |
|
| 2080 | + while($it->valid() && $end < $maxDate) { |
|
| 2081 | + $end = $it->getDtEnd(); |
|
| 2082 | + $it->next(); |
|
| 2083 | + |
|
| 2084 | + } |
|
| 2085 | + $lastOccurrence = $end->getTimestamp(); |
|
| 2086 | + } |
|
| 2087 | + |
|
| 2088 | + } |
|
| 2089 | + } |
|
| 2090 | + |
|
| 2091 | + if ($component->CLASS) { |
|
| 2092 | + $classification = CalDavBackend::CLASSIFICATION_PRIVATE; |
|
| 2093 | + switch ($component->CLASS->getValue()) { |
|
| 2094 | + case 'PUBLIC': |
|
| 2095 | + $classification = CalDavBackend::CLASSIFICATION_PUBLIC; |
|
| 2096 | + break; |
|
| 2097 | + case 'CONFIDENTIAL': |
|
| 2098 | + $classification = CalDavBackend::CLASSIFICATION_CONFIDENTIAL; |
|
| 2099 | + break; |
|
| 2100 | + } |
|
| 2101 | + } |
|
| 2102 | + return [ |
|
| 2103 | + 'etag' => md5($calendarData), |
|
| 2104 | + 'size' => strlen($calendarData), |
|
| 2105 | + 'componentType' => $componentType, |
|
| 2106 | + 'firstOccurence' => is_null($firstOccurrence) ? null : max(0, $firstOccurrence), |
|
| 2107 | + 'lastOccurence' => $lastOccurrence, |
|
| 2108 | + 'uid' => $uid, |
|
| 2109 | + 'classification' => $classification |
|
| 2110 | + ]; |
|
| 2111 | + |
|
| 2112 | + } |
|
| 2113 | + |
|
| 2114 | + private function readBlob($cardData) { |
|
| 2115 | + if (is_resource($cardData)) { |
|
| 2116 | + return stream_get_contents($cardData); |
|
| 2117 | + } |
|
| 2118 | + |
|
| 2119 | + return $cardData; |
|
| 2120 | + } |
|
| 2121 | + |
|
| 2122 | + /** |
|
| 2123 | + * @param IShareable $shareable |
|
| 2124 | + * @param array $add |
|
| 2125 | + * @param array $remove |
|
| 2126 | + */ |
|
| 2127 | + public function updateShares($shareable, $add, $remove) { |
|
| 2128 | + $calendarId = $shareable->getResourceId(); |
|
| 2129 | + $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateShares', new GenericEvent( |
|
| 2130 | + '\OCA\DAV\CalDAV\CalDavBackend::updateShares', |
|
| 2131 | + [ |
|
| 2132 | + 'calendarId' => $calendarId, |
|
| 2133 | + 'calendarData' => $this->getCalendarById($calendarId), |
|
| 2134 | + 'shares' => $this->getShares($calendarId), |
|
| 2135 | + 'add' => $add, |
|
| 2136 | + 'remove' => $remove, |
|
| 2137 | + ])); |
|
| 2138 | + $this->sharingBackend->updateShares($shareable, $add, $remove); |
|
| 2139 | + } |
|
| 2140 | + |
|
| 2141 | + /** |
|
| 2142 | + * @param int $resourceId |
|
| 2143 | + * @return array |
|
| 2144 | + */ |
|
| 2145 | + public function getShares($resourceId) { |
|
| 2146 | + return $this->sharingBackend->getShares($resourceId); |
|
| 2147 | + } |
|
| 2148 | + |
|
| 2149 | + /** |
|
| 2150 | + * @param boolean $value |
|
| 2151 | + * @param \OCA\DAV\CalDAV\Calendar $calendar |
|
| 2152 | + * @return string|null |
|
| 2153 | + */ |
|
| 2154 | + public function setPublishStatus($value, $calendar) { |
|
| 2155 | + |
|
| 2156 | + $calendarId = $calendar->getResourceId(); |
|
| 2157 | + $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::publishCalendar', new GenericEvent( |
|
| 2158 | + '\OCA\DAV\CalDAV\CalDavBackend::updateShares', |
|
| 2159 | + [ |
|
| 2160 | + 'calendarId' => $calendarId, |
|
| 2161 | + 'calendarData' => $this->getCalendarById($calendarId), |
|
| 2162 | + 'public' => $value, |
|
| 2163 | + ])); |
|
| 2164 | + |
|
| 2165 | + $query = $this->db->getQueryBuilder(); |
|
| 2166 | + if ($value) { |
|
| 2167 | + $publicUri = $this->random->generate(16, ISecureRandom::CHAR_HUMAN_READABLE); |
|
| 2168 | + $query->insert('dav_shares') |
|
| 2169 | + ->values([ |
|
| 2170 | + 'principaluri' => $query->createNamedParameter($calendar->getPrincipalURI()), |
|
| 2171 | + 'type' => $query->createNamedParameter('calendar'), |
|
| 2172 | + 'access' => $query->createNamedParameter(self::ACCESS_PUBLIC), |
|
| 2173 | + 'resourceid' => $query->createNamedParameter($calendar->getResourceId()), |
|
| 2174 | + 'publicuri' => $query->createNamedParameter($publicUri) |
|
| 2175 | + ]); |
|
| 2176 | + $query->execute(); |
|
| 2177 | + return $publicUri; |
|
| 2178 | + } |
|
| 2179 | + $query->delete('dav_shares') |
|
| 2180 | + ->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId()))) |
|
| 2181 | + ->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC))); |
|
| 2182 | + $query->execute(); |
|
| 2183 | + return null; |
|
| 2184 | + } |
|
| 2185 | + |
|
| 2186 | + /** |
|
| 2187 | + * @param \OCA\DAV\CalDAV\Calendar $calendar |
|
| 2188 | + * @return mixed |
|
| 2189 | + */ |
|
| 2190 | + public function getPublishStatus($calendar) { |
|
| 2191 | + $query = $this->db->getQueryBuilder(); |
|
| 2192 | + $result = $query->select('publicuri') |
|
| 2193 | + ->from('dav_shares') |
|
| 2194 | + ->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId()))) |
|
| 2195 | + ->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC))) |
|
| 2196 | + ->execute(); |
|
| 2197 | + |
|
| 2198 | + $row = $result->fetch(); |
|
| 2199 | + $result->closeCursor(); |
|
| 2200 | + return $row ? reset($row) : false; |
|
| 2201 | + } |
|
| 2202 | + |
|
| 2203 | + /** |
|
| 2204 | + * @param int $resourceId |
|
| 2205 | + * @param array $acl |
|
| 2206 | + * @return array |
|
| 2207 | + */ |
|
| 2208 | + public function applyShareAcl($resourceId, $acl) { |
|
| 2209 | + return $this->sharingBackend->applyShareAcl($resourceId, $acl); |
|
| 2210 | + } |
|
| 2211 | + |
|
| 2212 | + |
|
| 2213 | + |
|
| 2214 | + /** |
|
| 2215 | + * update properties table |
|
| 2216 | + * |
|
| 2217 | + * @param int $calendarId |
|
| 2218 | + * @param string $objectUri |
|
| 2219 | + * @param string $calendarData |
|
| 2220 | + */ |
|
| 2221 | + public function updateProperties($calendarId, $objectUri, $calendarData) { |
|
| 2222 | + $objectId = $this->getCalendarObjectId($calendarId, $objectUri); |
|
| 2223 | + |
|
| 2224 | + try { |
|
| 2225 | + $vCalendar = $this->readCalendarData($calendarData); |
|
| 2226 | + } catch (\Exception $ex) { |
|
| 2227 | + return; |
|
| 2228 | + } |
|
| 2229 | + |
|
| 2230 | + $this->purgeProperties($calendarId, $objectId); |
|
| 2231 | + |
|
| 2232 | + $query = $this->db->getQueryBuilder(); |
|
| 2233 | + $query->insert($this->dbObjectPropertiesTable) |
|
| 2234 | + ->values( |
|
| 2235 | + [ |
|
| 2236 | + 'calendarid' => $query->createNamedParameter($calendarId), |
|
| 2237 | + 'objectid' => $query->createNamedParameter($objectId), |
|
| 2238 | + 'name' => $query->createParameter('name'), |
|
| 2239 | + 'parameter' => $query->createParameter('parameter'), |
|
| 2240 | + 'value' => $query->createParameter('value'), |
|
| 2241 | + ] |
|
| 2242 | + ); |
|
| 2243 | + |
|
| 2244 | + $indexComponents = ['VEVENT', 'VJOURNAL', 'VTODO']; |
|
| 2245 | + foreach ($vCalendar->getComponents() as $component) { |
|
| 2246 | + if (!in_array($component->name, $indexComponents)) { |
|
| 2247 | + continue; |
|
| 2248 | + } |
|
| 2249 | + |
|
| 2250 | + foreach ($component->children() as $property) { |
|
| 2251 | + if (in_array($property->name, self::$indexProperties)) { |
|
| 2252 | + $value = $property->getValue(); |
|
| 2253 | + // is this a shitty db? |
|
| 2254 | + if (!$this->db->supports4ByteText()) { |
|
| 2255 | + $value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value); |
|
| 2256 | + } |
|
| 2257 | + $value = mb_substr($value, 0, 254); |
|
| 2258 | + |
|
| 2259 | + $query->setParameter('name', $property->name); |
|
| 2260 | + $query->setParameter('parameter', null); |
|
| 2261 | + $query->setParameter('value', $value); |
|
| 2262 | + $query->execute(); |
|
| 2263 | + } |
|
| 2264 | + |
|
| 2265 | + if (array_key_exists($property->name, self::$indexParameters)) { |
|
| 2266 | + $parameters = $property->parameters(); |
|
| 2267 | + $indexedParametersForProperty = self::$indexParameters[$property->name]; |
|
| 2268 | + |
|
| 2269 | + foreach ($parameters as $key => $value) { |
|
| 2270 | + if (in_array($key, $indexedParametersForProperty)) { |
|
| 2271 | + // is this a shitty db? |
|
| 2272 | + if ($this->db->supports4ByteText()) { |
|
| 2273 | + $value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value); |
|
| 2274 | + } |
|
| 2275 | + $value = mb_substr($value, 0, 254); |
|
| 2276 | + |
|
| 2277 | + $query->setParameter('name', $property->name); |
|
| 2278 | + $query->setParameter('parameter', substr($key, 0, 254)); |
|
| 2279 | + $query->setParameter('value', substr($value, 0, 254)); |
|
| 2280 | + $query->execute(); |
|
| 2281 | + } |
|
| 2282 | + } |
|
| 2283 | + } |
|
| 2284 | + } |
|
| 2285 | + } |
|
| 2286 | + } |
|
| 2287 | + |
|
| 2288 | + /** |
|
| 2289 | + * deletes all birthday calendars |
|
| 2290 | + */ |
|
| 2291 | + public function deleteAllBirthdayCalendars() { |
|
| 2292 | + $query = $this->db->getQueryBuilder(); |
|
| 2293 | + $result = $query->select(['id'])->from('calendars') |
|
| 2294 | + ->where($query->expr()->eq('uri', |
|
| 2295 | + $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI))) |
|
| 2296 | + ->execute(); |
|
| 2297 | + |
|
| 2298 | + $ids = $result->fetchAll(); |
|
| 2299 | + foreach($ids as $id) { |
|
| 2300 | + $this->deleteCalendar($id['id']); |
|
| 2301 | + } |
|
| 2302 | + } |
|
| 2303 | + |
|
| 2304 | + /** |
|
| 2305 | + * read VCalendar data into a VCalendar object |
|
| 2306 | + * |
|
| 2307 | + * @param string $objectData |
|
| 2308 | + * @return VCalendar |
|
| 2309 | + */ |
|
| 2310 | + protected function readCalendarData($objectData) { |
|
| 2311 | + return Reader::read($objectData); |
|
| 2312 | + } |
|
| 2313 | + |
|
| 2314 | + /** |
|
| 2315 | + * delete all properties from a given calendar object |
|
| 2316 | + * |
|
| 2317 | + * @param int $calendarId |
|
| 2318 | + * @param int $objectId |
|
| 2319 | + */ |
|
| 2320 | + protected function purgeProperties($calendarId, $objectId) { |
|
| 2321 | + $query = $this->db->getQueryBuilder(); |
|
| 2322 | + $query->delete($this->dbObjectPropertiesTable) |
|
| 2323 | + ->where($query->expr()->eq('objectid', $query->createNamedParameter($objectId))) |
|
| 2324 | + ->andWhere($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))); |
|
| 2325 | + $query->execute(); |
|
| 2326 | + } |
|
| 2327 | + |
|
| 2328 | + /** |
|
| 2329 | + * get ID from a given calendar object |
|
| 2330 | + * |
|
| 2331 | + * @param int $calendarId |
|
| 2332 | + * @param string $uri |
|
| 2333 | + * @return int |
|
| 2334 | + */ |
|
| 2335 | + protected function getCalendarObjectId($calendarId, $uri) { |
|
| 2336 | + $query = $this->db->getQueryBuilder(); |
|
| 2337 | + $query->select('id')->from('calendarobjects') |
|
| 2338 | + ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) |
|
| 2339 | + ->andWhere($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))); |
|
| 2340 | + |
|
| 2341 | + $result = $query->execute(); |
|
| 2342 | + $objectIds = $result->fetch(); |
|
| 2343 | + $result->closeCursor(); |
|
| 2344 | + |
|
| 2345 | + if (!isset($objectIds['id'])) { |
|
| 2346 | + throw new \InvalidArgumentException('Calendarobject does not exists: ' . $uri); |
|
| 2347 | + } |
|
| 2348 | + |
|
| 2349 | + return (int)$objectIds['id']; |
|
| 2350 | + } |
|
| 2351 | + |
|
| 2352 | + private function convertPrincipal($principalUri, $toV2) { |
|
| 2353 | + if ($this->principalBackend->getPrincipalPrefix() === 'principals') { |
|
| 2354 | + list(, $name) = Uri\split($principalUri); |
|
| 2355 | + if ($toV2 === true) { |
|
| 2356 | + return "principals/users/$name"; |
|
| 2357 | + } |
|
| 2358 | + return "principals/$name"; |
|
| 2359 | + } |
|
| 2360 | + return $principalUri; |
|
| 2361 | + } |
|
| 2362 | + |
|
| 2363 | + private function addOwnerPrincipal(&$calendarInfo) { |
|
| 2364 | + $ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'; |
|
| 2365 | + $displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'; |
|
| 2366 | + if (isset($calendarInfo[$ownerPrincipalKey])) { |
|
| 2367 | + $uri = $calendarInfo[$ownerPrincipalKey]; |
|
| 2368 | + } else { |
|
| 2369 | + $uri = $calendarInfo['principaluri']; |
|
| 2370 | + } |
|
| 2371 | + |
|
| 2372 | + $principalInformation = $this->principalBackend->getPrincipalByPath($uri); |
|
| 2373 | + if (isset($principalInformation['{DAV:}displayname'])) { |
|
| 2374 | + $calendarInfo[$displaynameKey] = $principalInformation['{DAV:}displayname']; |
|
| 2375 | + } |
|
| 2376 | + } |
|
| 2377 | 2377 | } |
@@ -6,185 +6,185 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInitDAV |
| 8 | 8 | { |
| 9 | - public static $prefixLengthsPsr4 = array ( |
|
| 9 | + public static $prefixLengthsPsr4 = array( |
|
| 10 | 10 | 'O' => |
| 11 | - array ( |
|
| 11 | + array( |
|
| 12 | 12 | 'OCA\\DAV\\' => 8, |
| 13 | 13 | ), |
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | - public static $prefixDirsPsr4 = array ( |
|
| 16 | + public static $prefixDirsPsr4 = array( |
|
| 17 | 17 | 'OCA\\DAV\\' => |
| 18 | - array ( |
|
| 19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
| 18 | + array( |
|
| 19 | + 0 => __DIR__.'/..'.'/../lib', |
|
| 20 | 20 | ), |
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - public static $classMap = array ( |
|
| 24 | - 'OCA\\DAV\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
| 25 | - 'OCA\\DAV\\AppInfo\\PluginManager' => __DIR__ . '/..' . '/../lib/AppInfo/PluginManager.php', |
|
| 26 | - 'OCA\\DAV\\Avatars\\AvatarHome' => __DIR__ . '/..' . '/../lib/Avatars/AvatarHome.php', |
|
| 27 | - 'OCA\\DAV\\Avatars\\AvatarNode' => __DIR__ . '/..' . '/../lib/Avatars/AvatarNode.php', |
|
| 28 | - 'OCA\\DAV\\Avatars\\RootCollection' => __DIR__ . '/..' . '/../lib/Avatars/RootCollection.php', |
|
| 29 | - 'OCA\\DAV\\BackgroundJob\\CleanupDirectLinksJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupDirectLinksJob.php', |
|
| 30 | - 'OCA\\DAV\\BackgroundJob\\GenerateBirthdayCalendarBackgroundJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php', |
|
| 31 | - 'OCA\\DAV\\BackgroundJob\\UpdateCalendarResourcesRoomsBackgroundJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php', |
|
| 32 | - 'OCA\\DAV\\CalDAV\\Activity\\Backend' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Backend.php', |
|
| 33 | - 'OCA\\DAV\\CalDAV\\Activity\\Filter\\Calendar' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Filter/Calendar.php', |
|
| 34 | - 'OCA\\DAV\\CalDAV\\Activity\\Filter\\Todo' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Filter/Todo.php', |
|
| 35 | - 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Base' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Provider/Base.php', |
|
| 36 | - 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Calendar' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Provider/Calendar.php', |
|
| 37 | - 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Event' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Provider/Event.php', |
|
| 38 | - 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Todo' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Provider/Todo.php', |
|
| 39 | - 'OCA\\DAV\\CalDAV\\Activity\\Setting\\Calendar' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Setting/Calendar.php', |
|
| 40 | - 'OCA\\DAV\\CalDAV\\Activity\\Setting\\Event' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Setting/Event.php', |
|
| 41 | - 'OCA\\DAV\\CalDAV\\Activity\\Setting\\Todo' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Setting/Todo.php', |
|
| 42 | - 'OCA\\DAV\\CalDAV\\BirthdayCalendar\\EnablePlugin' => __DIR__ . '/..' . '/../lib/CalDAV/BirthdayCalendar/EnablePlugin.php', |
|
| 43 | - 'OCA\\DAV\\CalDAV\\BirthdayService' => __DIR__ . '/..' . '/../lib/CalDAV/BirthdayService.php', |
|
| 44 | - 'OCA\\DAV\\CalDAV\\CalDavBackend' => __DIR__ . '/..' . '/../lib/CalDAV/CalDavBackend.php', |
|
| 45 | - 'OCA\\DAV\\CalDAV\\Calendar' => __DIR__ . '/..' . '/../lib/CalDAV/Calendar.php', |
|
| 46 | - 'OCA\\DAV\\CalDAV\\CalendarHome' => __DIR__ . '/..' . '/../lib/CalDAV/CalendarHome.php', |
|
| 47 | - 'OCA\\DAV\\CalDAV\\CalendarImpl' => __DIR__ . '/..' . '/../lib/CalDAV/CalendarImpl.php', |
|
| 48 | - 'OCA\\DAV\\CalDAV\\CalendarManager' => __DIR__ . '/..' . '/../lib/CalDAV/CalendarManager.php', |
|
| 49 | - 'OCA\\DAV\\CalDAV\\CalendarObject' => __DIR__ . '/..' . '/../lib/CalDAV/CalendarObject.php', |
|
| 50 | - 'OCA\\DAV\\CalDAV\\CalendarRoot' => __DIR__ . '/..' . '/../lib/CalDAV/CalendarRoot.php', |
|
| 51 | - 'OCA\\DAV\\CalDAV\\Plugin' => __DIR__ . '/..' . '/../lib/CalDAV/Plugin.php', |
|
| 52 | - 'OCA\\DAV\\CalDAV\\Principal\\Collection' => __DIR__ . '/..' . '/../lib/CalDAV/Principal/Collection.php', |
|
| 53 | - 'OCA\\DAV\\CalDAV\\Principal\\User' => __DIR__ . '/..' . '/../lib/CalDAV/Principal/User.php', |
|
| 54 | - 'OCA\\DAV\\CalDAV\\PublicCalendar' => __DIR__ . '/..' . '/../lib/CalDAV/PublicCalendar.php', |
|
| 55 | - 'OCA\\DAV\\CalDAV\\PublicCalendarObject' => __DIR__ . '/..' . '/../lib/CalDAV/PublicCalendarObject.php', |
|
| 56 | - 'OCA\\DAV\\CalDAV\\PublicCalendarRoot' => __DIR__ . '/..' . '/../lib/CalDAV/PublicCalendarRoot.php', |
|
| 57 | - 'OCA\\DAV\\CalDAV\\Publishing\\PublishPlugin' => __DIR__ . '/..' . '/../lib/CalDAV/Publishing/PublishPlugin.php', |
|
| 58 | - 'OCA\\DAV\\CalDAV\\Publishing\\Xml\\Publisher' => __DIR__ . '/..' . '/../lib/CalDAV/Publishing/Xml/Publisher.php', |
|
| 59 | - 'OCA\\DAV\\CalDAV\\ResourceBooking\\AbstractPrincipalBackend' => __DIR__ . '/..' . '/../lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php', |
|
| 60 | - 'OCA\\DAV\\CalDAV\\ResourceBooking\\ResourcePrincipalBackend' => __DIR__ . '/..' . '/../lib/CalDAV/ResourceBooking/ResourcePrincipalBackend.php', |
|
| 61 | - 'OCA\\DAV\\CalDAV\\ResourceBooking\\RoomPrincipalBackend' => __DIR__ . '/..' . '/../lib/CalDAV/ResourceBooking/RoomPrincipalBackend.php', |
|
| 62 | - 'OCA\\DAV\\CalDAV\\Schedule\\IMipPlugin' => __DIR__ . '/..' . '/../lib/CalDAV/Schedule/IMipPlugin.php', |
|
| 63 | - 'OCA\\DAV\\CalDAV\\Schedule\\Plugin' => __DIR__ . '/..' . '/../lib/CalDAV/Schedule/Plugin.php', |
|
| 64 | - 'OCA\\DAV\\CalDAV\\Search\\SearchPlugin' => __DIR__ . '/..' . '/../lib/CalDAV/Search/SearchPlugin.php', |
|
| 65 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Filter/CompFilter.php', |
|
| 66 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Filter/LimitFilter.php', |
|
| 67 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Filter/OffsetFilter.php', |
|
| 68 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Filter/ParamFilter.php', |
|
| 69 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Filter/PropFilter.php', |
|
| 70 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Filter/SearchTermFilter.php', |
|
| 71 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport' => __DIR__ . '/..' . '/../lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php', |
|
| 72 | - 'OCA\\DAV\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php', |
|
| 73 | - 'OCA\\DAV\\CardDAV\\AddressBook' => __DIR__ . '/..' . '/../lib/CardDAV/AddressBook.php', |
|
| 74 | - 'OCA\\DAV\\CardDAV\\AddressBookImpl' => __DIR__ . '/..' . '/../lib/CardDAV/AddressBookImpl.php', |
|
| 75 | - 'OCA\\DAV\\CardDAV\\AddressBookRoot' => __DIR__ . '/..' . '/../lib/CardDAV/AddressBookRoot.php', |
|
| 76 | - 'OCA\\DAV\\CardDAV\\CardDavBackend' => __DIR__ . '/..' . '/../lib/CardDAV/CardDavBackend.php', |
|
| 77 | - 'OCA\\DAV\\CardDAV\\ContactsManager' => __DIR__ . '/..' . '/../lib/CardDAV/ContactsManager.php', |
|
| 78 | - 'OCA\\DAV\\CardDAV\\Converter' => __DIR__ . '/..' . '/../lib/CardDAV/Converter.php', |
|
| 79 | - 'OCA\\DAV\\CardDAV\\ImageExportPlugin' => __DIR__ . '/..' . '/../lib/CardDAV/ImageExportPlugin.php', |
|
| 80 | - 'OCA\\DAV\\CardDAV\\PhotoCache' => __DIR__ . '/..' . '/../lib/CardDAV/PhotoCache.php', |
|
| 81 | - 'OCA\\DAV\\CardDAV\\Plugin' => __DIR__ . '/..' . '/../lib/CardDAV/Plugin.php', |
|
| 82 | - 'OCA\\DAV\\CardDAV\\SyncService' => __DIR__ . '/..' . '/../lib/CardDAV/SyncService.php', |
|
| 83 | - 'OCA\\DAV\\CardDAV\\UserAddressBooks' => __DIR__ . '/..' . '/../lib/CardDAV/UserAddressBooks.php', |
|
| 84 | - 'OCA\\DAV\\CardDAV\\Xml\\Groups' => __DIR__ . '/..' . '/../lib/CardDAV/Xml/Groups.php', |
|
| 85 | - 'OCA\\DAV\\Command\\CreateAddressBook' => __DIR__ . '/..' . '/../lib/Command/CreateAddressBook.php', |
|
| 86 | - 'OCA\\DAV\\Command\\CreateCalendar' => __DIR__ . '/..' . '/../lib/Command/CreateCalendar.php', |
|
| 87 | - 'OCA\\DAV\\Command\\RemoveInvalidShares' => __DIR__ . '/..' . '/../lib/Command/RemoveInvalidShares.php', |
|
| 88 | - 'OCA\\DAV\\Command\\SyncBirthdayCalendar' => __DIR__ . '/..' . '/../lib/Command/SyncBirthdayCalendar.php', |
|
| 89 | - 'OCA\\DAV\\Command\\SyncSystemAddressBook' => __DIR__ . '/..' . '/../lib/Command/SyncSystemAddressBook.php', |
|
| 90 | - 'OCA\\DAV\\Comments\\CommentNode' => __DIR__ . '/..' . '/../lib/Comments/CommentNode.php', |
|
| 91 | - 'OCA\\DAV\\Comments\\CommentsPlugin' => __DIR__ . '/..' . '/../lib/Comments/CommentsPlugin.php', |
|
| 92 | - 'OCA\\DAV\\Comments\\EntityCollection' => __DIR__ . '/..' . '/../lib/Comments/EntityCollection.php', |
|
| 93 | - 'OCA\\DAV\\Comments\\EntityTypeCollection' => __DIR__ . '/..' . '/../lib/Comments/EntityTypeCollection.php', |
|
| 94 | - 'OCA\\DAV\\Comments\\RootCollection' => __DIR__ . '/..' . '/../lib/Comments/RootCollection.php', |
|
| 95 | - 'OCA\\DAV\\Connector\\LegacyDAVACL' => __DIR__ . '/..' . '/../lib/Connector/LegacyDAVACL.php', |
|
| 96 | - 'OCA\\DAV\\Connector\\PublicAuth' => __DIR__ . '/..' . '/../lib/Connector/PublicAuth.php', |
|
| 97 | - 'OCA\\DAV\\Connector\\Sabre\\AnonymousOptionsPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/AnonymousOptionsPlugin.php', |
|
| 98 | - 'OCA\\DAV\\Connector\\Sabre\\AppEnabledPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/AppEnabledPlugin.php', |
|
| 99 | - 'OCA\\DAV\\Connector\\Sabre\\Auth' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Auth.php', |
|
| 100 | - 'OCA\\DAV\\Connector\\Sabre\\BearerAuth' => __DIR__ . '/..' . '/../lib/Connector/Sabre/BearerAuth.php', |
|
| 101 | - 'OCA\\DAV\\Connector\\Sabre\\BlockLegacyClientPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/BlockLegacyClientPlugin.php', |
|
| 102 | - 'OCA\\DAV\\Connector\\Sabre\\CachingTree' => __DIR__ . '/..' . '/../lib/Connector/Sabre/CachingTree.php', |
|
| 103 | - 'OCA\\DAV\\Connector\\Sabre\\ChecksumList' => __DIR__ . '/..' . '/../lib/Connector/Sabre/ChecksumList.php', |
|
| 104 | - 'OCA\\DAV\\Connector\\Sabre\\CommentPropertiesPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/CommentPropertiesPlugin.php', |
|
| 105 | - 'OCA\\DAV\\Connector\\Sabre\\CopyEtagHeaderPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/CopyEtagHeaderPlugin.php', |
|
| 106 | - 'OCA\\DAV\\Connector\\Sabre\\CustomPropertiesBackend' => __DIR__ . '/..' . '/../lib/Connector/Sabre/CustomPropertiesBackend.php', |
|
| 107 | - 'OCA\\DAV\\Connector\\Sabre\\DavAclPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/DavAclPlugin.php', |
|
| 108 | - 'OCA\\DAV\\Connector\\Sabre\\Directory' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Directory.php', |
|
| 109 | - 'OCA\\DAV\\Connector\\Sabre\\DummyGetResponsePlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/DummyGetResponsePlugin.php', |
|
| 110 | - 'OCA\\DAV\\Connector\\Sabre\\ExceptionLoggerPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/ExceptionLoggerPlugin.php', |
|
| 111 | - 'OCA\\DAV\\Connector\\Sabre\\Exception\\EntityTooLarge' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Exception/EntityTooLarge.php', |
|
| 112 | - 'OCA\\DAV\\Connector\\Sabre\\Exception\\FileLocked' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Exception/FileLocked.php', |
|
| 113 | - 'OCA\\DAV\\Connector\\Sabre\\Exception\\Forbidden' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Exception/Forbidden.php', |
|
| 114 | - 'OCA\\DAV\\Connector\\Sabre\\Exception\\InvalidPath' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Exception/InvalidPath.php', |
|
| 115 | - 'OCA\\DAV\\Connector\\Sabre\\Exception\\PasswordLoginForbidden' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Exception/PasswordLoginForbidden.php', |
|
| 116 | - 'OCA\\DAV\\Connector\\Sabre\\Exception\\UnsupportedMediaType' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Exception/UnsupportedMediaType.php', |
|
| 117 | - 'OCA\\DAV\\Connector\\Sabre\\FakeLockerPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/FakeLockerPlugin.php', |
|
| 118 | - 'OCA\\DAV\\Connector\\Sabre\\File' => __DIR__ . '/..' . '/../lib/Connector/Sabre/File.php', |
|
| 119 | - 'OCA\\DAV\\Connector\\Sabre\\FilesPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/FilesPlugin.php', |
|
| 120 | - 'OCA\\DAV\\Connector\\Sabre\\FilesReportPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/FilesReportPlugin.php', |
|
| 121 | - 'OCA\\DAV\\Connector\\Sabre\\LockPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/LockPlugin.php', |
|
| 122 | - 'OCA\\DAV\\Connector\\Sabre\\MaintenancePlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/MaintenancePlugin.php', |
|
| 123 | - 'OCA\\DAV\\Connector\\Sabre\\Node' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Node.php', |
|
| 124 | - 'OCA\\DAV\\Connector\\Sabre\\ObjectTree' => __DIR__ . '/..' . '/../lib/Connector/Sabre/ObjectTree.php', |
|
| 125 | - 'OCA\\DAV\\Connector\\Sabre\\Principal' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Principal.php', |
|
| 126 | - 'OCA\\DAV\\Connector\\Sabre\\QuotaPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/QuotaPlugin.php', |
|
| 127 | - 'OCA\\DAV\\Connector\\Sabre\\Server' => __DIR__ . '/..' . '/../lib/Connector/Sabre/Server.php', |
|
| 128 | - 'OCA\\DAV\\Connector\\Sabre\\ServerFactory' => __DIR__ . '/..' . '/../lib/Connector/Sabre/ServerFactory.php', |
|
| 129 | - 'OCA\\DAV\\Connector\\Sabre\\ShareTypeList' => __DIR__ . '/..' . '/../lib/Connector/Sabre/ShareTypeList.php', |
|
| 130 | - 'OCA\\DAV\\Connector\\Sabre\\SharesPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/SharesPlugin.php', |
|
| 131 | - 'OCA\\DAV\\Connector\\Sabre\\TagList' => __DIR__ . '/..' . '/../lib/Connector/Sabre/TagList.php', |
|
| 132 | - 'OCA\\DAV\\Connector\\Sabre\\TagsPlugin' => __DIR__ . '/..' . '/../lib/Connector/Sabre/TagsPlugin.php', |
|
| 133 | - 'OCA\\DAV\\Controller\\BirthdayCalendarController' => __DIR__ . '/..' . '/../lib/Controller/BirthdayCalendarController.php', |
|
| 134 | - 'OCA\\DAV\\Controller\\DirectController' => __DIR__ . '/..' . '/../lib/Controller/DirectController.php', |
|
| 135 | - 'OCA\\DAV\\DAV\\CustomPropertiesBackend' => __DIR__ . '/..' . '/../lib/DAV/CustomPropertiesBackend.php', |
|
| 136 | - 'OCA\\DAV\\DAV\\GroupPrincipalBackend' => __DIR__ . '/..' . '/../lib/DAV/GroupPrincipalBackend.php', |
|
| 137 | - 'OCA\\DAV\\DAV\\PublicAuth' => __DIR__ . '/..' . '/../lib/DAV/PublicAuth.php', |
|
| 138 | - 'OCA\\DAV\\DAV\\Sharing\\Backend' => __DIR__ . '/..' . '/../lib/DAV/Sharing/Backend.php', |
|
| 139 | - 'OCA\\DAV\\DAV\\Sharing\\IShareable' => __DIR__ . '/..' . '/../lib/DAV/Sharing/IShareable.php', |
|
| 140 | - 'OCA\\DAV\\DAV\\Sharing\\Plugin' => __DIR__ . '/..' . '/../lib/DAV/Sharing/Plugin.php', |
|
| 141 | - 'OCA\\DAV\\DAV\\Sharing\\Xml\\Invite' => __DIR__ . '/..' . '/../lib/DAV/Sharing/Xml/Invite.php', |
|
| 142 | - 'OCA\\DAV\\DAV\\Sharing\\Xml\\ShareRequest' => __DIR__ . '/..' . '/../lib/DAV/Sharing/Xml/ShareRequest.php', |
|
| 143 | - 'OCA\\DAV\\DAV\\SystemPrincipalBackend' => __DIR__ . '/..' . '/../lib/DAV/SystemPrincipalBackend.php', |
|
| 144 | - 'OCA\\DAV\\Db\\Direct' => __DIR__ . '/..' . '/../lib/Db/Direct.php', |
|
| 145 | - 'OCA\\DAV\\Db\\DirectMapper' => __DIR__ . '/..' . '/../lib/Db/DirectMapper.php', |
|
| 146 | - 'OCA\\DAV\\Direct\\DirectFile' => __DIR__ . '/..' . '/../lib/Direct/DirectFile.php', |
|
| 147 | - 'OCA\\DAV\\Direct\\DirectHome' => __DIR__ . '/..' . '/../lib/Direct/DirectHome.php', |
|
| 148 | - 'OCA\\DAV\\Direct\\Server' => __DIR__ . '/..' . '/../lib/Direct/Server.php', |
|
| 149 | - 'OCA\\DAV\\Direct\\ServerFactory' => __DIR__ . '/..' . '/../lib/Direct/ServerFactory.php', |
|
| 150 | - 'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => __DIR__ . '/..' . '/../lib/Files/BrowserErrorPagePlugin.php', |
|
| 151 | - 'OCA\\DAV\\Files\\FileSearchBackend' => __DIR__ . '/..' . '/../lib/Files/FileSearchBackend.php', |
|
| 152 | - 'OCA\\DAV\\Files\\FilesHome' => __DIR__ . '/..' . '/../lib/Files/FilesHome.php', |
|
| 153 | - 'OCA\\DAV\\Files\\RootCollection' => __DIR__ . '/..' . '/../lib/Files/RootCollection.php', |
|
| 154 | - 'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => __DIR__ . '/..' . '/../lib/Files/Sharing/FilesDropPlugin.php', |
|
| 155 | - 'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => __DIR__ . '/..' . '/../lib/Files/Sharing/PublicLinkCheckPlugin.php', |
|
| 156 | - 'OCA\\DAV\\HookManager' => __DIR__ . '/..' . '/../lib/HookManager.php', |
|
| 157 | - 'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => __DIR__ . '/..' . '/../lib/Migration/BuildCalendarSearchIndex.php', |
|
| 158 | - 'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => __DIR__ . '/..' . '/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php', |
|
| 159 | - 'OCA\\DAV\\Migration\\CalDAVRemoveEmptyValue' => __DIR__ . '/..' . '/../lib/Migration/CalDAVRemoveEmptyValue.php', |
|
| 160 | - 'OCA\\DAV\\Migration\\FixBirthdayCalendarComponent' => __DIR__ . '/..' . '/../lib/Migration/FixBirthdayCalendarComponent.php', |
|
| 161 | - 'OCA\\DAV\\Migration\\Version1004Date20170825134824' => __DIR__ . '/..' . '/../lib/Migration/Version1004Date20170825134824.php', |
|
| 162 | - 'OCA\\DAV\\Migration\\Version1004Date20170919104507' => __DIR__ . '/..' . '/../lib/Migration/Version1004Date20170919104507.php', |
|
| 163 | - 'OCA\\DAV\\Migration\\Version1004Date20170924124212' => __DIR__ . '/..' . '/../lib/Migration/Version1004Date20170924124212.php', |
|
| 164 | - 'OCA\\DAV\\Migration\\Version1004Date20170926103422' => __DIR__ . '/..' . '/../lib/Migration/Version1004Date20170926103422.php', |
|
| 165 | - 'OCA\\DAV\\Migration\\Version1005Date20180413093149' => __DIR__ . '/..' . '/../lib/Migration/Version1005Date20180413093149.php', |
|
| 166 | - 'OCA\\DAV\\Migration\\Version1005Date20180530124431' => __DIR__ . '/..' . '/../lib/Migration/Version1005Date20180530124431.php', |
|
| 167 | - 'OCA\\DAV\\RootCollection' => __DIR__ . '/..' . '/../lib/RootCollection.php', |
|
| 168 | - 'OCA\\DAV\\Server' => __DIR__ . '/..' . '/../lib/Server.php', |
|
| 169 | - 'OCA\\DAV\\Settings\\CalDAVSettings' => __DIR__ . '/..' . '/../lib/Settings/CalDAVSettings.php', |
|
| 170 | - 'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagMappingNode.php', |
|
| 171 | - 'OCA\\DAV\\SystemTag\\SystemTagNode' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagNode.php', |
|
| 172 | - 'OCA\\DAV\\SystemTag\\SystemTagPlugin' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagPlugin.php', |
|
| 173 | - 'OCA\\DAV\\SystemTag\\SystemTagsByIdCollection' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagsByIdCollection.php', |
|
| 174 | - 'OCA\\DAV\\SystemTag\\SystemTagsObjectMappingCollection' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagsObjectMappingCollection.php', |
|
| 175 | - 'OCA\\DAV\\SystemTag\\SystemTagsObjectTypeCollection' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagsObjectTypeCollection.php', |
|
| 176 | - 'OCA\\DAV\\SystemTag\\SystemTagsRelationsCollection' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagsRelationsCollection.php', |
|
| 177 | - 'OCA\\DAV\\Upload\\AssemblyStream' => __DIR__ . '/..' . '/../lib/Upload/AssemblyStream.php', |
|
| 178 | - 'OCA\\DAV\\Upload\\ChunkingPlugin' => __DIR__ . '/..' . '/../lib/Upload/ChunkingPlugin.php', |
|
| 179 | - 'OCA\\DAV\\Upload\\FutureFile' => __DIR__ . '/..' . '/../lib/Upload/FutureFile.php', |
|
| 180 | - 'OCA\\DAV\\Upload\\RootCollection' => __DIR__ . '/..' . '/../lib/Upload/RootCollection.php', |
|
| 181 | - 'OCA\\DAV\\Upload\\UploadFolder' => __DIR__ . '/..' . '/../lib/Upload/UploadFolder.php', |
|
| 182 | - 'OCA\\DAV\\Upload\\UploadHome' => __DIR__ . '/..' . '/../lib/Upload/UploadHome.php', |
|
| 23 | + public static $classMap = array( |
|
| 24 | + 'OCA\\DAV\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
| 25 | + 'OCA\\DAV\\AppInfo\\PluginManager' => __DIR__.'/..'.'/../lib/AppInfo/PluginManager.php', |
|
| 26 | + 'OCA\\DAV\\Avatars\\AvatarHome' => __DIR__.'/..'.'/../lib/Avatars/AvatarHome.php', |
|
| 27 | + 'OCA\\DAV\\Avatars\\AvatarNode' => __DIR__.'/..'.'/../lib/Avatars/AvatarNode.php', |
|
| 28 | + 'OCA\\DAV\\Avatars\\RootCollection' => __DIR__.'/..'.'/../lib/Avatars/RootCollection.php', |
|
| 29 | + 'OCA\\DAV\\BackgroundJob\\CleanupDirectLinksJob' => __DIR__.'/..'.'/../lib/BackgroundJob/CleanupDirectLinksJob.php', |
|
| 30 | + 'OCA\\DAV\\BackgroundJob\\GenerateBirthdayCalendarBackgroundJob' => __DIR__.'/..'.'/../lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php', |
|
| 31 | + 'OCA\\DAV\\BackgroundJob\\UpdateCalendarResourcesRoomsBackgroundJob' => __DIR__.'/..'.'/../lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php', |
|
| 32 | + 'OCA\\DAV\\CalDAV\\Activity\\Backend' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Backend.php', |
|
| 33 | + 'OCA\\DAV\\CalDAV\\Activity\\Filter\\Calendar' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Filter/Calendar.php', |
|
| 34 | + 'OCA\\DAV\\CalDAV\\Activity\\Filter\\Todo' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Filter/Todo.php', |
|
| 35 | + 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Base' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Provider/Base.php', |
|
| 36 | + 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Calendar' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Provider/Calendar.php', |
|
| 37 | + 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Event' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Provider/Event.php', |
|
| 38 | + 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Todo' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Provider/Todo.php', |
|
| 39 | + 'OCA\\DAV\\CalDAV\\Activity\\Setting\\Calendar' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Setting/Calendar.php', |
|
| 40 | + 'OCA\\DAV\\CalDAV\\Activity\\Setting\\Event' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Setting/Event.php', |
|
| 41 | + 'OCA\\DAV\\CalDAV\\Activity\\Setting\\Todo' => __DIR__.'/..'.'/../lib/CalDAV/Activity/Setting/Todo.php', |
|
| 42 | + 'OCA\\DAV\\CalDAV\\BirthdayCalendar\\EnablePlugin' => __DIR__.'/..'.'/../lib/CalDAV/BirthdayCalendar/EnablePlugin.php', |
|
| 43 | + 'OCA\\DAV\\CalDAV\\BirthdayService' => __DIR__.'/..'.'/../lib/CalDAV/BirthdayService.php', |
|
| 44 | + 'OCA\\DAV\\CalDAV\\CalDavBackend' => __DIR__.'/..'.'/../lib/CalDAV/CalDavBackend.php', |
|
| 45 | + 'OCA\\DAV\\CalDAV\\Calendar' => __DIR__.'/..'.'/../lib/CalDAV/Calendar.php', |
|
| 46 | + 'OCA\\DAV\\CalDAV\\CalendarHome' => __DIR__.'/..'.'/../lib/CalDAV/CalendarHome.php', |
|
| 47 | + 'OCA\\DAV\\CalDAV\\CalendarImpl' => __DIR__.'/..'.'/../lib/CalDAV/CalendarImpl.php', |
|
| 48 | + 'OCA\\DAV\\CalDAV\\CalendarManager' => __DIR__.'/..'.'/../lib/CalDAV/CalendarManager.php', |
|
| 49 | + 'OCA\\DAV\\CalDAV\\CalendarObject' => __DIR__.'/..'.'/../lib/CalDAV/CalendarObject.php', |
|
| 50 | + 'OCA\\DAV\\CalDAV\\CalendarRoot' => __DIR__.'/..'.'/../lib/CalDAV/CalendarRoot.php', |
|
| 51 | + 'OCA\\DAV\\CalDAV\\Plugin' => __DIR__.'/..'.'/../lib/CalDAV/Plugin.php', |
|
| 52 | + 'OCA\\DAV\\CalDAV\\Principal\\Collection' => __DIR__.'/..'.'/../lib/CalDAV/Principal/Collection.php', |
|
| 53 | + 'OCA\\DAV\\CalDAV\\Principal\\User' => __DIR__.'/..'.'/../lib/CalDAV/Principal/User.php', |
|
| 54 | + 'OCA\\DAV\\CalDAV\\PublicCalendar' => __DIR__.'/..'.'/../lib/CalDAV/PublicCalendar.php', |
|
| 55 | + 'OCA\\DAV\\CalDAV\\PublicCalendarObject' => __DIR__.'/..'.'/../lib/CalDAV/PublicCalendarObject.php', |
|
| 56 | + 'OCA\\DAV\\CalDAV\\PublicCalendarRoot' => __DIR__.'/..'.'/../lib/CalDAV/PublicCalendarRoot.php', |
|
| 57 | + 'OCA\\DAV\\CalDAV\\Publishing\\PublishPlugin' => __DIR__.'/..'.'/../lib/CalDAV/Publishing/PublishPlugin.php', |
|
| 58 | + 'OCA\\DAV\\CalDAV\\Publishing\\Xml\\Publisher' => __DIR__.'/..'.'/../lib/CalDAV/Publishing/Xml/Publisher.php', |
|
| 59 | + 'OCA\\DAV\\CalDAV\\ResourceBooking\\AbstractPrincipalBackend' => __DIR__.'/..'.'/../lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php', |
|
| 60 | + 'OCA\\DAV\\CalDAV\\ResourceBooking\\ResourcePrincipalBackend' => __DIR__.'/..'.'/../lib/CalDAV/ResourceBooking/ResourcePrincipalBackend.php', |
|
| 61 | + 'OCA\\DAV\\CalDAV\\ResourceBooking\\RoomPrincipalBackend' => __DIR__.'/..'.'/../lib/CalDAV/ResourceBooking/RoomPrincipalBackend.php', |
|
| 62 | + 'OCA\\DAV\\CalDAV\\Schedule\\IMipPlugin' => __DIR__.'/..'.'/../lib/CalDAV/Schedule/IMipPlugin.php', |
|
| 63 | + 'OCA\\DAV\\CalDAV\\Schedule\\Plugin' => __DIR__.'/..'.'/../lib/CalDAV/Schedule/Plugin.php', |
|
| 64 | + 'OCA\\DAV\\CalDAV\\Search\\SearchPlugin' => __DIR__.'/..'.'/../lib/CalDAV/Search/SearchPlugin.php', |
|
| 65 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Filter/CompFilter.php', |
|
| 66 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Filter/LimitFilter.php', |
|
| 67 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Filter/OffsetFilter.php', |
|
| 68 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Filter/ParamFilter.php', |
|
| 69 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Filter/PropFilter.php', |
|
| 70 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Filter/SearchTermFilter.php', |
|
| 71 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport' => __DIR__.'/..'.'/../lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php', |
|
| 72 | + 'OCA\\DAV\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php', |
|
| 73 | + 'OCA\\DAV\\CardDAV\\AddressBook' => __DIR__.'/..'.'/../lib/CardDAV/AddressBook.php', |
|
| 74 | + 'OCA\\DAV\\CardDAV\\AddressBookImpl' => __DIR__.'/..'.'/../lib/CardDAV/AddressBookImpl.php', |
|
| 75 | + 'OCA\\DAV\\CardDAV\\AddressBookRoot' => __DIR__.'/..'.'/../lib/CardDAV/AddressBookRoot.php', |
|
| 76 | + 'OCA\\DAV\\CardDAV\\CardDavBackend' => __DIR__.'/..'.'/../lib/CardDAV/CardDavBackend.php', |
|
| 77 | + 'OCA\\DAV\\CardDAV\\ContactsManager' => __DIR__.'/..'.'/../lib/CardDAV/ContactsManager.php', |
|
| 78 | + 'OCA\\DAV\\CardDAV\\Converter' => __DIR__.'/..'.'/../lib/CardDAV/Converter.php', |
|
| 79 | + 'OCA\\DAV\\CardDAV\\ImageExportPlugin' => __DIR__.'/..'.'/../lib/CardDAV/ImageExportPlugin.php', |
|
| 80 | + 'OCA\\DAV\\CardDAV\\PhotoCache' => __DIR__.'/..'.'/../lib/CardDAV/PhotoCache.php', |
|
| 81 | + 'OCA\\DAV\\CardDAV\\Plugin' => __DIR__.'/..'.'/../lib/CardDAV/Plugin.php', |
|
| 82 | + 'OCA\\DAV\\CardDAV\\SyncService' => __DIR__.'/..'.'/../lib/CardDAV/SyncService.php', |
|
| 83 | + 'OCA\\DAV\\CardDAV\\UserAddressBooks' => __DIR__.'/..'.'/../lib/CardDAV/UserAddressBooks.php', |
|
| 84 | + 'OCA\\DAV\\CardDAV\\Xml\\Groups' => __DIR__.'/..'.'/../lib/CardDAV/Xml/Groups.php', |
|
| 85 | + 'OCA\\DAV\\Command\\CreateAddressBook' => __DIR__.'/..'.'/../lib/Command/CreateAddressBook.php', |
|
| 86 | + 'OCA\\DAV\\Command\\CreateCalendar' => __DIR__.'/..'.'/../lib/Command/CreateCalendar.php', |
|
| 87 | + 'OCA\\DAV\\Command\\RemoveInvalidShares' => __DIR__.'/..'.'/../lib/Command/RemoveInvalidShares.php', |
|
| 88 | + 'OCA\\DAV\\Command\\SyncBirthdayCalendar' => __DIR__.'/..'.'/../lib/Command/SyncBirthdayCalendar.php', |
|
| 89 | + 'OCA\\DAV\\Command\\SyncSystemAddressBook' => __DIR__.'/..'.'/../lib/Command/SyncSystemAddressBook.php', |
|
| 90 | + 'OCA\\DAV\\Comments\\CommentNode' => __DIR__.'/..'.'/../lib/Comments/CommentNode.php', |
|
| 91 | + 'OCA\\DAV\\Comments\\CommentsPlugin' => __DIR__.'/..'.'/../lib/Comments/CommentsPlugin.php', |
|
| 92 | + 'OCA\\DAV\\Comments\\EntityCollection' => __DIR__.'/..'.'/../lib/Comments/EntityCollection.php', |
|
| 93 | + 'OCA\\DAV\\Comments\\EntityTypeCollection' => __DIR__.'/..'.'/../lib/Comments/EntityTypeCollection.php', |
|
| 94 | + 'OCA\\DAV\\Comments\\RootCollection' => __DIR__.'/..'.'/../lib/Comments/RootCollection.php', |
|
| 95 | + 'OCA\\DAV\\Connector\\LegacyDAVACL' => __DIR__.'/..'.'/../lib/Connector/LegacyDAVACL.php', |
|
| 96 | + 'OCA\\DAV\\Connector\\PublicAuth' => __DIR__.'/..'.'/../lib/Connector/PublicAuth.php', |
|
| 97 | + 'OCA\\DAV\\Connector\\Sabre\\AnonymousOptionsPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/AnonymousOptionsPlugin.php', |
|
| 98 | + 'OCA\\DAV\\Connector\\Sabre\\AppEnabledPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/AppEnabledPlugin.php', |
|
| 99 | + 'OCA\\DAV\\Connector\\Sabre\\Auth' => __DIR__.'/..'.'/../lib/Connector/Sabre/Auth.php', |
|
| 100 | + 'OCA\\DAV\\Connector\\Sabre\\BearerAuth' => __DIR__.'/..'.'/../lib/Connector/Sabre/BearerAuth.php', |
|
| 101 | + 'OCA\\DAV\\Connector\\Sabre\\BlockLegacyClientPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/BlockLegacyClientPlugin.php', |
|
| 102 | + 'OCA\\DAV\\Connector\\Sabre\\CachingTree' => __DIR__.'/..'.'/../lib/Connector/Sabre/CachingTree.php', |
|
| 103 | + 'OCA\\DAV\\Connector\\Sabre\\ChecksumList' => __DIR__.'/..'.'/../lib/Connector/Sabre/ChecksumList.php', |
|
| 104 | + 'OCA\\DAV\\Connector\\Sabre\\CommentPropertiesPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/CommentPropertiesPlugin.php', |
|
| 105 | + 'OCA\\DAV\\Connector\\Sabre\\CopyEtagHeaderPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/CopyEtagHeaderPlugin.php', |
|
| 106 | + 'OCA\\DAV\\Connector\\Sabre\\CustomPropertiesBackend' => __DIR__.'/..'.'/../lib/Connector/Sabre/CustomPropertiesBackend.php', |
|
| 107 | + 'OCA\\DAV\\Connector\\Sabre\\DavAclPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/DavAclPlugin.php', |
|
| 108 | + 'OCA\\DAV\\Connector\\Sabre\\Directory' => __DIR__.'/..'.'/../lib/Connector/Sabre/Directory.php', |
|
| 109 | + 'OCA\\DAV\\Connector\\Sabre\\DummyGetResponsePlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/DummyGetResponsePlugin.php', |
|
| 110 | + 'OCA\\DAV\\Connector\\Sabre\\ExceptionLoggerPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/ExceptionLoggerPlugin.php', |
|
| 111 | + 'OCA\\DAV\\Connector\\Sabre\\Exception\\EntityTooLarge' => __DIR__.'/..'.'/../lib/Connector/Sabre/Exception/EntityTooLarge.php', |
|
| 112 | + 'OCA\\DAV\\Connector\\Sabre\\Exception\\FileLocked' => __DIR__.'/..'.'/../lib/Connector/Sabre/Exception/FileLocked.php', |
|
| 113 | + 'OCA\\DAV\\Connector\\Sabre\\Exception\\Forbidden' => __DIR__.'/..'.'/../lib/Connector/Sabre/Exception/Forbidden.php', |
|
| 114 | + 'OCA\\DAV\\Connector\\Sabre\\Exception\\InvalidPath' => __DIR__.'/..'.'/../lib/Connector/Sabre/Exception/InvalidPath.php', |
|
| 115 | + 'OCA\\DAV\\Connector\\Sabre\\Exception\\PasswordLoginForbidden' => __DIR__.'/..'.'/../lib/Connector/Sabre/Exception/PasswordLoginForbidden.php', |
|
| 116 | + 'OCA\\DAV\\Connector\\Sabre\\Exception\\UnsupportedMediaType' => __DIR__.'/..'.'/../lib/Connector/Sabre/Exception/UnsupportedMediaType.php', |
|
| 117 | + 'OCA\\DAV\\Connector\\Sabre\\FakeLockerPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/FakeLockerPlugin.php', |
|
| 118 | + 'OCA\\DAV\\Connector\\Sabre\\File' => __DIR__.'/..'.'/../lib/Connector/Sabre/File.php', |
|
| 119 | + 'OCA\\DAV\\Connector\\Sabre\\FilesPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/FilesPlugin.php', |
|
| 120 | + 'OCA\\DAV\\Connector\\Sabre\\FilesReportPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/FilesReportPlugin.php', |
|
| 121 | + 'OCA\\DAV\\Connector\\Sabre\\LockPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/LockPlugin.php', |
|
| 122 | + 'OCA\\DAV\\Connector\\Sabre\\MaintenancePlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/MaintenancePlugin.php', |
|
| 123 | + 'OCA\\DAV\\Connector\\Sabre\\Node' => __DIR__.'/..'.'/../lib/Connector/Sabre/Node.php', |
|
| 124 | + 'OCA\\DAV\\Connector\\Sabre\\ObjectTree' => __DIR__.'/..'.'/../lib/Connector/Sabre/ObjectTree.php', |
|
| 125 | + 'OCA\\DAV\\Connector\\Sabre\\Principal' => __DIR__.'/..'.'/../lib/Connector/Sabre/Principal.php', |
|
| 126 | + 'OCA\\DAV\\Connector\\Sabre\\QuotaPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/QuotaPlugin.php', |
|
| 127 | + 'OCA\\DAV\\Connector\\Sabre\\Server' => __DIR__.'/..'.'/../lib/Connector/Sabre/Server.php', |
|
| 128 | + 'OCA\\DAV\\Connector\\Sabre\\ServerFactory' => __DIR__.'/..'.'/../lib/Connector/Sabre/ServerFactory.php', |
|
| 129 | + 'OCA\\DAV\\Connector\\Sabre\\ShareTypeList' => __DIR__.'/..'.'/../lib/Connector/Sabre/ShareTypeList.php', |
|
| 130 | + 'OCA\\DAV\\Connector\\Sabre\\SharesPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/SharesPlugin.php', |
|
| 131 | + 'OCA\\DAV\\Connector\\Sabre\\TagList' => __DIR__.'/..'.'/../lib/Connector/Sabre/TagList.php', |
|
| 132 | + 'OCA\\DAV\\Connector\\Sabre\\TagsPlugin' => __DIR__.'/..'.'/../lib/Connector/Sabre/TagsPlugin.php', |
|
| 133 | + 'OCA\\DAV\\Controller\\BirthdayCalendarController' => __DIR__.'/..'.'/../lib/Controller/BirthdayCalendarController.php', |
|
| 134 | + 'OCA\\DAV\\Controller\\DirectController' => __DIR__.'/..'.'/../lib/Controller/DirectController.php', |
|
| 135 | + 'OCA\\DAV\\DAV\\CustomPropertiesBackend' => __DIR__.'/..'.'/../lib/DAV/CustomPropertiesBackend.php', |
|
| 136 | + 'OCA\\DAV\\DAV\\GroupPrincipalBackend' => __DIR__.'/..'.'/../lib/DAV/GroupPrincipalBackend.php', |
|
| 137 | + 'OCA\\DAV\\DAV\\PublicAuth' => __DIR__.'/..'.'/../lib/DAV/PublicAuth.php', |
|
| 138 | + 'OCA\\DAV\\DAV\\Sharing\\Backend' => __DIR__.'/..'.'/../lib/DAV/Sharing/Backend.php', |
|
| 139 | + 'OCA\\DAV\\DAV\\Sharing\\IShareable' => __DIR__.'/..'.'/../lib/DAV/Sharing/IShareable.php', |
|
| 140 | + 'OCA\\DAV\\DAV\\Sharing\\Plugin' => __DIR__.'/..'.'/../lib/DAV/Sharing/Plugin.php', |
|
| 141 | + 'OCA\\DAV\\DAV\\Sharing\\Xml\\Invite' => __DIR__.'/..'.'/../lib/DAV/Sharing/Xml/Invite.php', |
|
| 142 | + 'OCA\\DAV\\DAV\\Sharing\\Xml\\ShareRequest' => __DIR__.'/..'.'/../lib/DAV/Sharing/Xml/ShareRequest.php', |
|
| 143 | + 'OCA\\DAV\\DAV\\SystemPrincipalBackend' => __DIR__.'/..'.'/../lib/DAV/SystemPrincipalBackend.php', |
|
| 144 | + 'OCA\\DAV\\Db\\Direct' => __DIR__.'/..'.'/../lib/Db/Direct.php', |
|
| 145 | + 'OCA\\DAV\\Db\\DirectMapper' => __DIR__.'/..'.'/../lib/Db/DirectMapper.php', |
|
| 146 | + 'OCA\\DAV\\Direct\\DirectFile' => __DIR__.'/..'.'/../lib/Direct/DirectFile.php', |
|
| 147 | + 'OCA\\DAV\\Direct\\DirectHome' => __DIR__.'/..'.'/../lib/Direct/DirectHome.php', |
|
| 148 | + 'OCA\\DAV\\Direct\\Server' => __DIR__.'/..'.'/../lib/Direct/Server.php', |
|
| 149 | + 'OCA\\DAV\\Direct\\ServerFactory' => __DIR__.'/..'.'/../lib/Direct/ServerFactory.php', |
|
| 150 | + 'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => __DIR__.'/..'.'/../lib/Files/BrowserErrorPagePlugin.php', |
|
| 151 | + 'OCA\\DAV\\Files\\FileSearchBackend' => __DIR__.'/..'.'/../lib/Files/FileSearchBackend.php', |
|
| 152 | + 'OCA\\DAV\\Files\\FilesHome' => __DIR__.'/..'.'/../lib/Files/FilesHome.php', |
|
| 153 | + 'OCA\\DAV\\Files\\RootCollection' => __DIR__.'/..'.'/../lib/Files/RootCollection.php', |
|
| 154 | + 'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => __DIR__.'/..'.'/../lib/Files/Sharing/FilesDropPlugin.php', |
|
| 155 | + 'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => __DIR__.'/..'.'/../lib/Files/Sharing/PublicLinkCheckPlugin.php', |
|
| 156 | + 'OCA\\DAV\\HookManager' => __DIR__.'/..'.'/../lib/HookManager.php', |
|
| 157 | + 'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => __DIR__.'/..'.'/../lib/Migration/BuildCalendarSearchIndex.php', |
|
| 158 | + 'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => __DIR__.'/..'.'/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php', |
|
| 159 | + 'OCA\\DAV\\Migration\\CalDAVRemoveEmptyValue' => __DIR__.'/..'.'/../lib/Migration/CalDAVRemoveEmptyValue.php', |
|
| 160 | + 'OCA\\DAV\\Migration\\FixBirthdayCalendarComponent' => __DIR__.'/..'.'/../lib/Migration/FixBirthdayCalendarComponent.php', |
|
| 161 | + 'OCA\\DAV\\Migration\\Version1004Date20170825134824' => __DIR__.'/..'.'/../lib/Migration/Version1004Date20170825134824.php', |
|
| 162 | + 'OCA\\DAV\\Migration\\Version1004Date20170919104507' => __DIR__.'/..'.'/../lib/Migration/Version1004Date20170919104507.php', |
|
| 163 | + 'OCA\\DAV\\Migration\\Version1004Date20170924124212' => __DIR__.'/..'.'/../lib/Migration/Version1004Date20170924124212.php', |
|
| 164 | + 'OCA\\DAV\\Migration\\Version1004Date20170926103422' => __DIR__.'/..'.'/../lib/Migration/Version1004Date20170926103422.php', |
|
| 165 | + 'OCA\\DAV\\Migration\\Version1005Date20180413093149' => __DIR__.'/..'.'/../lib/Migration/Version1005Date20180413093149.php', |
|
| 166 | + 'OCA\\DAV\\Migration\\Version1005Date20180530124431' => __DIR__.'/..'.'/../lib/Migration/Version1005Date20180530124431.php', |
|
| 167 | + 'OCA\\DAV\\RootCollection' => __DIR__.'/..'.'/../lib/RootCollection.php', |
|
| 168 | + 'OCA\\DAV\\Server' => __DIR__.'/..'.'/../lib/Server.php', |
|
| 169 | + 'OCA\\DAV\\Settings\\CalDAVSettings' => __DIR__.'/..'.'/../lib/Settings/CalDAVSettings.php', |
|
| 170 | + 'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagMappingNode.php', |
|
| 171 | + 'OCA\\DAV\\SystemTag\\SystemTagNode' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagNode.php', |
|
| 172 | + 'OCA\\DAV\\SystemTag\\SystemTagPlugin' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagPlugin.php', |
|
| 173 | + 'OCA\\DAV\\SystemTag\\SystemTagsByIdCollection' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagsByIdCollection.php', |
|
| 174 | + 'OCA\\DAV\\SystemTag\\SystemTagsObjectMappingCollection' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagsObjectMappingCollection.php', |
|
| 175 | + 'OCA\\DAV\\SystemTag\\SystemTagsObjectTypeCollection' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagsObjectTypeCollection.php', |
|
| 176 | + 'OCA\\DAV\\SystemTag\\SystemTagsRelationsCollection' => __DIR__.'/..'.'/../lib/SystemTag/SystemTagsRelationsCollection.php', |
|
| 177 | + 'OCA\\DAV\\Upload\\AssemblyStream' => __DIR__.'/..'.'/../lib/Upload/AssemblyStream.php', |
|
| 178 | + 'OCA\\DAV\\Upload\\ChunkingPlugin' => __DIR__.'/..'.'/../lib/Upload/ChunkingPlugin.php', |
|
| 179 | + 'OCA\\DAV\\Upload\\FutureFile' => __DIR__.'/..'.'/../lib/Upload/FutureFile.php', |
|
| 180 | + 'OCA\\DAV\\Upload\\RootCollection' => __DIR__.'/..'.'/../lib/Upload/RootCollection.php', |
|
| 181 | + 'OCA\\DAV\\Upload\\UploadFolder' => __DIR__.'/..'.'/../lib/Upload/UploadFolder.php', |
|
| 182 | + 'OCA\\DAV\\Upload\\UploadHome' => __DIR__.'/..'.'/../lib/Upload/UploadHome.php', |
|
| 183 | 183 | ); |
| 184 | 184 | |
| 185 | 185 | public static function getInitializer(ClassLoader $loader) |
| 186 | 186 | { |
| 187 | - return \Closure::bind(function () use ($loader) { |
|
| 187 | + return \Closure::bind(function() use ($loader) { |
|
| 188 | 188 | $loader->prefixLengthsPsr4 = ComposerStaticInitDAV::$prefixLengthsPsr4; |
| 189 | 189 | $loader->prefixDirsPsr4 = ComposerStaticInitDAV::$prefixDirsPsr4; |
| 190 | 190 | $loader->classMap = ComposerStaticInitDAV::$classMap; |
@@ -6,163 +6,163 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'OCA\\DAV\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', |
|
| 10 | - 'OCA\\DAV\\AppInfo\\PluginManager' => $baseDir . '/../lib/AppInfo/PluginManager.php', |
|
| 11 | - 'OCA\\DAV\\Avatars\\AvatarHome' => $baseDir . '/../lib/Avatars/AvatarHome.php', |
|
| 12 | - 'OCA\\DAV\\Avatars\\AvatarNode' => $baseDir . '/../lib/Avatars/AvatarNode.php', |
|
| 13 | - 'OCA\\DAV\\Avatars\\RootCollection' => $baseDir . '/../lib/Avatars/RootCollection.php', |
|
| 14 | - 'OCA\\DAV\\BackgroundJob\\CleanupDirectLinksJob' => $baseDir . '/../lib/BackgroundJob/CleanupDirectLinksJob.php', |
|
| 15 | - 'OCA\\DAV\\BackgroundJob\\GenerateBirthdayCalendarBackgroundJob' => $baseDir . '/../lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php', |
|
| 16 | - 'OCA\\DAV\\BackgroundJob\\UpdateCalendarResourcesRoomsBackgroundJob' => $baseDir . '/../lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php', |
|
| 17 | - 'OCA\\DAV\\CalDAV\\Activity\\Backend' => $baseDir . '/../lib/CalDAV/Activity/Backend.php', |
|
| 18 | - 'OCA\\DAV\\CalDAV\\Activity\\Filter\\Calendar' => $baseDir . '/../lib/CalDAV/Activity/Filter/Calendar.php', |
|
| 19 | - 'OCA\\DAV\\CalDAV\\Activity\\Filter\\Todo' => $baseDir . '/../lib/CalDAV/Activity/Filter/Todo.php', |
|
| 20 | - 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Base' => $baseDir . '/../lib/CalDAV/Activity/Provider/Base.php', |
|
| 21 | - 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Calendar' => $baseDir . '/../lib/CalDAV/Activity/Provider/Calendar.php', |
|
| 22 | - 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Event' => $baseDir . '/../lib/CalDAV/Activity/Provider/Event.php', |
|
| 23 | - 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Todo' => $baseDir . '/../lib/CalDAV/Activity/Provider/Todo.php', |
|
| 24 | - 'OCA\\DAV\\CalDAV\\Activity\\Setting\\Calendar' => $baseDir . '/../lib/CalDAV/Activity/Setting/Calendar.php', |
|
| 25 | - 'OCA\\DAV\\CalDAV\\Activity\\Setting\\Event' => $baseDir . '/../lib/CalDAV/Activity/Setting/Event.php', |
|
| 26 | - 'OCA\\DAV\\CalDAV\\Activity\\Setting\\Todo' => $baseDir . '/../lib/CalDAV/Activity/Setting/Todo.php', |
|
| 27 | - 'OCA\\DAV\\CalDAV\\BirthdayCalendar\\EnablePlugin' => $baseDir . '/../lib/CalDAV/BirthdayCalendar/EnablePlugin.php', |
|
| 28 | - 'OCA\\DAV\\CalDAV\\BirthdayService' => $baseDir . '/../lib/CalDAV/BirthdayService.php', |
|
| 29 | - 'OCA\\DAV\\CalDAV\\CalDavBackend' => $baseDir . '/../lib/CalDAV/CalDavBackend.php', |
|
| 30 | - 'OCA\\DAV\\CalDAV\\Calendar' => $baseDir . '/../lib/CalDAV/Calendar.php', |
|
| 31 | - 'OCA\\DAV\\CalDAV\\CalendarHome' => $baseDir . '/../lib/CalDAV/CalendarHome.php', |
|
| 32 | - 'OCA\\DAV\\CalDAV\\CalendarImpl' => $baseDir . '/../lib/CalDAV/CalendarImpl.php', |
|
| 33 | - 'OCA\\DAV\\CalDAV\\CalendarManager' => $baseDir . '/../lib/CalDAV/CalendarManager.php', |
|
| 34 | - 'OCA\\DAV\\CalDAV\\CalendarObject' => $baseDir . '/../lib/CalDAV/CalendarObject.php', |
|
| 35 | - 'OCA\\DAV\\CalDAV\\CalendarRoot' => $baseDir . '/../lib/CalDAV/CalendarRoot.php', |
|
| 36 | - 'OCA\\DAV\\CalDAV\\Plugin' => $baseDir . '/../lib/CalDAV/Plugin.php', |
|
| 37 | - 'OCA\\DAV\\CalDAV\\Principal\\Collection' => $baseDir . '/../lib/CalDAV/Principal/Collection.php', |
|
| 38 | - 'OCA\\DAV\\CalDAV\\Principal\\User' => $baseDir . '/../lib/CalDAV/Principal/User.php', |
|
| 39 | - 'OCA\\DAV\\CalDAV\\PublicCalendar' => $baseDir . '/../lib/CalDAV/PublicCalendar.php', |
|
| 40 | - 'OCA\\DAV\\CalDAV\\PublicCalendarObject' => $baseDir . '/../lib/CalDAV/PublicCalendarObject.php', |
|
| 41 | - 'OCA\\DAV\\CalDAV\\PublicCalendarRoot' => $baseDir . '/../lib/CalDAV/PublicCalendarRoot.php', |
|
| 42 | - 'OCA\\DAV\\CalDAV\\Publishing\\PublishPlugin' => $baseDir . '/../lib/CalDAV/Publishing/PublishPlugin.php', |
|
| 43 | - 'OCA\\DAV\\CalDAV\\Publishing\\Xml\\Publisher' => $baseDir . '/../lib/CalDAV/Publishing/Xml/Publisher.php', |
|
| 44 | - 'OCA\\DAV\\CalDAV\\ResourceBooking\\AbstractPrincipalBackend' => $baseDir . '/../lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php', |
|
| 45 | - 'OCA\\DAV\\CalDAV\\ResourceBooking\\ResourcePrincipalBackend' => $baseDir . '/../lib/CalDAV/ResourceBooking/ResourcePrincipalBackend.php', |
|
| 46 | - 'OCA\\DAV\\CalDAV\\ResourceBooking\\RoomPrincipalBackend' => $baseDir . '/../lib/CalDAV/ResourceBooking/RoomPrincipalBackend.php', |
|
| 47 | - 'OCA\\DAV\\CalDAV\\Schedule\\IMipPlugin' => $baseDir . '/../lib/CalDAV/Schedule/IMipPlugin.php', |
|
| 48 | - 'OCA\\DAV\\CalDAV\\Schedule\\Plugin' => $baseDir . '/../lib/CalDAV/Schedule/Plugin.php', |
|
| 49 | - 'OCA\\DAV\\CalDAV\\Search\\SearchPlugin' => $baseDir . '/../lib/CalDAV/Search/SearchPlugin.php', |
|
| 50 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter' => $baseDir . '/../lib/CalDAV/Search/Xml/Filter/CompFilter.php', |
|
| 51 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter' => $baseDir . '/../lib/CalDAV/Search/Xml/Filter/LimitFilter.php', |
|
| 52 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter' => $baseDir . '/../lib/CalDAV/Search/Xml/Filter/OffsetFilter.php', |
|
| 53 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter' => $baseDir . '/../lib/CalDAV/Search/Xml/Filter/ParamFilter.php', |
|
| 54 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter' => $baseDir . '/../lib/CalDAV/Search/Xml/Filter/PropFilter.php', |
|
| 55 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter' => $baseDir . '/../lib/CalDAV/Search/Xml/Filter/SearchTermFilter.php', |
|
| 56 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport' => $baseDir . '/../lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php', |
|
| 57 | - 'OCA\\DAV\\Capabilities' => $baseDir . '/../lib/Capabilities.php', |
|
| 58 | - 'OCA\\DAV\\CardDAV\\AddressBook' => $baseDir . '/../lib/CardDAV/AddressBook.php', |
|
| 59 | - 'OCA\\DAV\\CardDAV\\AddressBookImpl' => $baseDir . '/../lib/CardDAV/AddressBookImpl.php', |
|
| 60 | - 'OCA\\DAV\\CardDAV\\AddressBookRoot' => $baseDir . '/../lib/CardDAV/AddressBookRoot.php', |
|
| 61 | - 'OCA\\DAV\\CardDAV\\CardDavBackend' => $baseDir . '/../lib/CardDAV/CardDavBackend.php', |
|
| 62 | - 'OCA\\DAV\\CardDAV\\ContactsManager' => $baseDir . '/../lib/CardDAV/ContactsManager.php', |
|
| 63 | - 'OCA\\DAV\\CardDAV\\Converter' => $baseDir . '/../lib/CardDAV/Converter.php', |
|
| 64 | - 'OCA\\DAV\\CardDAV\\ImageExportPlugin' => $baseDir . '/../lib/CardDAV/ImageExportPlugin.php', |
|
| 65 | - 'OCA\\DAV\\CardDAV\\PhotoCache' => $baseDir . '/../lib/CardDAV/PhotoCache.php', |
|
| 66 | - 'OCA\\DAV\\CardDAV\\Plugin' => $baseDir . '/../lib/CardDAV/Plugin.php', |
|
| 67 | - 'OCA\\DAV\\CardDAV\\SyncService' => $baseDir . '/../lib/CardDAV/SyncService.php', |
|
| 68 | - 'OCA\\DAV\\CardDAV\\UserAddressBooks' => $baseDir . '/../lib/CardDAV/UserAddressBooks.php', |
|
| 69 | - 'OCA\\DAV\\CardDAV\\Xml\\Groups' => $baseDir . '/../lib/CardDAV/Xml/Groups.php', |
|
| 70 | - 'OCA\\DAV\\Command\\CreateAddressBook' => $baseDir . '/../lib/Command/CreateAddressBook.php', |
|
| 71 | - 'OCA\\DAV\\Command\\CreateCalendar' => $baseDir . '/../lib/Command/CreateCalendar.php', |
|
| 72 | - 'OCA\\DAV\\Command\\RemoveInvalidShares' => $baseDir . '/../lib/Command/RemoveInvalidShares.php', |
|
| 73 | - 'OCA\\DAV\\Command\\SyncBirthdayCalendar' => $baseDir . '/../lib/Command/SyncBirthdayCalendar.php', |
|
| 74 | - 'OCA\\DAV\\Command\\SyncSystemAddressBook' => $baseDir . '/../lib/Command/SyncSystemAddressBook.php', |
|
| 75 | - 'OCA\\DAV\\Comments\\CommentNode' => $baseDir . '/../lib/Comments/CommentNode.php', |
|
| 76 | - 'OCA\\DAV\\Comments\\CommentsPlugin' => $baseDir . '/../lib/Comments/CommentsPlugin.php', |
|
| 77 | - 'OCA\\DAV\\Comments\\EntityCollection' => $baseDir . '/../lib/Comments/EntityCollection.php', |
|
| 78 | - 'OCA\\DAV\\Comments\\EntityTypeCollection' => $baseDir . '/../lib/Comments/EntityTypeCollection.php', |
|
| 79 | - 'OCA\\DAV\\Comments\\RootCollection' => $baseDir . '/../lib/Comments/RootCollection.php', |
|
| 80 | - 'OCA\\DAV\\Connector\\LegacyDAVACL' => $baseDir . '/../lib/Connector/LegacyDAVACL.php', |
|
| 81 | - 'OCA\\DAV\\Connector\\PublicAuth' => $baseDir . '/../lib/Connector/PublicAuth.php', |
|
| 82 | - 'OCA\\DAV\\Connector\\Sabre\\AnonymousOptionsPlugin' => $baseDir . '/../lib/Connector/Sabre/AnonymousOptionsPlugin.php', |
|
| 83 | - 'OCA\\DAV\\Connector\\Sabre\\AppEnabledPlugin' => $baseDir . '/../lib/Connector/Sabre/AppEnabledPlugin.php', |
|
| 84 | - 'OCA\\DAV\\Connector\\Sabre\\Auth' => $baseDir . '/../lib/Connector/Sabre/Auth.php', |
|
| 85 | - 'OCA\\DAV\\Connector\\Sabre\\BearerAuth' => $baseDir . '/../lib/Connector/Sabre/BearerAuth.php', |
|
| 86 | - 'OCA\\DAV\\Connector\\Sabre\\BlockLegacyClientPlugin' => $baseDir . '/../lib/Connector/Sabre/BlockLegacyClientPlugin.php', |
|
| 87 | - 'OCA\\DAV\\Connector\\Sabre\\CachingTree' => $baseDir . '/../lib/Connector/Sabre/CachingTree.php', |
|
| 88 | - 'OCA\\DAV\\Connector\\Sabre\\ChecksumList' => $baseDir . '/../lib/Connector/Sabre/ChecksumList.php', |
|
| 89 | - 'OCA\\DAV\\Connector\\Sabre\\CommentPropertiesPlugin' => $baseDir . '/../lib/Connector/Sabre/CommentPropertiesPlugin.php', |
|
| 90 | - 'OCA\\DAV\\Connector\\Sabre\\CopyEtagHeaderPlugin' => $baseDir . '/../lib/Connector/Sabre/CopyEtagHeaderPlugin.php', |
|
| 91 | - 'OCA\\DAV\\Connector\\Sabre\\CustomPropertiesBackend' => $baseDir . '/../lib/Connector/Sabre/CustomPropertiesBackend.php', |
|
| 92 | - 'OCA\\DAV\\Connector\\Sabre\\DavAclPlugin' => $baseDir . '/../lib/Connector/Sabre/DavAclPlugin.php', |
|
| 93 | - 'OCA\\DAV\\Connector\\Sabre\\Directory' => $baseDir . '/../lib/Connector/Sabre/Directory.php', |
|
| 94 | - 'OCA\\DAV\\Connector\\Sabre\\DummyGetResponsePlugin' => $baseDir . '/../lib/Connector/Sabre/DummyGetResponsePlugin.php', |
|
| 95 | - 'OCA\\DAV\\Connector\\Sabre\\ExceptionLoggerPlugin' => $baseDir . '/../lib/Connector/Sabre/ExceptionLoggerPlugin.php', |
|
| 96 | - 'OCA\\DAV\\Connector\\Sabre\\Exception\\EntityTooLarge' => $baseDir . '/../lib/Connector/Sabre/Exception/EntityTooLarge.php', |
|
| 97 | - 'OCA\\DAV\\Connector\\Sabre\\Exception\\FileLocked' => $baseDir . '/../lib/Connector/Sabre/Exception/FileLocked.php', |
|
| 98 | - 'OCA\\DAV\\Connector\\Sabre\\Exception\\Forbidden' => $baseDir . '/../lib/Connector/Sabre/Exception/Forbidden.php', |
|
| 99 | - 'OCA\\DAV\\Connector\\Sabre\\Exception\\InvalidPath' => $baseDir . '/../lib/Connector/Sabre/Exception/InvalidPath.php', |
|
| 100 | - 'OCA\\DAV\\Connector\\Sabre\\Exception\\PasswordLoginForbidden' => $baseDir . '/../lib/Connector/Sabre/Exception/PasswordLoginForbidden.php', |
|
| 101 | - 'OCA\\DAV\\Connector\\Sabre\\Exception\\UnsupportedMediaType' => $baseDir . '/../lib/Connector/Sabre/Exception/UnsupportedMediaType.php', |
|
| 102 | - 'OCA\\DAV\\Connector\\Sabre\\FakeLockerPlugin' => $baseDir . '/../lib/Connector/Sabre/FakeLockerPlugin.php', |
|
| 103 | - 'OCA\\DAV\\Connector\\Sabre\\File' => $baseDir . '/../lib/Connector/Sabre/File.php', |
|
| 104 | - 'OCA\\DAV\\Connector\\Sabre\\FilesPlugin' => $baseDir . '/../lib/Connector/Sabre/FilesPlugin.php', |
|
| 105 | - 'OCA\\DAV\\Connector\\Sabre\\FilesReportPlugin' => $baseDir . '/../lib/Connector/Sabre/FilesReportPlugin.php', |
|
| 106 | - 'OCA\\DAV\\Connector\\Sabre\\LockPlugin' => $baseDir . '/../lib/Connector/Sabre/LockPlugin.php', |
|
| 107 | - 'OCA\\DAV\\Connector\\Sabre\\MaintenancePlugin' => $baseDir . '/../lib/Connector/Sabre/MaintenancePlugin.php', |
|
| 108 | - 'OCA\\DAV\\Connector\\Sabre\\Node' => $baseDir . '/../lib/Connector/Sabre/Node.php', |
|
| 109 | - 'OCA\\DAV\\Connector\\Sabre\\ObjectTree' => $baseDir . '/../lib/Connector/Sabre/ObjectTree.php', |
|
| 110 | - 'OCA\\DAV\\Connector\\Sabre\\Principal' => $baseDir . '/../lib/Connector/Sabre/Principal.php', |
|
| 111 | - 'OCA\\DAV\\Connector\\Sabre\\QuotaPlugin' => $baseDir . '/../lib/Connector/Sabre/QuotaPlugin.php', |
|
| 112 | - 'OCA\\DAV\\Connector\\Sabre\\Server' => $baseDir . '/../lib/Connector/Sabre/Server.php', |
|
| 113 | - 'OCA\\DAV\\Connector\\Sabre\\ServerFactory' => $baseDir . '/../lib/Connector/Sabre/ServerFactory.php', |
|
| 114 | - 'OCA\\DAV\\Connector\\Sabre\\ShareTypeList' => $baseDir . '/../lib/Connector/Sabre/ShareTypeList.php', |
|
| 115 | - 'OCA\\DAV\\Connector\\Sabre\\SharesPlugin' => $baseDir . '/../lib/Connector/Sabre/SharesPlugin.php', |
|
| 116 | - 'OCA\\DAV\\Connector\\Sabre\\TagList' => $baseDir . '/../lib/Connector/Sabre/TagList.php', |
|
| 117 | - 'OCA\\DAV\\Connector\\Sabre\\TagsPlugin' => $baseDir . '/../lib/Connector/Sabre/TagsPlugin.php', |
|
| 118 | - 'OCA\\DAV\\Controller\\BirthdayCalendarController' => $baseDir . '/../lib/Controller/BirthdayCalendarController.php', |
|
| 119 | - 'OCA\\DAV\\Controller\\DirectController' => $baseDir . '/../lib/Controller/DirectController.php', |
|
| 120 | - 'OCA\\DAV\\DAV\\CustomPropertiesBackend' => $baseDir . '/../lib/DAV/CustomPropertiesBackend.php', |
|
| 121 | - 'OCA\\DAV\\DAV\\GroupPrincipalBackend' => $baseDir . '/../lib/DAV/GroupPrincipalBackend.php', |
|
| 122 | - 'OCA\\DAV\\DAV\\PublicAuth' => $baseDir . '/../lib/DAV/PublicAuth.php', |
|
| 123 | - 'OCA\\DAV\\DAV\\Sharing\\Backend' => $baseDir . '/../lib/DAV/Sharing/Backend.php', |
|
| 124 | - 'OCA\\DAV\\DAV\\Sharing\\IShareable' => $baseDir . '/../lib/DAV/Sharing/IShareable.php', |
|
| 125 | - 'OCA\\DAV\\DAV\\Sharing\\Plugin' => $baseDir . '/../lib/DAV/Sharing/Plugin.php', |
|
| 126 | - 'OCA\\DAV\\DAV\\Sharing\\Xml\\Invite' => $baseDir . '/../lib/DAV/Sharing/Xml/Invite.php', |
|
| 127 | - 'OCA\\DAV\\DAV\\Sharing\\Xml\\ShareRequest' => $baseDir . '/../lib/DAV/Sharing/Xml/ShareRequest.php', |
|
| 128 | - 'OCA\\DAV\\DAV\\SystemPrincipalBackend' => $baseDir . '/../lib/DAV/SystemPrincipalBackend.php', |
|
| 129 | - 'OCA\\DAV\\Db\\Direct' => $baseDir . '/../lib/Db/Direct.php', |
|
| 130 | - 'OCA\\DAV\\Db\\DirectMapper' => $baseDir . '/../lib/Db/DirectMapper.php', |
|
| 131 | - 'OCA\\DAV\\Direct\\DirectFile' => $baseDir . '/../lib/Direct/DirectFile.php', |
|
| 132 | - 'OCA\\DAV\\Direct\\DirectHome' => $baseDir . '/../lib/Direct/DirectHome.php', |
|
| 133 | - 'OCA\\DAV\\Direct\\Server' => $baseDir . '/../lib/Direct/Server.php', |
|
| 134 | - 'OCA\\DAV\\Direct\\ServerFactory' => $baseDir . '/../lib/Direct/ServerFactory.php', |
|
| 135 | - 'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => $baseDir . '/../lib/Files/BrowserErrorPagePlugin.php', |
|
| 136 | - 'OCA\\DAV\\Files\\FileSearchBackend' => $baseDir . '/../lib/Files/FileSearchBackend.php', |
|
| 137 | - 'OCA\\DAV\\Files\\FilesHome' => $baseDir . '/../lib/Files/FilesHome.php', |
|
| 138 | - 'OCA\\DAV\\Files\\RootCollection' => $baseDir . '/../lib/Files/RootCollection.php', |
|
| 139 | - 'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => $baseDir . '/../lib/Files/Sharing/FilesDropPlugin.php', |
|
| 140 | - 'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => $baseDir . '/../lib/Files/Sharing/PublicLinkCheckPlugin.php', |
|
| 141 | - 'OCA\\DAV\\HookManager' => $baseDir . '/../lib/HookManager.php', |
|
| 142 | - 'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => $baseDir . '/../lib/Migration/BuildCalendarSearchIndex.php', |
|
| 143 | - 'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => $baseDir . '/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php', |
|
| 144 | - 'OCA\\DAV\\Migration\\CalDAVRemoveEmptyValue' => $baseDir . '/../lib/Migration/CalDAVRemoveEmptyValue.php', |
|
| 145 | - 'OCA\\DAV\\Migration\\FixBirthdayCalendarComponent' => $baseDir . '/../lib/Migration/FixBirthdayCalendarComponent.php', |
|
| 146 | - 'OCA\\DAV\\Migration\\Version1004Date20170825134824' => $baseDir . '/../lib/Migration/Version1004Date20170825134824.php', |
|
| 147 | - 'OCA\\DAV\\Migration\\Version1004Date20170919104507' => $baseDir . '/../lib/Migration/Version1004Date20170919104507.php', |
|
| 148 | - 'OCA\\DAV\\Migration\\Version1004Date20170924124212' => $baseDir . '/../lib/Migration/Version1004Date20170924124212.php', |
|
| 149 | - 'OCA\\DAV\\Migration\\Version1004Date20170926103422' => $baseDir . '/../lib/Migration/Version1004Date20170926103422.php', |
|
| 150 | - 'OCA\\DAV\\Migration\\Version1005Date20180413093149' => $baseDir . '/../lib/Migration/Version1005Date20180413093149.php', |
|
| 151 | - 'OCA\\DAV\\Migration\\Version1005Date20180530124431' => $baseDir . '/../lib/Migration/Version1005Date20180530124431.php', |
|
| 152 | - 'OCA\\DAV\\RootCollection' => $baseDir . '/../lib/RootCollection.php', |
|
| 153 | - 'OCA\\DAV\\Server' => $baseDir . '/../lib/Server.php', |
|
| 154 | - 'OCA\\DAV\\Settings\\CalDAVSettings' => $baseDir . '/../lib/Settings/CalDAVSettings.php', |
|
| 155 | - 'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => $baseDir . '/../lib/SystemTag/SystemTagMappingNode.php', |
|
| 156 | - 'OCA\\DAV\\SystemTag\\SystemTagNode' => $baseDir . '/../lib/SystemTag/SystemTagNode.php', |
|
| 157 | - 'OCA\\DAV\\SystemTag\\SystemTagPlugin' => $baseDir . '/../lib/SystemTag/SystemTagPlugin.php', |
|
| 158 | - 'OCA\\DAV\\SystemTag\\SystemTagsByIdCollection' => $baseDir . '/../lib/SystemTag/SystemTagsByIdCollection.php', |
|
| 159 | - 'OCA\\DAV\\SystemTag\\SystemTagsObjectMappingCollection' => $baseDir . '/../lib/SystemTag/SystemTagsObjectMappingCollection.php', |
|
| 160 | - 'OCA\\DAV\\SystemTag\\SystemTagsObjectTypeCollection' => $baseDir . '/../lib/SystemTag/SystemTagsObjectTypeCollection.php', |
|
| 161 | - 'OCA\\DAV\\SystemTag\\SystemTagsRelationsCollection' => $baseDir . '/../lib/SystemTag/SystemTagsRelationsCollection.php', |
|
| 162 | - 'OCA\\DAV\\Upload\\AssemblyStream' => $baseDir . '/../lib/Upload/AssemblyStream.php', |
|
| 163 | - 'OCA\\DAV\\Upload\\ChunkingPlugin' => $baseDir . '/../lib/Upload/ChunkingPlugin.php', |
|
| 164 | - 'OCA\\DAV\\Upload\\FutureFile' => $baseDir . '/../lib/Upload/FutureFile.php', |
|
| 165 | - 'OCA\\DAV\\Upload\\RootCollection' => $baseDir . '/../lib/Upload/RootCollection.php', |
|
| 166 | - 'OCA\\DAV\\Upload\\UploadFolder' => $baseDir . '/../lib/Upload/UploadFolder.php', |
|
| 167 | - 'OCA\\DAV\\Upload\\UploadHome' => $baseDir . '/../lib/Upload/UploadHome.php', |
|
| 9 | + 'OCA\\DAV\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', |
|
| 10 | + 'OCA\\DAV\\AppInfo\\PluginManager' => $baseDir.'/../lib/AppInfo/PluginManager.php', |
|
| 11 | + 'OCA\\DAV\\Avatars\\AvatarHome' => $baseDir.'/../lib/Avatars/AvatarHome.php', |
|
| 12 | + 'OCA\\DAV\\Avatars\\AvatarNode' => $baseDir.'/../lib/Avatars/AvatarNode.php', |
|
| 13 | + 'OCA\\DAV\\Avatars\\RootCollection' => $baseDir.'/../lib/Avatars/RootCollection.php', |
|
| 14 | + 'OCA\\DAV\\BackgroundJob\\CleanupDirectLinksJob' => $baseDir.'/../lib/BackgroundJob/CleanupDirectLinksJob.php', |
|
| 15 | + 'OCA\\DAV\\BackgroundJob\\GenerateBirthdayCalendarBackgroundJob' => $baseDir.'/../lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php', |
|
| 16 | + 'OCA\\DAV\\BackgroundJob\\UpdateCalendarResourcesRoomsBackgroundJob' => $baseDir.'/../lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php', |
|
| 17 | + 'OCA\\DAV\\CalDAV\\Activity\\Backend' => $baseDir.'/../lib/CalDAV/Activity/Backend.php', |
|
| 18 | + 'OCA\\DAV\\CalDAV\\Activity\\Filter\\Calendar' => $baseDir.'/../lib/CalDAV/Activity/Filter/Calendar.php', |
|
| 19 | + 'OCA\\DAV\\CalDAV\\Activity\\Filter\\Todo' => $baseDir.'/../lib/CalDAV/Activity/Filter/Todo.php', |
|
| 20 | + 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Base' => $baseDir.'/../lib/CalDAV/Activity/Provider/Base.php', |
|
| 21 | + 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Calendar' => $baseDir.'/../lib/CalDAV/Activity/Provider/Calendar.php', |
|
| 22 | + 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Event' => $baseDir.'/../lib/CalDAV/Activity/Provider/Event.php', |
|
| 23 | + 'OCA\\DAV\\CalDAV\\Activity\\Provider\\Todo' => $baseDir.'/../lib/CalDAV/Activity/Provider/Todo.php', |
|
| 24 | + 'OCA\\DAV\\CalDAV\\Activity\\Setting\\Calendar' => $baseDir.'/../lib/CalDAV/Activity/Setting/Calendar.php', |
|
| 25 | + 'OCA\\DAV\\CalDAV\\Activity\\Setting\\Event' => $baseDir.'/../lib/CalDAV/Activity/Setting/Event.php', |
|
| 26 | + 'OCA\\DAV\\CalDAV\\Activity\\Setting\\Todo' => $baseDir.'/../lib/CalDAV/Activity/Setting/Todo.php', |
|
| 27 | + 'OCA\\DAV\\CalDAV\\BirthdayCalendar\\EnablePlugin' => $baseDir.'/../lib/CalDAV/BirthdayCalendar/EnablePlugin.php', |
|
| 28 | + 'OCA\\DAV\\CalDAV\\BirthdayService' => $baseDir.'/../lib/CalDAV/BirthdayService.php', |
|
| 29 | + 'OCA\\DAV\\CalDAV\\CalDavBackend' => $baseDir.'/../lib/CalDAV/CalDavBackend.php', |
|
| 30 | + 'OCA\\DAV\\CalDAV\\Calendar' => $baseDir.'/../lib/CalDAV/Calendar.php', |
|
| 31 | + 'OCA\\DAV\\CalDAV\\CalendarHome' => $baseDir.'/../lib/CalDAV/CalendarHome.php', |
|
| 32 | + 'OCA\\DAV\\CalDAV\\CalendarImpl' => $baseDir.'/../lib/CalDAV/CalendarImpl.php', |
|
| 33 | + 'OCA\\DAV\\CalDAV\\CalendarManager' => $baseDir.'/../lib/CalDAV/CalendarManager.php', |
|
| 34 | + 'OCA\\DAV\\CalDAV\\CalendarObject' => $baseDir.'/../lib/CalDAV/CalendarObject.php', |
|
| 35 | + 'OCA\\DAV\\CalDAV\\CalendarRoot' => $baseDir.'/../lib/CalDAV/CalendarRoot.php', |
|
| 36 | + 'OCA\\DAV\\CalDAV\\Plugin' => $baseDir.'/../lib/CalDAV/Plugin.php', |
|
| 37 | + 'OCA\\DAV\\CalDAV\\Principal\\Collection' => $baseDir.'/../lib/CalDAV/Principal/Collection.php', |
|
| 38 | + 'OCA\\DAV\\CalDAV\\Principal\\User' => $baseDir.'/../lib/CalDAV/Principal/User.php', |
|
| 39 | + 'OCA\\DAV\\CalDAV\\PublicCalendar' => $baseDir.'/../lib/CalDAV/PublicCalendar.php', |
|
| 40 | + 'OCA\\DAV\\CalDAV\\PublicCalendarObject' => $baseDir.'/../lib/CalDAV/PublicCalendarObject.php', |
|
| 41 | + 'OCA\\DAV\\CalDAV\\PublicCalendarRoot' => $baseDir.'/../lib/CalDAV/PublicCalendarRoot.php', |
|
| 42 | + 'OCA\\DAV\\CalDAV\\Publishing\\PublishPlugin' => $baseDir.'/../lib/CalDAV/Publishing/PublishPlugin.php', |
|
| 43 | + 'OCA\\DAV\\CalDAV\\Publishing\\Xml\\Publisher' => $baseDir.'/../lib/CalDAV/Publishing/Xml/Publisher.php', |
|
| 44 | + 'OCA\\DAV\\CalDAV\\ResourceBooking\\AbstractPrincipalBackend' => $baseDir.'/../lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php', |
|
| 45 | + 'OCA\\DAV\\CalDAV\\ResourceBooking\\ResourcePrincipalBackend' => $baseDir.'/../lib/CalDAV/ResourceBooking/ResourcePrincipalBackend.php', |
|
| 46 | + 'OCA\\DAV\\CalDAV\\ResourceBooking\\RoomPrincipalBackend' => $baseDir.'/../lib/CalDAV/ResourceBooking/RoomPrincipalBackend.php', |
|
| 47 | + 'OCA\\DAV\\CalDAV\\Schedule\\IMipPlugin' => $baseDir.'/../lib/CalDAV/Schedule/IMipPlugin.php', |
|
| 48 | + 'OCA\\DAV\\CalDAV\\Schedule\\Plugin' => $baseDir.'/../lib/CalDAV/Schedule/Plugin.php', |
|
| 49 | + 'OCA\\DAV\\CalDAV\\Search\\SearchPlugin' => $baseDir.'/../lib/CalDAV/Search/SearchPlugin.php', |
|
| 50 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter' => $baseDir.'/../lib/CalDAV/Search/Xml/Filter/CompFilter.php', |
|
| 51 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter' => $baseDir.'/../lib/CalDAV/Search/Xml/Filter/LimitFilter.php', |
|
| 52 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter' => $baseDir.'/../lib/CalDAV/Search/Xml/Filter/OffsetFilter.php', |
|
| 53 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter' => $baseDir.'/../lib/CalDAV/Search/Xml/Filter/ParamFilter.php', |
|
| 54 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter' => $baseDir.'/../lib/CalDAV/Search/Xml/Filter/PropFilter.php', |
|
| 55 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter' => $baseDir.'/../lib/CalDAV/Search/Xml/Filter/SearchTermFilter.php', |
|
| 56 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport' => $baseDir.'/../lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php', |
|
| 57 | + 'OCA\\DAV\\Capabilities' => $baseDir.'/../lib/Capabilities.php', |
|
| 58 | + 'OCA\\DAV\\CardDAV\\AddressBook' => $baseDir.'/../lib/CardDAV/AddressBook.php', |
|
| 59 | + 'OCA\\DAV\\CardDAV\\AddressBookImpl' => $baseDir.'/../lib/CardDAV/AddressBookImpl.php', |
|
| 60 | + 'OCA\\DAV\\CardDAV\\AddressBookRoot' => $baseDir.'/../lib/CardDAV/AddressBookRoot.php', |
|
| 61 | + 'OCA\\DAV\\CardDAV\\CardDavBackend' => $baseDir.'/../lib/CardDAV/CardDavBackend.php', |
|
| 62 | + 'OCA\\DAV\\CardDAV\\ContactsManager' => $baseDir.'/../lib/CardDAV/ContactsManager.php', |
|
| 63 | + 'OCA\\DAV\\CardDAV\\Converter' => $baseDir.'/../lib/CardDAV/Converter.php', |
|
| 64 | + 'OCA\\DAV\\CardDAV\\ImageExportPlugin' => $baseDir.'/../lib/CardDAV/ImageExportPlugin.php', |
|
| 65 | + 'OCA\\DAV\\CardDAV\\PhotoCache' => $baseDir.'/../lib/CardDAV/PhotoCache.php', |
|
| 66 | + 'OCA\\DAV\\CardDAV\\Plugin' => $baseDir.'/../lib/CardDAV/Plugin.php', |
|
| 67 | + 'OCA\\DAV\\CardDAV\\SyncService' => $baseDir.'/../lib/CardDAV/SyncService.php', |
|
| 68 | + 'OCA\\DAV\\CardDAV\\UserAddressBooks' => $baseDir.'/../lib/CardDAV/UserAddressBooks.php', |
|
| 69 | + 'OCA\\DAV\\CardDAV\\Xml\\Groups' => $baseDir.'/../lib/CardDAV/Xml/Groups.php', |
|
| 70 | + 'OCA\\DAV\\Command\\CreateAddressBook' => $baseDir.'/../lib/Command/CreateAddressBook.php', |
|
| 71 | + 'OCA\\DAV\\Command\\CreateCalendar' => $baseDir.'/../lib/Command/CreateCalendar.php', |
|
| 72 | + 'OCA\\DAV\\Command\\RemoveInvalidShares' => $baseDir.'/../lib/Command/RemoveInvalidShares.php', |
|
| 73 | + 'OCA\\DAV\\Command\\SyncBirthdayCalendar' => $baseDir.'/../lib/Command/SyncBirthdayCalendar.php', |
|
| 74 | + 'OCA\\DAV\\Command\\SyncSystemAddressBook' => $baseDir.'/../lib/Command/SyncSystemAddressBook.php', |
|
| 75 | + 'OCA\\DAV\\Comments\\CommentNode' => $baseDir.'/../lib/Comments/CommentNode.php', |
|
| 76 | + 'OCA\\DAV\\Comments\\CommentsPlugin' => $baseDir.'/../lib/Comments/CommentsPlugin.php', |
|
| 77 | + 'OCA\\DAV\\Comments\\EntityCollection' => $baseDir.'/../lib/Comments/EntityCollection.php', |
|
| 78 | + 'OCA\\DAV\\Comments\\EntityTypeCollection' => $baseDir.'/../lib/Comments/EntityTypeCollection.php', |
|
| 79 | + 'OCA\\DAV\\Comments\\RootCollection' => $baseDir.'/../lib/Comments/RootCollection.php', |
|
| 80 | + 'OCA\\DAV\\Connector\\LegacyDAVACL' => $baseDir.'/../lib/Connector/LegacyDAVACL.php', |
|
| 81 | + 'OCA\\DAV\\Connector\\PublicAuth' => $baseDir.'/../lib/Connector/PublicAuth.php', |
|
| 82 | + 'OCA\\DAV\\Connector\\Sabre\\AnonymousOptionsPlugin' => $baseDir.'/../lib/Connector/Sabre/AnonymousOptionsPlugin.php', |
|
| 83 | + 'OCA\\DAV\\Connector\\Sabre\\AppEnabledPlugin' => $baseDir.'/../lib/Connector/Sabre/AppEnabledPlugin.php', |
|
| 84 | + 'OCA\\DAV\\Connector\\Sabre\\Auth' => $baseDir.'/../lib/Connector/Sabre/Auth.php', |
|
| 85 | + 'OCA\\DAV\\Connector\\Sabre\\BearerAuth' => $baseDir.'/../lib/Connector/Sabre/BearerAuth.php', |
|
| 86 | + 'OCA\\DAV\\Connector\\Sabre\\BlockLegacyClientPlugin' => $baseDir.'/../lib/Connector/Sabre/BlockLegacyClientPlugin.php', |
|
| 87 | + 'OCA\\DAV\\Connector\\Sabre\\CachingTree' => $baseDir.'/../lib/Connector/Sabre/CachingTree.php', |
|
| 88 | + 'OCA\\DAV\\Connector\\Sabre\\ChecksumList' => $baseDir.'/../lib/Connector/Sabre/ChecksumList.php', |
|
| 89 | + 'OCA\\DAV\\Connector\\Sabre\\CommentPropertiesPlugin' => $baseDir.'/../lib/Connector/Sabre/CommentPropertiesPlugin.php', |
|
| 90 | + 'OCA\\DAV\\Connector\\Sabre\\CopyEtagHeaderPlugin' => $baseDir.'/../lib/Connector/Sabre/CopyEtagHeaderPlugin.php', |
|
| 91 | + 'OCA\\DAV\\Connector\\Sabre\\CustomPropertiesBackend' => $baseDir.'/../lib/Connector/Sabre/CustomPropertiesBackend.php', |
|
| 92 | + 'OCA\\DAV\\Connector\\Sabre\\DavAclPlugin' => $baseDir.'/../lib/Connector/Sabre/DavAclPlugin.php', |
|
| 93 | + 'OCA\\DAV\\Connector\\Sabre\\Directory' => $baseDir.'/../lib/Connector/Sabre/Directory.php', |
|
| 94 | + 'OCA\\DAV\\Connector\\Sabre\\DummyGetResponsePlugin' => $baseDir.'/../lib/Connector/Sabre/DummyGetResponsePlugin.php', |
|
| 95 | + 'OCA\\DAV\\Connector\\Sabre\\ExceptionLoggerPlugin' => $baseDir.'/../lib/Connector/Sabre/ExceptionLoggerPlugin.php', |
|
| 96 | + 'OCA\\DAV\\Connector\\Sabre\\Exception\\EntityTooLarge' => $baseDir.'/../lib/Connector/Sabre/Exception/EntityTooLarge.php', |
|
| 97 | + 'OCA\\DAV\\Connector\\Sabre\\Exception\\FileLocked' => $baseDir.'/../lib/Connector/Sabre/Exception/FileLocked.php', |
|
| 98 | + 'OCA\\DAV\\Connector\\Sabre\\Exception\\Forbidden' => $baseDir.'/../lib/Connector/Sabre/Exception/Forbidden.php', |
|
| 99 | + 'OCA\\DAV\\Connector\\Sabre\\Exception\\InvalidPath' => $baseDir.'/../lib/Connector/Sabre/Exception/InvalidPath.php', |
|
| 100 | + 'OCA\\DAV\\Connector\\Sabre\\Exception\\PasswordLoginForbidden' => $baseDir.'/../lib/Connector/Sabre/Exception/PasswordLoginForbidden.php', |
|
| 101 | + 'OCA\\DAV\\Connector\\Sabre\\Exception\\UnsupportedMediaType' => $baseDir.'/../lib/Connector/Sabre/Exception/UnsupportedMediaType.php', |
|
| 102 | + 'OCA\\DAV\\Connector\\Sabre\\FakeLockerPlugin' => $baseDir.'/../lib/Connector/Sabre/FakeLockerPlugin.php', |
|
| 103 | + 'OCA\\DAV\\Connector\\Sabre\\File' => $baseDir.'/../lib/Connector/Sabre/File.php', |
|
| 104 | + 'OCA\\DAV\\Connector\\Sabre\\FilesPlugin' => $baseDir.'/../lib/Connector/Sabre/FilesPlugin.php', |
|
| 105 | + 'OCA\\DAV\\Connector\\Sabre\\FilesReportPlugin' => $baseDir.'/../lib/Connector/Sabre/FilesReportPlugin.php', |
|
| 106 | + 'OCA\\DAV\\Connector\\Sabre\\LockPlugin' => $baseDir.'/../lib/Connector/Sabre/LockPlugin.php', |
|
| 107 | + 'OCA\\DAV\\Connector\\Sabre\\MaintenancePlugin' => $baseDir.'/../lib/Connector/Sabre/MaintenancePlugin.php', |
|
| 108 | + 'OCA\\DAV\\Connector\\Sabre\\Node' => $baseDir.'/../lib/Connector/Sabre/Node.php', |
|
| 109 | + 'OCA\\DAV\\Connector\\Sabre\\ObjectTree' => $baseDir.'/../lib/Connector/Sabre/ObjectTree.php', |
|
| 110 | + 'OCA\\DAV\\Connector\\Sabre\\Principal' => $baseDir.'/../lib/Connector/Sabre/Principal.php', |
|
| 111 | + 'OCA\\DAV\\Connector\\Sabre\\QuotaPlugin' => $baseDir.'/../lib/Connector/Sabre/QuotaPlugin.php', |
|
| 112 | + 'OCA\\DAV\\Connector\\Sabre\\Server' => $baseDir.'/../lib/Connector/Sabre/Server.php', |
|
| 113 | + 'OCA\\DAV\\Connector\\Sabre\\ServerFactory' => $baseDir.'/../lib/Connector/Sabre/ServerFactory.php', |
|
| 114 | + 'OCA\\DAV\\Connector\\Sabre\\ShareTypeList' => $baseDir.'/../lib/Connector/Sabre/ShareTypeList.php', |
|
| 115 | + 'OCA\\DAV\\Connector\\Sabre\\SharesPlugin' => $baseDir.'/../lib/Connector/Sabre/SharesPlugin.php', |
|
| 116 | + 'OCA\\DAV\\Connector\\Sabre\\TagList' => $baseDir.'/../lib/Connector/Sabre/TagList.php', |
|
| 117 | + 'OCA\\DAV\\Connector\\Sabre\\TagsPlugin' => $baseDir.'/../lib/Connector/Sabre/TagsPlugin.php', |
|
| 118 | + 'OCA\\DAV\\Controller\\BirthdayCalendarController' => $baseDir.'/../lib/Controller/BirthdayCalendarController.php', |
|
| 119 | + 'OCA\\DAV\\Controller\\DirectController' => $baseDir.'/../lib/Controller/DirectController.php', |
|
| 120 | + 'OCA\\DAV\\DAV\\CustomPropertiesBackend' => $baseDir.'/../lib/DAV/CustomPropertiesBackend.php', |
|
| 121 | + 'OCA\\DAV\\DAV\\GroupPrincipalBackend' => $baseDir.'/../lib/DAV/GroupPrincipalBackend.php', |
|
| 122 | + 'OCA\\DAV\\DAV\\PublicAuth' => $baseDir.'/../lib/DAV/PublicAuth.php', |
|
| 123 | + 'OCA\\DAV\\DAV\\Sharing\\Backend' => $baseDir.'/../lib/DAV/Sharing/Backend.php', |
|
| 124 | + 'OCA\\DAV\\DAV\\Sharing\\IShareable' => $baseDir.'/../lib/DAV/Sharing/IShareable.php', |
|
| 125 | + 'OCA\\DAV\\DAV\\Sharing\\Plugin' => $baseDir.'/../lib/DAV/Sharing/Plugin.php', |
|
| 126 | + 'OCA\\DAV\\DAV\\Sharing\\Xml\\Invite' => $baseDir.'/../lib/DAV/Sharing/Xml/Invite.php', |
|
| 127 | + 'OCA\\DAV\\DAV\\Sharing\\Xml\\ShareRequest' => $baseDir.'/../lib/DAV/Sharing/Xml/ShareRequest.php', |
|
| 128 | + 'OCA\\DAV\\DAV\\SystemPrincipalBackend' => $baseDir.'/../lib/DAV/SystemPrincipalBackend.php', |
|
| 129 | + 'OCA\\DAV\\Db\\Direct' => $baseDir.'/../lib/Db/Direct.php', |
|
| 130 | + 'OCA\\DAV\\Db\\DirectMapper' => $baseDir.'/../lib/Db/DirectMapper.php', |
|
| 131 | + 'OCA\\DAV\\Direct\\DirectFile' => $baseDir.'/../lib/Direct/DirectFile.php', |
|
| 132 | + 'OCA\\DAV\\Direct\\DirectHome' => $baseDir.'/../lib/Direct/DirectHome.php', |
|
| 133 | + 'OCA\\DAV\\Direct\\Server' => $baseDir.'/../lib/Direct/Server.php', |
|
| 134 | + 'OCA\\DAV\\Direct\\ServerFactory' => $baseDir.'/../lib/Direct/ServerFactory.php', |
|
| 135 | + 'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => $baseDir.'/../lib/Files/BrowserErrorPagePlugin.php', |
|
| 136 | + 'OCA\\DAV\\Files\\FileSearchBackend' => $baseDir.'/../lib/Files/FileSearchBackend.php', |
|
| 137 | + 'OCA\\DAV\\Files\\FilesHome' => $baseDir.'/../lib/Files/FilesHome.php', |
|
| 138 | + 'OCA\\DAV\\Files\\RootCollection' => $baseDir.'/../lib/Files/RootCollection.php', |
|
| 139 | + 'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => $baseDir.'/../lib/Files/Sharing/FilesDropPlugin.php', |
|
| 140 | + 'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => $baseDir.'/../lib/Files/Sharing/PublicLinkCheckPlugin.php', |
|
| 141 | + 'OCA\\DAV\\HookManager' => $baseDir.'/../lib/HookManager.php', |
|
| 142 | + 'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => $baseDir.'/../lib/Migration/BuildCalendarSearchIndex.php', |
|
| 143 | + 'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => $baseDir.'/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php', |
|
| 144 | + 'OCA\\DAV\\Migration\\CalDAVRemoveEmptyValue' => $baseDir.'/../lib/Migration/CalDAVRemoveEmptyValue.php', |
|
| 145 | + 'OCA\\DAV\\Migration\\FixBirthdayCalendarComponent' => $baseDir.'/../lib/Migration/FixBirthdayCalendarComponent.php', |
|
| 146 | + 'OCA\\DAV\\Migration\\Version1004Date20170825134824' => $baseDir.'/../lib/Migration/Version1004Date20170825134824.php', |
|
| 147 | + 'OCA\\DAV\\Migration\\Version1004Date20170919104507' => $baseDir.'/../lib/Migration/Version1004Date20170919104507.php', |
|
| 148 | + 'OCA\\DAV\\Migration\\Version1004Date20170924124212' => $baseDir.'/../lib/Migration/Version1004Date20170924124212.php', |
|
| 149 | + 'OCA\\DAV\\Migration\\Version1004Date20170926103422' => $baseDir.'/../lib/Migration/Version1004Date20170926103422.php', |
|
| 150 | + 'OCA\\DAV\\Migration\\Version1005Date20180413093149' => $baseDir.'/../lib/Migration/Version1005Date20180413093149.php', |
|
| 151 | + 'OCA\\DAV\\Migration\\Version1005Date20180530124431' => $baseDir.'/../lib/Migration/Version1005Date20180530124431.php', |
|
| 152 | + 'OCA\\DAV\\RootCollection' => $baseDir.'/../lib/RootCollection.php', |
|
| 153 | + 'OCA\\DAV\\Server' => $baseDir.'/../lib/Server.php', |
|
| 154 | + 'OCA\\DAV\\Settings\\CalDAVSettings' => $baseDir.'/../lib/Settings/CalDAVSettings.php', |
|
| 155 | + 'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => $baseDir.'/../lib/SystemTag/SystemTagMappingNode.php', |
|
| 156 | + 'OCA\\DAV\\SystemTag\\SystemTagNode' => $baseDir.'/../lib/SystemTag/SystemTagNode.php', |
|
| 157 | + 'OCA\\DAV\\SystemTag\\SystemTagPlugin' => $baseDir.'/../lib/SystemTag/SystemTagPlugin.php', |
|
| 158 | + 'OCA\\DAV\\SystemTag\\SystemTagsByIdCollection' => $baseDir.'/../lib/SystemTag/SystemTagsByIdCollection.php', |
|
| 159 | + 'OCA\\DAV\\SystemTag\\SystemTagsObjectMappingCollection' => $baseDir.'/../lib/SystemTag/SystemTagsObjectMappingCollection.php', |
|
| 160 | + 'OCA\\DAV\\SystemTag\\SystemTagsObjectTypeCollection' => $baseDir.'/../lib/SystemTag/SystemTagsObjectTypeCollection.php', |
|
| 161 | + 'OCA\\DAV\\SystemTag\\SystemTagsRelationsCollection' => $baseDir.'/../lib/SystemTag/SystemTagsRelationsCollection.php', |
|
| 162 | + 'OCA\\DAV\\Upload\\AssemblyStream' => $baseDir.'/../lib/Upload/AssemblyStream.php', |
|
| 163 | + 'OCA\\DAV\\Upload\\ChunkingPlugin' => $baseDir.'/../lib/Upload/ChunkingPlugin.php', |
|
| 164 | + 'OCA\\DAV\\Upload\\FutureFile' => $baseDir.'/../lib/Upload/FutureFile.php', |
|
| 165 | + 'OCA\\DAV\\Upload\\RootCollection' => $baseDir.'/../lib/Upload/RootCollection.php', |
|
| 166 | + 'OCA\\DAV\\Upload\\UploadFolder' => $baseDir.'/../lib/Upload/UploadFolder.php', |
|
| 167 | + 'OCA\\DAV\\Upload\\UploadHome' => $baseDir.'/../lib/Upload/UploadHome.php', |
|
| 168 | 168 | ); |
@@ -153,1848 +153,1848 @@ |
||
| 153 | 153 | * TODO: hookup all manager classes |
| 154 | 154 | */ |
| 155 | 155 | class Server extends ServerContainer implements IServerContainer { |
| 156 | - /** @var string */ |
|
| 157 | - private $webRoot; |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * @param string $webRoot |
|
| 161 | - * @param \OC\Config $config |
|
| 162 | - */ |
|
| 163 | - public function __construct($webRoot, \OC\Config $config) { |
|
| 164 | - parent::__construct(); |
|
| 165 | - $this->webRoot = $webRoot; |
|
| 166 | - |
|
| 167 | - // To find out if we are running from CLI or not |
|
| 168 | - $this->registerParameter('isCLI', \OC::$CLI); |
|
| 169 | - |
|
| 170 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
| 171 | - return $c; |
|
| 172 | - }); |
|
| 173 | - |
|
| 174 | - $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
| 175 | - $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
| 176 | - |
|
| 177 | - $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
| 178 | - $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
| 179 | - |
|
| 180 | - $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
| 181 | - $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
| 182 | - |
|
| 183 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
| 184 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
| 185 | - |
|
| 186 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
| 187 | - |
|
| 188 | - |
|
| 189 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
| 190 | - return new PreviewManager( |
|
| 191 | - $c->getConfig(), |
|
| 192 | - $c->getRootFolder(), |
|
| 193 | - $c->getAppDataDir('preview'), |
|
| 194 | - $c->getEventDispatcher(), |
|
| 195 | - $c->getSession()->get('user_id') |
|
| 196 | - ); |
|
| 197 | - }); |
|
| 198 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
| 199 | - |
|
| 200 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 201 | - return new \OC\Preview\Watcher( |
|
| 202 | - $c->getAppDataDir('preview') |
|
| 203 | - ); |
|
| 204 | - }); |
|
| 205 | - |
|
| 206 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
| 207 | - $view = new View(); |
|
| 208 | - $util = new Encryption\Util( |
|
| 209 | - $view, |
|
| 210 | - $c->getUserManager(), |
|
| 211 | - $c->getGroupManager(), |
|
| 212 | - $c->getConfig() |
|
| 213 | - ); |
|
| 214 | - return new Encryption\Manager( |
|
| 215 | - $c->getConfig(), |
|
| 216 | - $c->getLogger(), |
|
| 217 | - $c->getL10N('core'), |
|
| 218 | - new View(), |
|
| 219 | - $util, |
|
| 220 | - new ArrayCache() |
|
| 221 | - ); |
|
| 222 | - }); |
|
| 223 | - |
|
| 224 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 225 | - $util = new Encryption\Util( |
|
| 226 | - new View(), |
|
| 227 | - $c->getUserManager(), |
|
| 228 | - $c->getGroupManager(), |
|
| 229 | - $c->getConfig() |
|
| 230 | - ); |
|
| 231 | - return new Encryption\File( |
|
| 232 | - $util, |
|
| 233 | - $c->getRootFolder(), |
|
| 234 | - $c->getShareManager() |
|
| 235 | - ); |
|
| 236 | - }); |
|
| 237 | - |
|
| 238 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 239 | - $view = new View(); |
|
| 240 | - $util = new Encryption\Util( |
|
| 241 | - $view, |
|
| 242 | - $c->getUserManager(), |
|
| 243 | - $c->getGroupManager(), |
|
| 244 | - $c->getConfig() |
|
| 245 | - ); |
|
| 246 | - |
|
| 247 | - return new Encryption\Keys\Storage($view, $util); |
|
| 248 | - }); |
|
| 249 | - $this->registerService('TagMapper', function (Server $c) { |
|
| 250 | - return new TagMapper($c->getDatabaseConnection()); |
|
| 251 | - }); |
|
| 252 | - |
|
| 253 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
| 254 | - $tagMapper = $c->query('TagMapper'); |
|
| 255 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
| 256 | - }); |
|
| 257 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
| 258 | - |
|
| 259 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 260 | - $config = $c->getConfig(); |
|
| 261 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
| 262 | - return new $factoryClass($this); |
|
| 263 | - }); |
|
| 264 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
| 265 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
| 266 | - }); |
|
| 267 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
| 268 | - |
|
| 269 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
| 270 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
| 271 | - }); |
|
| 272 | - $this->registerService('RootFolder', function (Server $c) { |
|
| 273 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
| 274 | - $view = new View(); |
|
| 275 | - $root = new Root( |
|
| 276 | - $manager, |
|
| 277 | - $view, |
|
| 278 | - null, |
|
| 279 | - $c->getUserMountCache(), |
|
| 280 | - $this->getLogger(), |
|
| 281 | - $this->getUserManager() |
|
| 282 | - ); |
|
| 283 | - $connector = new HookConnector($root, $view); |
|
| 284 | - $connector->viewToNode(); |
|
| 285 | - |
|
| 286 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
| 287 | - $previewConnector->connectWatcher(); |
|
| 288 | - |
|
| 289 | - return $root; |
|
| 290 | - }); |
|
| 291 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
| 292 | - |
|
| 293 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
| 294 | - return new LazyRoot(function () use ($c) { |
|
| 295 | - return $c->query('RootFolder'); |
|
| 296 | - }); |
|
| 297 | - }); |
|
| 298 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
| 299 | - |
|
| 300 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
| 301 | - $config = $c->getConfig(); |
|
| 302 | - return new \OC\User\Manager($config); |
|
| 303 | - }); |
|
| 304 | - $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
| 305 | - $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
| 306 | - |
|
| 307 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 308 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
| 309 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 310 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
| 311 | - }); |
|
| 312 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
| 313 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
| 314 | - }); |
|
| 315 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 316 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
| 317 | - }); |
|
| 318 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 319 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
| 320 | - }); |
|
| 321 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 322 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 323 | - }); |
|
| 324 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 325 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 326 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
| 327 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 328 | - }); |
|
| 329 | - return $groupManager; |
|
| 330 | - }); |
|
| 331 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
| 332 | - |
|
| 333 | - $this->registerService(Store::class, function (Server $c) { |
|
| 334 | - $session = $c->getSession(); |
|
| 335 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 336 | - $tokenProvider = $c->query(IProvider::class); |
|
| 337 | - } else { |
|
| 338 | - $tokenProvider = null; |
|
| 339 | - } |
|
| 340 | - $logger = $c->getLogger(); |
|
| 341 | - return new Store($session, $logger, $tokenProvider); |
|
| 342 | - }); |
|
| 343 | - $this->registerAlias(IStore::class, Store::class); |
|
| 344 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
| 345 | - $dbConnection = $c->getDatabaseConnection(); |
|
| 346 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
| 347 | - }); |
|
| 348 | - $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
|
| 349 | - |
|
| 350 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
| 351 | - $manager = $c->getUserManager(); |
|
| 352 | - $session = new \OC\Session\Memory(''); |
|
| 353 | - $timeFactory = new TimeFactory(); |
|
| 354 | - // Token providers might require a working database. This code |
|
| 355 | - // might however be called when ownCloud is not yet setup. |
|
| 356 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 357 | - $defaultTokenProvider = $c->query(IProvider::class); |
|
| 358 | - } else { |
|
| 359 | - $defaultTokenProvider = null; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - $dispatcher = $c->getEventDispatcher(); |
|
| 363 | - |
|
| 364 | - $userSession = new \OC\User\Session( |
|
| 365 | - $manager, |
|
| 366 | - $session, |
|
| 367 | - $timeFactory, |
|
| 368 | - $defaultTokenProvider, |
|
| 369 | - $c->getConfig(), |
|
| 370 | - $c->getSecureRandom(), |
|
| 371 | - $c->getLockdownManager(), |
|
| 372 | - $c->getLogger() |
|
| 373 | - ); |
|
| 374 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 375 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
| 376 | - }); |
|
| 377 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 378 | - /** @var $user \OC\User\User */ |
|
| 379 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
| 380 | - }); |
|
| 381 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
| 382 | - /** @var $user \OC\User\User */ |
|
| 383 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
| 384 | - $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
| 385 | - }); |
|
| 386 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 387 | - /** @var $user \OC\User\User */ |
|
| 388 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
| 389 | - }); |
|
| 390 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 391 | - /** @var $user \OC\User\User */ |
|
| 392 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
| 393 | - }); |
|
| 394 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 395 | - /** @var $user \OC\User\User */ |
|
| 396 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
| 397 | - }); |
|
| 398 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 399 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
| 400 | - }); |
|
| 401 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
| 402 | - /** @var $user \OC\User\User */ |
|
| 403 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
| 404 | - }); |
|
| 405 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
| 406 | - /** @var $user \OC\User\User */ |
|
| 407 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
| 408 | - }); |
|
| 409 | - $userSession->listen('\OC\User', 'logout', function () { |
|
| 410 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
| 411 | - }); |
|
| 412 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
| 413 | - /** @var $user \OC\User\User */ |
|
| 414 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
| 415 | - $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
| 416 | - }); |
|
| 417 | - return $userSession; |
|
| 418 | - }); |
|
| 419 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
| 420 | - |
|
| 421 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
| 422 | - return new \OC\Authentication\TwoFactorAuth\Manager( |
|
| 423 | - $c->getAppManager(), |
|
| 424 | - $c->getSession(), |
|
| 425 | - $c->getConfig(), |
|
| 426 | - $c->getActivityManager(), |
|
| 427 | - $c->getLogger(), |
|
| 428 | - $c->query(IProvider::class), |
|
| 429 | - $c->query(ITimeFactory::class), |
|
| 430 | - $c->query(EventDispatcherInterface::class) |
|
| 431 | - ); |
|
| 432 | - }); |
|
| 433 | - |
|
| 434 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
| 435 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
| 436 | - |
|
| 437 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
| 438 | - return new \OC\AllConfig( |
|
| 439 | - $c->getSystemConfig() |
|
| 440 | - ); |
|
| 441 | - }); |
|
| 442 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
| 443 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
| 444 | - |
|
| 445 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
| 446 | - return new \OC\SystemConfig($config); |
|
| 447 | - }); |
|
| 448 | - |
|
| 449 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
| 450 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
| 451 | - }); |
|
| 452 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
| 453 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
| 454 | - |
|
| 455 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
| 456 | - return new \OC\L10N\Factory( |
|
| 457 | - $c->getConfig(), |
|
| 458 | - $c->getRequest(), |
|
| 459 | - $c->getUserSession(), |
|
| 460 | - \OC::$SERVERROOT |
|
| 461 | - ); |
|
| 462 | - }); |
|
| 463 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
| 464 | - |
|
| 465 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
| 466 | - $config = $c->getConfig(); |
|
| 467 | - $cacheFactory = $c->getMemCacheFactory(); |
|
| 468 | - $request = $c->getRequest(); |
|
| 469 | - return new \OC\URLGenerator( |
|
| 470 | - $config, |
|
| 471 | - $cacheFactory, |
|
| 472 | - $request |
|
| 473 | - ); |
|
| 474 | - }); |
|
| 475 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
| 476 | - |
|
| 477 | - $this->registerAlias('AppFetcher', AppFetcher::class); |
|
| 478 | - $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
| 479 | - |
|
| 480 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
| 481 | - return new Cache\File(); |
|
| 482 | - }); |
|
| 483 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
| 484 | - |
|
| 485 | - $this->registerService(Factory::class, function (Server $c) { |
|
| 486 | - |
|
| 487 | - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
| 488 | - ArrayCache::class, |
|
| 489 | - ArrayCache::class, |
|
| 490 | - ArrayCache::class |
|
| 491 | - ); |
|
| 492 | - $config = $c->getConfig(); |
|
| 493 | - $request = $c->getRequest(); |
|
| 494 | - $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
| 495 | - |
|
| 496 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 497 | - $v = \OC_App::getAppVersions(); |
|
| 498 | - $v['core'] = implode(',', \OC_Util::getVersion()); |
|
| 499 | - $version = implode(',', $v); |
|
| 500 | - $instanceId = \OC_Util::getInstanceId(); |
|
| 501 | - $path = \OC::$SERVERROOT; |
|
| 502 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
| 503 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
| 504 | - $config->getSystemValue('memcache.local', null), |
|
| 505 | - $config->getSystemValue('memcache.distributed', null), |
|
| 506 | - $config->getSystemValue('memcache.locking', null) |
|
| 507 | - ); |
|
| 508 | - } |
|
| 509 | - return $arrayCacheFactory; |
|
| 510 | - |
|
| 511 | - }); |
|
| 512 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
| 513 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
| 514 | - |
|
| 515 | - $this->registerService('RedisFactory', function (Server $c) { |
|
| 516 | - $systemConfig = $c->getSystemConfig(); |
|
| 517 | - return new RedisFactory($systemConfig); |
|
| 518 | - }); |
|
| 519 | - |
|
| 520 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 521 | - return new \OC\Activity\Manager( |
|
| 522 | - $c->getRequest(), |
|
| 523 | - $c->getUserSession(), |
|
| 524 | - $c->getConfig(), |
|
| 525 | - $c->query(IValidator::class) |
|
| 526 | - ); |
|
| 527 | - }); |
|
| 528 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
| 529 | - |
|
| 530 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 531 | - return new \OC\Activity\EventMerger( |
|
| 532 | - $c->getL10N('lib') |
|
| 533 | - ); |
|
| 534 | - }); |
|
| 535 | - $this->registerAlias(IValidator::class, Validator::class); |
|
| 536 | - |
|
| 537 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
| 538 | - return new AvatarManager( |
|
| 539 | - $c->query(\OC\User\Manager::class), |
|
| 540 | - $c->getAppDataDir('avatar'), |
|
| 541 | - $c->getL10N('lib'), |
|
| 542 | - $c->getLogger(), |
|
| 543 | - $c->getConfig() |
|
| 544 | - ); |
|
| 545 | - }); |
|
| 546 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
| 547 | - |
|
| 548 | - $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
| 549 | - |
|
| 550 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
| 551 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
| 552 | - $factory = new LogFactory($c, $this->getSystemConfig()); |
|
| 553 | - $logger = $factory->get($logType); |
|
| 554 | - $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
| 555 | - |
|
| 556 | - return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
| 557 | - }); |
|
| 558 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
| 559 | - |
|
| 560 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
| 561 | - return new LogFactory($c, $this->getSystemConfig()); |
|
| 562 | - }); |
|
| 563 | - |
|
| 564 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
| 565 | - $config = $c->getConfig(); |
|
| 566 | - return new \OC\BackgroundJob\JobList( |
|
| 567 | - $c->getDatabaseConnection(), |
|
| 568 | - $config, |
|
| 569 | - new TimeFactory() |
|
| 570 | - ); |
|
| 571 | - }); |
|
| 572 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
| 573 | - |
|
| 574 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
| 575 | - $cacheFactory = $c->getMemCacheFactory(); |
|
| 576 | - $logger = $c->getLogger(); |
|
| 577 | - if ($cacheFactory->isLocalCacheAvailable()) { |
|
| 578 | - $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
| 579 | - } else { |
|
| 580 | - $router = new \OC\Route\Router($logger); |
|
| 581 | - } |
|
| 582 | - return $router; |
|
| 583 | - }); |
|
| 584 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
| 585 | - |
|
| 586 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
| 587 | - return new Search(); |
|
| 588 | - }); |
|
| 589 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
| 590 | - |
|
| 591 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
| 592 | - return new \OC\Security\RateLimiting\Limiter( |
|
| 593 | - $this->getUserSession(), |
|
| 594 | - $this->getRequest(), |
|
| 595 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
| 596 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
| 597 | - ); |
|
| 598 | - }); |
|
| 599 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
| 600 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
| 601 | - $this->getMemCacheFactory(), |
|
| 602 | - new \OC\AppFramework\Utility\TimeFactory() |
|
| 603 | - ); |
|
| 604 | - }); |
|
| 605 | - |
|
| 606 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
| 607 | - return new SecureRandom(); |
|
| 608 | - }); |
|
| 609 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
| 610 | - |
|
| 611 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
| 612 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
| 613 | - }); |
|
| 614 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
| 615 | - |
|
| 616 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
| 617 | - return new Hasher($c->getConfig()); |
|
| 618 | - }); |
|
| 619 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
| 620 | - |
|
| 621 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
| 622 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
| 623 | - }); |
|
| 624 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
| 625 | - |
|
| 626 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 627 | - $systemConfig = $c->getSystemConfig(); |
|
| 628 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
| 629 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
| 630 | - if (!$factory->isValidType($type)) { |
|
| 631 | - throw new \OC\DatabaseException('Invalid database type'); |
|
| 632 | - } |
|
| 633 | - $connectionParams = $factory->createConnectionParams(); |
|
| 634 | - $connection = $factory->getConnection($type, $connectionParams); |
|
| 635 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
| 636 | - return $connection; |
|
| 637 | - }); |
|
| 638 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
| 639 | - |
|
| 640 | - |
|
| 641 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
| 642 | - $user = \OC_User::getUser(); |
|
| 643 | - $uid = $user ? $user : null; |
|
| 644 | - return new ClientService( |
|
| 645 | - $c->getConfig(), |
|
| 646 | - new \OC\Security\CertificateManager( |
|
| 647 | - $uid, |
|
| 648 | - new View(), |
|
| 649 | - $c->getConfig(), |
|
| 650 | - $c->getLogger(), |
|
| 651 | - $c->getSecureRandom() |
|
| 652 | - ) |
|
| 653 | - ); |
|
| 654 | - }); |
|
| 655 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
| 656 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
| 657 | - $eventLogger = new EventLogger(); |
|
| 658 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 659 | - // In debug mode, module is being activated by default |
|
| 660 | - $eventLogger->activate(); |
|
| 661 | - } |
|
| 662 | - return $eventLogger; |
|
| 663 | - }); |
|
| 664 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
| 665 | - |
|
| 666 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
| 667 | - $queryLogger = new QueryLogger(); |
|
| 668 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 669 | - // In debug mode, module is being activated by default |
|
| 670 | - $queryLogger->activate(); |
|
| 671 | - } |
|
| 672 | - return $queryLogger; |
|
| 673 | - }); |
|
| 674 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
| 675 | - |
|
| 676 | - $this->registerService(TempManager::class, function (Server $c) { |
|
| 677 | - return new TempManager( |
|
| 678 | - $c->getLogger(), |
|
| 679 | - $c->getConfig() |
|
| 680 | - ); |
|
| 681 | - }); |
|
| 682 | - $this->registerAlias('TempManager', TempManager::class); |
|
| 683 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
| 684 | - |
|
| 685 | - $this->registerService(AppManager::class, function (Server $c) { |
|
| 686 | - return new \OC\App\AppManager( |
|
| 687 | - $c->getUserSession(), |
|
| 688 | - $c->query(\OC\AppConfig::class), |
|
| 689 | - $c->getGroupManager(), |
|
| 690 | - $c->getMemCacheFactory(), |
|
| 691 | - $c->getEventDispatcher() |
|
| 692 | - ); |
|
| 693 | - }); |
|
| 694 | - $this->registerAlias('AppManager', AppManager::class); |
|
| 695 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
| 696 | - |
|
| 697 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
| 698 | - return new DateTimeZone( |
|
| 699 | - $c->getConfig(), |
|
| 700 | - $c->getSession() |
|
| 701 | - ); |
|
| 702 | - }); |
|
| 703 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
| 704 | - |
|
| 705 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
| 706 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
| 707 | - |
|
| 708 | - return new DateTimeFormatter( |
|
| 709 | - $c->getDateTimeZone()->getTimeZone(), |
|
| 710 | - $c->getL10N('lib', $language) |
|
| 711 | - ); |
|
| 712 | - }); |
|
| 713 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
| 714 | - |
|
| 715 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
| 716 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
| 717 | - $listener = new UserMountCacheListener($mountCache); |
|
| 718 | - $listener->listen($c->getUserManager()); |
|
| 719 | - return $mountCache; |
|
| 720 | - }); |
|
| 721 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
| 722 | - |
|
| 723 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
| 724 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
| 725 | - $mountCache = $c->query('UserMountCache'); |
|
| 726 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
| 727 | - |
|
| 728 | - // builtin providers |
|
| 729 | - |
|
| 730 | - $config = $c->getConfig(); |
|
| 731 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
| 732 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
| 733 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
| 734 | - |
|
| 735 | - return $manager; |
|
| 736 | - }); |
|
| 737 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
| 738 | - |
|
| 739 | - $this->registerService('IniWrapper', function ($c) { |
|
| 740 | - return new IniGetWrapper(); |
|
| 741 | - }); |
|
| 742 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 743 | - $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
| 744 | - if ($busClass) { |
|
| 745 | - list($app, $class) = explode('::', $busClass, 2); |
|
| 746 | - if ($c->getAppManager()->isInstalled($app)) { |
|
| 747 | - \OC_App::loadApp($app); |
|
| 748 | - return $c->query($class); |
|
| 749 | - } else { |
|
| 750 | - throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
| 751 | - } |
|
| 752 | - } else { |
|
| 753 | - $jobList = $c->getJobList(); |
|
| 754 | - return new CronBus($jobList); |
|
| 755 | - } |
|
| 756 | - }); |
|
| 757 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
| 758 | - return new TrustedDomainHelper($this->getConfig()); |
|
| 759 | - }); |
|
| 760 | - $this->registerService('Throttler', function (Server $c) { |
|
| 761 | - return new Throttler( |
|
| 762 | - $c->getDatabaseConnection(), |
|
| 763 | - new TimeFactory(), |
|
| 764 | - $c->getLogger(), |
|
| 765 | - $c->getConfig() |
|
| 766 | - ); |
|
| 767 | - }); |
|
| 768 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 769 | - // IConfig and IAppManager requires a working database. This code |
|
| 770 | - // might however be called when ownCloud is not yet setup. |
|
| 771 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 772 | - $config = $c->getConfig(); |
|
| 773 | - $appManager = $c->getAppManager(); |
|
| 774 | - } else { |
|
| 775 | - $config = null; |
|
| 776 | - $appManager = null; |
|
| 777 | - } |
|
| 778 | - |
|
| 779 | - return new Checker( |
|
| 780 | - new EnvironmentHelper(), |
|
| 781 | - new FileAccessHelper(), |
|
| 782 | - new AppLocator(), |
|
| 783 | - $config, |
|
| 784 | - $c->getMemCacheFactory(), |
|
| 785 | - $appManager, |
|
| 786 | - $c->getTempManager() |
|
| 787 | - ); |
|
| 788 | - }); |
|
| 789 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 790 | - if (isset($this['urlParams'])) { |
|
| 791 | - $urlParams = $this['urlParams']; |
|
| 792 | - } else { |
|
| 793 | - $urlParams = []; |
|
| 794 | - } |
|
| 795 | - |
|
| 796 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
| 797 | - && in_array('fakeinput', stream_get_wrappers()) |
|
| 798 | - ) { |
|
| 799 | - $stream = 'fakeinput://data'; |
|
| 800 | - } else { |
|
| 801 | - $stream = 'php://input'; |
|
| 802 | - } |
|
| 803 | - |
|
| 804 | - return new Request( |
|
| 805 | - [ |
|
| 806 | - 'get' => $_GET, |
|
| 807 | - 'post' => $_POST, |
|
| 808 | - 'files' => $_FILES, |
|
| 809 | - 'server' => $_SERVER, |
|
| 810 | - 'env' => $_ENV, |
|
| 811 | - 'cookies' => $_COOKIE, |
|
| 812 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 813 | - ? $_SERVER['REQUEST_METHOD'] |
|
| 814 | - : '', |
|
| 815 | - 'urlParams' => $urlParams, |
|
| 816 | - ], |
|
| 817 | - $this->getSecureRandom(), |
|
| 818 | - $this->getConfig(), |
|
| 819 | - $this->getCsrfTokenManager(), |
|
| 820 | - $stream |
|
| 821 | - ); |
|
| 822 | - }); |
|
| 823 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
| 824 | - |
|
| 825 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
| 826 | - return new Mailer( |
|
| 827 | - $c->getConfig(), |
|
| 828 | - $c->getLogger(), |
|
| 829 | - $c->query(Defaults::class), |
|
| 830 | - $c->getURLGenerator(), |
|
| 831 | - $c->getL10N('lib') |
|
| 832 | - ); |
|
| 833 | - }); |
|
| 834 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
| 835 | - |
|
| 836 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
| 837 | - $config = $c->getConfig(); |
|
| 838 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
| 839 | - if (is_null($factoryClass)) { |
|
| 840 | - throw new \Exception('ldapProviderFactory not set'); |
|
| 841 | - } |
|
| 842 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
| 843 | - $factory = new $factoryClass($this); |
|
| 844 | - return $factory->getLDAPProvider(); |
|
| 845 | - }); |
|
| 846 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
| 847 | - $ini = $c->getIniWrapper(); |
|
| 848 | - $config = $c->getConfig(); |
|
| 849 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
| 850 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 851 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
| 852 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
| 853 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
| 854 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
| 855 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
| 856 | - } |
|
| 857 | - return new DBLockingProvider( |
|
| 858 | - $c->getDatabaseConnection(), |
|
| 859 | - $c->getLogger(), |
|
| 860 | - new TimeFactory(), |
|
| 861 | - $ttl, |
|
| 862 | - !\OC::$CLI |
|
| 863 | - ); |
|
| 864 | - } |
|
| 865 | - return new NoopLockingProvider(); |
|
| 866 | - }); |
|
| 867 | - $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
| 868 | - |
|
| 869 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
| 870 | - return new \OC\Files\Mount\Manager(); |
|
| 871 | - }); |
|
| 872 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
| 873 | - |
|
| 874 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
| 875 | - return new \OC\Files\Type\Detection( |
|
| 876 | - $c->getURLGenerator(), |
|
| 877 | - \OC::$configDir, |
|
| 878 | - \OC::$SERVERROOT . '/resources/config/' |
|
| 879 | - ); |
|
| 880 | - }); |
|
| 881 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
| 882 | - |
|
| 883 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
| 884 | - return new \OC\Files\Type\Loader( |
|
| 885 | - $c->getDatabaseConnection() |
|
| 886 | - ); |
|
| 887 | - }); |
|
| 888 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
| 889 | - $this->registerService(BundleFetcher::class, function () { |
|
| 890 | - return new BundleFetcher($this->getL10N('lib')); |
|
| 891 | - }); |
|
| 892 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
| 893 | - return new Manager( |
|
| 894 | - $c->query(IValidator::class) |
|
| 895 | - ); |
|
| 896 | - }); |
|
| 897 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
| 898 | - |
|
| 899 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
| 900 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
| 901 | - $manager->registerCapability(function () use ($c) { |
|
| 902 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
| 903 | - }); |
|
| 904 | - $manager->registerCapability(function () use ($c) { |
|
| 905 | - return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
| 906 | - }); |
|
| 907 | - return $manager; |
|
| 908 | - }); |
|
| 909 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
| 910 | - |
|
| 911 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
| 912 | - $config = $c->getConfig(); |
|
| 913 | - $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
| 914 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
| 915 | - $factory = new $factoryClass($this); |
|
| 916 | - $manager = $factory->getManager(); |
|
| 917 | - |
|
| 918 | - $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
| 919 | - $manager = $c->getUserManager(); |
|
| 920 | - $user = $manager->get($id); |
|
| 921 | - if(is_null($user)) { |
|
| 922 | - $l = $c->getL10N('core'); |
|
| 923 | - $displayName = $l->t('Unknown user'); |
|
| 924 | - } else { |
|
| 925 | - $displayName = $user->getDisplayName(); |
|
| 926 | - } |
|
| 927 | - return $displayName; |
|
| 928 | - }); |
|
| 929 | - |
|
| 930 | - return $manager; |
|
| 931 | - }); |
|
| 932 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
| 933 | - |
|
| 934 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
| 935 | - /* |
|
| 156 | + /** @var string */ |
|
| 157 | + private $webRoot; |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * @param string $webRoot |
|
| 161 | + * @param \OC\Config $config |
|
| 162 | + */ |
|
| 163 | + public function __construct($webRoot, \OC\Config $config) { |
|
| 164 | + parent::__construct(); |
|
| 165 | + $this->webRoot = $webRoot; |
|
| 166 | + |
|
| 167 | + // To find out if we are running from CLI or not |
|
| 168 | + $this->registerParameter('isCLI', \OC::$CLI); |
|
| 169 | + |
|
| 170 | + $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
| 171 | + return $c; |
|
| 172 | + }); |
|
| 173 | + |
|
| 174 | + $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
| 175 | + $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
| 176 | + |
|
| 177 | + $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
| 178 | + $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
| 179 | + |
|
| 180 | + $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
| 181 | + $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
| 182 | + |
|
| 183 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
| 184 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
| 185 | + |
|
| 186 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
| 187 | + |
|
| 188 | + |
|
| 189 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
| 190 | + return new PreviewManager( |
|
| 191 | + $c->getConfig(), |
|
| 192 | + $c->getRootFolder(), |
|
| 193 | + $c->getAppDataDir('preview'), |
|
| 194 | + $c->getEventDispatcher(), |
|
| 195 | + $c->getSession()->get('user_id') |
|
| 196 | + ); |
|
| 197 | + }); |
|
| 198 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
| 199 | + |
|
| 200 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 201 | + return new \OC\Preview\Watcher( |
|
| 202 | + $c->getAppDataDir('preview') |
|
| 203 | + ); |
|
| 204 | + }); |
|
| 205 | + |
|
| 206 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
| 207 | + $view = new View(); |
|
| 208 | + $util = new Encryption\Util( |
|
| 209 | + $view, |
|
| 210 | + $c->getUserManager(), |
|
| 211 | + $c->getGroupManager(), |
|
| 212 | + $c->getConfig() |
|
| 213 | + ); |
|
| 214 | + return new Encryption\Manager( |
|
| 215 | + $c->getConfig(), |
|
| 216 | + $c->getLogger(), |
|
| 217 | + $c->getL10N('core'), |
|
| 218 | + new View(), |
|
| 219 | + $util, |
|
| 220 | + new ArrayCache() |
|
| 221 | + ); |
|
| 222 | + }); |
|
| 223 | + |
|
| 224 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 225 | + $util = new Encryption\Util( |
|
| 226 | + new View(), |
|
| 227 | + $c->getUserManager(), |
|
| 228 | + $c->getGroupManager(), |
|
| 229 | + $c->getConfig() |
|
| 230 | + ); |
|
| 231 | + return new Encryption\File( |
|
| 232 | + $util, |
|
| 233 | + $c->getRootFolder(), |
|
| 234 | + $c->getShareManager() |
|
| 235 | + ); |
|
| 236 | + }); |
|
| 237 | + |
|
| 238 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 239 | + $view = new View(); |
|
| 240 | + $util = new Encryption\Util( |
|
| 241 | + $view, |
|
| 242 | + $c->getUserManager(), |
|
| 243 | + $c->getGroupManager(), |
|
| 244 | + $c->getConfig() |
|
| 245 | + ); |
|
| 246 | + |
|
| 247 | + return new Encryption\Keys\Storage($view, $util); |
|
| 248 | + }); |
|
| 249 | + $this->registerService('TagMapper', function (Server $c) { |
|
| 250 | + return new TagMapper($c->getDatabaseConnection()); |
|
| 251 | + }); |
|
| 252 | + |
|
| 253 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
| 254 | + $tagMapper = $c->query('TagMapper'); |
|
| 255 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
| 256 | + }); |
|
| 257 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
| 258 | + |
|
| 259 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 260 | + $config = $c->getConfig(); |
|
| 261 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
| 262 | + return new $factoryClass($this); |
|
| 263 | + }); |
|
| 264 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
| 265 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
| 266 | + }); |
|
| 267 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
| 268 | + |
|
| 269 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
| 270 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
| 271 | + }); |
|
| 272 | + $this->registerService('RootFolder', function (Server $c) { |
|
| 273 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
| 274 | + $view = new View(); |
|
| 275 | + $root = new Root( |
|
| 276 | + $manager, |
|
| 277 | + $view, |
|
| 278 | + null, |
|
| 279 | + $c->getUserMountCache(), |
|
| 280 | + $this->getLogger(), |
|
| 281 | + $this->getUserManager() |
|
| 282 | + ); |
|
| 283 | + $connector = new HookConnector($root, $view); |
|
| 284 | + $connector->viewToNode(); |
|
| 285 | + |
|
| 286 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
| 287 | + $previewConnector->connectWatcher(); |
|
| 288 | + |
|
| 289 | + return $root; |
|
| 290 | + }); |
|
| 291 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
| 292 | + |
|
| 293 | + $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
| 294 | + return new LazyRoot(function () use ($c) { |
|
| 295 | + return $c->query('RootFolder'); |
|
| 296 | + }); |
|
| 297 | + }); |
|
| 298 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
| 299 | + |
|
| 300 | + $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
| 301 | + $config = $c->getConfig(); |
|
| 302 | + return new \OC\User\Manager($config); |
|
| 303 | + }); |
|
| 304 | + $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
| 305 | + $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
| 306 | + |
|
| 307 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 308 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
| 309 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 310 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
| 311 | + }); |
|
| 312 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
| 313 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
| 314 | + }); |
|
| 315 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 316 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
| 317 | + }); |
|
| 318 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 319 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
| 320 | + }); |
|
| 321 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 322 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 323 | + }); |
|
| 324 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 325 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 326 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
| 327 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 328 | + }); |
|
| 329 | + return $groupManager; |
|
| 330 | + }); |
|
| 331 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
| 332 | + |
|
| 333 | + $this->registerService(Store::class, function (Server $c) { |
|
| 334 | + $session = $c->getSession(); |
|
| 335 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 336 | + $tokenProvider = $c->query(IProvider::class); |
|
| 337 | + } else { |
|
| 338 | + $tokenProvider = null; |
|
| 339 | + } |
|
| 340 | + $logger = $c->getLogger(); |
|
| 341 | + return new Store($session, $logger, $tokenProvider); |
|
| 342 | + }); |
|
| 343 | + $this->registerAlias(IStore::class, Store::class); |
|
| 344 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
| 345 | + $dbConnection = $c->getDatabaseConnection(); |
|
| 346 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
| 347 | + }); |
|
| 348 | + $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
|
| 349 | + |
|
| 350 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
| 351 | + $manager = $c->getUserManager(); |
|
| 352 | + $session = new \OC\Session\Memory(''); |
|
| 353 | + $timeFactory = new TimeFactory(); |
|
| 354 | + // Token providers might require a working database. This code |
|
| 355 | + // might however be called when ownCloud is not yet setup. |
|
| 356 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 357 | + $defaultTokenProvider = $c->query(IProvider::class); |
|
| 358 | + } else { |
|
| 359 | + $defaultTokenProvider = null; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + $dispatcher = $c->getEventDispatcher(); |
|
| 363 | + |
|
| 364 | + $userSession = new \OC\User\Session( |
|
| 365 | + $manager, |
|
| 366 | + $session, |
|
| 367 | + $timeFactory, |
|
| 368 | + $defaultTokenProvider, |
|
| 369 | + $c->getConfig(), |
|
| 370 | + $c->getSecureRandom(), |
|
| 371 | + $c->getLockdownManager(), |
|
| 372 | + $c->getLogger() |
|
| 373 | + ); |
|
| 374 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 375 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
| 376 | + }); |
|
| 377 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 378 | + /** @var $user \OC\User\User */ |
|
| 379 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
| 380 | + }); |
|
| 381 | + $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
| 382 | + /** @var $user \OC\User\User */ |
|
| 383 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
| 384 | + $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
| 385 | + }); |
|
| 386 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 387 | + /** @var $user \OC\User\User */ |
|
| 388 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
| 389 | + }); |
|
| 390 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 391 | + /** @var $user \OC\User\User */ |
|
| 392 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
| 393 | + }); |
|
| 394 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 395 | + /** @var $user \OC\User\User */ |
|
| 396 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
| 397 | + }); |
|
| 398 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 399 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
| 400 | + }); |
|
| 401 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
| 402 | + /** @var $user \OC\User\User */ |
|
| 403 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
| 404 | + }); |
|
| 405 | + $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
| 406 | + /** @var $user \OC\User\User */ |
|
| 407 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
| 408 | + }); |
|
| 409 | + $userSession->listen('\OC\User', 'logout', function () { |
|
| 410 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
| 411 | + }); |
|
| 412 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
| 413 | + /** @var $user \OC\User\User */ |
|
| 414 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
| 415 | + $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
| 416 | + }); |
|
| 417 | + return $userSession; |
|
| 418 | + }); |
|
| 419 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
| 420 | + |
|
| 421 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
| 422 | + return new \OC\Authentication\TwoFactorAuth\Manager( |
|
| 423 | + $c->getAppManager(), |
|
| 424 | + $c->getSession(), |
|
| 425 | + $c->getConfig(), |
|
| 426 | + $c->getActivityManager(), |
|
| 427 | + $c->getLogger(), |
|
| 428 | + $c->query(IProvider::class), |
|
| 429 | + $c->query(ITimeFactory::class), |
|
| 430 | + $c->query(EventDispatcherInterface::class) |
|
| 431 | + ); |
|
| 432 | + }); |
|
| 433 | + |
|
| 434 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
| 435 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
| 436 | + |
|
| 437 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
| 438 | + return new \OC\AllConfig( |
|
| 439 | + $c->getSystemConfig() |
|
| 440 | + ); |
|
| 441 | + }); |
|
| 442 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
| 443 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
| 444 | + |
|
| 445 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
| 446 | + return new \OC\SystemConfig($config); |
|
| 447 | + }); |
|
| 448 | + |
|
| 449 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
| 450 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
| 451 | + }); |
|
| 452 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
| 453 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
| 454 | + |
|
| 455 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
| 456 | + return new \OC\L10N\Factory( |
|
| 457 | + $c->getConfig(), |
|
| 458 | + $c->getRequest(), |
|
| 459 | + $c->getUserSession(), |
|
| 460 | + \OC::$SERVERROOT |
|
| 461 | + ); |
|
| 462 | + }); |
|
| 463 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
| 464 | + |
|
| 465 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
| 466 | + $config = $c->getConfig(); |
|
| 467 | + $cacheFactory = $c->getMemCacheFactory(); |
|
| 468 | + $request = $c->getRequest(); |
|
| 469 | + return new \OC\URLGenerator( |
|
| 470 | + $config, |
|
| 471 | + $cacheFactory, |
|
| 472 | + $request |
|
| 473 | + ); |
|
| 474 | + }); |
|
| 475 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
| 476 | + |
|
| 477 | + $this->registerAlias('AppFetcher', AppFetcher::class); |
|
| 478 | + $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
| 479 | + |
|
| 480 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
| 481 | + return new Cache\File(); |
|
| 482 | + }); |
|
| 483 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
| 484 | + |
|
| 485 | + $this->registerService(Factory::class, function (Server $c) { |
|
| 486 | + |
|
| 487 | + $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
| 488 | + ArrayCache::class, |
|
| 489 | + ArrayCache::class, |
|
| 490 | + ArrayCache::class |
|
| 491 | + ); |
|
| 492 | + $config = $c->getConfig(); |
|
| 493 | + $request = $c->getRequest(); |
|
| 494 | + $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
| 495 | + |
|
| 496 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 497 | + $v = \OC_App::getAppVersions(); |
|
| 498 | + $v['core'] = implode(',', \OC_Util::getVersion()); |
|
| 499 | + $version = implode(',', $v); |
|
| 500 | + $instanceId = \OC_Util::getInstanceId(); |
|
| 501 | + $path = \OC::$SERVERROOT; |
|
| 502 | + $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
| 503 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
| 504 | + $config->getSystemValue('memcache.local', null), |
|
| 505 | + $config->getSystemValue('memcache.distributed', null), |
|
| 506 | + $config->getSystemValue('memcache.locking', null) |
|
| 507 | + ); |
|
| 508 | + } |
|
| 509 | + return $arrayCacheFactory; |
|
| 510 | + |
|
| 511 | + }); |
|
| 512 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
| 513 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
| 514 | + |
|
| 515 | + $this->registerService('RedisFactory', function (Server $c) { |
|
| 516 | + $systemConfig = $c->getSystemConfig(); |
|
| 517 | + return new RedisFactory($systemConfig); |
|
| 518 | + }); |
|
| 519 | + |
|
| 520 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 521 | + return new \OC\Activity\Manager( |
|
| 522 | + $c->getRequest(), |
|
| 523 | + $c->getUserSession(), |
|
| 524 | + $c->getConfig(), |
|
| 525 | + $c->query(IValidator::class) |
|
| 526 | + ); |
|
| 527 | + }); |
|
| 528 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
| 529 | + |
|
| 530 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 531 | + return new \OC\Activity\EventMerger( |
|
| 532 | + $c->getL10N('lib') |
|
| 533 | + ); |
|
| 534 | + }); |
|
| 535 | + $this->registerAlias(IValidator::class, Validator::class); |
|
| 536 | + |
|
| 537 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
| 538 | + return new AvatarManager( |
|
| 539 | + $c->query(\OC\User\Manager::class), |
|
| 540 | + $c->getAppDataDir('avatar'), |
|
| 541 | + $c->getL10N('lib'), |
|
| 542 | + $c->getLogger(), |
|
| 543 | + $c->getConfig() |
|
| 544 | + ); |
|
| 545 | + }); |
|
| 546 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
| 547 | + |
|
| 548 | + $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
| 549 | + |
|
| 550 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
| 551 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
| 552 | + $factory = new LogFactory($c, $this->getSystemConfig()); |
|
| 553 | + $logger = $factory->get($logType); |
|
| 554 | + $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
| 555 | + |
|
| 556 | + return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
| 557 | + }); |
|
| 558 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
| 559 | + |
|
| 560 | + $this->registerService(ILogFactory::class, function (Server $c) { |
|
| 561 | + return new LogFactory($c, $this->getSystemConfig()); |
|
| 562 | + }); |
|
| 563 | + |
|
| 564 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
| 565 | + $config = $c->getConfig(); |
|
| 566 | + return new \OC\BackgroundJob\JobList( |
|
| 567 | + $c->getDatabaseConnection(), |
|
| 568 | + $config, |
|
| 569 | + new TimeFactory() |
|
| 570 | + ); |
|
| 571 | + }); |
|
| 572 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
| 573 | + |
|
| 574 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
| 575 | + $cacheFactory = $c->getMemCacheFactory(); |
|
| 576 | + $logger = $c->getLogger(); |
|
| 577 | + if ($cacheFactory->isLocalCacheAvailable()) { |
|
| 578 | + $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
| 579 | + } else { |
|
| 580 | + $router = new \OC\Route\Router($logger); |
|
| 581 | + } |
|
| 582 | + return $router; |
|
| 583 | + }); |
|
| 584 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
| 585 | + |
|
| 586 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
| 587 | + return new Search(); |
|
| 588 | + }); |
|
| 589 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
| 590 | + |
|
| 591 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
| 592 | + return new \OC\Security\RateLimiting\Limiter( |
|
| 593 | + $this->getUserSession(), |
|
| 594 | + $this->getRequest(), |
|
| 595 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
| 596 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
| 597 | + ); |
|
| 598 | + }); |
|
| 599 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
| 600 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
| 601 | + $this->getMemCacheFactory(), |
|
| 602 | + new \OC\AppFramework\Utility\TimeFactory() |
|
| 603 | + ); |
|
| 604 | + }); |
|
| 605 | + |
|
| 606 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
| 607 | + return new SecureRandom(); |
|
| 608 | + }); |
|
| 609 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
| 610 | + |
|
| 611 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
| 612 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
| 613 | + }); |
|
| 614 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
| 615 | + |
|
| 616 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
| 617 | + return new Hasher($c->getConfig()); |
|
| 618 | + }); |
|
| 619 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
| 620 | + |
|
| 621 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
| 622 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
| 623 | + }); |
|
| 624 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
| 625 | + |
|
| 626 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 627 | + $systemConfig = $c->getSystemConfig(); |
|
| 628 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
| 629 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
| 630 | + if (!$factory->isValidType($type)) { |
|
| 631 | + throw new \OC\DatabaseException('Invalid database type'); |
|
| 632 | + } |
|
| 633 | + $connectionParams = $factory->createConnectionParams(); |
|
| 634 | + $connection = $factory->getConnection($type, $connectionParams); |
|
| 635 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
| 636 | + return $connection; |
|
| 637 | + }); |
|
| 638 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
| 639 | + |
|
| 640 | + |
|
| 641 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
| 642 | + $user = \OC_User::getUser(); |
|
| 643 | + $uid = $user ? $user : null; |
|
| 644 | + return new ClientService( |
|
| 645 | + $c->getConfig(), |
|
| 646 | + new \OC\Security\CertificateManager( |
|
| 647 | + $uid, |
|
| 648 | + new View(), |
|
| 649 | + $c->getConfig(), |
|
| 650 | + $c->getLogger(), |
|
| 651 | + $c->getSecureRandom() |
|
| 652 | + ) |
|
| 653 | + ); |
|
| 654 | + }); |
|
| 655 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
| 656 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
| 657 | + $eventLogger = new EventLogger(); |
|
| 658 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 659 | + // In debug mode, module is being activated by default |
|
| 660 | + $eventLogger->activate(); |
|
| 661 | + } |
|
| 662 | + return $eventLogger; |
|
| 663 | + }); |
|
| 664 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
| 665 | + |
|
| 666 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
| 667 | + $queryLogger = new QueryLogger(); |
|
| 668 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 669 | + // In debug mode, module is being activated by default |
|
| 670 | + $queryLogger->activate(); |
|
| 671 | + } |
|
| 672 | + return $queryLogger; |
|
| 673 | + }); |
|
| 674 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
| 675 | + |
|
| 676 | + $this->registerService(TempManager::class, function (Server $c) { |
|
| 677 | + return new TempManager( |
|
| 678 | + $c->getLogger(), |
|
| 679 | + $c->getConfig() |
|
| 680 | + ); |
|
| 681 | + }); |
|
| 682 | + $this->registerAlias('TempManager', TempManager::class); |
|
| 683 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
| 684 | + |
|
| 685 | + $this->registerService(AppManager::class, function (Server $c) { |
|
| 686 | + return new \OC\App\AppManager( |
|
| 687 | + $c->getUserSession(), |
|
| 688 | + $c->query(\OC\AppConfig::class), |
|
| 689 | + $c->getGroupManager(), |
|
| 690 | + $c->getMemCacheFactory(), |
|
| 691 | + $c->getEventDispatcher() |
|
| 692 | + ); |
|
| 693 | + }); |
|
| 694 | + $this->registerAlias('AppManager', AppManager::class); |
|
| 695 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
| 696 | + |
|
| 697 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
| 698 | + return new DateTimeZone( |
|
| 699 | + $c->getConfig(), |
|
| 700 | + $c->getSession() |
|
| 701 | + ); |
|
| 702 | + }); |
|
| 703 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
| 704 | + |
|
| 705 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
| 706 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
| 707 | + |
|
| 708 | + return new DateTimeFormatter( |
|
| 709 | + $c->getDateTimeZone()->getTimeZone(), |
|
| 710 | + $c->getL10N('lib', $language) |
|
| 711 | + ); |
|
| 712 | + }); |
|
| 713 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
| 714 | + |
|
| 715 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
| 716 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
| 717 | + $listener = new UserMountCacheListener($mountCache); |
|
| 718 | + $listener->listen($c->getUserManager()); |
|
| 719 | + return $mountCache; |
|
| 720 | + }); |
|
| 721 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
| 722 | + |
|
| 723 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
| 724 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
| 725 | + $mountCache = $c->query('UserMountCache'); |
|
| 726 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
| 727 | + |
|
| 728 | + // builtin providers |
|
| 729 | + |
|
| 730 | + $config = $c->getConfig(); |
|
| 731 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
| 732 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
| 733 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
| 734 | + |
|
| 735 | + return $manager; |
|
| 736 | + }); |
|
| 737 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
| 738 | + |
|
| 739 | + $this->registerService('IniWrapper', function ($c) { |
|
| 740 | + return new IniGetWrapper(); |
|
| 741 | + }); |
|
| 742 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 743 | + $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
| 744 | + if ($busClass) { |
|
| 745 | + list($app, $class) = explode('::', $busClass, 2); |
|
| 746 | + if ($c->getAppManager()->isInstalled($app)) { |
|
| 747 | + \OC_App::loadApp($app); |
|
| 748 | + return $c->query($class); |
|
| 749 | + } else { |
|
| 750 | + throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
| 751 | + } |
|
| 752 | + } else { |
|
| 753 | + $jobList = $c->getJobList(); |
|
| 754 | + return new CronBus($jobList); |
|
| 755 | + } |
|
| 756 | + }); |
|
| 757 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
| 758 | + return new TrustedDomainHelper($this->getConfig()); |
|
| 759 | + }); |
|
| 760 | + $this->registerService('Throttler', function (Server $c) { |
|
| 761 | + return new Throttler( |
|
| 762 | + $c->getDatabaseConnection(), |
|
| 763 | + new TimeFactory(), |
|
| 764 | + $c->getLogger(), |
|
| 765 | + $c->getConfig() |
|
| 766 | + ); |
|
| 767 | + }); |
|
| 768 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 769 | + // IConfig and IAppManager requires a working database. This code |
|
| 770 | + // might however be called when ownCloud is not yet setup. |
|
| 771 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 772 | + $config = $c->getConfig(); |
|
| 773 | + $appManager = $c->getAppManager(); |
|
| 774 | + } else { |
|
| 775 | + $config = null; |
|
| 776 | + $appManager = null; |
|
| 777 | + } |
|
| 778 | + |
|
| 779 | + return new Checker( |
|
| 780 | + new EnvironmentHelper(), |
|
| 781 | + new FileAccessHelper(), |
|
| 782 | + new AppLocator(), |
|
| 783 | + $config, |
|
| 784 | + $c->getMemCacheFactory(), |
|
| 785 | + $appManager, |
|
| 786 | + $c->getTempManager() |
|
| 787 | + ); |
|
| 788 | + }); |
|
| 789 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 790 | + if (isset($this['urlParams'])) { |
|
| 791 | + $urlParams = $this['urlParams']; |
|
| 792 | + } else { |
|
| 793 | + $urlParams = []; |
|
| 794 | + } |
|
| 795 | + |
|
| 796 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
| 797 | + && in_array('fakeinput', stream_get_wrappers()) |
|
| 798 | + ) { |
|
| 799 | + $stream = 'fakeinput://data'; |
|
| 800 | + } else { |
|
| 801 | + $stream = 'php://input'; |
|
| 802 | + } |
|
| 803 | + |
|
| 804 | + return new Request( |
|
| 805 | + [ |
|
| 806 | + 'get' => $_GET, |
|
| 807 | + 'post' => $_POST, |
|
| 808 | + 'files' => $_FILES, |
|
| 809 | + 'server' => $_SERVER, |
|
| 810 | + 'env' => $_ENV, |
|
| 811 | + 'cookies' => $_COOKIE, |
|
| 812 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 813 | + ? $_SERVER['REQUEST_METHOD'] |
|
| 814 | + : '', |
|
| 815 | + 'urlParams' => $urlParams, |
|
| 816 | + ], |
|
| 817 | + $this->getSecureRandom(), |
|
| 818 | + $this->getConfig(), |
|
| 819 | + $this->getCsrfTokenManager(), |
|
| 820 | + $stream |
|
| 821 | + ); |
|
| 822 | + }); |
|
| 823 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
| 824 | + |
|
| 825 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
| 826 | + return new Mailer( |
|
| 827 | + $c->getConfig(), |
|
| 828 | + $c->getLogger(), |
|
| 829 | + $c->query(Defaults::class), |
|
| 830 | + $c->getURLGenerator(), |
|
| 831 | + $c->getL10N('lib') |
|
| 832 | + ); |
|
| 833 | + }); |
|
| 834 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
| 835 | + |
|
| 836 | + $this->registerService('LDAPProvider', function (Server $c) { |
|
| 837 | + $config = $c->getConfig(); |
|
| 838 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
| 839 | + if (is_null($factoryClass)) { |
|
| 840 | + throw new \Exception('ldapProviderFactory not set'); |
|
| 841 | + } |
|
| 842 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
| 843 | + $factory = new $factoryClass($this); |
|
| 844 | + return $factory->getLDAPProvider(); |
|
| 845 | + }); |
|
| 846 | + $this->registerService(ILockingProvider::class, function (Server $c) { |
|
| 847 | + $ini = $c->getIniWrapper(); |
|
| 848 | + $config = $c->getConfig(); |
|
| 849 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
| 850 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 851 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
| 852 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
| 853 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
| 854 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
| 855 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
| 856 | + } |
|
| 857 | + return new DBLockingProvider( |
|
| 858 | + $c->getDatabaseConnection(), |
|
| 859 | + $c->getLogger(), |
|
| 860 | + new TimeFactory(), |
|
| 861 | + $ttl, |
|
| 862 | + !\OC::$CLI |
|
| 863 | + ); |
|
| 864 | + } |
|
| 865 | + return new NoopLockingProvider(); |
|
| 866 | + }); |
|
| 867 | + $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
| 868 | + |
|
| 869 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
| 870 | + return new \OC\Files\Mount\Manager(); |
|
| 871 | + }); |
|
| 872 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
| 873 | + |
|
| 874 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
| 875 | + return new \OC\Files\Type\Detection( |
|
| 876 | + $c->getURLGenerator(), |
|
| 877 | + \OC::$configDir, |
|
| 878 | + \OC::$SERVERROOT . '/resources/config/' |
|
| 879 | + ); |
|
| 880 | + }); |
|
| 881 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
| 882 | + |
|
| 883 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
| 884 | + return new \OC\Files\Type\Loader( |
|
| 885 | + $c->getDatabaseConnection() |
|
| 886 | + ); |
|
| 887 | + }); |
|
| 888 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
| 889 | + $this->registerService(BundleFetcher::class, function () { |
|
| 890 | + return new BundleFetcher($this->getL10N('lib')); |
|
| 891 | + }); |
|
| 892 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
| 893 | + return new Manager( |
|
| 894 | + $c->query(IValidator::class) |
|
| 895 | + ); |
|
| 896 | + }); |
|
| 897 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
| 898 | + |
|
| 899 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
| 900 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
| 901 | + $manager->registerCapability(function () use ($c) { |
|
| 902 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
| 903 | + }); |
|
| 904 | + $manager->registerCapability(function () use ($c) { |
|
| 905 | + return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
| 906 | + }); |
|
| 907 | + return $manager; |
|
| 908 | + }); |
|
| 909 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
| 910 | + |
|
| 911 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
| 912 | + $config = $c->getConfig(); |
|
| 913 | + $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
| 914 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
| 915 | + $factory = new $factoryClass($this); |
|
| 916 | + $manager = $factory->getManager(); |
|
| 917 | + |
|
| 918 | + $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
| 919 | + $manager = $c->getUserManager(); |
|
| 920 | + $user = $manager->get($id); |
|
| 921 | + if(is_null($user)) { |
|
| 922 | + $l = $c->getL10N('core'); |
|
| 923 | + $displayName = $l->t('Unknown user'); |
|
| 924 | + } else { |
|
| 925 | + $displayName = $user->getDisplayName(); |
|
| 926 | + } |
|
| 927 | + return $displayName; |
|
| 928 | + }); |
|
| 929 | + |
|
| 930 | + return $manager; |
|
| 931 | + }); |
|
| 932 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
| 933 | + |
|
| 934 | + $this->registerService('ThemingDefaults', function (Server $c) { |
|
| 935 | + /* |
|
| 936 | 936 | * Dark magic for autoloader. |
| 937 | 937 | * If we do a class_exists it will try to load the class which will |
| 938 | 938 | * make composer cache the result. Resulting in errors when enabling |
| 939 | 939 | * the theming app. |
| 940 | 940 | */ |
| 941 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
| 942 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
| 943 | - $classExists = true; |
|
| 944 | - } else { |
|
| 945 | - $classExists = false; |
|
| 946 | - } |
|
| 947 | - |
|
| 948 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
| 949 | - return new ThemingDefaults( |
|
| 950 | - $c->getConfig(), |
|
| 951 | - $c->getL10N('theming'), |
|
| 952 | - $c->getURLGenerator(), |
|
| 953 | - $c->getMemCacheFactory(), |
|
| 954 | - new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
| 955 | - new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
| 956 | - $c->getAppManager() |
|
| 957 | - ); |
|
| 958 | - } |
|
| 959 | - return new \OC_Defaults(); |
|
| 960 | - }); |
|
| 961 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
| 962 | - /** @var Factory $cacheFactory */ |
|
| 963 | - $cacheFactory = $c->query(Factory::class); |
|
| 964 | - return new SCSSCacher( |
|
| 965 | - $c->getLogger(), |
|
| 966 | - $c->query(\OC\Files\AppData\Factory::class), |
|
| 967 | - $c->getURLGenerator(), |
|
| 968 | - $c->getConfig(), |
|
| 969 | - $c->getThemingDefaults(), |
|
| 970 | - \OC::$SERVERROOT, |
|
| 971 | - $this->getMemCacheFactory() |
|
| 972 | - ); |
|
| 973 | - }); |
|
| 974 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
| 975 | - /** @var Factory $cacheFactory */ |
|
| 976 | - $cacheFactory = $c->query(Factory::class); |
|
| 977 | - return new JSCombiner( |
|
| 978 | - $c->getAppDataDir('js'), |
|
| 979 | - $c->getURLGenerator(), |
|
| 980 | - $this->getMemCacheFactory(), |
|
| 981 | - $c->getSystemConfig(), |
|
| 982 | - $c->getLogger() |
|
| 983 | - ); |
|
| 984 | - }); |
|
| 985 | - $this->registerService(EventDispatcher::class, function () { |
|
| 986 | - return new EventDispatcher(); |
|
| 987 | - }); |
|
| 988 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
| 989 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
| 990 | - |
|
| 991 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 992 | - // FIXME: Instantiiated here due to cyclic dependency |
|
| 993 | - $request = new Request( |
|
| 994 | - [ |
|
| 995 | - 'get' => $_GET, |
|
| 996 | - 'post' => $_POST, |
|
| 997 | - 'files' => $_FILES, |
|
| 998 | - 'server' => $_SERVER, |
|
| 999 | - 'env' => $_ENV, |
|
| 1000 | - 'cookies' => $_COOKIE, |
|
| 1001 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 1002 | - ? $_SERVER['REQUEST_METHOD'] |
|
| 1003 | - : null, |
|
| 1004 | - ], |
|
| 1005 | - $c->getSecureRandom(), |
|
| 1006 | - $c->getConfig() |
|
| 1007 | - ); |
|
| 1008 | - |
|
| 1009 | - return new CryptoWrapper( |
|
| 1010 | - $c->getConfig(), |
|
| 1011 | - $c->getCrypto(), |
|
| 1012 | - $c->getSecureRandom(), |
|
| 1013 | - $request |
|
| 1014 | - ); |
|
| 1015 | - }); |
|
| 1016 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
| 1017 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
| 1018 | - |
|
| 1019 | - return new CsrfTokenManager( |
|
| 1020 | - $tokenGenerator, |
|
| 1021 | - $c->query(SessionStorage::class) |
|
| 1022 | - ); |
|
| 1023 | - }); |
|
| 1024 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 1025 | - return new SessionStorage($c->getSession()); |
|
| 1026 | - }); |
|
| 1027 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
| 1028 | - return new ContentSecurityPolicyManager(); |
|
| 1029 | - }); |
|
| 1030 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
| 1031 | - |
|
| 1032 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
| 1033 | - return new ContentSecurityPolicyNonceManager( |
|
| 1034 | - $c->getCsrfTokenManager(), |
|
| 1035 | - $c->getRequest() |
|
| 1036 | - ); |
|
| 1037 | - }); |
|
| 1038 | - |
|
| 1039 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
| 1040 | - $config = $c->getConfig(); |
|
| 1041 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
| 1042 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
| 1043 | - $factory = new $factoryClass($this); |
|
| 1044 | - |
|
| 1045 | - $manager = new \OC\Share20\Manager( |
|
| 1046 | - $c->getLogger(), |
|
| 1047 | - $c->getConfig(), |
|
| 1048 | - $c->getSecureRandom(), |
|
| 1049 | - $c->getHasher(), |
|
| 1050 | - $c->getMountManager(), |
|
| 1051 | - $c->getGroupManager(), |
|
| 1052 | - $c->getL10N('lib'), |
|
| 1053 | - $c->getL10NFactory(), |
|
| 1054 | - $factory, |
|
| 1055 | - $c->getUserManager(), |
|
| 1056 | - $c->getLazyRootFolder(), |
|
| 1057 | - $c->getEventDispatcher(), |
|
| 1058 | - $c->getMailer(), |
|
| 1059 | - $c->getURLGenerator(), |
|
| 1060 | - $c->getThemingDefaults() |
|
| 1061 | - ); |
|
| 1062 | - |
|
| 1063 | - return $manager; |
|
| 1064 | - }); |
|
| 1065 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
| 1066 | - |
|
| 1067 | - $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
| 1068 | - $instance = new Collaboration\Collaborators\Search($c); |
|
| 1069 | - |
|
| 1070 | - // register default plugins |
|
| 1071 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
| 1072 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
| 1073 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
| 1074 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
| 1075 | - |
|
| 1076 | - return $instance; |
|
| 1077 | - }); |
|
| 1078 | - $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
| 1079 | - |
|
| 1080 | - $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
| 1081 | - |
|
| 1082 | - $this->registerService('SettingsManager', function (Server $c) { |
|
| 1083 | - $manager = new \OC\Settings\Manager( |
|
| 1084 | - $c->getLogger(), |
|
| 1085 | - $c->getDatabaseConnection(), |
|
| 1086 | - $c->getL10N('lib'), |
|
| 1087 | - $c->getConfig(), |
|
| 1088 | - $c->getEncryptionManager(), |
|
| 1089 | - $c->getUserManager(), |
|
| 1090 | - $c->getLockingProvider(), |
|
| 1091 | - $c->getRequest(), |
|
| 1092 | - $c->getURLGenerator(), |
|
| 1093 | - $c->query(AccountManager::class), |
|
| 1094 | - $c->getGroupManager(), |
|
| 1095 | - $c->getL10NFactory(), |
|
| 1096 | - $c->getAppManager() |
|
| 1097 | - ); |
|
| 1098 | - return $manager; |
|
| 1099 | - }); |
|
| 1100 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 1101 | - return new \OC\Files\AppData\Factory( |
|
| 1102 | - $c->getRootFolder(), |
|
| 1103 | - $c->getSystemConfig() |
|
| 1104 | - ); |
|
| 1105 | - }); |
|
| 1106 | - |
|
| 1107 | - $this->registerService('LockdownManager', function (Server $c) { |
|
| 1108 | - return new LockdownManager(function () use ($c) { |
|
| 1109 | - return $c->getSession(); |
|
| 1110 | - }); |
|
| 1111 | - }); |
|
| 1112 | - |
|
| 1113 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 1114 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
| 1115 | - }); |
|
| 1116 | - |
|
| 1117 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 1118 | - return new CloudIdManager(); |
|
| 1119 | - }); |
|
| 1120 | - |
|
| 1121 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
| 1122 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
| 1123 | - |
|
| 1124 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
| 1125 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
| 1126 | - |
|
| 1127 | - $this->registerService(Defaults::class, function (Server $c) { |
|
| 1128 | - return new Defaults( |
|
| 1129 | - $c->getThemingDefaults() |
|
| 1130 | - ); |
|
| 1131 | - }); |
|
| 1132 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
| 1133 | - |
|
| 1134 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
| 1135 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
| 1136 | - }); |
|
| 1137 | - |
|
| 1138 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
| 1139 | - return new ShareHelper( |
|
| 1140 | - $c->query(\OCP\Share\IManager::class) |
|
| 1141 | - ); |
|
| 1142 | - }); |
|
| 1143 | - |
|
| 1144 | - $this->registerService(Installer::class, function(Server $c) { |
|
| 1145 | - return new Installer( |
|
| 1146 | - $c->getAppFetcher(), |
|
| 1147 | - $c->getHTTPClientService(), |
|
| 1148 | - $c->getTempManager(), |
|
| 1149 | - $c->getLogger(), |
|
| 1150 | - $c->getConfig() |
|
| 1151 | - ); |
|
| 1152 | - }); |
|
| 1153 | - |
|
| 1154 | - $this->registerService(IApiFactory::class, function(Server $c) { |
|
| 1155 | - return new ApiFactory($c->getHTTPClientService()); |
|
| 1156 | - }); |
|
| 1157 | - |
|
| 1158 | - $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
| 1159 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
| 1160 | - return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
| 1161 | - }); |
|
| 1162 | - |
|
| 1163 | - $this->registerService(IContactsStore::class, function(Server $c) { |
|
| 1164 | - return new ContactsStore( |
|
| 1165 | - $c->getContactsManager(), |
|
| 1166 | - $c->getConfig(), |
|
| 1167 | - $c->getUserManager(), |
|
| 1168 | - $c->getGroupManager() |
|
| 1169 | - ); |
|
| 1170 | - }); |
|
| 1171 | - $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
| 1172 | - |
|
| 1173 | - $this->connectDispatcher(); |
|
| 1174 | - } |
|
| 1175 | - |
|
| 1176 | - /** |
|
| 1177 | - * @return \OCP\Calendar\IManager |
|
| 1178 | - */ |
|
| 1179 | - public function getCalendarManager() { |
|
| 1180 | - return $this->query('CalendarManager'); |
|
| 1181 | - } |
|
| 1182 | - |
|
| 1183 | - /** |
|
| 1184 | - * @return \OCP\Calendar\Resource\IManager |
|
| 1185 | - */ |
|
| 1186 | - public function getCalendarResourceBackendManager() { |
|
| 1187 | - return $this->query('CalendarResourceBackendManager'); |
|
| 1188 | - } |
|
| 1189 | - |
|
| 1190 | - /** |
|
| 1191 | - * @return \OCP\Calendar\Room\IManager |
|
| 1192 | - */ |
|
| 1193 | - public function getCalendarRoomBackendManager() { |
|
| 1194 | - return $this->query('CalendarRoomBackendManager'); |
|
| 1195 | - } |
|
| 1196 | - |
|
| 1197 | - private function connectDispatcher() { |
|
| 1198 | - $dispatcher = $this->getEventDispatcher(); |
|
| 1199 | - |
|
| 1200 | - // Delete avatar on user deletion |
|
| 1201 | - $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
| 1202 | - $logger = $this->getLogger(); |
|
| 1203 | - $manager = $this->getAvatarManager(); |
|
| 1204 | - /** @var IUser $user */ |
|
| 1205 | - $user = $e->getSubject(); |
|
| 1206 | - |
|
| 1207 | - try { |
|
| 1208 | - $avatar = $manager->getAvatar($user->getUID()); |
|
| 1209 | - $avatar->remove(); |
|
| 1210 | - } catch (NotFoundException $e) { |
|
| 1211 | - // no avatar to remove |
|
| 1212 | - } catch (\Exception $e) { |
|
| 1213 | - // Ignore exceptions |
|
| 1214 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
| 1215 | - } |
|
| 1216 | - }); |
|
| 1217 | - |
|
| 1218 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
| 1219 | - $manager = $this->getAvatarManager(); |
|
| 1220 | - /** @var IUser $user */ |
|
| 1221 | - $user = $e->getSubject(); |
|
| 1222 | - $feature = $e->getArgument('feature'); |
|
| 1223 | - $oldValue = $e->getArgument('oldValue'); |
|
| 1224 | - $value = $e->getArgument('value'); |
|
| 1225 | - |
|
| 1226 | - try { |
|
| 1227 | - $avatar = $manager->getAvatar($user->getUID()); |
|
| 1228 | - $avatar->userChanged($feature, $oldValue, $value); |
|
| 1229 | - } catch (NotFoundException $e) { |
|
| 1230 | - // no avatar to remove |
|
| 1231 | - } |
|
| 1232 | - }); |
|
| 1233 | - } |
|
| 1234 | - |
|
| 1235 | - /** |
|
| 1236 | - * @return \OCP\Contacts\IManager |
|
| 1237 | - */ |
|
| 1238 | - public function getContactsManager() { |
|
| 1239 | - return $this->query('ContactsManager'); |
|
| 1240 | - } |
|
| 1241 | - |
|
| 1242 | - /** |
|
| 1243 | - * @return \OC\Encryption\Manager |
|
| 1244 | - */ |
|
| 1245 | - public function getEncryptionManager() { |
|
| 1246 | - return $this->query('EncryptionManager'); |
|
| 1247 | - } |
|
| 1248 | - |
|
| 1249 | - /** |
|
| 1250 | - * @return \OC\Encryption\File |
|
| 1251 | - */ |
|
| 1252 | - public function getEncryptionFilesHelper() { |
|
| 1253 | - return $this->query('EncryptionFileHelper'); |
|
| 1254 | - } |
|
| 1255 | - |
|
| 1256 | - /** |
|
| 1257 | - * @return \OCP\Encryption\Keys\IStorage |
|
| 1258 | - */ |
|
| 1259 | - public function getEncryptionKeyStorage() { |
|
| 1260 | - return $this->query('EncryptionKeyStorage'); |
|
| 1261 | - } |
|
| 1262 | - |
|
| 1263 | - /** |
|
| 1264 | - * The current request object holding all information about the request |
|
| 1265 | - * currently being processed is returned from this method. |
|
| 1266 | - * In case the current execution was not initiated by a web request null is returned |
|
| 1267 | - * |
|
| 1268 | - * @return \OCP\IRequest |
|
| 1269 | - */ |
|
| 1270 | - public function getRequest() { |
|
| 1271 | - return $this->query('Request'); |
|
| 1272 | - } |
|
| 1273 | - |
|
| 1274 | - /** |
|
| 1275 | - * Returns the preview manager which can create preview images for a given file |
|
| 1276 | - * |
|
| 1277 | - * @return \OCP\IPreview |
|
| 1278 | - */ |
|
| 1279 | - public function getPreviewManager() { |
|
| 1280 | - return $this->query('PreviewManager'); |
|
| 1281 | - } |
|
| 1282 | - |
|
| 1283 | - /** |
|
| 1284 | - * Returns the tag manager which can get and set tags for different object types |
|
| 1285 | - * |
|
| 1286 | - * @see \OCP\ITagManager::load() |
|
| 1287 | - * @return \OCP\ITagManager |
|
| 1288 | - */ |
|
| 1289 | - public function getTagManager() { |
|
| 1290 | - return $this->query('TagManager'); |
|
| 1291 | - } |
|
| 1292 | - |
|
| 1293 | - /** |
|
| 1294 | - * Returns the system-tag manager |
|
| 1295 | - * |
|
| 1296 | - * @return \OCP\SystemTag\ISystemTagManager |
|
| 1297 | - * |
|
| 1298 | - * @since 9.0.0 |
|
| 1299 | - */ |
|
| 1300 | - public function getSystemTagManager() { |
|
| 1301 | - return $this->query('SystemTagManager'); |
|
| 1302 | - } |
|
| 1303 | - |
|
| 1304 | - /** |
|
| 1305 | - * Returns the system-tag object mapper |
|
| 1306 | - * |
|
| 1307 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
| 1308 | - * |
|
| 1309 | - * @since 9.0.0 |
|
| 1310 | - */ |
|
| 1311 | - public function getSystemTagObjectMapper() { |
|
| 1312 | - return $this->query('SystemTagObjectMapper'); |
|
| 1313 | - } |
|
| 1314 | - |
|
| 1315 | - /** |
|
| 1316 | - * Returns the avatar manager, used for avatar functionality |
|
| 1317 | - * |
|
| 1318 | - * @return \OCP\IAvatarManager |
|
| 1319 | - */ |
|
| 1320 | - public function getAvatarManager() { |
|
| 1321 | - return $this->query('AvatarManager'); |
|
| 1322 | - } |
|
| 1323 | - |
|
| 1324 | - /** |
|
| 1325 | - * Returns the root folder of ownCloud's data directory |
|
| 1326 | - * |
|
| 1327 | - * @return \OCP\Files\IRootFolder |
|
| 1328 | - */ |
|
| 1329 | - public function getRootFolder() { |
|
| 1330 | - return $this->query('LazyRootFolder'); |
|
| 1331 | - } |
|
| 1332 | - |
|
| 1333 | - /** |
|
| 1334 | - * Returns the root folder of ownCloud's data directory |
|
| 1335 | - * This is the lazy variant so this gets only initialized once it |
|
| 1336 | - * is actually used. |
|
| 1337 | - * |
|
| 1338 | - * @return \OCP\Files\IRootFolder |
|
| 1339 | - */ |
|
| 1340 | - public function getLazyRootFolder() { |
|
| 1341 | - return $this->query('LazyRootFolder'); |
|
| 1342 | - } |
|
| 1343 | - |
|
| 1344 | - /** |
|
| 1345 | - * Returns a view to ownCloud's files folder |
|
| 1346 | - * |
|
| 1347 | - * @param string $userId user ID |
|
| 1348 | - * @return \OCP\Files\Folder|null |
|
| 1349 | - */ |
|
| 1350 | - public function getUserFolder($userId = null) { |
|
| 1351 | - if ($userId === null) { |
|
| 1352 | - $user = $this->getUserSession()->getUser(); |
|
| 1353 | - if (!$user) { |
|
| 1354 | - return null; |
|
| 1355 | - } |
|
| 1356 | - $userId = $user->getUID(); |
|
| 1357 | - } |
|
| 1358 | - $root = $this->getRootFolder(); |
|
| 1359 | - return $root->getUserFolder($userId); |
|
| 1360 | - } |
|
| 1361 | - |
|
| 1362 | - /** |
|
| 1363 | - * Returns an app-specific view in ownClouds data directory |
|
| 1364 | - * |
|
| 1365 | - * @return \OCP\Files\Folder |
|
| 1366 | - * @deprecated since 9.2.0 use IAppData |
|
| 1367 | - */ |
|
| 1368 | - public function getAppFolder() { |
|
| 1369 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
| 1370 | - $root = $this->getRootFolder(); |
|
| 1371 | - if (!$root->nodeExists($dir)) { |
|
| 1372 | - $folder = $root->newFolder($dir); |
|
| 1373 | - } else { |
|
| 1374 | - $folder = $root->get($dir); |
|
| 1375 | - } |
|
| 1376 | - return $folder; |
|
| 1377 | - } |
|
| 1378 | - |
|
| 1379 | - /** |
|
| 1380 | - * @return \OC\User\Manager |
|
| 1381 | - */ |
|
| 1382 | - public function getUserManager() { |
|
| 1383 | - return $this->query('UserManager'); |
|
| 1384 | - } |
|
| 1385 | - |
|
| 1386 | - /** |
|
| 1387 | - * @return \OC\Group\Manager |
|
| 1388 | - */ |
|
| 1389 | - public function getGroupManager() { |
|
| 1390 | - return $this->query('GroupManager'); |
|
| 1391 | - } |
|
| 1392 | - |
|
| 1393 | - /** |
|
| 1394 | - * @return \OC\User\Session |
|
| 1395 | - */ |
|
| 1396 | - public function getUserSession() { |
|
| 1397 | - return $this->query('UserSession'); |
|
| 1398 | - } |
|
| 1399 | - |
|
| 1400 | - /** |
|
| 1401 | - * @return \OCP\ISession |
|
| 1402 | - */ |
|
| 1403 | - public function getSession() { |
|
| 1404 | - return $this->query('UserSession')->getSession(); |
|
| 1405 | - } |
|
| 1406 | - |
|
| 1407 | - /** |
|
| 1408 | - * @param \OCP\ISession $session |
|
| 1409 | - */ |
|
| 1410 | - public function setSession(\OCP\ISession $session) { |
|
| 1411 | - $this->query(SessionStorage::class)->setSession($session); |
|
| 1412 | - $this->query('UserSession')->setSession($session); |
|
| 1413 | - $this->query(Store::class)->setSession($session); |
|
| 1414 | - } |
|
| 1415 | - |
|
| 1416 | - /** |
|
| 1417 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
| 1418 | - */ |
|
| 1419 | - public function getTwoFactorAuthManager() { |
|
| 1420 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
| 1421 | - } |
|
| 1422 | - |
|
| 1423 | - /** |
|
| 1424 | - * @return \OC\NavigationManager |
|
| 1425 | - */ |
|
| 1426 | - public function getNavigationManager() { |
|
| 1427 | - return $this->query('NavigationManager'); |
|
| 1428 | - } |
|
| 1429 | - |
|
| 1430 | - /** |
|
| 1431 | - * @return \OCP\IConfig |
|
| 1432 | - */ |
|
| 1433 | - public function getConfig() { |
|
| 1434 | - return $this->query('AllConfig'); |
|
| 1435 | - } |
|
| 1436 | - |
|
| 1437 | - /** |
|
| 1438 | - * @return \OC\SystemConfig |
|
| 1439 | - */ |
|
| 1440 | - public function getSystemConfig() { |
|
| 1441 | - return $this->query('SystemConfig'); |
|
| 1442 | - } |
|
| 1443 | - |
|
| 1444 | - /** |
|
| 1445 | - * Returns the app config manager |
|
| 1446 | - * |
|
| 1447 | - * @return \OCP\IAppConfig |
|
| 1448 | - */ |
|
| 1449 | - public function getAppConfig() { |
|
| 1450 | - return $this->query('AppConfig'); |
|
| 1451 | - } |
|
| 1452 | - |
|
| 1453 | - /** |
|
| 1454 | - * @return \OCP\L10N\IFactory |
|
| 1455 | - */ |
|
| 1456 | - public function getL10NFactory() { |
|
| 1457 | - return $this->query('L10NFactory'); |
|
| 1458 | - } |
|
| 1459 | - |
|
| 1460 | - /** |
|
| 1461 | - * get an L10N instance |
|
| 1462 | - * |
|
| 1463 | - * @param string $app appid |
|
| 1464 | - * @param string $lang |
|
| 1465 | - * @return IL10N |
|
| 1466 | - */ |
|
| 1467 | - public function getL10N($app, $lang = null) { |
|
| 1468 | - return $this->getL10NFactory()->get($app, $lang); |
|
| 1469 | - } |
|
| 1470 | - |
|
| 1471 | - /** |
|
| 1472 | - * @return \OCP\IURLGenerator |
|
| 1473 | - */ |
|
| 1474 | - public function getURLGenerator() { |
|
| 1475 | - return $this->query('URLGenerator'); |
|
| 1476 | - } |
|
| 1477 | - |
|
| 1478 | - /** |
|
| 1479 | - * @return AppFetcher |
|
| 1480 | - */ |
|
| 1481 | - public function getAppFetcher() { |
|
| 1482 | - return $this->query(AppFetcher::class); |
|
| 1483 | - } |
|
| 1484 | - |
|
| 1485 | - /** |
|
| 1486 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
| 1487 | - * getMemCacheFactory() instead. |
|
| 1488 | - * |
|
| 1489 | - * @return \OCP\ICache |
|
| 1490 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
| 1491 | - */ |
|
| 1492 | - public function getCache() { |
|
| 1493 | - return $this->query('UserCache'); |
|
| 1494 | - } |
|
| 1495 | - |
|
| 1496 | - /** |
|
| 1497 | - * Returns an \OCP\CacheFactory instance |
|
| 1498 | - * |
|
| 1499 | - * @return \OCP\ICacheFactory |
|
| 1500 | - */ |
|
| 1501 | - public function getMemCacheFactory() { |
|
| 1502 | - return $this->query('MemCacheFactory'); |
|
| 1503 | - } |
|
| 1504 | - |
|
| 1505 | - /** |
|
| 1506 | - * Returns an \OC\RedisFactory instance |
|
| 1507 | - * |
|
| 1508 | - * @return \OC\RedisFactory |
|
| 1509 | - */ |
|
| 1510 | - public function getGetRedisFactory() { |
|
| 1511 | - return $this->query('RedisFactory'); |
|
| 1512 | - } |
|
| 1513 | - |
|
| 1514 | - |
|
| 1515 | - /** |
|
| 1516 | - * Returns the current session |
|
| 1517 | - * |
|
| 1518 | - * @return \OCP\IDBConnection |
|
| 1519 | - */ |
|
| 1520 | - public function getDatabaseConnection() { |
|
| 1521 | - return $this->query('DatabaseConnection'); |
|
| 1522 | - } |
|
| 1523 | - |
|
| 1524 | - /** |
|
| 1525 | - * Returns the activity manager |
|
| 1526 | - * |
|
| 1527 | - * @return \OCP\Activity\IManager |
|
| 1528 | - */ |
|
| 1529 | - public function getActivityManager() { |
|
| 1530 | - return $this->query('ActivityManager'); |
|
| 1531 | - } |
|
| 1532 | - |
|
| 1533 | - /** |
|
| 1534 | - * Returns an job list for controlling background jobs |
|
| 1535 | - * |
|
| 1536 | - * @return \OCP\BackgroundJob\IJobList |
|
| 1537 | - */ |
|
| 1538 | - public function getJobList() { |
|
| 1539 | - return $this->query('JobList'); |
|
| 1540 | - } |
|
| 1541 | - |
|
| 1542 | - /** |
|
| 1543 | - * Returns a logger instance |
|
| 1544 | - * |
|
| 1545 | - * @return \OCP\ILogger |
|
| 1546 | - */ |
|
| 1547 | - public function getLogger() { |
|
| 1548 | - return $this->query('Logger'); |
|
| 1549 | - } |
|
| 1550 | - |
|
| 1551 | - /** |
|
| 1552 | - * @return ILogFactory |
|
| 1553 | - * @throws \OCP\AppFramework\QueryException |
|
| 1554 | - */ |
|
| 1555 | - public function getLogFactory() { |
|
| 1556 | - return $this->query(ILogFactory::class); |
|
| 1557 | - } |
|
| 1558 | - |
|
| 1559 | - /** |
|
| 1560 | - * Returns a router for generating and matching urls |
|
| 1561 | - * |
|
| 1562 | - * @return \OCP\Route\IRouter |
|
| 1563 | - */ |
|
| 1564 | - public function getRouter() { |
|
| 1565 | - return $this->query('Router'); |
|
| 1566 | - } |
|
| 1567 | - |
|
| 1568 | - /** |
|
| 1569 | - * Returns a search instance |
|
| 1570 | - * |
|
| 1571 | - * @return \OCP\ISearch |
|
| 1572 | - */ |
|
| 1573 | - public function getSearch() { |
|
| 1574 | - return $this->query('Search'); |
|
| 1575 | - } |
|
| 1576 | - |
|
| 1577 | - /** |
|
| 1578 | - * Returns a SecureRandom instance |
|
| 1579 | - * |
|
| 1580 | - * @return \OCP\Security\ISecureRandom |
|
| 1581 | - */ |
|
| 1582 | - public function getSecureRandom() { |
|
| 1583 | - return $this->query('SecureRandom'); |
|
| 1584 | - } |
|
| 1585 | - |
|
| 1586 | - /** |
|
| 1587 | - * Returns a Crypto instance |
|
| 1588 | - * |
|
| 1589 | - * @return \OCP\Security\ICrypto |
|
| 1590 | - */ |
|
| 1591 | - public function getCrypto() { |
|
| 1592 | - return $this->query('Crypto'); |
|
| 1593 | - } |
|
| 1594 | - |
|
| 1595 | - /** |
|
| 1596 | - * Returns a Hasher instance |
|
| 1597 | - * |
|
| 1598 | - * @return \OCP\Security\IHasher |
|
| 1599 | - */ |
|
| 1600 | - public function getHasher() { |
|
| 1601 | - return $this->query('Hasher'); |
|
| 1602 | - } |
|
| 1603 | - |
|
| 1604 | - /** |
|
| 1605 | - * Returns a CredentialsManager instance |
|
| 1606 | - * |
|
| 1607 | - * @return \OCP\Security\ICredentialsManager |
|
| 1608 | - */ |
|
| 1609 | - public function getCredentialsManager() { |
|
| 1610 | - return $this->query('CredentialsManager'); |
|
| 1611 | - } |
|
| 1612 | - |
|
| 1613 | - /** |
|
| 1614 | - * Get the certificate manager for the user |
|
| 1615 | - * |
|
| 1616 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 1617 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
| 1618 | - */ |
|
| 1619 | - public function getCertificateManager($userId = '') { |
|
| 1620 | - if ($userId === '') { |
|
| 1621 | - $userSession = $this->getUserSession(); |
|
| 1622 | - $user = $userSession->getUser(); |
|
| 1623 | - if (is_null($user)) { |
|
| 1624 | - return null; |
|
| 1625 | - } |
|
| 1626 | - $userId = $user->getUID(); |
|
| 1627 | - } |
|
| 1628 | - return new CertificateManager( |
|
| 1629 | - $userId, |
|
| 1630 | - new View(), |
|
| 1631 | - $this->getConfig(), |
|
| 1632 | - $this->getLogger(), |
|
| 1633 | - $this->getSecureRandom() |
|
| 1634 | - ); |
|
| 1635 | - } |
|
| 1636 | - |
|
| 1637 | - /** |
|
| 1638 | - * Returns an instance of the HTTP client service |
|
| 1639 | - * |
|
| 1640 | - * @return \OCP\Http\Client\IClientService |
|
| 1641 | - */ |
|
| 1642 | - public function getHTTPClientService() { |
|
| 1643 | - return $this->query('HttpClientService'); |
|
| 1644 | - } |
|
| 1645 | - |
|
| 1646 | - /** |
|
| 1647 | - * Create a new event source |
|
| 1648 | - * |
|
| 1649 | - * @return \OCP\IEventSource |
|
| 1650 | - */ |
|
| 1651 | - public function createEventSource() { |
|
| 1652 | - return new \OC_EventSource(); |
|
| 1653 | - } |
|
| 1654 | - |
|
| 1655 | - /** |
|
| 1656 | - * Get the active event logger |
|
| 1657 | - * |
|
| 1658 | - * The returned logger only logs data when debug mode is enabled |
|
| 1659 | - * |
|
| 1660 | - * @return \OCP\Diagnostics\IEventLogger |
|
| 1661 | - */ |
|
| 1662 | - public function getEventLogger() { |
|
| 1663 | - return $this->query('EventLogger'); |
|
| 1664 | - } |
|
| 1665 | - |
|
| 1666 | - /** |
|
| 1667 | - * Get the active query logger |
|
| 1668 | - * |
|
| 1669 | - * The returned logger only logs data when debug mode is enabled |
|
| 1670 | - * |
|
| 1671 | - * @return \OCP\Diagnostics\IQueryLogger |
|
| 1672 | - */ |
|
| 1673 | - public function getQueryLogger() { |
|
| 1674 | - return $this->query('QueryLogger'); |
|
| 1675 | - } |
|
| 1676 | - |
|
| 1677 | - /** |
|
| 1678 | - * Get the manager for temporary files and folders |
|
| 1679 | - * |
|
| 1680 | - * @return \OCP\ITempManager |
|
| 1681 | - */ |
|
| 1682 | - public function getTempManager() { |
|
| 1683 | - return $this->query('TempManager'); |
|
| 1684 | - } |
|
| 1685 | - |
|
| 1686 | - /** |
|
| 1687 | - * Get the app manager |
|
| 1688 | - * |
|
| 1689 | - * @return \OCP\App\IAppManager |
|
| 1690 | - */ |
|
| 1691 | - public function getAppManager() { |
|
| 1692 | - return $this->query('AppManager'); |
|
| 1693 | - } |
|
| 1694 | - |
|
| 1695 | - /** |
|
| 1696 | - * Creates a new mailer |
|
| 1697 | - * |
|
| 1698 | - * @return \OCP\Mail\IMailer |
|
| 1699 | - */ |
|
| 1700 | - public function getMailer() { |
|
| 1701 | - return $this->query('Mailer'); |
|
| 1702 | - } |
|
| 1703 | - |
|
| 1704 | - /** |
|
| 1705 | - * Get the webroot |
|
| 1706 | - * |
|
| 1707 | - * @return string |
|
| 1708 | - */ |
|
| 1709 | - public function getWebRoot() { |
|
| 1710 | - return $this->webRoot; |
|
| 1711 | - } |
|
| 1712 | - |
|
| 1713 | - /** |
|
| 1714 | - * @return \OC\OCSClient |
|
| 1715 | - */ |
|
| 1716 | - public function getOcsClient() { |
|
| 1717 | - return $this->query('OcsClient'); |
|
| 1718 | - } |
|
| 1719 | - |
|
| 1720 | - /** |
|
| 1721 | - * @return \OCP\IDateTimeZone |
|
| 1722 | - */ |
|
| 1723 | - public function getDateTimeZone() { |
|
| 1724 | - return $this->query('DateTimeZone'); |
|
| 1725 | - } |
|
| 1726 | - |
|
| 1727 | - /** |
|
| 1728 | - * @return \OCP\IDateTimeFormatter |
|
| 1729 | - */ |
|
| 1730 | - public function getDateTimeFormatter() { |
|
| 1731 | - return $this->query('DateTimeFormatter'); |
|
| 1732 | - } |
|
| 1733 | - |
|
| 1734 | - /** |
|
| 1735 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
| 1736 | - */ |
|
| 1737 | - public function getMountProviderCollection() { |
|
| 1738 | - return $this->query('MountConfigManager'); |
|
| 1739 | - } |
|
| 1740 | - |
|
| 1741 | - /** |
|
| 1742 | - * Get the IniWrapper |
|
| 1743 | - * |
|
| 1744 | - * @return IniGetWrapper |
|
| 1745 | - */ |
|
| 1746 | - public function getIniWrapper() { |
|
| 1747 | - return $this->query('IniWrapper'); |
|
| 1748 | - } |
|
| 1749 | - |
|
| 1750 | - /** |
|
| 1751 | - * @return \OCP\Command\IBus |
|
| 1752 | - */ |
|
| 1753 | - public function getCommandBus() { |
|
| 1754 | - return $this->query('AsyncCommandBus'); |
|
| 1755 | - } |
|
| 1756 | - |
|
| 1757 | - /** |
|
| 1758 | - * Get the trusted domain helper |
|
| 1759 | - * |
|
| 1760 | - * @return TrustedDomainHelper |
|
| 1761 | - */ |
|
| 1762 | - public function getTrustedDomainHelper() { |
|
| 1763 | - return $this->query('TrustedDomainHelper'); |
|
| 1764 | - } |
|
| 1765 | - |
|
| 1766 | - /** |
|
| 1767 | - * Get the locking provider |
|
| 1768 | - * |
|
| 1769 | - * @return \OCP\Lock\ILockingProvider |
|
| 1770 | - * @since 8.1.0 |
|
| 1771 | - */ |
|
| 1772 | - public function getLockingProvider() { |
|
| 1773 | - return $this->query('LockingProvider'); |
|
| 1774 | - } |
|
| 1775 | - |
|
| 1776 | - /** |
|
| 1777 | - * @return \OCP\Files\Mount\IMountManager |
|
| 1778 | - **/ |
|
| 1779 | - function getMountManager() { |
|
| 1780 | - return $this->query('MountManager'); |
|
| 1781 | - } |
|
| 1782 | - |
|
| 1783 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
| 1784 | - function getUserMountCache() { |
|
| 1785 | - return $this->query('UserMountCache'); |
|
| 1786 | - } |
|
| 1787 | - |
|
| 1788 | - /** |
|
| 1789 | - * Get the MimeTypeDetector |
|
| 1790 | - * |
|
| 1791 | - * @return \OCP\Files\IMimeTypeDetector |
|
| 1792 | - */ |
|
| 1793 | - public function getMimeTypeDetector() { |
|
| 1794 | - return $this->query('MimeTypeDetector'); |
|
| 1795 | - } |
|
| 1796 | - |
|
| 1797 | - /** |
|
| 1798 | - * Get the MimeTypeLoader |
|
| 1799 | - * |
|
| 1800 | - * @return \OCP\Files\IMimeTypeLoader |
|
| 1801 | - */ |
|
| 1802 | - public function getMimeTypeLoader() { |
|
| 1803 | - return $this->query('MimeTypeLoader'); |
|
| 1804 | - } |
|
| 1805 | - |
|
| 1806 | - /** |
|
| 1807 | - * Get the manager of all the capabilities |
|
| 1808 | - * |
|
| 1809 | - * @return \OC\CapabilitiesManager |
|
| 1810 | - */ |
|
| 1811 | - public function getCapabilitiesManager() { |
|
| 1812 | - return $this->query('CapabilitiesManager'); |
|
| 1813 | - } |
|
| 1814 | - |
|
| 1815 | - /** |
|
| 1816 | - * Get the EventDispatcher |
|
| 1817 | - * |
|
| 1818 | - * @return EventDispatcherInterface |
|
| 1819 | - * @since 8.2.0 |
|
| 1820 | - */ |
|
| 1821 | - public function getEventDispatcher() { |
|
| 1822 | - return $this->query('EventDispatcher'); |
|
| 1823 | - } |
|
| 1824 | - |
|
| 1825 | - /** |
|
| 1826 | - * Get the Notification Manager |
|
| 1827 | - * |
|
| 1828 | - * @return \OCP\Notification\IManager |
|
| 1829 | - * @since 8.2.0 |
|
| 1830 | - */ |
|
| 1831 | - public function getNotificationManager() { |
|
| 1832 | - return $this->query('NotificationManager'); |
|
| 1833 | - } |
|
| 1834 | - |
|
| 1835 | - /** |
|
| 1836 | - * @return \OCP\Comments\ICommentsManager |
|
| 1837 | - */ |
|
| 1838 | - public function getCommentsManager() { |
|
| 1839 | - return $this->query('CommentsManager'); |
|
| 1840 | - } |
|
| 1841 | - |
|
| 1842 | - /** |
|
| 1843 | - * @return \OCA\Theming\ThemingDefaults |
|
| 1844 | - */ |
|
| 1845 | - public function getThemingDefaults() { |
|
| 1846 | - return $this->query('ThemingDefaults'); |
|
| 1847 | - } |
|
| 1848 | - |
|
| 1849 | - /** |
|
| 1850 | - * @return \OC\IntegrityCheck\Checker |
|
| 1851 | - */ |
|
| 1852 | - public function getIntegrityCodeChecker() { |
|
| 1853 | - return $this->query('IntegrityCodeChecker'); |
|
| 1854 | - } |
|
| 1855 | - |
|
| 1856 | - /** |
|
| 1857 | - * @return \OC\Session\CryptoWrapper |
|
| 1858 | - */ |
|
| 1859 | - public function getSessionCryptoWrapper() { |
|
| 1860 | - return $this->query('CryptoWrapper'); |
|
| 1861 | - } |
|
| 1862 | - |
|
| 1863 | - /** |
|
| 1864 | - * @return CsrfTokenManager |
|
| 1865 | - */ |
|
| 1866 | - public function getCsrfTokenManager() { |
|
| 1867 | - return $this->query('CsrfTokenManager'); |
|
| 1868 | - } |
|
| 1869 | - |
|
| 1870 | - /** |
|
| 1871 | - * @return Throttler |
|
| 1872 | - */ |
|
| 1873 | - public function getBruteForceThrottler() { |
|
| 1874 | - return $this->query('Throttler'); |
|
| 1875 | - } |
|
| 1876 | - |
|
| 1877 | - /** |
|
| 1878 | - * @return IContentSecurityPolicyManager |
|
| 1879 | - */ |
|
| 1880 | - public function getContentSecurityPolicyManager() { |
|
| 1881 | - return $this->query('ContentSecurityPolicyManager'); |
|
| 1882 | - } |
|
| 1883 | - |
|
| 1884 | - /** |
|
| 1885 | - * @return ContentSecurityPolicyNonceManager |
|
| 1886 | - */ |
|
| 1887 | - public function getContentSecurityPolicyNonceManager() { |
|
| 1888 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
| 1889 | - } |
|
| 1890 | - |
|
| 1891 | - /** |
|
| 1892 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 1893 | - * |
|
| 1894 | - * @return \OCA\Files_External\Service\BackendService |
|
| 1895 | - */ |
|
| 1896 | - public function getStoragesBackendService() { |
|
| 1897 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
| 1898 | - } |
|
| 1899 | - |
|
| 1900 | - /** |
|
| 1901 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 1902 | - * |
|
| 1903 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
| 1904 | - */ |
|
| 1905 | - public function getGlobalStoragesService() { |
|
| 1906 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
| 1907 | - } |
|
| 1908 | - |
|
| 1909 | - /** |
|
| 1910 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 1911 | - * |
|
| 1912 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
| 1913 | - */ |
|
| 1914 | - public function getUserGlobalStoragesService() { |
|
| 1915 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
| 1916 | - } |
|
| 1917 | - |
|
| 1918 | - /** |
|
| 1919 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 1920 | - * |
|
| 1921 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
| 1922 | - */ |
|
| 1923 | - public function getUserStoragesService() { |
|
| 1924 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
| 1925 | - } |
|
| 1926 | - |
|
| 1927 | - /** |
|
| 1928 | - * @return \OCP\Share\IManager |
|
| 1929 | - */ |
|
| 1930 | - public function getShareManager() { |
|
| 1931 | - return $this->query('ShareManager'); |
|
| 1932 | - } |
|
| 1933 | - |
|
| 1934 | - /** |
|
| 1935 | - * @return \OCP\Collaboration\Collaborators\ISearch |
|
| 1936 | - */ |
|
| 1937 | - public function getCollaboratorSearch() { |
|
| 1938 | - return $this->query('CollaboratorSearch'); |
|
| 1939 | - } |
|
| 1940 | - |
|
| 1941 | - /** |
|
| 1942 | - * @return \OCP\Collaboration\AutoComplete\IManager |
|
| 1943 | - */ |
|
| 1944 | - public function getAutoCompleteManager(){ |
|
| 1945 | - return $this->query(IManager::class); |
|
| 1946 | - } |
|
| 1947 | - |
|
| 1948 | - /** |
|
| 1949 | - * Returns the LDAP Provider |
|
| 1950 | - * |
|
| 1951 | - * @return \OCP\LDAP\ILDAPProvider |
|
| 1952 | - */ |
|
| 1953 | - public function getLDAPProvider() { |
|
| 1954 | - return $this->query('LDAPProvider'); |
|
| 1955 | - } |
|
| 1956 | - |
|
| 1957 | - /** |
|
| 1958 | - * @return \OCP\Settings\IManager |
|
| 1959 | - */ |
|
| 1960 | - public function getSettingsManager() { |
|
| 1961 | - return $this->query('SettingsManager'); |
|
| 1962 | - } |
|
| 1963 | - |
|
| 1964 | - /** |
|
| 1965 | - * @return \OCP\Files\IAppData |
|
| 1966 | - */ |
|
| 1967 | - public function getAppDataDir($app) { |
|
| 1968 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
| 1969 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
| 1970 | - return $factory->get($app); |
|
| 1971 | - } |
|
| 1972 | - |
|
| 1973 | - /** |
|
| 1974 | - * @return \OCP\Lockdown\ILockdownManager |
|
| 1975 | - */ |
|
| 1976 | - public function getLockdownManager() { |
|
| 1977 | - return $this->query('LockdownManager'); |
|
| 1978 | - } |
|
| 1979 | - |
|
| 1980 | - /** |
|
| 1981 | - * @return \OCP\Federation\ICloudIdManager |
|
| 1982 | - */ |
|
| 1983 | - public function getCloudIdManager() { |
|
| 1984 | - return $this->query(ICloudIdManager::class); |
|
| 1985 | - } |
|
| 1986 | - |
|
| 1987 | - /** |
|
| 1988 | - * @return \OCP\Remote\Api\IApiFactory |
|
| 1989 | - */ |
|
| 1990 | - public function getRemoteApiFactory() { |
|
| 1991 | - return $this->query(IApiFactory::class); |
|
| 1992 | - } |
|
| 1993 | - |
|
| 1994 | - /** |
|
| 1995 | - * @return \OCP\Remote\IInstanceFactory |
|
| 1996 | - */ |
|
| 1997 | - public function getRemoteInstanceFactory() { |
|
| 1998 | - return $this->query(IInstanceFactory::class); |
|
| 1999 | - } |
|
| 941 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
| 942 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
| 943 | + $classExists = true; |
|
| 944 | + } else { |
|
| 945 | + $classExists = false; |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
| 949 | + return new ThemingDefaults( |
|
| 950 | + $c->getConfig(), |
|
| 951 | + $c->getL10N('theming'), |
|
| 952 | + $c->getURLGenerator(), |
|
| 953 | + $c->getMemCacheFactory(), |
|
| 954 | + new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
| 955 | + new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
| 956 | + $c->getAppManager() |
|
| 957 | + ); |
|
| 958 | + } |
|
| 959 | + return new \OC_Defaults(); |
|
| 960 | + }); |
|
| 961 | + $this->registerService(SCSSCacher::class, function (Server $c) { |
|
| 962 | + /** @var Factory $cacheFactory */ |
|
| 963 | + $cacheFactory = $c->query(Factory::class); |
|
| 964 | + return new SCSSCacher( |
|
| 965 | + $c->getLogger(), |
|
| 966 | + $c->query(\OC\Files\AppData\Factory::class), |
|
| 967 | + $c->getURLGenerator(), |
|
| 968 | + $c->getConfig(), |
|
| 969 | + $c->getThemingDefaults(), |
|
| 970 | + \OC::$SERVERROOT, |
|
| 971 | + $this->getMemCacheFactory() |
|
| 972 | + ); |
|
| 973 | + }); |
|
| 974 | + $this->registerService(JSCombiner::class, function (Server $c) { |
|
| 975 | + /** @var Factory $cacheFactory */ |
|
| 976 | + $cacheFactory = $c->query(Factory::class); |
|
| 977 | + return new JSCombiner( |
|
| 978 | + $c->getAppDataDir('js'), |
|
| 979 | + $c->getURLGenerator(), |
|
| 980 | + $this->getMemCacheFactory(), |
|
| 981 | + $c->getSystemConfig(), |
|
| 982 | + $c->getLogger() |
|
| 983 | + ); |
|
| 984 | + }); |
|
| 985 | + $this->registerService(EventDispatcher::class, function () { |
|
| 986 | + return new EventDispatcher(); |
|
| 987 | + }); |
|
| 988 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
| 989 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
| 990 | + |
|
| 991 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 992 | + // FIXME: Instantiiated here due to cyclic dependency |
|
| 993 | + $request = new Request( |
|
| 994 | + [ |
|
| 995 | + 'get' => $_GET, |
|
| 996 | + 'post' => $_POST, |
|
| 997 | + 'files' => $_FILES, |
|
| 998 | + 'server' => $_SERVER, |
|
| 999 | + 'env' => $_ENV, |
|
| 1000 | + 'cookies' => $_COOKIE, |
|
| 1001 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 1002 | + ? $_SERVER['REQUEST_METHOD'] |
|
| 1003 | + : null, |
|
| 1004 | + ], |
|
| 1005 | + $c->getSecureRandom(), |
|
| 1006 | + $c->getConfig() |
|
| 1007 | + ); |
|
| 1008 | + |
|
| 1009 | + return new CryptoWrapper( |
|
| 1010 | + $c->getConfig(), |
|
| 1011 | + $c->getCrypto(), |
|
| 1012 | + $c->getSecureRandom(), |
|
| 1013 | + $request |
|
| 1014 | + ); |
|
| 1015 | + }); |
|
| 1016 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
| 1017 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
| 1018 | + |
|
| 1019 | + return new CsrfTokenManager( |
|
| 1020 | + $tokenGenerator, |
|
| 1021 | + $c->query(SessionStorage::class) |
|
| 1022 | + ); |
|
| 1023 | + }); |
|
| 1024 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 1025 | + return new SessionStorage($c->getSession()); |
|
| 1026 | + }); |
|
| 1027 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
| 1028 | + return new ContentSecurityPolicyManager(); |
|
| 1029 | + }); |
|
| 1030 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
| 1031 | + |
|
| 1032 | + $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
| 1033 | + return new ContentSecurityPolicyNonceManager( |
|
| 1034 | + $c->getCsrfTokenManager(), |
|
| 1035 | + $c->getRequest() |
|
| 1036 | + ); |
|
| 1037 | + }); |
|
| 1038 | + |
|
| 1039 | + $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
| 1040 | + $config = $c->getConfig(); |
|
| 1041 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
| 1042 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
| 1043 | + $factory = new $factoryClass($this); |
|
| 1044 | + |
|
| 1045 | + $manager = new \OC\Share20\Manager( |
|
| 1046 | + $c->getLogger(), |
|
| 1047 | + $c->getConfig(), |
|
| 1048 | + $c->getSecureRandom(), |
|
| 1049 | + $c->getHasher(), |
|
| 1050 | + $c->getMountManager(), |
|
| 1051 | + $c->getGroupManager(), |
|
| 1052 | + $c->getL10N('lib'), |
|
| 1053 | + $c->getL10NFactory(), |
|
| 1054 | + $factory, |
|
| 1055 | + $c->getUserManager(), |
|
| 1056 | + $c->getLazyRootFolder(), |
|
| 1057 | + $c->getEventDispatcher(), |
|
| 1058 | + $c->getMailer(), |
|
| 1059 | + $c->getURLGenerator(), |
|
| 1060 | + $c->getThemingDefaults() |
|
| 1061 | + ); |
|
| 1062 | + |
|
| 1063 | + return $manager; |
|
| 1064 | + }); |
|
| 1065 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
| 1066 | + |
|
| 1067 | + $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
| 1068 | + $instance = new Collaboration\Collaborators\Search($c); |
|
| 1069 | + |
|
| 1070 | + // register default plugins |
|
| 1071 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
| 1072 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
| 1073 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
| 1074 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
| 1075 | + |
|
| 1076 | + return $instance; |
|
| 1077 | + }); |
|
| 1078 | + $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
| 1079 | + |
|
| 1080 | + $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
| 1081 | + |
|
| 1082 | + $this->registerService('SettingsManager', function (Server $c) { |
|
| 1083 | + $manager = new \OC\Settings\Manager( |
|
| 1084 | + $c->getLogger(), |
|
| 1085 | + $c->getDatabaseConnection(), |
|
| 1086 | + $c->getL10N('lib'), |
|
| 1087 | + $c->getConfig(), |
|
| 1088 | + $c->getEncryptionManager(), |
|
| 1089 | + $c->getUserManager(), |
|
| 1090 | + $c->getLockingProvider(), |
|
| 1091 | + $c->getRequest(), |
|
| 1092 | + $c->getURLGenerator(), |
|
| 1093 | + $c->query(AccountManager::class), |
|
| 1094 | + $c->getGroupManager(), |
|
| 1095 | + $c->getL10NFactory(), |
|
| 1096 | + $c->getAppManager() |
|
| 1097 | + ); |
|
| 1098 | + return $manager; |
|
| 1099 | + }); |
|
| 1100 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 1101 | + return new \OC\Files\AppData\Factory( |
|
| 1102 | + $c->getRootFolder(), |
|
| 1103 | + $c->getSystemConfig() |
|
| 1104 | + ); |
|
| 1105 | + }); |
|
| 1106 | + |
|
| 1107 | + $this->registerService('LockdownManager', function (Server $c) { |
|
| 1108 | + return new LockdownManager(function () use ($c) { |
|
| 1109 | + return $c->getSession(); |
|
| 1110 | + }); |
|
| 1111 | + }); |
|
| 1112 | + |
|
| 1113 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 1114 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
| 1115 | + }); |
|
| 1116 | + |
|
| 1117 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 1118 | + return new CloudIdManager(); |
|
| 1119 | + }); |
|
| 1120 | + |
|
| 1121 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
| 1122 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
| 1123 | + |
|
| 1124 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
| 1125 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
| 1126 | + |
|
| 1127 | + $this->registerService(Defaults::class, function (Server $c) { |
|
| 1128 | + return new Defaults( |
|
| 1129 | + $c->getThemingDefaults() |
|
| 1130 | + ); |
|
| 1131 | + }); |
|
| 1132 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
| 1133 | + |
|
| 1134 | + $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
| 1135 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
| 1136 | + }); |
|
| 1137 | + |
|
| 1138 | + $this->registerService(IShareHelper::class, function (Server $c) { |
|
| 1139 | + return new ShareHelper( |
|
| 1140 | + $c->query(\OCP\Share\IManager::class) |
|
| 1141 | + ); |
|
| 1142 | + }); |
|
| 1143 | + |
|
| 1144 | + $this->registerService(Installer::class, function(Server $c) { |
|
| 1145 | + return new Installer( |
|
| 1146 | + $c->getAppFetcher(), |
|
| 1147 | + $c->getHTTPClientService(), |
|
| 1148 | + $c->getTempManager(), |
|
| 1149 | + $c->getLogger(), |
|
| 1150 | + $c->getConfig() |
|
| 1151 | + ); |
|
| 1152 | + }); |
|
| 1153 | + |
|
| 1154 | + $this->registerService(IApiFactory::class, function(Server $c) { |
|
| 1155 | + return new ApiFactory($c->getHTTPClientService()); |
|
| 1156 | + }); |
|
| 1157 | + |
|
| 1158 | + $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
| 1159 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
| 1160 | + return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
| 1161 | + }); |
|
| 1162 | + |
|
| 1163 | + $this->registerService(IContactsStore::class, function(Server $c) { |
|
| 1164 | + return new ContactsStore( |
|
| 1165 | + $c->getContactsManager(), |
|
| 1166 | + $c->getConfig(), |
|
| 1167 | + $c->getUserManager(), |
|
| 1168 | + $c->getGroupManager() |
|
| 1169 | + ); |
|
| 1170 | + }); |
|
| 1171 | + $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
| 1172 | + |
|
| 1173 | + $this->connectDispatcher(); |
|
| 1174 | + } |
|
| 1175 | + |
|
| 1176 | + /** |
|
| 1177 | + * @return \OCP\Calendar\IManager |
|
| 1178 | + */ |
|
| 1179 | + public function getCalendarManager() { |
|
| 1180 | + return $this->query('CalendarManager'); |
|
| 1181 | + } |
|
| 1182 | + |
|
| 1183 | + /** |
|
| 1184 | + * @return \OCP\Calendar\Resource\IManager |
|
| 1185 | + */ |
|
| 1186 | + public function getCalendarResourceBackendManager() { |
|
| 1187 | + return $this->query('CalendarResourceBackendManager'); |
|
| 1188 | + } |
|
| 1189 | + |
|
| 1190 | + /** |
|
| 1191 | + * @return \OCP\Calendar\Room\IManager |
|
| 1192 | + */ |
|
| 1193 | + public function getCalendarRoomBackendManager() { |
|
| 1194 | + return $this->query('CalendarRoomBackendManager'); |
|
| 1195 | + } |
|
| 1196 | + |
|
| 1197 | + private function connectDispatcher() { |
|
| 1198 | + $dispatcher = $this->getEventDispatcher(); |
|
| 1199 | + |
|
| 1200 | + // Delete avatar on user deletion |
|
| 1201 | + $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
| 1202 | + $logger = $this->getLogger(); |
|
| 1203 | + $manager = $this->getAvatarManager(); |
|
| 1204 | + /** @var IUser $user */ |
|
| 1205 | + $user = $e->getSubject(); |
|
| 1206 | + |
|
| 1207 | + try { |
|
| 1208 | + $avatar = $manager->getAvatar($user->getUID()); |
|
| 1209 | + $avatar->remove(); |
|
| 1210 | + } catch (NotFoundException $e) { |
|
| 1211 | + // no avatar to remove |
|
| 1212 | + } catch (\Exception $e) { |
|
| 1213 | + // Ignore exceptions |
|
| 1214 | + $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
| 1215 | + } |
|
| 1216 | + }); |
|
| 1217 | + |
|
| 1218 | + $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
| 1219 | + $manager = $this->getAvatarManager(); |
|
| 1220 | + /** @var IUser $user */ |
|
| 1221 | + $user = $e->getSubject(); |
|
| 1222 | + $feature = $e->getArgument('feature'); |
|
| 1223 | + $oldValue = $e->getArgument('oldValue'); |
|
| 1224 | + $value = $e->getArgument('value'); |
|
| 1225 | + |
|
| 1226 | + try { |
|
| 1227 | + $avatar = $manager->getAvatar($user->getUID()); |
|
| 1228 | + $avatar->userChanged($feature, $oldValue, $value); |
|
| 1229 | + } catch (NotFoundException $e) { |
|
| 1230 | + // no avatar to remove |
|
| 1231 | + } |
|
| 1232 | + }); |
|
| 1233 | + } |
|
| 1234 | + |
|
| 1235 | + /** |
|
| 1236 | + * @return \OCP\Contacts\IManager |
|
| 1237 | + */ |
|
| 1238 | + public function getContactsManager() { |
|
| 1239 | + return $this->query('ContactsManager'); |
|
| 1240 | + } |
|
| 1241 | + |
|
| 1242 | + /** |
|
| 1243 | + * @return \OC\Encryption\Manager |
|
| 1244 | + */ |
|
| 1245 | + public function getEncryptionManager() { |
|
| 1246 | + return $this->query('EncryptionManager'); |
|
| 1247 | + } |
|
| 1248 | + |
|
| 1249 | + /** |
|
| 1250 | + * @return \OC\Encryption\File |
|
| 1251 | + */ |
|
| 1252 | + public function getEncryptionFilesHelper() { |
|
| 1253 | + return $this->query('EncryptionFileHelper'); |
|
| 1254 | + } |
|
| 1255 | + |
|
| 1256 | + /** |
|
| 1257 | + * @return \OCP\Encryption\Keys\IStorage |
|
| 1258 | + */ |
|
| 1259 | + public function getEncryptionKeyStorage() { |
|
| 1260 | + return $this->query('EncryptionKeyStorage'); |
|
| 1261 | + } |
|
| 1262 | + |
|
| 1263 | + /** |
|
| 1264 | + * The current request object holding all information about the request |
|
| 1265 | + * currently being processed is returned from this method. |
|
| 1266 | + * In case the current execution was not initiated by a web request null is returned |
|
| 1267 | + * |
|
| 1268 | + * @return \OCP\IRequest |
|
| 1269 | + */ |
|
| 1270 | + public function getRequest() { |
|
| 1271 | + return $this->query('Request'); |
|
| 1272 | + } |
|
| 1273 | + |
|
| 1274 | + /** |
|
| 1275 | + * Returns the preview manager which can create preview images for a given file |
|
| 1276 | + * |
|
| 1277 | + * @return \OCP\IPreview |
|
| 1278 | + */ |
|
| 1279 | + public function getPreviewManager() { |
|
| 1280 | + return $this->query('PreviewManager'); |
|
| 1281 | + } |
|
| 1282 | + |
|
| 1283 | + /** |
|
| 1284 | + * Returns the tag manager which can get and set tags for different object types |
|
| 1285 | + * |
|
| 1286 | + * @see \OCP\ITagManager::load() |
|
| 1287 | + * @return \OCP\ITagManager |
|
| 1288 | + */ |
|
| 1289 | + public function getTagManager() { |
|
| 1290 | + return $this->query('TagManager'); |
|
| 1291 | + } |
|
| 1292 | + |
|
| 1293 | + /** |
|
| 1294 | + * Returns the system-tag manager |
|
| 1295 | + * |
|
| 1296 | + * @return \OCP\SystemTag\ISystemTagManager |
|
| 1297 | + * |
|
| 1298 | + * @since 9.0.0 |
|
| 1299 | + */ |
|
| 1300 | + public function getSystemTagManager() { |
|
| 1301 | + return $this->query('SystemTagManager'); |
|
| 1302 | + } |
|
| 1303 | + |
|
| 1304 | + /** |
|
| 1305 | + * Returns the system-tag object mapper |
|
| 1306 | + * |
|
| 1307 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
| 1308 | + * |
|
| 1309 | + * @since 9.0.0 |
|
| 1310 | + */ |
|
| 1311 | + public function getSystemTagObjectMapper() { |
|
| 1312 | + return $this->query('SystemTagObjectMapper'); |
|
| 1313 | + } |
|
| 1314 | + |
|
| 1315 | + /** |
|
| 1316 | + * Returns the avatar manager, used for avatar functionality |
|
| 1317 | + * |
|
| 1318 | + * @return \OCP\IAvatarManager |
|
| 1319 | + */ |
|
| 1320 | + public function getAvatarManager() { |
|
| 1321 | + return $this->query('AvatarManager'); |
|
| 1322 | + } |
|
| 1323 | + |
|
| 1324 | + /** |
|
| 1325 | + * Returns the root folder of ownCloud's data directory |
|
| 1326 | + * |
|
| 1327 | + * @return \OCP\Files\IRootFolder |
|
| 1328 | + */ |
|
| 1329 | + public function getRootFolder() { |
|
| 1330 | + return $this->query('LazyRootFolder'); |
|
| 1331 | + } |
|
| 1332 | + |
|
| 1333 | + /** |
|
| 1334 | + * Returns the root folder of ownCloud's data directory |
|
| 1335 | + * This is the lazy variant so this gets only initialized once it |
|
| 1336 | + * is actually used. |
|
| 1337 | + * |
|
| 1338 | + * @return \OCP\Files\IRootFolder |
|
| 1339 | + */ |
|
| 1340 | + public function getLazyRootFolder() { |
|
| 1341 | + return $this->query('LazyRootFolder'); |
|
| 1342 | + } |
|
| 1343 | + |
|
| 1344 | + /** |
|
| 1345 | + * Returns a view to ownCloud's files folder |
|
| 1346 | + * |
|
| 1347 | + * @param string $userId user ID |
|
| 1348 | + * @return \OCP\Files\Folder|null |
|
| 1349 | + */ |
|
| 1350 | + public function getUserFolder($userId = null) { |
|
| 1351 | + if ($userId === null) { |
|
| 1352 | + $user = $this->getUserSession()->getUser(); |
|
| 1353 | + if (!$user) { |
|
| 1354 | + return null; |
|
| 1355 | + } |
|
| 1356 | + $userId = $user->getUID(); |
|
| 1357 | + } |
|
| 1358 | + $root = $this->getRootFolder(); |
|
| 1359 | + return $root->getUserFolder($userId); |
|
| 1360 | + } |
|
| 1361 | + |
|
| 1362 | + /** |
|
| 1363 | + * Returns an app-specific view in ownClouds data directory |
|
| 1364 | + * |
|
| 1365 | + * @return \OCP\Files\Folder |
|
| 1366 | + * @deprecated since 9.2.0 use IAppData |
|
| 1367 | + */ |
|
| 1368 | + public function getAppFolder() { |
|
| 1369 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
| 1370 | + $root = $this->getRootFolder(); |
|
| 1371 | + if (!$root->nodeExists($dir)) { |
|
| 1372 | + $folder = $root->newFolder($dir); |
|
| 1373 | + } else { |
|
| 1374 | + $folder = $root->get($dir); |
|
| 1375 | + } |
|
| 1376 | + return $folder; |
|
| 1377 | + } |
|
| 1378 | + |
|
| 1379 | + /** |
|
| 1380 | + * @return \OC\User\Manager |
|
| 1381 | + */ |
|
| 1382 | + public function getUserManager() { |
|
| 1383 | + return $this->query('UserManager'); |
|
| 1384 | + } |
|
| 1385 | + |
|
| 1386 | + /** |
|
| 1387 | + * @return \OC\Group\Manager |
|
| 1388 | + */ |
|
| 1389 | + public function getGroupManager() { |
|
| 1390 | + return $this->query('GroupManager'); |
|
| 1391 | + } |
|
| 1392 | + |
|
| 1393 | + /** |
|
| 1394 | + * @return \OC\User\Session |
|
| 1395 | + */ |
|
| 1396 | + public function getUserSession() { |
|
| 1397 | + return $this->query('UserSession'); |
|
| 1398 | + } |
|
| 1399 | + |
|
| 1400 | + /** |
|
| 1401 | + * @return \OCP\ISession |
|
| 1402 | + */ |
|
| 1403 | + public function getSession() { |
|
| 1404 | + return $this->query('UserSession')->getSession(); |
|
| 1405 | + } |
|
| 1406 | + |
|
| 1407 | + /** |
|
| 1408 | + * @param \OCP\ISession $session |
|
| 1409 | + */ |
|
| 1410 | + public function setSession(\OCP\ISession $session) { |
|
| 1411 | + $this->query(SessionStorage::class)->setSession($session); |
|
| 1412 | + $this->query('UserSession')->setSession($session); |
|
| 1413 | + $this->query(Store::class)->setSession($session); |
|
| 1414 | + } |
|
| 1415 | + |
|
| 1416 | + /** |
|
| 1417 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
| 1418 | + */ |
|
| 1419 | + public function getTwoFactorAuthManager() { |
|
| 1420 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
| 1421 | + } |
|
| 1422 | + |
|
| 1423 | + /** |
|
| 1424 | + * @return \OC\NavigationManager |
|
| 1425 | + */ |
|
| 1426 | + public function getNavigationManager() { |
|
| 1427 | + return $this->query('NavigationManager'); |
|
| 1428 | + } |
|
| 1429 | + |
|
| 1430 | + /** |
|
| 1431 | + * @return \OCP\IConfig |
|
| 1432 | + */ |
|
| 1433 | + public function getConfig() { |
|
| 1434 | + return $this->query('AllConfig'); |
|
| 1435 | + } |
|
| 1436 | + |
|
| 1437 | + /** |
|
| 1438 | + * @return \OC\SystemConfig |
|
| 1439 | + */ |
|
| 1440 | + public function getSystemConfig() { |
|
| 1441 | + return $this->query('SystemConfig'); |
|
| 1442 | + } |
|
| 1443 | + |
|
| 1444 | + /** |
|
| 1445 | + * Returns the app config manager |
|
| 1446 | + * |
|
| 1447 | + * @return \OCP\IAppConfig |
|
| 1448 | + */ |
|
| 1449 | + public function getAppConfig() { |
|
| 1450 | + return $this->query('AppConfig'); |
|
| 1451 | + } |
|
| 1452 | + |
|
| 1453 | + /** |
|
| 1454 | + * @return \OCP\L10N\IFactory |
|
| 1455 | + */ |
|
| 1456 | + public function getL10NFactory() { |
|
| 1457 | + return $this->query('L10NFactory'); |
|
| 1458 | + } |
|
| 1459 | + |
|
| 1460 | + /** |
|
| 1461 | + * get an L10N instance |
|
| 1462 | + * |
|
| 1463 | + * @param string $app appid |
|
| 1464 | + * @param string $lang |
|
| 1465 | + * @return IL10N |
|
| 1466 | + */ |
|
| 1467 | + public function getL10N($app, $lang = null) { |
|
| 1468 | + return $this->getL10NFactory()->get($app, $lang); |
|
| 1469 | + } |
|
| 1470 | + |
|
| 1471 | + /** |
|
| 1472 | + * @return \OCP\IURLGenerator |
|
| 1473 | + */ |
|
| 1474 | + public function getURLGenerator() { |
|
| 1475 | + return $this->query('URLGenerator'); |
|
| 1476 | + } |
|
| 1477 | + |
|
| 1478 | + /** |
|
| 1479 | + * @return AppFetcher |
|
| 1480 | + */ |
|
| 1481 | + public function getAppFetcher() { |
|
| 1482 | + return $this->query(AppFetcher::class); |
|
| 1483 | + } |
|
| 1484 | + |
|
| 1485 | + /** |
|
| 1486 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
| 1487 | + * getMemCacheFactory() instead. |
|
| 1488 | + * |
|
| 1489 | + * @return \OCP\ICache |
|
| 1490 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
| 1491 | + */ |
|
| 1492 | + public function getCache() { |
|
| 1493 | + return $this->query('UserCache'); |
|
| 1494 | + } |
|
| 1495 | + |
|
| 1496 | + /** |
|
| 1497 | + * Returns an \OCP\CacheFactory instance |
|
| 1498 | + * |
|
| 1499 | + * @return \OCP\ICacheFactory |
|
| 1500 | + */ |
|
| 1501 | + public function getMemCacheFactory() { |
|
| 1502 | + return $this->query('MemCacheFactory'); |
|
| 1503 | + } |
|
| 1504 | + |
|
| 1505 | + /** |
|
| 1506 | + * Returns an \OC\RedisFactory instance |
|
| 1507 | + * |
|
| 1508 | + * @return \OC\RedisFactory |
|
| 1509 | + */ |
|
| 1510 | + public function getGetRedisFactory() { |
|
| 1511 | + return $this->query('RedisFactory'); |
|
| 1512 | + } |
|
| 1513 | + |
|
| 1514 | + |
|
| 1515 | + /** |
|
| 1516 | + * Returns the current session |
|
| 1517 | + * |
|
| 1518 | + * @return \OCP\IDBConnection |
|
| 1519 | + */ |
|
| 1520 | + public function getDatabaseConnection() { |
|
| 1521 | + return $this->query('DatabaseConnection'); |
|
| 1522 | + } |
|
| 1523 | + |
|
| 1524 | + /** |
|
| 1525 | + * Returns the activity manager |
|
| 1526 | + * |
|
| 1527 | + * @return \OCP\Activity\IManager |
|
| 1528 | + */ |
|
| 1529 | + public function getActivityManager() { |
|
| 1530 | + return $this->query('ActivityManager'); |
|
| 1531 | + } |
|
| 1532 | + |
|
| 1533 | + /** |
|
| 1534 | + * Returns an job list for controlling background jobs |
|
| 1535 | + * |
|
| 1536 | + * @return \OCP\BackgroundJob\IJobList |
|
| 1537 | + */ |
|
| 1538 | + public function getJobList() { |
|
| 1539 | + return $this->query('JobList'); |
|
| 1540 | + } |
|
| 1541 | + |
|
| 1542 | + /** |
|
| 1543 | + * Returns a logger instance |
|
| 1544 | + * |
|
| 1545 | + * @return \OCP\ILogger |
|
| 1546 | + */ |
|
| 1547 | + public function getLogger() { |
|
| 1548 | + return $this->query('Logger'); |
|
| 1549 | + } |
|
| 1550 | + |
|
| 1551 | + /** |
|
| 1552 | + * @return ILogFactory |
|
| 1553 | + * @throws \OCP\AppFramework\QueryException |
|
| 1554 | + */ |
|
| 1555 | + public function getLogFactory() { |
|
| 1556 | + return $this->query(ILogFactory::class); |
|
| 1557 | + } |
|
| 1558 | + |
|
| 1559 | + /** |
|
| 1560 | + * Returns a router for generating and matching urls |
|
| 1561 | + * |
|
| 1562 | + * @return \OCP\Route\IRouter |
|
| 1563 | + */ |
|
| 1564 | + public function getRouter() { |
|
| 1565 | + return $this->query('Router'); |
|
| 1566 | + } |
|
| 1567 | + |
|
| 1568 | + /** |
|
| 1569 | + * Returns a search instance |
|
| 1570 | + * |
|
| 1571 | + * @return \OCP\ISearch |
|
| 1572 | + */ |
|
| 1573 | + public function getSearch() { |
|
| 1574 | + return $this->query('Search'); |
|
| 1575 | + } |
|
| 1576 | + |
|
| 1577 | + /** |
|
| 1578 | + * Returns a SecureRandom instance |
|
| 1579 | + * |
|
| 1580 | + * @return \OCP\Security\ISecureRandom |
|
| 1581 | + */ |
|
| 1582 | + public function getSecureRandom() { |
|
| 1583 | + return $this->query('SecureRandom'); |
|
| 1584 | + } |
|
| 1585 | + |
|
| 1586 | + /** |
|
| 1587 | + * Returns a Crypto instance |
|
| 1588 | + * |
|
| 1589 | + * @return \OCP\Security\ICrypto |
|
| 1590 | + */ |
|
| 1591 | + public function getCrypto() { |
|
| 1592 | + return $this->query('Crypto'); |
|
| 1593 | + } |
|
| 1594 | + |
|
| 1595 | + /** |
|
| 1596 | + * Returns a Hasher instance |
|
| 1597 | + * |
|
| 1598 | + * @return \OCP\Security\IHasher |
|
| 1599 | + */ |
|
| 1600 | + public function getHasher() { |
|
| 1601 | + return $this->query('Hasher'); |
|
| 1602 | + } |
|
| 1603 | + |
|
| 1604 | + /** |
|
| 1605 | + * Returns a CredentialsManager instance |
|
| 1606 | + * |
|
| 1607 | + * @return \OCP\Security\ICredentialsManager |
|
| 1608 | + */ |
|
| 1609 | + public function getCredentialsManager() { |
|
| 1610 | + return $this->query('CredentialsManager'); |
|
| 1611 | + } |
|
| 1612 | + |
|
| 1613 | + /** |
|
| 1614 | + * Get the certificate manager for the user |
|
| 1615 | + * |
|
| 1616 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 1617 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
| 1618 | + */ |
|
| 1619 | + public function getCertificateManager($userId = '') { |
|
| 1620 | + if ($userId === '') { |
|
| 1621 | + $userSession = $this->getUserSession(); |
|
| 1622 | + $user = $userSession->getUser(); |
|
| 1623 | + if (is_null($user)) { |
|
| 1624 | + return null; |
|
| 1625 | + } |
|
| 1626 | + $userId = $user->getUID(); |
|
| 1627 | + } |
|
| 1628 | + return new CertificateManager( |
|
| 1629 | + $userId, |
|
| 1630 | + new View(), |
|
| 1631 | + $this->getConfig(), |
|
| 1632 | + $this->getLogger(), |
|
| 1633 | + $this->getSecureRandom() |
|
| 1634 | + ); |
|
| 1635 | + } |
|
| 1636 | + |
|
| 1637 | + /** |
|
| 1638 | + * Returns an instance of the HTTP client service |
|
| 1639 | + * |
|
| 1640 | + * @return \OCP\Http\Client\IClientService |
|
| 1641 | + */ |
|
| 1642 | + public function getHTTPClientService() { |
|
| 1643 | + return $this->query('HttpClientService'); |
|
| 1644 | + } |
|
| 1645 | + |
|
| 1646 | + /** |
|
| 1647 | + * Create a new event source |
|
| 1648 | + * |
|
| 1649 | + * @return \OCP\IEventSource |
|
| 1650 | + */ |
|
| 1651 | + public function createEventSource() { |
|
| 1652 | + return new \OC_EventSource(); |
|
| 1653 | + } |
|
| 1654 | + |
|
| 1655 | + /** |
|
| 1656 | + * Get the active event logger |
|
| 1657 | + * |
|
| 1658 | + * The returned logger only logs data when debug mode is enabled |
|
| 1659 | + * |
|
| 1660 | + * @return \OCP\Diagnostics\IEventLogger |
|
| 1661 | + */ |
|
| 1662 | + public function getEventLogger() { |
|
| 1663 | + return $this->query('EventLogger'); |
|
| 1664 | + } |
|
| 1665 | + |
|
| 1666 | + /** |
|
| 1667 | + * Get the active query logger |
|
| 1668 | + * |
|
| 1669 | + * The returned logger only logs data when debug mode is enabled |
|
| 1670 | + * |
|
| 1671 | + * @return \OCP\Diagnostics\IQueryLogger |
|
| 1672 | + */ |
|
| 1673 | + public function getQueryLogger() { |
|
| 1674 | + return $this->query('QueryLogger'); |
|
| 1675 | + } |
|
| 1676 | + |
|
| 1677 | + /** |
|
| 1678 | + * Get the manager for temporary files and folders |
|
| 1679 | + * |
|
| 1680 | + * @return \OCP\ITempManager |
|
| 1681 | + */ |
|
| 1682 | + public function getTempManager() { |
|
| 1683 | + return $this->query('TempManager'); |
|
| 1684 | + } |
|
| 1685 | + |
|
| 1686 | + /** |
|
| 1687 | + * Get the app manager |
|
| 1688 | + * |
|
| 1689 | + * @return \OCP\App\IAppManager |
|
| 1690 | + */ |
|
| 1691 | + public function getAppManager() { |
|
| 1692 | + return $this->query('AppManager'); |
|
| 1693 | + } |
|
| 1694 | + |
|
| 1695 | + /** |
|
| 1696 | + * Creates a new mailer |
|
| 1697 | + * |
|
| 1698 | + * @return \OCP\Mail\IMailer |
|
| 1699 | + */ |
|
| 1700 | + public function getMailer() { |
|
| 1701 | + return $this->query('Mailer'); |
|
| 1702 | + } |
|
| 1703 | + |
|
| 1704 | + /** |
|
| 1705 | + * Get the webroot |
|
| 1706 | + * |
|
| 1707 | + * @return string |
|
| 1708 | + */ |
|
| 1709 | + public function getWebRoot() { |
|
| 1710 | + return $this->webRoot; |
|
| 1711 | + } |
|
| 1712 | + |
|
| 1713 | + /** |
|
| 1714 | + * @return \OC\OCSClient |
|
| 1715 | + */ |
|
| 1716 | + public function getOcsClient() { |
|
| 1717 | + return $this->query('OcsClient'); |
|
| 1718 | + } |
|
| 1719 | + |
|
| 1720 | + /** |
|
| 1721 | + * @return \OCP\IDateTimeZone |
|
| 1722 | + */ |
|
| 1723 | + public function getDateTimeZone() { |
|
| 1724 | + return $this->query('DateTimeZone'); |
|
| 1725 | + } |
|
| 1726 | + |
|
| 1727 | + /** |
|
| 1728 | + * @return \OCP\IDateTimeFormatter |
|
| 1729 | + */ |
|
| 1730 | + public function getDateTimeFormatter() { |
|
| 1731 | + return $this->query('DateTimeFormatter'); |
|
| 1732 | + } |
|
| 1733 | + |
|
| 1734 | + /** |
|
| 1735 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
| 1736 | + */ |
|
| 1737 | + public function getMountProviderCollection() { |
|
| 1738 | + return $this->query('MountConfigManager'); |
|
| 1739 | + } |
|
| 1740 | + |
|
| 1741 | + /** |
|
| 1742 | + * Get the IniWrapper |
|
| 1743 | + * |
|
| 1744 | + * @return IniGetWrapper |
|
| 1745 | + */ |
|
| 1746 | + public function getIniWrapper() { |
|
| 1747 | + return $this->query('IniWrapper'); |
|
| 1748 | + } |
|
| 1749 | + |
|
| 1750 | + /** |
|
| 1751 | + * @return \OCP\Command\IBus |
|
| 1752 | + */ |
|
| 1753 | + public function getCommandBus() { |
|
| 1754 | + return $this->query('AsyncCommandBus'); |
|
| 1755 | + } |
|
| 1756 | + |
|
| 1757 | + /** |
|
| 1758 | + * Get the trusted domain helper |
|
| 1759 | + * |
|
| 1760 | + * @return TrustedDomainHelper |
|
| 1761 | + */ |
|
| 1762 | + public function getTrustedDomainHelper() { |
|
| 1763 | + return $this->query('TrustedDomainHelper'); |
|
| 1764 | + } |
|
| 1765 | + |
|
| 1766 | + /** |
|
| 1767 | + * Get the locking provider |
|
| 1768 | + * |
|
| 1769 | + * @return \OCP\Lock\ILockingProvider |
|
| 1770 | + * @since 8.1.0 |
|
| 1771 | + */ |
|
| 1772 | + public function getLockingProvider() { |
|
| 1773 | + return $this->query('LockingProvider'); |
|
| 1774 | + } |
|
| 1775 | + |
|
| 1776 | + /** |
|
| 1777 | + * @return \OCP\Files\Mount\IMountManager |
|
| 1778 | + **/ |
|
| 1779 | + function getMountManager() { |
|
| 1780 | + return $this->query('MountManager'); |
|
| 1781 | + } |
|
| 1782 | + |
|
| 1783 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
| 1784 | + function getUserMountCache() { |
|
| 1785 | + return $this->query('UserMountCache'); |
|
| 1786 | + } |
|
| 1787 | + |
|
| 1788 | + /** |
|
| 1789 | + * Get the MimeTypeDetector |
|
| 1790 | + * |
|
| 1791 | + * @return \OCP\Files\IMimeTypeDetector |
|
| 1792 | + */ |
|
| 1793 | + public function getMimeTypeDetector() { |
|
| 1794 | + return $this->query('MimeTypeDetector'); |
|
| 1795 | + } |
|
| 1796 | + |
|
| 1797 | + /** |
|
| 1798 | + * Get the MimeTypeLoader |
|
| 1799 | + * |
|
| 1800 | + * @return \OCP\Files\IMimeTypeLoader |
|
| 1801 | + */ |
|
| 1802 | + public function getMimeTypeLoader() { |
|
| 1803 | + return $this->query('MimeTypeLoader'); |
|
| 1804 | + } |
|
| 1805 | + |
|
| 1806 | + /** |
|
| 1807 | + * Get the manager of all the capabilities |
|
| 1808 | + * |
|
| 1809 | + * @return \OC\CapabilitiesManager |
|
| 1810 | + */ |
|
| 1811 | + public function getCapabilitiesManager() { |
|
| 1812 | + return $this->query('CapabilitiesManager'); |
|
| 1813 | + } |
|
| 1814 | + |
|
| 1815 | + /** |
|
| 1816 | + * Get the EventDispatcher |
|
| 1817 | + * |
|
| 1818 | + * @return EventDispatcherInterface |
|
| 1819 | + * @since 8.2.0 |
|
| 1820 | + */ |
|
| 1821 | + public function getEventDispatcher() { |
|
| 1822 | + return $this->query('EventDispatcher'); |
|
| 1823 | + } |
|
| 1824 | + |
|
| 1825 | + /** |
|
| 1826 | + * Get the Notification Manager |
|
| 1827 | + * |
|
| 1828 | + * @return \OCP\Notification\IManager |
|
| 1829 | + * @since 8.2.0 |
|
| 1830 | + */ |
|
| 1831 | + public function getNotificationManager() { |
|
| 1832 | + return $this->query('NotificationManager'); |
|
| 1833 | + } |
|
| 1834 | + |
|
| 1835 | + /** |
|
| 1836 | + * @return \OCP\Comments\ICommentsManager |
|
| 1837 | + */ |
|
| 1838 | + public function getCommentsManager() { |
|
| 1839 | + return $this->query('CommentsManager'); |
|
| 1840 | + } |
|
| 1841 | + |
|
| 1842 | + /** |
|
| 1843 | + * @return \OCA\Theming\ThemingDefaults |
|
| 1844 | + */ |
|
| 1845 | + public function getThemingDefaults() { |
|
| 1846 | + return $this->query('ThemingDefaults'); |
|
| 1847 | + } |
|
| 1848 | + |
|
| 1849 | + /** |
|
| 1850 | + * @return \OC\IntegrityCheck\Checker |
|
| 1851 | + */ |
|
| 1852 | + public function getIntegrityCodeChecker() { |
|
| 1853 | + return $this->query('IntegrityCodeChecker'); |
|
| 1854 | + } |
|
| 1855 | + |
|
| 1856 | + /** |
|
| 1857 | + * @return \OC\Session\CryptoWrapper |
|
| 1858 | + */ |
|
| 1859 | + public function getSessionCryptoWrapper() { |
|
| 1860 | + return $this->query('CryptoWrapper'); |
|
| 1861 | + } |
|
| 1862 | + |
|
| 1863 | + /** |
|
| 1864 | + * @return CsrfTokenManager |
|
| 1865 | + */ |
|
| 1866 | + public function getCsrfTokenManager() { |
|
| 1867 | + return $this->query('CsrfTokenManager'); |
|
| 1868 | + } |
|
| 1869 | + |
|
| 1870 | + /** |
|
| 1871 | + * @return Throttler |
|
| 1872 | + */ |
|
| 1873 | + public function getBruteForceThrottler() { |
|
| 1874 | + return $this->query('Throttler'); |
|
| 1875 | + } |
|
| 1876 | + |
|
| 1877 | + /** |
|
| 1878 | + * @return IContentSecurityPolicyManager |
|
| 1879 | + */ |
|
| 1880 | + public function getContentSecurityPolicyManager() { |
|
| 1881 | + return $this->query('ContentSecurityPolicyManager'); |
|
| 1882 | + } |
|
| 1883 | + |
|
| 1884 | + /** |
|
| 1885 | + * @return ContentSecurityPolicyNonceManager |
|
| 1886 | + */ |
|
| 1887 | + public function getContentSecurityPolicyNonceManager() { |
|
| 1888 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
| 1889 | + } |
|
| 1890 | + |
|
| 1891 | + /** |
|
| 1892 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 1893 | + * |
|
| 1894 | + * @return \OCA\Files_External\Service\BackendService |
|
| 1895 | + */ |
|
| 1896 | + public function getStoragesBackendService() { |
|
| 1897 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
| 1898 | + } |
|
| 1899 | + |
|
| 1900 | + /** |
|
| 1901 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 1902 | + * |
|
| 1903 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
| 1904 | + */ |
|
| 1905 | + public function getGlobalStoragesService() { |
|
| 1906 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
| 1907 | + } |
|
| 1908 | + |
|
| 1909 | + /** |
|
| 1910 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 1911 | + * |
|
| 1912 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
| 1913 | + */ |
|
| 1914 | + public function getUserGlobalStoragesService() { |
|
| 1915 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
| 1916 | + } |
|
| 1917 | + |
|
| 1918 | + /** |
|
| 1919 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 1920 | + * |
|
| 1921 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
| 1922 | + */ |
|
| 1923 | + public function getUserStoragesService() { |
|
| 1924 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
| 1925 | + } |
|
| 1926 | + |
|
| 1927 | + /** |
|
| 1928 | + * @return \OCP\Share\IManager |
|
| 1929 | + */ |
|
| 1930 | + public function getShareManager() { |
|
| 1931 | + return $this->query('ShareManager'); |
|
| 1932 | + } |
|
| 1933 | + |
|
| 1934 | + /** |
|
| 1935 | + * @return \OCP\Collaboration\Collaborators\ISearch |
|
| 1936 | + */ |
|
| 1937 | + public function getCollaboratorSearch() { |
|
| 1938 | + return $this->query('CollaboratorSearch'); |
|
| 1939 | + } |
|
| 1940 | + |
|
| 1941 | + /** |
|
| 1942 | + * @return \OCP\Collaboration\AutoComplete\IManager |
|
| 1943 | + */ |
|
| 1944 | + public function getAutoCompleteManager(){ |
|
| 1945 | + return $this->query(IManager::class); |
|
| 1946 | + } |
|
| 1947 | + |
|
| 1948 | + /** |
|
| 1949 | + * Returns the LDAP Provider |
|
| 1950 | + * |
|
| 1951 | + * @return \OCP\LDAP\ILDAPProvider |
|
| 1952 | + */ |
|
| 1953 | + public function getLDAPProvider() { |
|
| 1954 | + return $this->query('LDAPProvider'); |
|
| 1955 | + } |
|
| 1956 | + |
|
| 1957 | + /** |
|
| 1958 | + * @return \OCP\Settings\IManager |
|
| 1959 | + */ |
|
| 1960 | + public function getSettingsManager() { |
|
| 1961 | + return $this->query('SettingsManager'); |
|
| 1962 | + } |
|
| 1963 | + |
|
| 1964 | + /** |
|
| 1965 | + * @return \OCP\Files\IAppData |
|
| 1966 | + */ |
|
| 1967 | + public function getAppDataDir($app) { |
|
| 1968 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
| 1969 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
| 1970 | + return $factory->get($app); |
|
| 1971 | + } |
|
| 1972 | + |
|
| 1973 | + /** |
|
| 1974 | + * @return \OCP\Lockdown\ILockdownManager |
|
| 1975 | + */ |
|
| 1976 | + public function getLockdownManager() { |
|
| 1977 | + return $this->query('LockdownManager'); |
|
| 1978 | + } |
|
| 1979 | + |
|
| 1980 | + /** |
|
| 1981 | + * @return \OCP\Federation\ICloudIdManager |
|
| 1982 | + */ |
|
| 1983 | + public function getCloudIdManager() { |
|
| 1984 | + return $this->query(ICloudIdManager::class); |
|
| 1985 | + } |
|
| 1986 | + |
|
| 1987 | + /** |
|
| 1988 | + * @return \OCP\Remote\Api\IApiFactory |
|
| 1989 | + */ |
|
| 1990 | + public function getRemoteApiFactory() { |
|
| 1991 | + return $this->query(IApiFactory::class); |
|
| 1992 | + } |
|
| 1993 | + |
|
| 1994 | + /** |
|
| 1995 | + * @return \OCP\Remote\IInstanceFactory |
|
| 1996 | + */ |
|
| 1997 | + public function getRemoteInstanceFactory() { |
|
| 1998 | + return $this->query(IInstanceFactory::class); |
|
| 1999 | + } |
|
| 2000 | 2000 | } |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | $cachedResourceIds = $this->getCachedResourceIds($cachedResources); |
| 99 | 99 | |
| 100 | 100 | $remoteResourceIds = []; |
| 101 | - foreach($resourceBackends as $resourceBackend) { |
|
| 101 | + foreach ($resourceBackends as $resourceBackend) { |
|
| 102 | 102 | try { |
| 103 | 103 | $remoteResourceIds[$resourceBackend->getBackendIdentifier()] = |
| 104 | 104 | $resourceBackend->listAllResources(); |
| 105 | - } catch(BackendTemporarilyUnavailableException $ex) { |
|
| 105 | + } catch (BackendTemporarilyUnavailableException $ex) { |
|
| 106 | 106 | // If the backend is temporarily unavailable |
| 107 | 107 | // ignore this backend in this execution |
| 108 | 108 | unset($cachedResourceIds[$resourceBackend->getBackendIdentifier()]); |
@@ -111,20 +111,20 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | $sortedResources = $this->sortByNewDeletedExisting($cachedResourceIds, $remoteResourceIds); |
| 113 | 113 | |
| 114 | - foreach($sortedResources['new'] as $backendId => $newResources) { |
|
| 114 | + foreach ($sortedResources['new'] as $backendId => $newResources) { |
|
| 115 | 115 | foreach ($newResources as $newResource) { |
| 116 | 116 | $resource = $this->resourceManager->getBackend($backendId) |
| 117 | 117 | ->getResource($newResource); |
| 118 | 118 | $this->addToCache($this->resourceDbTable, $resource); |
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | - foreach($sortedResources['deleted'] as $backendId => $deletedResources) { |
|
| 121 | + foreach ($sortedResources['deleted'] as $backendId => $deletedResources) { |
|
| 122 | 122 | foreach ($deletedResources as $deletedResource) { |
| 123 | 123 | $this->deleteFromCache($this->resourceDbTable, |
| 124 | 124 | $this->resourcePrincipalUri, $backendId, $deletedResource); |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | - foreach($sortedResources['edited'] as $backendId => $editedResources) { |
|
| 127 | + foreach ($sortedResources['edited'] as $backendId => $editedResources) { |
|
| 128 | 128 | foreach ($editedResources as $editedResource) { |
| 129 | 129 | $resource = $this->resourceManager->getBackend($backendId) |
| 130 | 130 | ->getResource($editedResource); |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | $cachedRoomIds = $this->getCachedRoomIds($cachedRooms); |
| 143 | 143 | |
| 144 | 144 | $remoteRoomIds = []; |
| 145 | - foreach($roomBackends as $roomBackend) { |
|
| 145 | + foreach ($roomBackends as $roomBackend) { |
|
| 146 | 146 | try { |
| 147 | 147 | $remoteRoomIds[$roomBackend->getBackendIdentifier()] = |
| 148 | 148 | $roomBackend->listAllRooms(); |
| 149 | - } catch(BackendTemporarilyUnavailableException $ex) { |
|
| 149 | + } catch (BackendTemporarilyUnavailableException $ex) { |
|
| 150 | 150 | // If the backend is temporarily unavailable |
| 151 | 151 | // ignore this backend in this execution |
| 152 | 152 | unset($cachedRoomIds[$roomBackend->getBackendIdentifier()]); |
@@ -155,20 +155,20 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | $sortedRooms = $this->sortByNewDeletedExisting($cachedRoomIds, $remoteRoomIds); |
| 157 | 157 | |
| 158 | - foreach($sortedRooms['new'] as $backendId => $newRooms) { |
|
| 158 | + foreach ($sortedRooms['new'] as $backendId => $newRooms) { |
|
| 159 | 159 | foreach ($newRooms as $newRoom) { |
| 160 | 160 | $resource = $this->roomManager->getBackend($backendId) |
| 161 | 161 | ->getRoom($newRoom); |
| 162 | 162 | $this->addToCache($this->roomDbTable, $resource); |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | - foreach($sortedRooms['deleted'] as $backendId => $deletedRooms) { |
|
| 165 | + foreach ($sortedRooms['deleted'] as $backendId => $deletedRooms) { |
|
| 166 | 166 | foreach ($deletedRooms as $deletedRoom) { |
| 167 | 167 | $this->deleteFromCache($this->roomDbTable, |
| 168 | 168 | $this->roomPrincipalUri, $backendId, $deletedRoom); |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | - foreach($sortedRooms['edited'] as $backendId => $editedRooms) { |
|
| 171 | + foreach ($sortedRooms['edited'] as $backendId => $editedRooms) { |
|
| 172 | 172 | foreach ($editedRooms as $editedRoom) { |
| 173 | 173 | $resource = $this->roomManager->getBackend($backendId) |
| 174 | 174 | ->getRoom($editedRoom); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | $rows = []; |
| 190 | 190 | $stmt = $query->execute(); |
| 191 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 191 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 192 | 192 | $rows[] = $row; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | ]; |
| 248 | 248 | |
| 249 | 249 | $backendIds = array_merge(array_keys($cached), array_keys($remote)); |
| 250 | - foreach($backendIds as $backendId) { |
|
| 250 | + foreach ($backendIds as $backendId) { |
|
| 251 | 251 | if (!isset($cached[$backendId])) { |
| 252 | 252 | $sorted['new'][$backendId] = $remote[$backendId]; |
| 253 | 253 | } elseif (!isset($remote[$backendId])) { |
@@ -34,304 +34,304 @@ |
||
| 34 | 34 | |
| 35 | 35 | class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob { |
| 36 | 36 | |
| 37 | - /** @var IResourceManager */ |
|
| 38 | - private $resourceManager; |
|
| 39 | - |
|
| 40 | - /** @var IRoomManager */ |
|
| 41 | - private $roomManager; |
|
| 42 | - |
|
| 43 | - /** @var IDBConnection */ |
|
| 44 | - private $db; |
|
| 45 | - |
|
| 46 | - /** @var CalDavBackend */ |
|
| 47 | - private $calDavBackend; |
|
| 48 | - |
|
| 49 | - /** @var string */ |
|
| 50 | - private $resourceDbTable; |
|
| 51 | - |
|
| 52 | - /** @var string */ |
|
| 53 | - private $resourcePrincipalUri; |
|
| 54 | - |
|
| 55 | - /** @var string */ |
|
| 56 | - private $roomDbTable; |
|
| 57 | - |
|
| 58 | - /** @var string */ |
|
| 59 | - private $roomPrincipalUri; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * UpdateCalendarResourcesRoomsBackgroundJob constructor. |
|
| 63 | - * |
|
| 64 | - * @param IResourceManager $resourceManager |
|
| 65 | - * @param IRoomManager $roomManager |
|
| 66 | - * @param IDBConnection $dbConnection |
|
| 67 | - * @param CalDavBackend $calDavBackend |
|
| 68 | - */ |
|
| 69 | - public function __construct(IResourceManager $resourceManager, IRoomManager $roomManager, |
|
| 70 | - IDBConnection $dbConnection, CalDavBackend $calDavBackend) { |
|
| 71 | - $this->resourceManager = $resourceManager; |
|
| 72 | - $this->roomManager = $roomManager; |
|
| 73 | - $this->db = $dbConnection; |
|
| 74 | - $this->calDavBackend = $calDavBackend; |
|
| 75 | - $this->resourceDbTable = 'calendar_resources_cache'; |
|
| 76 | - $this->resourcePrincipalUri = 'principals/calendar-resources'; |
|
| 77 | - $this->roomDbTable = 'calendar_rooms_cache'; |
|
| 78 | - $this->roomPrincipalUri = 'principals/calendar-rooms'; |
|
| 79 | - |
|
| 80 | - // run once an hour |
|
| 81 | - $this->setInterval(60 * 60); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @param $argument |
|
| 86 | - */ |
|
| 87 | - public function run($argument) { |
|
| 88 | - $this->runResources(); |
|
| 89 | - $this->runRooms(); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * run timed job for resources |
|
| 94 | - */ |
|
| 95 | - private function runResources() { |
|
| 96 | - $resourceBackends = $this->resourceManager->getBackends(); |
|
| 97 | - $cachedResources = $this->getCached($this->resourceDbTable); |
|
| 98 | - $cachedResourceIds = $this->getCachedResourceIds($cachedResources); |
|
| 99 | - |
|
| 100 | - $remoteResourceIds = []; |
|
| 101 | - foreach($resourceBackends as $resourceBackend) { |
|
| 102 | - try { |
|
| 103 | - $remoteResourceIds[$resourceBackend->getBackendIdentifier()] = |
|
| 104 | - $resourceBackend->listAllResources(); |
|
| 105 | - } catch(BackendTemporarilyUnavailableException $ex) { |
|
| 106 | - // If the backend is temporarily unavailable |
|
| 107 | - // ignore this backend in this execution |
|
| 108 | - unset($cachedResourceIds[$resourceBackend->getBackendIdentifier()]); |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $sortedResources = $this->sortByNewDeletedExisting($cachedResourceIds, $remoteResourceIds); |
|
| 113 | - |
|
| 114 | - foreach($sortedResources['new'] as $backendId => $newResources) { |
|
| 115 | - foreach ($newResources as $newResource) { |
|
| 116 | - $resource = $this->resourceManager->getBackend($backendId) |
|
| 117 | - ->getResource($newResource); |
|
| 118 | - $this->addToCache($this->resourceDbTable, $resource); |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - foreach($sortedResources['deleted'] as $backendId => $deletedResources) { |
|
| 122 | - foreach ($deletedResources as $deletedResource) { |
|
| 123 | - $this->deleteFromCache($this->resourceDbTable, |
|
| 124 | - $this->resourcePrincipalUri, $backendId, $deletedResource); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - foreach($sortedResources['edited'] as $backendId => $editedResources) { |
|
| 128 | - foreach ($editedResources as $editedResource) { |
|
| 129 | - $resource = $this->resourceManager->getBackend($backendId) |
|
| 130 | - ->getResource($editedResource); |
|
| 131 | - $this->updateCache($this->resourceDbTable, $resource); |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * run timed job for rooms |
|
| 138 | - */ |
|
| 139 | - private function runRooms() { |
|
| 140 | - $roomBackends = $this->roomManager->getBackends(); |
|
| 141 | - $cachedRooms = $this->getCached($this->roomDbTable); |
|
| 142 | - $cachedRoomIds = $this->getCachedRoomIds($cachedRooms); |
|
| 143 | - |
|
| 144 | - $remoteRoomIds = []; |
|
| 145 | - foreach($roomBackends as $roomBackend) { |
|
| 146 | - try { |
|
| 147 | - $remoteRoomIds[$roomBackend->getBackendIdentifier()] = |
|
| 148 | - $roomBackend->listAllRooms(); |
|
| 149 | - } catch(BackendTemporarilyUnavailableException $ex) { |
|
| 150 | - // If the backend is temporarily unavailable |
|
| 151 | - // ignore this backend in this execution |
|
| 152 | - unset($cachedRoomIds[$roomBackend->getBackendIdentifier()]); |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - $sortedRooms = $this->sortByNewDeletedExisting($cachedRoomIds, $remoteRoomIds); |
|
| 157 | - |
|
| 158 | - foreach($sortedRooms['new'] as $backendId => $newRooms) { |
|
| 159 | - foreach ($newRooms as $newRoom) { |
|
| 160 | - $resource = $this->roomManager->getBackend($backendId) |
|
| 161 | - ->getRoom($newRoom); |
|
| 162 | - $this->addToCache($this->roomDbTable, $resource); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - foreach($sortedRooms['deleted'] as $backendId => $deletedRooms) { |
|
| 166 | - foreach ($deletedRooms as $deletedRoom) { |
|
| 167 | - $this->deleteFromCache($this->roomDbTable, |
|
| 168 | - $this->roomPrincipalUri, $backendId, $deletedRoom); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - foreach($sortedRooms['edited'] as $backendId => $editedRooms) { |
|
| 172 | - foreach ($editedRooms as $editedRoom) { |
|
| 173 | - $resource = $this->roomManager->getBackend($backendId) |
|
| 174 | - ->getRoom($editedRoom); |
|
| 175 | - $this->updateCache($this->roomDbTable, $resource); |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * get cached db rows for resources / rooms |
|
| 182 | - * @param string $tableName |
|
| 183 | - * @return array |
|
| 184 | - */ |
|
| 185 | - private function getCached($tableName):array { |
|
| 186 | - $query = $this->db->getQueryBuilder(); |
|
| 187 | - $query->select('*')->from($tableName); |
|
| 188 | - |
|
| 189 | - $rows = []; |
|
| 190 | - $stmt = $query->execute(); |
|
| 191 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 192 | - $rows[] = $row; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - return $rows; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * @param array $cachedResources |
|
| 200 | - * @return array |
|
| 201 | - */ |
|
| 202 | - private function getCachedResourceIds(array $cachedResources):array { |
|
| 203 | - $cachedResourceIds = []; |
|
| 204 | - foreach ($cachedResources as $cachedResource) { |
|
| 205 | - if (!isset($cachedResourceIds[$cachedResource['backend_id']])) { |
|
| 206 | - $cachedResourceIds[$cachedResource['backend_id']] = []; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - $cachedResourceIds[$cachedResource['backend_id']][] = |
|
| 210 | - $cachedResource['resource_id']; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - return $cachedResourceIds; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * @param array $cachedRooms |
|
| 218 | - * @return array |
|
| 219 | - */ |
|
| 220 | - private function getCachedRoomIds(array $cachedRooms):array { |
|
| 221 | - $cachedRoomIds = []; |
|
| 222 | - foreach ($cachedRooms as $cachedRoom) { |
|
| 223 | - if (!isset($cachedRoomIds[$cachedRoom['backend_id']])) { |
|
| 224 | - $cachedRoomIds[$cachedRoom['backend_id']] = []; |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - $cachedRoomIds[$cachedRoom['backend_id']][] = |
|
| 228 | - $cachedRoom['resource_id']; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - return $cachedRoomIds; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * sort list of ids by whether they appear only in the backend / |
|
| 236 | - * only in the cache / in both |
|
| 237 | - * |
|
| 238 | - * @param array $cached |
|
| 239 | - * @param array $remote |
|
| 240 | - * @return array |
|
| 241 | - */ |
|
| 242 | - private function sortByNewDeletedExisting(array $cached, array $remote):array { |
|
| 243 | - $sorted = [ |
|
| 244 | - 'new' => [], |
|
| 245 | - 'deleted' => [], |
|
| 246 | - 'edited' => [], |
|
| 247 | - ]; |
|
| 248 | - |
|
| 249 | - $backendIds = array_merge(array_keys($cached), array_keys($remote)); |
|
| 250 | - foreach($backendIds as $backendId) { |
|
| 251 | - if (!isset($cached[$backendId])) { |
|
| 252 | - $sorted['new'][$backendId] = $remote[$backendId]; |
|
| 253 | - } elseif (!isset($remote[$backendId])) { |
|
| 254 | - $sorted['deleted'][$backendId] = $cached[$backendId]; |
|
| 255 | - } else { |
|
| 256 | - $sorted['new'][$backendId] = array_diff($remote[$backendId], $cached[$backendId]); |
|
| 257 | - $sorted['deleted'][$backendId] = array_diff($cached[$backendId], $remote[$backendId]); |
|
| 258 | - $sorted['edited'][$backendId] = array_intersect($remote[$backendId], $cached[$backendId]); |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - return $sorted; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * add entry to cache that exists remotely but not yet in cache |
|
| 267 | - * |
|
| 268 | - * @param string $table |
|
| 269 | - * @param IResource|IRoom $remote |
|
| 270 | - */ |
|
| 271 | - private function addToCache($table, $remote) { |
|
| 272 | - $query = $this->db->getQueryBuilder(); |
|
| 273 | - $query->insert($table) |
|
| 274 | - ->values([ |
|
| 275 | - 'backend_id' => $query->createNamedParameter($remote->getBackend()->getBackendIdentifier()), |
|
| 276 | - 'resource_id' => $query->createNamedParameter($remote->getId()), |
|
| 277 | - 'email' => $query->createNamedParameter($remote->getEMail()), |
|
| 278 | - 'displayname' => $query->createNamedParameter($remote->getDisplayName()), |
|
| 279 | - 'group_restrictions' => $query->createNamedParameter( |
|
| 280 | - $this->serializeGroupRestrictions( |
|
| 281 | - $remote->getGroupRestrictions() |
|
| 282 | - )) |
|
| 283 | - ]) |
|
| 284 | - ->execute(); |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * delete entry from cache that does not exist anymore remotely |
|
| 289 | - * |
|
| 290 | - * @param string $table |
|
| 291 | - * @param string $principalUri |
|
| 292 | - * @param string $backendId |
|
| 293 | - * @param string $resourceId |
|
| 294 | - */ |
|
| 295 | - private function deleteFromCache($table, $principalUri, $backendId, $resourceId) { |
|
| 296 | - $query = $this->db->getQueryBuilder(); |
|
| 297 | - $query->delete($table) |
|
| 298 | - ->where($query->expr()->eq('backend_id', $query->createNamedParameter($backendId))) |
|
| 299 | - ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resourceId))) |
|
| 300 | - ->execute(); |
|
| 301 | - |
|
| 302 | - $calendar = $this->calDavBackend->getCalendarByUri($principalUri, implode('-', [$backendId, $resourceId])); |
|
| 303 | - if ($calendar !== null) { |
|
| 304 | - $this->calDavBackend->deleteCalendar($calendar['id']); |
|
| 305 | - } |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * update an existing entry in cache |
|
| 310 | - * |
|
| 311 | - * @param string $table |
|
| 312 | - * @param IResource|IRoom $remote |
|
| 313 | - */ |
|
| 314 | - private function updateCache($table, $remote) { |
|
| 315 | - $query = $this->db->getQueryBuilder(); |
|
| 316 | - $query->update($table) |
|
| 317 | - ->set('email', $query->createNamedParameter($remote->getEMail())) |
|
| 318 | - ->set('displayname', $query->createNamedParameter($remote->getDisplayName())) |
|
| 319 | - ->set('group_restrictions', $query->createNamedParameter( |
|
| 320 | - $this->serializeGroupRestrictions( |
|
| 321 | - $remote->getGroupRestrictions() |
|
| 322 | - ))) |
|
| 323 | - ->where($query->expr()->eq('backend_id', $query->createNamedParameter($remote->getBackend()->getBackendIdentifier()))) |
|
| 324 | - ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($remote->getId()))) |
|
| 325 | - ->execute(); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * serialize array of group restrictions to store them in database |
|
| 330 | - * |
|
| 331 | - * @param array $groups |
|
| 332 | - * @return string |
|
| 333 | - */ |
|
| 334 | - private function serializeGroupRestrictions(array $groups):string { |
|
| 335 | - return \json_encode($groups); |
|
| 336 | - } |
|
| 37 | + /** @var IResourceManager */ |
|
| 38 | + private $resourceManager; |
|
| 39 | + |
|
| 40 | + /** @var IRoomManager */ |
|
| 41 | + private $roomManager; |
|
| 42 | + |
|
| 43 | + /** @var IDBConnection */ |
|
| 44 | + private $db; |
|
| 45 | + |
|
| 46 | + /** @var CalDavBackend */ |
|
| 47 | + private $calDavBackend; |
|
| 48 | + |
|
| 49 | + /** @var string */ |
|
| 50 | + private $resourceDbTable; |
|
| 51 | + |
|
| 52 | + /** @var string */ |
|
| 53 | + private $resourcePrincipalUri; |
|
| 54 | + |
|
| 55 | + /** @var string */ |
|
| 56 | + private $roomDbTable; |
|
| 57 | + |
|
| 58 | + /** @var string */ |
|
| 59 | + private $roomPrincipalUri; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * UpdateCalendarResourcesRoomsBackgroundJob constructor. |
|
| 63 | + * |
|
| 64 | + * @param IResourceManager $resourceManager |
|
| 65 | + * @param IRoomManager $roomManager |
|
| 66 | + * @param IDBConnection $dbConnection |
|
| 67 | + * @param CalDavBackend $calDavBackend |
|
| 68 | + */ |
|
| 69 | + public function __construct(IResourceManager $resourceManager, IRoomManager $roomManager, |
|
| 70 | + IDBConnection $dbConnection, CalDavBackend $calDavBackend) { |
|
| 71 | + $this->resourceManager = $resourceManager; |
|
| 72 | + $this->roomManager = $roomManager; |
|
| 73 | + $this->db = $dbConnection; |
|
| 74 | + $this->calDavBackend = $calDavBackend; |
|
| 75 | + $this->resourceDbTable = 'calendar_resources_cache'; |
|
| 76 | + $this->resourcePrincipalUri = 'principals/calendar-resources'; |
|
| 77 | + $this->roomDbTable = 'calendar_rooms_cache'; |
|
| 78 | + $this->roomPrincipalUri = 'principals/calendar-rooms'; |
|
| 79 | + |
|
| 80 | + // run once an hour |
|
| 81 | + $this->setInterval(60 * 60); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @param $argument |
|
| 86 | + */ |
|
| 87 | + public function run($argument) { |
|
| 88 | + $this->runResources(); |
|
| 89 | + $this->runRooms(); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * run timed job for resources |
|
| 94 | + */ |
|
| 95 | + private function runResources() { |
|
| 96 | + $resourceBackends = $this->resourceManager->getBackends(); |
|
| 97 | + $cachedResources = $this->getCached($this->resourceDbTable); |
|
| 98 | + $cachedResourceIds = $this->getCachedResourceIds($cachedResources); |
|
| 99 | + |
|
| 100 | + $remoteResourceIds = []; |
|
| 101 | + foreach($resourceBackends as $resourceBackend) { |
|
| 102 | + try { |
|
| 103 | + $remoteResourceIds[$resourceBackend->getBackendIdentifier()] = |
|
| 104 | + $resourceBackend->listAllResources(); |
|
| 105 | + } catch(BackendTemporarilyUnavailableException $ex) { |
|
| 106 | + // If the backend is temporarily unavailable |
|
| 107 | + // ignore this backend in this execution |
|
| 108 | + unset($cachedResourceIds[$resourceBackend->getBackendIdentifier()]); |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $sortedResources = $this->sortByNewDeletedExisting($cachedResourceIds, $remoteResourceIds); |
|
| 113 | + |
|
| 114 | + foreach($sortedResources['new'] as $backendId => $newResources) { |
|
| 115 | + foreach ($newResources as $newResource) { |
|
| 116 | + $resource = $this->resourceManager->getBackend($backendId) |
|
| 117 | + ->getResource($newResource); |
|
| 118 | + $this->addToCache($this->resourceDbTable, $resource); |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + foreach($sortedResources['deleted'] as $backendId => $deletedResources) { |
|
| 122 | + foreach ($deletedResources as $deletedResource) { |
|
| 123 | + $this->deleteFromCache($this->resourceDbTable, |
|
| 124 | + $this->resourcePrincipalUri, $backendId, $deletedResource); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + foreach($sortedResources['edited'] as $backendId => $editedResources) { |
|
| 128 | + foreach ($editedResources as $editedResource) { |
|
| 129 | + $resource = $this->resourceManager->getBackend($backendId) |
|
| 130 | + ->getResource($editedResource); |
|
| 131 | + $this->updateCache($this->resourceDbTable, $resource); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * run timed job for rooms |
|
| 138 | + */ |
|
| 139 | + private function runRooms() { |
|
| 140 | + $roomBackends = $this->roomManager->getBackends(); |
|
| 141 | + $cachedRooms = $this->getCached($this->roomDbTable); |
|
| 142 | + $cachedRoomIds = $this->getCachedRoomIds($cachedRooms); |
|
| 143 | + |
|
| 144 | + $remoteRoomIds = []; |
|
| 145 | + foreach($roomBackends as $roomBackend) { |
|
| 146 | + try { |
|
| 147 | + $remoteRoomIds[$roomBackend->getBackendIdentifier()] = |
|
| 148 | + $roomBackend->listAllRooms(); |
|
| 149 | + } catch(BackendTemporarilyUnavailableException $ex) { |
|
| 150 | + // If the backend is temporarily unavailable |
|
| 151 | + // ignore this backend in this execution |
|
| 152 | + unset($cachedRoomIds[$roomBackend->getBackendIdentifier()]); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + $sortedRooms = $this->sortByNewDeletedExisting($cachedRoomIds, $remoteRoomIds); |
|
| 157 | + |
|
| 158 | + foreach($sortedRooms['new'] as $backendId => $newRooms) { |
|
| 159 | + foreach ($newRooms as $newRoom) { |
|
| 160 | + $resource = $this->roomManager->getBackend($backendId) |
|
| 161 | + ->getRoom($newRoom); |
|
| 162 | + $this->addToCache($this->roomDbTable, $resource); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + foreach($sortedRooms['deleted'] as $backendId => $deletedRooms) { |
|
| 166 | + foreach ($deletedRooms as $deletedRoom) { |
|
| 167 | + $this->deleteFromCache($this->roomDbTable, |
|
| 168 | + $this->roomPrincipalUri, $backendId, $deletedRoom); |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + foreach($sortedRooms['edited'] as $backendId => $editedRooms) { |
|
| 172 | + foreach ($editedRooms as $editedRoom) { |
|
| 173 | + $resource = $this->roomManager->getBackend($backendId) |
|
| 174 | + ->getRoom($editedRoom); |
|
| 175 | + $this->updateCache($this->roomDbTable, $resource); |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * get cached db rows for resources / rooms |
|
| 182 | + * @param string $tableName |
|
| 183 | + * @return array |
|
| 184 | + */ |
|
| 185 | + private function getCached($tableName):array { |
|
| 186 | + $query = $this->db->getQueryBuilder(); |
|
| 187 | + $query->select('*')->from($tableName); |
|
| 188 | + |
|
| 189 | + $rows = []; |
|
| 190 | + $stmt = $query->execute(); |
|
| 191 | + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 192 | + $rows[] = $row; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + return $rows; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * @param array $cachedResources |
|
| 200 | + * @return array |
|
| 201 | + */ |
|
| 202 | + private function getCachedResourceIds(array $cachedResources):array { |
|
| 203 | + $cachedResourceIds = []; |
|
| 204 | + foreach ($cachedResources as $cachedResource) { |
|
| 205 | + if (!isset($cachedResourceIds[$cachedResource['backend_id']])) { |
|
| 206 | + $cachedResourceIds[$cachedResource['backend_id']] = []; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + $cachedResourceIds[$cachedResource['backend_id']][] = |
|
| 210 | + $cachedResource['resource_id']; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + return $cachedResourceIds; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * @param array $cachedRooms |
|
| 218 | + * @return array |
|
| 219 | + */ |
|
| 220 | + private function getCachedRoomIds(array $cachedRooms):array { |
|
| 221 | + $cachedRoomIds = []; |
|
| 222 | + foreach ($cachedRooms as $cachedRoom) { |
|
| 223 | + if (!isset($cachedRoomIds[$cachedRoom['backend_id']])) { |
|
| 224 | + $cachedRoomIds[$cachedRoom['backend_id']] = []; |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $cachedRoomIds[$cachedRoom['backend_id']][] = |
|
| 228 | + $cachedRoom['resource_id']; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + return $cachedRoomIds; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * sort list of ids by whether they appear only in the backend / |
|
| 236 | + * only in the cache / in both |
|
| 237 | + * |
|
| 238 | + * @param array $cached |
|
| 239 | + * @param array $remote |
|
| 240 | + * @return array |
|
| 241 | + */ |
|
| 242 | + private function sortByNewDeletedExisting(array $cached, array $remote):array { |
|
| 243 | + $sorted = [ |
|
| 244 | + 'new' => [], |
|
| 245 | + 'deleted' => [], |
|
| 246 | + 'edited' => [], |
|
| 247 | + ]; |
|
| 248 | + |
|
| 249 | + $backendIds = array_merge(array_keys($cached), array_keys($remote)); |
|
| 250 | + foreach($backendIds as $backendId) { |
|
| 251 | + if (!isset($cached[$backendId])) { |
|
| 252 | + $sorted['new'][$backendId] = $remote[$backendId]; |
|
| 253 | + } elseif (!isset($remote[$backendId])) { |
|
| 254 | + $sorted['deleted'][$backendId] = $cached[$backendId]; |
|
| 255 | + } else { |
|
| 256 | + $sorted['new'][$backendId] = array_diff($remote[$backendId], $cached[$backendId]); |
|
| 257 | + $sorted['deleted'][$backendId] = array_diff($cached[$backendId], $remote[$backendId]); |
|
| 258 | + $sorted['edited'][$backendId] = array_intersect($remote[$backendId], $cached[$backendId]); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + return $sorted; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * add entry to cache that exists remotely but not yet in cache |
|
| 267 | + * |
|
| 268 | + * @param string $table |
|
| 269 | + * @param IResource|IRoom $remote |
|
| 270 | + */ |
|
| 271 | + private function addToCache($table, $remote) { |
|
| 272 | + $query = $this->db->getQueryBuilder(); |
|
| 273 | + $query->insert($table) |
|
| 274 | + ->values([ |
|
| 275 | + 'backend_id' => $query->createNamedParameter($remote->getBackend()->getBackendIdentifier()), |
|
| 276 | + 'resource_id' => $query->createNamedParameter($remote->getId()), |
|
| 277 | + 'email' => $query->createNamedParameter($remote->getEMail()), |
|
| 278 | + 'displayname' => $query->createNamedParameter($remote->getDisplayName()), |
|
| 279 | + 'group_restrictions' => $query->createNamedParameter( |
|
| 280 | + $this->serializeGroupRestrictions( |
|
| 281 | + $remote->getGroupRestrictions() |
|
| 282 | + )) |
|
| 283 | + ]) |
|
| 284 | + ->execute(); |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * delete entry from cache that does not exist anymore remotely |
|
| 289 | + * |
|
| 290 | + * @param string $table |
|
| 291 | + * @param string $principalUri |
|
| 292 | + * @param string $backendId |
|
| 293 | + * @param string $resourceId |
|
| 294 | + */ |
|
| 295 | + private function deleteFromCache($table, $principalUri, $backendId, $resourceId) { |
|
| 296 | + $query = $this->db->getQueryBuilder(); |
|
| 297 | + $query->delete($table) |
|
| 298 | + ->where($query->expr()->eq('backend_id', $query->createNamedParameter($backendId))) |
|
| 299 | + ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resourceId))) |
|
| 300 | + ->execute(); |
|
| 301 | + |
|
| 302 | + $calendar = $this->calDavBackend->getCalendarByUri($principalUri, implode('-', [$backendId, $resourceId])); |
|
| 303 | + if ($calendar !== null) { |
|
| 304 | + $this->calDavBackend->deleteCalendar($calendar['id']); |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * update an existing entry in cache |
|
| 310 | + * |
|
| 311 | + * @param string $table |
|
| 312 | + * @param IResource|IRoom $remote |
|
| 313 | + */ |
|
| 314 | + private function updateCache($table, $remote) { |
|
| 315 | + $query = $this->db->getQueryBuilder(); |
|
| 316 | + $query->update($table) |
|
| 317 | + ->set('email', $query->createNamedParameter($remote->getEMail())) |
|
| 318 | + ->set('displayname', $query->createNamedParameter($remote->getDisplayName())) |
|
| 319 | + ->set('group_restrictions', $query->createNamedParameter( |
|
| 320 | + $this->serializeGroupRestrictions( |
|
| 321 | + $remote->getGroupRestrictions() |
|
| 322 | + ))) |
|
| 323 | + ->where($query->expr()->eq('backend_id', $query->createNamedParameter($remote->getBackend()->getBackendIdentifier()))) |
|
| 324 | + ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($remote->getId()))) |
|
| 325 | + ->execute(); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * serialize array of group restrictions to store them in database |
|
| 330 | + * |
|
| 331 | + * @param array $groups |
|
| 332 | + * @return string |
|
| 333 | + */ |
|
| 334 | + private function serializeGroupRestrictions(array $groups):string { |
|
| 335 | + return \json_encode($groups); |
|
| 336 | + } |
|
| 337 | 337 | } |