@@ -29,16 +29,16 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | interface ICalendarHomePlugin { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Returns the path to a principal's calendar home. |
|
| 34 | - * |
|
| 35 | - * The return url must not end with a slash. |
|
| 36 | - * This function should return null in case a principal did not have |
|
| 37 | - * a calendar home. |
|
| 38 | - * |
|
| 39 | - * @param string $principalUrl |
|
| 40 | - * @return string|null |
|
| 41 | - */ |
|
| 42 | - public function getCalendarHomeForPrincipal($principalUrl); |
|
| 32 | + /** |
|
| 33 | + * Returns the path to a principal's calendar home. |
|
| 34 | + * |
|
| 35 | + * The return url must not end with a slash. |
|
| 36 | + * This function should return null in case a principal did not have |
|
| 37 | + * a calendar home. |
|
| 38 | + * |
|
| 39 | + * @param string $principalUrl |
|
| 40 | + * @return string|null |
|
| 41 | + */ |
|
| 42 | + public function getCalendarHomeForPrincipal($principalUrl); |
|
| 43 | 43 | |
| 44 | 44 | } |
| 45 | 45 | \ No newline at end of file |
@@ -60,218 +60,218 @@ |
||
| 60 | 60 | |
| 61 | 61 | class Server { |
| 62 | 62 | |
| 63 | - /** @var IRequest */ |
|
| 64 | - private $request; |
|
| 63 | + /** @var IRequest */ |
|
| 64 | + private $request; |
|
| 65 | 65 | |
| 66 | - /** @var string */ |
|
| 67 | - private $baseUri; |
|
| 66 | + /** @var string */ |
|
| 67 | + private $baseUri; |
|
| 68 | 68 | |
| 69 | - /** @var Connector\Sabre\Server */ |
|
| 70 | - private $server; |
|
| 69 | + /** @var Connector\Sabre\Server */ |
|
| 70 | + private $server; |
|
| 71 | 71 | |
| 72 | - public function __construct(IRequest $request, $baseUri) { |
|
| 73 | - $this->request = $request; |
|
| 74 | - $this->baseUri = $baseUri; |
|
| 75 | - $logger = \OC::$server->getLogger(); |
|
| 76 | - $mailer = \OC::$server->getMailer(); |
|
| 77 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
| 78 | - $timezone = new TimeFactory(); |
|
| 79 | - $sendInvitations = \OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes'; |
|
| 72 | + public function __construct(IRequest $request, $baseUri) { |
|
| 73 | + $this->request = $request; |
|
| 74 | + $this->baseUri = $baseUri; |
|
| 75 | + $logger = \OC::$server->getLogger(); |
|
| 76 | + $mailer = \OC::$server->getMailer(); |
|
| 77 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
| 78 | + $timezone = new TimeFactory(); |
|
| 79 | + $sendInvitations = \OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes'; |
|
| 80 | 80 | |
| 81 | - $root = new RootCollection(); |
|
| 82 | - $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); |
|
| 81 | + $root = new RootCollection(); |
|
| 82 | + $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); |
|
| 83 | 83 | |
| 84 | - // Add maintenance plugin |
|
| 85 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
| 84 | + // Add maintenance plugin |
|
| 85 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
| 86 | 86 | |
| 87 | - // Backends |
|
| 88 | - $authBackend = new Auth( |
|
| 89 | - \OC::$server->getSession(), |
|
| 90 | - \OC::$server->getUserSession(), |
|
| 91 | - \OC::$server->getRequest(), |
|
| 92 | - \OC::$server->getTwoFactorAuthManager(), |
|
| 93 | - \OC::$server->getBruteForceThrottler() |
|
| 94 | - ); |
|
| 87 | + // Backends |
|
| 88 | + $authBackend = new Auth( |
|
| 89 | + \OC::$server->getSession(), |
|
| 90 | + \OC::$server->getUserSession(), |
|
| 91 | + \OC::$server->getRequest(), |
|
| 92 | + \OC::$server->getTwoFactorAuthManager(), |
|
| 93 | + \OC::$server->getBruteForceThrottler() |
|
| 94 | + ); |
|
| 95 | 95 | |
| 96 | - // Set URL explicitly due to reverse-proxy situations |
|
| 97 | - $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
| 98 | - $this->server->setBaseUri($this->baseUri); |
|
| 96 | + // Set URL explicitly due to reverse-proxy situations |
|
| 97 | + $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
| 98 | + $this->server->setBaseUri($this->baseUri); |
|
| 99 | 99 | |
| 100 | - $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
| 101 | - $authPlugin = new Plugin(); |
|
| 102 | - $authPlugin->addBackend(new PublicAuth()); |
|
| 103 | - $this->server->addPlugin($authPlugin); |
|
| 100 | + $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
| 101 | + $authPlugin = new Plugin(); |
|
| 102 | + $authPlugin->addBackend(new PublicAuth()); |
|
| 103 | + $this->server->addPlugin($authPlugin); |
|
| 104 | 104 | |
| 105 | - // allow setup of additional auth backends |
|
| 106 | - $event = new SabrePluginEvent($this->server); |
|
| 107 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
| 105 | + // allow setup of additional auth backends |
|
| 106 | + $event = new SabrePluginEvent($this->server); |
|
| 107 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
| 108 | 108 | |
| 109 | - $bearerAuthBackend = new BearerAuth( |
|
| 110 | - \OC::$server->getUserSession(), |
|
| 111 | - \OC::$server->getSession(), |
|
| 112 | - \OC::$server->getRequest() |
|
| 113 | - ); |
|
| 114 | - $authPlugin->addBackend($bearerAuthBackend); |
|
| 115 | - // because we are throwing exceptions this plugin has to be the last one |
|
| 116 | - $authPlugin->addBackend($authBackend); |
|
| 109 | + $bearerAuthBackend = new BearerAuth( |
|
| 110 | + \OC::$server->getUserSession(), |
|
| 111 | + \OC::$server->getSession(), |
|
| 112 | + \OC::$server->getRequest() |
|
| 113 | + ); |
|
| 114 | + $authPlugin->addBackend($bearerAuthBackend); |
|
| 115 | + // because we are throwing exceptions this plugin has to be the last one |
|
| 116 | + $authPlugin->addBackend($authBackend); |
|
| 117 | 117 | |
| 118 | - // debugging |
|
| 119 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 120 | - $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
| 121 | - } else { |
|
| 122 | - $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
| 123 | - } |
|
| 118 | + // debugging |
|
| 119 | + if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 120 | + $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
| 121 | + } else { |
|
| 122 | + $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
| 126 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
| 127 | - $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
| 125 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
| 126 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
| 127 | + $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
| 128 | 128 | |
| 129 | - // acl |
|
| 130 | - $acl = new DavAclPlugin(); |
|
| 131 | - $acl->principalCollectionSet = [ |
|
| 132 | - 'principals/users', 'principals/groups' |
|
| 133 | - ]; |
|
| 134 | - $acl->defaultUsernamePath = 'principals/users'; |
|
| 135 | - $this->server->addPlugin($acl); |
|
| 129 | + // acl |
|
| 130 | + $acl = new DavAclPlugin(); |
|
| 131 | + $acl->principalCollectionSet = [ |
|
| 132 | + 'principals/users', 'principals/groups' |
|
| 133 | + ]; |
|
| 134 | + $acl->defaultUsernamePath = 'principals/users'; |
|
| 135 | + $this->server->addPlugin($acl); |
|
| 136 | 136 | |
| 137 | - // calendar plugins |
|
| 138 | - $this->server->addPlugin(new \Sabre\CalDAV\Plugin()); |
|
| 139 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
| 140 | - $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
| 141 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
| 142 | - if ($sendInvitations) { |
|
| 143 | - $this->server->addPlugin(new IMipPlugin($mailer, $logger, $timezone)); |
|
| 144 | - } |
|
| 145 | - $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
| 146 | - $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
| 147 | - $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
| 148 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
| 149 | - \OC::$server->getConfig(), |
|
| 150 | - \OC::$server->getURLGenerator() |
|
| 151 | - )); |
|
| 137 | + // calendar plugins |
|
| 138 | + $this->server->addPlugin(new \Sabre\CalDAV\Plugin()); |
|
| 139 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
| 140 | + $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
| 141 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
| 142 | + if ($sendInvitations) { |
|
| 143 | + $this->server->addPlugin(new IMipPlugin($mailer, $logger, $timezone)); |
|
| 144 | + } |
|
| 145 | + $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
| 146 | + $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
| 147 | + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
| 148 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
| 149 | + \OC::$server->getConfig(), |
|
| 150 | + \OC::$server->getURLGenerator() |
|
| 151 | + )); |
|
| 152 | 152 | |
| 153 | - // addressbook plugins |
|
| 154 | - $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
| 155 | - $this->server->addPlugin(new VCFExportPlugin()); |
|
| 156 | - $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); |
|
| 153 | + // addressbook plugins |
|
| 154 | + $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
| 155 | + $this->server->addPlugin(new VCFExportPlugin()); |
|
| 156 | + $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); |
|
| 157 | 157 | |
| 158 | - // system tags plugins |
|
| 159 | - $this->server->addPlugin(new SystemTagPlugin( |
|
| 160 | - \OC::$server->getSystemTagManager(), |
|
| 161 | - \OC::$server->getGroupManager(), |
|
| 162 | - \OC::$server->getUserSession() |
|
| 163 | - )); |
|
| 158 | + // system tags plugins |
|
| 159 | + $this->server->addPlugin(new SystemTagPlugin( |
|
| 160 | + \OC::$server->getSystemTagManager(), |
|
| 161 | + \OC::$server->getGroupManager(), |
|
| 162 | + \OC::$server->getUserSession() |
|
| 163 | + )); |
|
| 164 | 164 | |
| 165 | - // comments plugin |
|
| 166 | - $this->server->addPlugin(new CommentsPlugin( |
|
| 167 | - \OC::$server->getCommentsManager(), |
|
| 168 | - \OC::$server->getUserSession() |
|
| 169 | - )); |
|
| 165 | + // comments plugin |
|
| 166 | + $this->server->addPlugin(new CommentsPlugin( |
|
| 167 | + \OC::$server->getCommentsManager(), |
|
| 168 | + \OC::$server->getUserSession() |
|
| 169 | + )); |
|
| 170 | 170 | |
| 171 | - $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
| 171 | + $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
| 172 | 172 | |
| 173 | - // allow setup of additional plugins |
|
| 174 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
| 173 | + // allow setup of additional plugins |
|
| 174 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
| 175 | 175 | |
| 176 | - // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
| 177 | - // we do not provide locking we emulate it using a fake locking plugin. |
|
| 178 | - if($request->isUserAgent([ |
|
| 179 | - '/WebDAVFS/', |
|
| 180 | - '/Microsoft Office OneNote 2013/', |
|
| 181 | - '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
| 182 | - ])) { |
|
| 183 | - $this->server->addPlugin(new FakeLockerPlugin()); |
|
| 184 | - } |
|
| 176 | + // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
| 177 | + // we do not provide locking we emulate it using a fake locking plugin. |
|
| 178 | + if($request->isUserAgent([ |
|
| 179 | + '/WebDAVFS/', |
|
| 180 | + '/Microsoft Office OneNote 2013/', |
|
| 181 | + '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
| 182 | + ])) { |
|
| 183 | + $this->server->addPlugin(new FakeLockerPlugin()); |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
| 187 | - $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
| 188 | - } |
|
| 186 | + if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
| 187 | + $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - // wait with registering these until auth is handled and the filesystem is setup |
|
| 191 | - $this->server->on('beforeMethod', function () use ($root) { |
|
| 192 | - // custom properties plugin must be the last one |
|
| 193 | - $userSession = \OC::$server->getUserSession(); |
|
| 194 | - $user = $userSession->getUser(); |
|
| 195 | - if ($user !== null) { |
|
| 196 | - $view = \OC\Files\Filesystem::getView(); |
|
| 197 | - $this->server->addPlugin( |
|
| 198 | - new FilesPlugin( |
|
| 199 | - $this->server->tree, |
|
| 200 | - \OC::$server->getConfig(), |
|
| 201 | - $this->request, |
|
| 202 | - \OC::$server->getPreviewManager(), |
|
| 203 | - false, |
|
| 204 | - !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
| 205 | - ) |
|
| 206 | - ); |
|
| 190 | + // wait with registering these until auth is handled and the filesystem is setup |
|
| 191 | + $this->server->on('beforeMethod', function () use ($root) { |
|
| 192 | + // custom properties plugin must be the last one |
|
| 193 | + $userSession = \OC::$server->getUserSession(); |
|
| 194 | + $user = $userSession->getUser(); |
|
| 195 | + if ($user !== null) { |
|
| 196 | + $view = \OC\Files\Filesystem::getView(); |
|
| 197 | + $this->server->addPlugin( |
|
| 198 | + new FilesPlugin( |
|
| 199 | + $this->server->tree, |
|
| 200 | + \OC::$server->getConfig(), |
|
| 201 | + $this->request, |
|
| 202 | + \OC::$server->getPreviewManager(), |
|
| 203 | + false, |
|
| 204 | + !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
| 205 | + ) |
|
| 206 | + ); |
|
| 207 | 207 | |
| 208 | - $this->server->addPlugin( |
|
| 209 | - new \Sabre\DAV\PropertyStorage\Plugin( |
|
| 210 | - new CustomPropertiesBackend( |
|
| 211 | - $this->server->tree, |
|
| 212 | - \OC::$server->getDatabaseConnection(), |
|
| 213 | - \OC::$server->getUserSession()->getUser() |
|
| 214 | - ) |
|
| 215 | - ) |
|
| 216 | - ); |
|
| 217 | - if ($view !== null) { |
|
| 218 | - $this->server->addPlugin( |
|
| 219 | - new QuotaPlugin($view, false)); |
|
| 220 | - } |
|
| 221 | - $this->server->addPlugin( |
|
| 222 | - new TagsPlugin( |
|
| 223 | - $this->server->tree, \OC::$server->getTagManager() |
|
| 224 | - ) |
|
| 225 | - ); |
|
| 226 | - // TODO: switch to LazyUserFolder |
|
| 227 | - $userFolder = \OC::$server->getUserFolder(); |
|
| 228 | - $this->server->addPlugin(new SharesPlugin( |
|
| 229 | - $this->server->tree, |
|
| 230 | - $userSession, |
|
| 231 | - $userFolder, |
|
| 232 | - \OC::$server->getShareManager() |
|
| 233 | - )); |
|
| 234 | - $this->server->addPlugin(new CommentPropertiesPlugin( |
|
| 235 | - \OC::$server->getCommentsManager(), |
|
| 236 | - $userSession |
|
| 237 | - )); |
|
| 238 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
| 239 | - if ($view !== null) { |
|
| 240 | - $this->server->addPlugin(new FilesReportPlugin( |
|
| 241 | - $this->server->tree, |
|
| 242 | - $view, |
|
| 243 | - \OC::$server->getSystemTagManager(), |
|
| 244 | - \OC::$server->getSystemTagObjectMapper(), |
|
| 245 | - \OC::$server->getTagManager(), |
|
| 246 | - $userSession, |
|
| 247 | - \OC::$server->getGroupManager(), |
|
| 248 | - $userFolder |
|
| 249 | - )); |
|
| 250 | - $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
| 251 | - $this->server->tree, |
|
| 252 | - $user, |
|
| 253 | - \OC::$server->getRootFolder(), |
|
| 254 | - \OC::$server->getShareManager(), |
|
| 255 | - $view |
|
| 256 | - ))); |
|
| 257 | - } |
|
| 258 | - } |
|
| 208 | + $this->server->addPlugin( |
|
| 209 | + new \Sabre\DAV\PropertyStorage\Plugin( |
|
| 210 | + new CustomPropertiesBackend( |
|
| 211 | + $this->server->tree, |
|
| 212 | + \OC::$server->getDatabaseConnection(), |
|
| 213 | + \OC::$server->getUserSession()->getUser() |
|
| 214 | + ) |
|
| 215 | + ) |
|
| 216 | + ); |
|
| 217 | + if ($view !== null) { |
|
| 218 | + $this->server->addPlugin( |
|
| 219 | + new QuotaPlugin($view, false)); |
|
| 220 | + } |
|
| 221 | + $this->server->addPlugin( |
|
| 222 | + new TagsPlugin( |
|
| 223 | + $this->server->tree, \OC::$server->getTagManager() |
|
| 224 | + ) |
|
| 225 | + ); |
|
| 226 | + // TODO: switch to LazyUserFolder |
|
| 227 | + $userFolder = \OC::$server->getUserFolder(); |
|
| 228 | + $this->server->addPlugin(new SharesPlugin( |
|
| 229 | + $this->server->tree, |
|
| 230 | + $userSession, |
|
| 231 | + $userFolder, |
|
| 232 | + \OC::$server->getShareManager() |
|
| 233 | + )); |
|
| 234 | + $this->server->addPlugin(new CommentPropertiesPlugin( |
|
| 235 | + \OC::$server->getCommentsManager(), |
|
| 236 | + $userSession |
|
| 237 | + )); |
|
| 238 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
| 239 | + if ($view !== null) { |
|
| 240 | + $this->server->addPlugin(new FilesReportPlugin( |
|
| 241 | + $this->server->tree, |
|
| 242 | + $view, |
|
| 243 | + \OC::$server->getSystemTagManager(), |
|
| 244 | + \OC::$server->getSystemTagObjectMapper(), |
|
| 245 | + \OC::$server->getTagManager(), |
|
| 246 | + $userSession, |
|
| 247 | + \OC::$server->getGroupManager(), |
|
| 248 | + $userFolder |
|
| 249 | + )); |
|
| 250 | + $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
| 251 | + $this->server->tree, |
|
| 252 | + $user, |
|
| 253 | + \OC::$server->getRootFolder(), |
|
| 254 | + \OC::$server->getShareManager(), |
|
| 255 | + $view |
|
| 256 | + ))); |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - // register plugins from apps |
|
| 261 | - $pluginManager = new PluginManager( |
|
| 262 | - \OC::$server, |
|
| 263 | - \OC::$server->getAppManager() |
|
| 264 | - ); |
|
| 265 | - foreach ($pluginManager->getAppPlugins() as $appPlugin) { |
|
| 266 | - $this->server->addPlugin($appPlugin); |
|
| 267 | - } |
|
| 268 | - foreach ($pluginManager->getAppCollections() as $appCollection) { |
|
| 269 | - $root->addChild($appCollection); |
|
| 270 | - } |
|
| 271 | - }); |
|
| 272 | - } |
|
| 260 | + // register plugins from apps |
|
| 261 | + $pluginManager = new PluginManager( |
|
| 262 | + \OC::$server, |
|
| 263 | + \OC::$server->getAppManager() |
|
| 264 | + ); |
|
| 265 | + foreach ($pluginManager->getAppPlugins() as $appPlugin) { |
|
| 266 | + $this->server->addPlugin($appPlugin); |
|
| 267 | + } |
|
| 268 | + foreach ($pluginManager->getAppCollections() as $appCollection) { |
|
| 269 | + $root->addChild($appCollection); |
|
| 270 | + } |
|
| 271 | + }); |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - public function exec() { |
|
| 275 | - $this->server->exec(); |
|
| 276 | - } |
|
| 274 | + public function exec() { |
|
| 275 | + $this->server->exec(); |
|
| 276 | + } |
|
| 277 | 277 | } |
@@ -29,62 +29,62 @@ |
||
| 29 | 29 | |
| 30 | 30 | class Plugin extends \Sabre\CalDAV\Plugin implements ICalendarHomePlugin { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Initializes the plugin |
|
| 34 | - * |
|
| 35 | - * @param Server $server |
|
| 36 | - * @return void |
|
| 37 | - */ |
|
| 38 | - public function initialize(Server $server) { |
|
| 39 | - $this->server = $server; |
|
| 40 | - $server->on('propFind', [$this, 'propFind'], 90); |
|
| 41 | - } |
|
| 32 | + /** |
|
| 33 | + * Initializes the plugin |
|
| 34 | + * |
|
| 35 | + * @param Server $server |
|
| 36 | + * @return void |
|
| 37 | + */ |
|
| 38 | + public function initialize(Server $server) { |
|
| 39 | + $this->server = $server; |
|
| 40 | + $server->on('propFind', [$this, 'propFind'], 90); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * PropFind |
|
| 45 | - * |
|
| 46 | - * This method handler is invoked before any after properties for a |
|
| 47 | - * resource are fetched. This allows us to add in any CalDAV specific |
|
| 48 | - * properties. |
|
| 49 | - * |
|
| 50 | - * @param DAV\PropFind $propFind |
|
| 51 | - * @param DAV\INode $node |
|
| 52 | - * @return void |
|
| 53 | - */ |
|
| 54 | - public function propFind(DAV\PropFind $propFind, DAV\INode $node) { |
|
| 55 | - if ($node instanceof IPrincipal) { |
|
| 56 | - $principalUrl = $node->getPrincipalUrl(); |
|
| 57 | - $propFind->handle('{' . self::NS_CALDAV . '}calendar-home-set', function () use ($principalUrl) { |
|
| 58 | - $calendarHomes = []; |
|
| 59 | - // Make sure the dav apps caldav endpoint is at the first place |
|
| 60 | - $calendarHomePath = $this->getCalendarHomeForPrincipal($principalUrl); |
|
| 61 | - if ($calendarHomePath !== null) { |
|
| 62 | - $calendarHomes[] = $calendarHomePath; |
|
| 63 | - } |
|
| 64 | - foreach ($this->server->getPlugins() as $plugin) { |
|
| 65 | - if ($plugin instanceof ICalendarHomePlugin && $plugin !== $this) { |
|
| 66 | - $calendarHomePath = $plugin->getCalendarHomeForPrincipal($principalUrl); |
|
| 67 | - if ($calendarHomePath !== null) { |
|
| 68 | - $calendarHomes[] = $calendarHomePath; |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - return new LocalHref($calendarHomes); |
|
| 73 | - }); |
|
| 74 | - } |
|
| 75 | - } |
|
| 43 | + /** |
|
| 44 | + * PropFind |
|
| 45 | + * |
|
| 46 | + * This method handler is invoked before any after properties for a |
|
| 47 | + * resource are fetched. This allows us to add in any CalDAV specific |
|
| 48 | + * properties. |
|
| 49 | + * |
|
| 50 | + * @param DAV\PropFind $propFind |
|
| 51 | + * @param DAV\INode $node |
|
| 52 | + * @return void |
|
| 53 | + */ |
|
| 54 | + public function propFind(DAV\PropFind $propFind, DAV\INode $node) { |
|
| 55 | + if ($node instanceof IPrincipal) { |
|
| 56 | + $principalUrl = $node->getPrincipalUrl(); |
|
| 57 | + $propFind->handle('{' . self::NS_CALDAV . '}calendar-home-set', function () use ($principalUrl) { |
|
| 58 | + $calendarHomes = []; |
|
| 59 | + // Make sure the dav apps caldav endpoint is at the first place |
|
| 60 | + $calendarHomePath = $this->getCalendarHomeForPrincipal($principalUrl); |
|
| 61 | + if ($calendarHomePath !== null) { |
|
| 62 | + $calendarHomes[] = $calendarHomePath; |
|
| 63 | + } |
|
| 64 | + foreach ($this->server->getPlugins() as $plugin) { |
|
| 65 | + if ($plugin instanceof ICalendarHomePlugin && $plugin !== $this) { |
|
| 66 | + $calendarHomePath = $plugin->getCalendarHomeForPrincipal($principalUrl); |
|
| 67 | + if ($calendarHomePath !== null) { |
|
| 68 | + $calendarHomes[] = $calendarHomePath; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + return new LocalHref($calendarHomes); |
|
| 73 | + }); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Add the Nextcloud default calendar home |
|
| 79 | - * |
|
| 80 | - * @inheritdoc |
|
| 81 | - */ |
|
| 82 | - public function getCalendarHomeForPrincipal($principalUrl) { |
|
| 83 | - if (strrpos($principalUrl, 'principals/users', -strlen($principalUrl)) !== false) { |
|
| 84 | - list(, $principalId) = \Sabre\Uri\split($principalUrl); |
|
| 85 | - return self::CALENDAR_ROOT .'/' . $principalId; |
|
| 86 | - } |
|
| 87 | - return null; |
|
| 88 | - } |
|
| 77 | + /** |
|
| 78 | + * Add the Nextcloud default calendar home |
|
| 79 | + * |
|
| 80 | + * @inheritdoc |
|
| 81 | + */ |
|
| 82 | + public function getCalendarHomeForPrincipal($principalUrl) { |
|
| 83 | + if (strrpos($principalUrl, 'principals/users', -strlen($principalUrl)) !== false) { |
|
| 84 | + list(, $principalId) = \Sabre\Uri\split($principalUrl); |
|
| 85 | + return self::CALENDAR_ROOT .'/' . $principalId; |
|
| 86 | + } |
|
| 87 | + return null; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | public function propFind(DAV\PropFind $propFind, DAV\INode $node) { |
| 55 | 55 | if ($node instanceof IPrincipal) { |
| 56 | 56 | $principalUrl = $node->getPrincipalUrl(); |
| 57 | - $propFind->handle('{' . self::NS_CALDAV . '}calendar-home-set', function () use ($principalUrl) { |
|
| 57 | + $propFind->handle('{'.self::NS_CALDAV.'}calendar-home-set', function() use ($principalUrl) { |
|
| 58 | 58 | $calendarHomes = []; |
| 59 | 59 | // Make sure the dav apps caldav endpoint is at the first place |
| 60 | 60 | $calendarHomePath = $this->getCalendarHomeForPrincipal($principalUrl); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | public function getCalendarHomeForPrincipal($principalUrl) { |
| 83 | 83 | if (strrpos($principalUrl, 'principals/users', -strlen($principalUrl)) !== false) { |
| 84 | 84 | list(, $principalId) = \Sabre\Uri\split($principalUrl); |
| 85 | - return self::CALENDAR_ROOT .'/' . $principalId; |
|
| 85 | + return self::CALENDAR_ROOT.'/'.$principalId; |
|
| 86 | 86 | } |
| 87 | 87 | return null; |
| 88 | 88 | } |