@@ -60,214 +60,214 @@ |
||
| 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(); |
|
| 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 | 79 | |
| 80 | - $root = new RootCollection(); |
|
| 81 | - $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); |
|
| 80 | + $root = new RootCollection(); |
|
| 81 | + $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); |
|
| 82 | 82 | |
| 83 | - // Add maintenance plugin |
|
| 84 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
| 83 | + // Add maintenance plugin |
|
| 84 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
| 85 | 85 | |
| 86 | - // Backends |
|
| 87 | - $authBackend = new Auth( |
|
| 88 | - \OC::$server->getSession(), |
|
| 89 | - \OC::$server->getUserSession(), |
|
| 90 | - \OC::$server->getRequest(), |
|
| 91 | - \OC::$server->getTwoFactorAuthManager(), |
|
| 92 | - \OC::$server->getBruteForceThrottler() |
|
| 93 | - ); |
|
| 86 | + // Backends |
|
| 87 | + $authBackend = new Auth( |
|
| 88 | + \OC::$server->getSession(), |
|
| 89 | + \OC::$server->getUserSession(), |
|
| 90 | + \OC::$server->getRequest(), |
|
| 91 | + \OC::$server->getTwoFactorAuthManager(), |
|
| 92 | + \OC::$server->getBruteForceThrottler() |
|
| 93 | + ); |
|
| 94 | 94 | |
| 95 | - // Set URL explicitly due to reverse-proxy situations |
|
| 96 | - $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
| 97 | - $this->server->setBaseUri($this->baseUri); |
|
| 95 | + // Set URL explicitly due to reverse-proxy situations |
|
| 96 | + $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
| 97 | + $this->server->setBaseUri($this->baseUri); |
|
| 98 | 98 | |
| 99 | - $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
| 100 | - $authPlugin = new Plugin(); |
|
| 101 | - $authPlugin->addBackend(new PublicAuth()); |
|
| 102 | - $this->server->addPlugin($authPlugin); |
|
| 99 | + $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
| 100 | + $authPlugin = new Plugin(); |
|
| 101 | + $authPlugin->addBackend(new PublicAuth()); |
|
| 102 | + $this->server->addPlugin($authPlugin); |
|
| 103 | 103 | |
| 104 | - // allow setup of additional auth backends |
|
| 105 | - $event = new SabrePluginEvent($this->server); |
|
| 106 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
| 104 | + // allow setup of additional auth backends |
|
| 105 | + $event = new SabrePluginEvent($this->server); |
|
| 106 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
| 107 | 107 | |
| 108 | - $bearerAuthBackend = new BearerAuth( |
|
| 109 | - \OC::$server->getUserSession(), |
|
| 110 | - \OC::$server->getSession(), |
|
| 111 | - \OC::$server->getRequest() |
|
| 112 | - ); |
|
| 113 | - $authPlugin->addBackend($bearerAuthBackend); |
|
| 114 | - // because we are throwing exceptions this plugin has to be the last one |
|
| 115 | - $authPlugin->addBackend($authBackend); |
|
| 108 | + $bearerAuthBackend = new BearerAuth( |
|
| 109 | + \OC::$server->getUserSession(), |
|
| 110 | + \OC::$server->getSession(), |
|
| 111 | + \OC::$server->getRequest() |
|
| 112 | + ); |
|
| 113 | + $authPlugin->addBackend($bearerAuthBackend); |
|
| 114 | + // because we are throwing exceptions this plugin has to be the last one |
|
| 115 | + $authPlugin->addBackend($authBackend); |
|
| 116 | 116 | |
| 117 | - // debugging |
|
| 118 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 119 | - $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
| 120 | - } else { |
|
| 121 | - $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
| 122 | - } |
|
| 117 | + // debugging |
|
| 118 | + if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 119 | + $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
| 120 | + } else { |
|
| 121 | + $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
| 125 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
| 126 | - $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
| 124 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
| 125 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
| 126 | + $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
| 127 | 127 | |
| 128 | - // acl |
|
| 129 | - $acl = new DavAclPlugin(); |
|
| 130 | - $acl->principalCollectionSet = [ |
|
| 131 | - 'principals/users', 'principals/groups' |
|
| 132 | - ]; |
|
| 133 | - $acl->defaultUsernamePath = 'principals/users'; |
|
| 134 | - $this->server->addPlugin($acl); |
|
| 128 | + // acl |
|
| 129 | + $acl = new DavAclPlugin(); |
|
| 130 | + $acl->principalCollectionSet = [ |
|
| 131 | + 'principals/users', 'principals/groups' |
|
| 132 | + ]; |
|
| 133 | + $acl->defaultUsernamePath = 'principals/users'; |
|
| 134 | + $this->server->addPlugin($acl); |
|
| 135 | 135 | |
| 136 | - // calendar plugins |
|
| 137 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
| 138 | - $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
| 139 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
| 140 | - $this->server->addPlugin(new IMipPlugin($mailer, $logger, $timezone)); |
|
| 141 | - $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
| 142 | - $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
| 143 | - $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
| 144 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
| 145 | - \OC::$server->getConfig(), |
|
| 146 | - \OC::$server->getURLGenerator() |
|
| 147 | - )); |
|
| 136 | + // calendar plugins |
|
| 137 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
| 138 | + $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
| 139 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
| 140 | + $this->server->addPlugin(new IMipPlugin($mailer, $logger, $timezone)); |
|
| 141 | + $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
| 142 | + $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
| 143 | + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
| 144 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
| 145 | + \OC::$server->getConfig(), |
|
| 146 | + \OC::$server->getURLGenerator() |
|
| 147 | + )); |
|
| 148 | 148 | |
| 149 | - // addressbook plugins |
|
| 150 | - $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
| 151 | - $this->server->addPlugin(new VCFExportPlugin()); |
|
| 152 | - $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); |
|
| 149 | + // addressbook plugins |
|
| 150 | + $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
| 151 | + $this->server->addPlugin(new VCFExportPlugin()); |
|
| 152 | + $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); |
|
| 153 | 153 | |
| 154 | - // system tags plugins |
|
| 155 | - $this->server->addPlugin(new SystemTagPlugin( |
|
| 156 | - \OC::$server->getSystemTagManager(), |
|
| 157 | - \OC::$server->getGroupManager(), |
|
| 158 | - \OC::$server->getUserSession() |
|
| 159 | - )); |
|
| 154 | + // system tags plugins |
|
| 155 | + $this->server->addPlugin(new SystemTagPlugin( |
|
| 156 | + \OC::$server->getSystemTagManager(), |
|
| 157 | + \OC::$server->getGroupManager(), |
|
| 158 | + \OC::$server->getUserSession() |
|
| 159 | + )); |
|
| 160 | 160 | |
| 161 | - // comments plugin |
|
| 162 | - $this->server->addPlugin(new CommentsPlugin( |
|
| 163 | - \OC::$server->getCommentsManager(), |
|
| 164 | - \OC::$server->getUserSession() |
|
| 165 | - )); |
|
| 161 | + // comments plugin |
|
| 162 | + $this->server->addPlugin(new CommentsPlugin( |
|
| 163 | + \OC::$server->getCommentsManager(), |
|
| 164 | + \OC::$server->getUserSession() |
|
| 165 | + )); |
|
| 166 | 166 | |
| 167 | - $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
| 167 | + $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
| 168 | 168 | |
| 169 | - // allow setup of additional plugins |
|
| 170 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
| 169 | + // allow setup of additional plugins |
|
| 170 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
| 171 | 171 | |
| 172 | - // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
| 173 | - // we do not provide locking we emulate it using a fake locking plugin. |
|
| 174 | - if($request->isUserAgent([ |
|
| 175 | - '/WebDAVFS/', |
|
| 176 | - '/Microsoft Office OneNote 2013/', |
|
| 177 | - '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
| 178 | - ])) { |
|
| 179 | - $this->server->addPlugin(new FakeLockerPlugin()); |
|
| 180 | - } |
|
| 172 | + // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
| 173 | + // we do not provide locking we emulate it using a fake locking plugin. |
|
| 174 | + if($request->isUserAgent([ |
|
| 175 | + '/WebDAVFS/', |
|
| 176 | + '/Microsoft Office OneNote 2013/', |
|
| 177 | + '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
| 178 | + ])) { |
|
| 179 | + $this->server->addPlugin(new FakeLockerPlugin()); |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
| 183 | - $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
| 184 | - } |
|
| 182 | + if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
| 183 | + $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - // wait with registering these until auth is handled and the filesystem is setup |
|
| 187 | - $this->server->on('beforeMethod', function () use ($root) { |
|
| 188 | - // custom properties plugin must be the last one |
|
| 189 | - $userSession = \OC::$server->getUserSession(); |
|
| 190 | - $user = $userSession->getUser(); |
|
| 191 | - if ($user !== null) { |
|
| 192 | - $view = \OC\Files\Filesystem::getView(); |
|
| 193 | - $this->server->addPlugin( |
|
| 194 | - new FilesPlugin( |
|
| 195 | - $this->server->tree, |
|
| 196 | - \OC::$server->getConfig(), |
|
| 197 | - $this->request, |
|
| 198 | - \OC::$server->getPreviewManager(), |
|
| 199 | - false, |
|
| 200 | - !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
| 201 | - ) |
|
| 202 | - ); |
|
| 186 | + // wait with registering these until auth is handled and the filesystem is setup |
|
| 187 | + $this->server->on('beforeMethod', function () use ($root) { |
|
| 188 | + // custom properties plugin must be the last one |
|
| 189 | + $userSession = \OC::$server->getUserSession(); |
|
| 190 | + $user = $userSession->getUser(); |
|
| 191 | + if ($user !== null) { |
|
| 192 | + $view = \OC\Files\Filesystem::getView(); |
|
| 193 | + $this->server->addPlugin( |
|
| 194 | + new FilesPlugin( |
|
| 195 | + $this->server->tree, |
|
| 196 | + \OC::$server->getConfig(), |
|
| 197 | + $this->request, |
|
| 198 | + \OC::$server->getPreviewManager(), |
|
| 199 | + false, |
|
| 200 | + !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
| 201 | + ) |
|
| 202 | + ); |
|
| 203 | 203 | |
| 204 | - $this->server->addPlugin( |
|
| 205 | - new \Sabre\DAV\PropertyStorage\Plugin( |
|
| 206 | - new CustomPropertiesBackend( |
|
| 207 | - $this->server->tree, |
|
| 208 | - \OC::$server->getDatabaseConnection(), |
|
| 209 | - \OC::$server->getUserSession()->getUser() |
|
| 210 | - ) |
|
| 211 | - ) |
|
| 212 | - ); |
|
| 213 | - if ($view !== null) { |
|
| 214 | - $this->server->addPlugin( |
|
| 215 | - new QuotaPlugin($view, false)); |
|
| 216 | - } |
|
| 217 | - $this->server->addPlugin( |
|
| 218 | - new TagsPlugin( |
|
| 219 | - $this->server->tree, \OC::$server->getTagManager() |
|
| 220 | - ) |
|
| 221 | - ); |
|
| 222 | - // TODO: switch to LazyUserFolder |
|
| 223 | - $userFolder = \OC::$server->getUserFolder(); |
|
| 224 | - $this->server->addPlugin(new SharesPlugin( |
|
| 225 | - $this->server->tree, |
|
| 226 | - $userSession, |
|
| 227 | - $userFolder, |
|
| 228 | - \OC::$server->getShareManager() |
|
| 229 | - )); |
|
| 230 | - $this->server->addPlugin(new CommentPropertiesPlugin( |
|
| 231 | - \OC::$server->getCommentsManager(), |
|
| 232 | - $userSession |
|
| 233 | - )); |
|
| 234 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
| 235 | - if ($view !== null) { |
|
| 236 | - $this->server->addPlugin(new FilesReportPlugin( |
|
| 237 | - $this->server->tree, |
|
| 238 | - $view, |
|
| 239 | - \OC::$server->getSystemTagManager(), |
|
| 240 | - \OC::$server->getSystemTagObjectMapper(), |
|
| 241 | - \OC::$server->getTagManager(), |
|
| 242 | - $userSession, |
|
| 243 | - \OC::$server->getGroupManager(), |
|
| 244 | - $userFolder |
|
| 245 | - )); |
|
| 246 | - $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
| 247 | - $this->server->tree, |
|
| 248 | - $user, |
|
| 249 | - \OC::$server->getRootFolder(), |
|
| 250 | - \OC::$server->getShareManager(), |
|
| 251 | - $view |
|
| 252 | - ))); |
|
| 253 | - } |
|
| 254 | - } |
|
| 204 | + $this->server->addPlugin( |
|
| 205 | + new \Sabre\DAV\PropertyStorage\Plugin( |
|
| 206 | + new CustomPropertiesBackend( |
|
| 207 | + $this->server->tree, |
|
| 208 | + \OC::$server->getDatabaseConnection(), |
|
| 209 | + \OC::$server->getUserSession()->getUser() |
|
| 210 | + ) |
|
| 211 | + ) |
|
| 212 | + ); |
|
| 213 | + if ($view !== null) { |
|
| 214 | + $this->server->addPlugin( |
|
| 215 | + new QuotaPlugin($view, false)); |
|
| 216 | + } |
|
| 217 | + $this->server->addPlugin( |
|
| 218 | + new TagsPlugin( |
|
| 219 | + $this->server->tree, \OC::$server->getTagManager() |
|
| 220 | + ) |
|
| 221 | + ); |
|
| 222 | + // TODO: switch to LazyUserFolder |
|
| 223 | + $userFolder = \OC::$server->getUserFolder(); |
|
| 224 | + $this->server->addPlugin(new SharesPlugin( |
|
| 225 | + $this->server->tree, |
|
| 226 | + $userSession, |
|
| 227 | + $userFolder, |
|
| 228 | + \OC::$server->getShareManager() |
|
| 229 | + )); |
|
| 230 | + $this->server->addPlugin(new CommentPropertiesPlugin( |
|
| 231 | + \OC::$server->getCommentsManager(), |
|
| 232 | + $userSession |
|
| 233 | + )); |
|
| 234 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
| 235 | + if ($view !== null) { |
|
| 236 | + $this->server->addPlugin(new FilesReportPlugin( |
|
| 237 | + $this->server->tree, |
|
| 238 | + $view, |
|
| 239 | + \OC::$server->getSystemTagManager(), |
|
| 240 | + \OC::$server->getSystemTagObjectMapper(), |
|
| 241 | + \OC::$server->getTagManager(), |
|
| 242 | + $userSession, |
|
| 243 | + \OC::$server->getGroupManager(), |
|
| 244 | + $userFolder |
|
| 245 | + )); |
|
| 246 | + $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
| 247 | + $this->server->tree, |
|
| 248 | + $user, |
|
| 249 | + \OC::$server->getRootFolder(), |
|
| 250 | + \OC::$server->getShareManager(), |
|
| 251 | + $view |
|
| 252 | + ))); |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - // register plugins from apps |
|
| 257 | - $pluginManager = new PluginManager( |
|
| 258 | - \OC::$server, |
|
| 259 | - \OC::$server->getAppManager() |
|
| 260 | - ); |
|
| 261 | - foreach ($pluginManager->getAppPlugins() as $appPlugin) { |
|
| 262 | - $this->server->addPlugin($appPlugin); |
|
| 263 | - } |
|
| 264 | - foreach ($pluginManager->getAppCollections() as $appCollection) { |
|
| 265 | - $root->addChild($appCollection); |
|
| 266 | - } |
|
| 267 | - }); |
|
| 268 | - } |
|
| 256 | + // register plugins from apps |
|
| 257 | + $pluginManager = new PluginManager( |
|
| 258 | + \OC::$server, |
|
| 259 | + \OC::$server->getAppManager() |
|
| 260 | + ); |
|
| 261 | + foreach ($pluginManager->getAppPlugins() as $appPlugin) { |
|
| 262 | + $this->server->addPlugin($appPlugin); |
|
| 263 | + } |
|
| 264 | + foreach ($pluginManager->getAppCollections() as $appCollection) { |
|
| 265 | + $root->addChild($appCollection); |
|
| 266 | + } |
|
| 267 | + }); |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - public function exec() { |
|
| 271 | - $this->server->exec(); |
|
| 272 | - } |
|
| 270 | + public function exec() { |
|
| 271 | + $this->server->exec(); |
|
| 272 | + } |
|
| 273 | 273 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $authPlugin->addBackend($authBackend); |
| 116 | 116 | |
| 117 | 117 | // debugging |
| 118 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 118 | + if (\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 119 | 119 | $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
| 120 | 120 | } else { |
| 121 | 121 | $this->server->addPlugin(new DummyGetResponsePlugin()); |
@@ -171,10 +171,10 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
| 173 | 173 | // we do not provide locking we emulate it using a fake locking plugin. |
| 174 | - if($request->isUserAgent([ |
|
| 174 | + if ($request->isUserAgent([ |
|
| 175 | 175 | '/WebDAVFS/', |
| 176 | 176 | '/Microsoft Office OneNote 2013/', |
| 177 | - '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
| 177 | + '/^Microsoft-WebDAV/', // Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
| 178 | 178 | ])) { |
| 179 | 179 | $this->server->addPlugin(new FakeLockerPlugin()); |
| 180 | 180 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | // wait with registering these until auth is handled and the filesystem is setup |
| 187 | - $this->server->on('beforeMethod', function () use ($root) { |
|
| 187 | + $this->server->on('beforeMethod', function() use ($root) { |
|
| 188 | 188 | // custom properties plugin must be the last one |
| 189 | 189 | $userSession = \OC::$server->getUserSession(); |
| 190 | 190 | $user = $userSession->getUser(); |
@@ -30,141 +30,141 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class PluginManager { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var ServerContainer |
|
| 35 | - */ |
|
| 36 | - private $container; |
|
| 33 | + /** |
|
| 34 | + * @var ServerContainer |
|
| 35 | + */ |
|
| 36 | + private $container; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var IAppManager |
|
| 40 | - */ |
|
| 41 | - private $appManager; |
|
| 38 | + /** |
|
| 39 | + * @var IAppManager |
|
| 40 | + */ |
|
| 41 | + private $appManager; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * App plugins |
|
| 45 | - * |
|
| 46 | - * @var array |
|
| 47 | - */ |
|
| 48 | - private $plugins = null; |
|
| 43 | + /** |
|
| 44 | + * App plugins |
|
| 45 | + * |
|
| 46 | + * @var array |
|
| 47 | + */ |
|
| 48 | + private $plugins = null; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * App collections |
|
| 52 | - * |
|
| 53 | - * @var array |
|
| 54 | - */ |
|
| 55 | - private $collections = null; |
|
| 50 | + /** |
|
| 51 | + * App collections |
|
| 52 | + * |
|
| 53 | + * @var array |
|
| 54 | + */ |
|
| 55 | + private $collections = null; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Contstruct a PluginManager |
|
| 59 | - * |
|
| 60 | - * @param ServerContainer $container server container for resolving plugin classes |
|
| 61 | - * @param IAppManager $appManager app manager to loading apps and their info |
|
| 62 | - */ |
|
| 63 | - public function __construct(ServerContainer $container, IAppManager $appManager) { |
|
| 64 | - $this->container = $container; |
|
| 65 | - $this->appManager = $appManager; |
|
| 66 | - } |
|
| 57 | + /** |
|
| 58 | + * Contstruct a PluginManager |
|
| 59 | + * |
|
| 60 | + * @param ServerContainer $container server container for resolving plugin classes |
|
| 61 | + * @param IAppManager $appManager app manager to loading apps and their info |
|
| 62 | + */ |
|
| 63 | + public function __construct(ServerContainer $container, IAppManager $appManager) { |
|
| 64 | + $this->container = $container; |
|
| 65 | + $this->appManager = $appManager; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Returns an array of app-registered plugins |
|
| 70 | - * |
|
| 71 | - * @return array |
|
| 72 | - */ |
|
| 73 | - public function getAppPlugins() { |
|
| 74 | - if (null === $this->plugins) { |
|
| 75 | - $this->populate(); |
|
| 76 | - } |
|
| 77 | - return $this->plugins; |
|
| 78 | - } |
|
| 68 | + /** |
|
| 69 | + * Returns an array of app-registered plugins |
|
| 70 | + * |
|
| 71 | + * @return array |
|
| 72 | + */ |
|
| 73 | + public function getAppPlugins() { |
|
| 74 | + if (null === $this->plugins) { |
|
| 75 | + $this->populate(); |
|
| 76 | + } |
|
| 77 | + return $this->plugins; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Returns an array of app-registered collections |
|
| 82 | - * |
|
| 83 | - * @return array |
|
| 84 | - */ |
|
| 85 | - public function getAppCollections() { |
|
| 86 | - if (null === $this->collections) { |
|
| 87 | - $this->populate(); |
|
| 88 | - } |
|
| 89 | - return $this->collections; |
|
| 90 | - } |
|
| 80 | + /** |
|
| 81 | + * Returns an array of app-registered collections |
|
| 82 | + * |
|
| 83 | + * @return array |
|
| 84 | + */ |
|
| 85 | + public function getAppCollections() { |
|
| 86 | + if (null === $this->collections) { |
|
| 87 | + $this->populate(); |
|
| 88 | + } |
|
| 89 | + return $this->collections; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Retrieve plugin and collection list and populate attributes |
|
| 94 | - */ |
|
| 95 | - private function populate() { |
|
| 96 | - $this->plugins = []; |
|
| 97 | - $this->collections = []; |
|
| 98 | - foreach ($this->appManager->getInstalledApps() as $app) { |
|
| 99 | - // load plugins and collections from info.xml |
|
| 100 | - $info = $this->appManager->getAppInfo($app); |
|
| 101 | - if (!isset($info['types']) || !in_array('dav', $info['types'], true)) { |
|
| 102 | - continue; |
|
| 103 | - } |
|
| 104 | - // FIXME: switch to public API once available |
|
| 105 | - // load app to make sure its classes are available |
|
| 106 | - \OC_App::loadApp($app); |
|
| 107 | - $this->loadSabrePluginsFromInfoXml($this->extractPluginList($info)); |
|
| 108 | - $this->loadSabreCollectionsFromInfoXml($this->extractCollectionList($info)); |
|
| 109 | - } |
|
| 110 | - } |
|
| 92 | + /** |
|
| 93 | + * Retrieve plugin and collection list and populate attributes |
|
| 94 | + */ |
|
| 95 | + private function populate() { |
|
| 96 | + $this->plugins = []; |
|
| 97 | + $this->collections = []; |
|
| 98 | + foreach ($this->appManager->getInstalledApps() as $app) { |
|
| 99 | + // load plugins and collections from info.xml |
|
| 100 | + $info = $this->appManager->getAppInfo($app); |
|
| 101 | + if (!isset($info['types']) || !in_array('dav', $info['types'], true)) { |
|
| 102 | + continue; |
|
| 103 | + } |
|
| 104 | + // FIXME: switch to public API once available |
|
| 105 | + // load app to make sure its classes are available |
|
| 106 | + \OC_App::loadApp($app); |
|
| 107 | + $this->loadSabrePluginsFromInfoXml($this->extractPluginList($info)); |
|
| 108 | + $this->loadSabreCollectionsFromInfoXml($this->extractCollectionList($info)); |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - private function extractPluginList(array $array) { |
|
| 113 | - if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 114 | - if (isset($array['sabre']['plugins']) && is_array($array['sabre']['plugins'])) { |
|
| 115 | - if (isset($array['sabre']['plugins']['plugin'])) { |
|
| 116 | - $items = $array['sabre']['plugins']['plugin']; |
|
| 117 | - if (!is_array($items)) { |
|
| 118 | - $items = [$items]; |
|
| 119 | - } |
|
| 120 | - return $items; |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - return []; |
|
| 125 | - } |
|
| 112 | + private function extractPluginList(array $array) { |
|
| 113 | + if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 114 | + if (isset($array['sabre']['plugins']) && is_array($array['sabre']['plugins'])) { |
|
| 115 | + if (isset($array['sabre']['plugins']['plugin'])) { |
|
| 116 | + $items = $array['sabre']['plugins']['plugin']; |
|
| 117 | + if (!is_array($items)) { |
|
| 118 | + $items = [$items]; |
|
| 119 | + } |
|
| 120 | + return $items; |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + return []; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - private function extractCollectionList(array $array) { |
|
| 128 | - if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 129 | - if (isset($array['sabre']['collections']) && is_array($array['sabre']['collections'])) { |
|
| 130 | - if (isset($array['sabre']['collections']['collection'])) { |
|
| 131 | - $items = $array['sabre']['collections']['collection']; |
|
| 132 | - if (!is_array($items)) { |
|
| 133 | - $items = [$items]; |
|
| 134 | - } |
|
| 135 | - return $items; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - return []; |
|
| 140 | - } |
|
| 127 | + private function extractCollectionList(array $array) { |
|
| 128 | + if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 129 | + if (isset($array['sabre']['collections']) && is_array($array['sabre']['collections'])) { |
|
| 130 | + if (isset($array['sabre']['collections']['collection'])) { |
|
| 131 | + $items = $array['sabre']['collections']['collection']; |
|
| 132 | + if (!is_array($items)) { |
|
| 133 | + $items = [$items]; |
|
| 134 | + } |
|
| 135 | + return $items; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + return []; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - private function loadSabrePluginsFromInfoXml(array $plugins) { |
|
| 143 | - foreach ($plugins as $plugin) { |
|
| 144 | - try { |
|
| 145 | - $this->plugins[] = $this->container->query($plugin); |
|
| 146 | - } catch (QueryException $e) { |
|
| 147 | - if (class_exists($plugin)) { |
|
| 148 | - $this->plugins[] = new $plugin(); |
|
| 149 | - } else { |
|
| 150 | - throw new \Exception("Sabre plugin class '$plugin' is unknown and could not be loaded"); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - } |
|
| 142 | + private function loadSabrePluginsFromInfoXml(array $plugins) { |
|
| 143 | + foreach ($plugins as $plugin) { |
|
| 144 | + try { |
|
| 145 | + $this->plugins[] = $this->container->query($plugin); |
|
| 146 | + } catch (QueryException $e) { |
|
| 147 | + if (class_exists($plugin)) { |
|
| 148 | + $this->plugins[] = new $plugin(); |
|
| 149 | + } else { |
|
| 150 | + throw new \Exception("Sabre plugin class '$plugin' is unknown and could not be loaded"); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - private function loadSabreCollectionsFromInfoXml(array $collections) { |
|
| 157 | - foreach ($collections as $collection) { |
|
| 158 | - try { |
|
| 159 | - $this->collections[] = $this->container->query($collection); |
|
| 160 | - } catch (QueryException $e) { |
|
| 161 | - if (class_exists($collection)) { |
|
| 162 | - $this->collections[] = new $collection(); |
|
| 163 | - } else { |
|
| 164 | - throw new \Exception("Sabre collection class '$collection' is unknown and could not be loaded"); |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - } |
|
| 168 | - } |
|
| 156 | + private function loadSabreCollectionsFromInfoXml(array $collections) { |
|
| 157 | + foreach ($collections as $collection) { |
|
| 158 | + try { |
|
| 159 | + $this->collections[] = $this->container->query($collection); |
|
| 160 | + } catch (QueryException $e) { |
|
| 161 | + if (class_exists($collection)) { |
|
| 162 | + $this->collections[] = new $collection(); |
|
| 163 | + } else { |
|
| 164 | + throw new \Exception("Sabre collection class '$collection' is unknown and could not be loaded"); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | 170 | } |