@@ -31,22 +31,22 @@ |
||
31 | 31 | */ |
32 | 32 | class Version14000Date20180129121024 extends SimpleMigrationStep { |
33 | 33 | |
34 | - /** |
|
35 | - * @param IOutput $output |
|
36 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
37 | - * @param array $options |
|
38 | - * @return null|ISchemaWrapper |
|
39 | - * @since 13.0.0 |
|
40 | - */ |
|
41 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
42 | - /** @var ISchemaWrapper $schema */ |
|
43 | - $schema = $schemaClosure(); |
|
34 | + /** |
|
35 | + * @param IOutput $output |
|
36 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
37 | + * @param array $options |
|
38 | + * @return null|ISchemaWrapper |
|
39 | + * @since 13.0.0 |
|
40 | + */ |
|
41 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
42 | + /** @var ISchemaWrapper $schema */ |
|
43 | + $schema = $schemaClosure(); |
|
44 | 44 | |
45 | - $schema->dropTable('admin_sections'); |
|
46 | - $schema->dropTable('admin_settings'); |
|
47 | - $schema->dropTable('personal_sections'); |
|
48 | - $schema->dropTable('personal_settings'); |
|
45 | + $schema->dropTable('admin_sections'); |
|
46 | + $schema->dropTable('admin_settings'); |
|
47 | + $schema->dropTable('personal_sections'); |
|
48 | + $schema->dropTable('personal_settings'); |
|
49 | 49 | |
50 | - return $schema; |
|
51 | - } |
|
50 | + return $schema; |
|
51 | + } |
|
52 | 52 | } |
@@ -146,1832 +146,1832 @@ |
||
146 | 146 | * TODO: hookup all manager classes |
147 | 147 | */ |
148 | 148 | class Server extends ServerContainer implements IServerContainer { |
149 | - /** @var string */ |
|
150 | - private $webRoot; |
|
151 | - |
|
152 | - /** |
|
153 | - * @param string $webRoot |
|
154 | - * @param \OC\Config $config |
|
155 | - */ |
|
156 | - public function __construct($webRoot, \OC\Config $config) { |
|
157 | - parent::__construct(); |
|
158 | - $this->webRoot = $webRoot; |
|
159 | - |
|
160 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
161 | - return $c; |
|
162 | - }); |
|
163 | - |
|
164 | - $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
165 | - $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
166 | - |
|
167 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
168 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
169 | - |
|
170 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
171 | - |
|
172 | - |
|
173 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
174 | - return new PreviewManager( |
|
175 | - $c->getConfig(), |
|
176 | - $c->getRootFolder(), |
|
177 | - $c->getAppDataDir('preview'), |
|
178 | - $c->getEventDispatcher(), |
|
179 | - $c->getSession()->get('user_id') |
|
180 | - ); |
|
181 | - }); |
|
182 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
183 | - |
|
184 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
185 | - return new \OC\Preview\Watcher( |
|
186 | - $c->getAppDataDir('preview') |
|
187 | - ); |
|
188 | - }); |
|
189 | - |
|
190 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
191 | - $view = new View(); |
|
192 | - $util = new Encryption\Util( |
|
193 | - $view, |
|
194 | - $c->getUserManager(), |
|
195 | - $c->getGroupManager(), |
|
196 | - $c->getConfig() |
|
197 | - ); |
|
198 | - return new Encryption\Manager( |
|
199 | - $c->getConfig(), |
|
200 | - $c->getLogger(), |
|
201 | - $c->getL10N('core'), |
|
202 | - new View(), |
|
203 | - $util, |
|
204 | - new ArrayCache() |
|
205 | - ); |
|
206 | - }); |
|
207 | - |
|
208 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
209 | - $util = new Encryption\Util( |
|
210 | - new View(), |
|
211 | - $c->getUserManager(), |
|
212 | - $c->getGroupManager(), |
|
213 | - $c->getConfig() |
|
214 | - ); |
|
215 | - return new Encryption\File( |
|
216 | - $util, |
|
217 | - $c->getRootFolder(), |
|
218 | - $c->getShareManager() |
|
219 | - ); |
|
220 | - }); |
|
221 | - |
|
222 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
223 | - $view = new View(); |
|
224 | - $util = new Encryption\Util( |
|
225 | - $view, |
|
226 | - $c->getUserManager(), |
|
227 | - $c->getGroupManager(), |
|
228 | - $c->getConfig() |
|
229 | - ); |
|
230 | - |
|
231 | - return new Encryption\Keys\Storage($view, $util); |
|
232 | - }); |
|
233 | - $this->registerService('TagMapper', function (Server $c) { |
|
234 | - return new TagMapper($c->getDatabaseConnection()); |
|
235 | - }); |
|
236 | - |
|
237 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
238 | - $tagMapper = $c->query('TagMapper'); |
|
239 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
240 | - }); |
|
241 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
242 | - |
|
243 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
244 | - $config = $c->getConfig(); |
|
245 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
246 | - return new $factoryClass($this); |
|
247 | - }); |
|
248 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
249 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
250 | - }); |
|
251 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
252 | - |
|
253 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
254 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
255 | - }); |
|
256 | - $this->registerService('RootFolder', function (Server $c) { |
|
257 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
258 | - $view = new View(); |
|
259 | - $root = new Root( |
|
260 | - $manager, |
|
261 | - $view, |
|
262 | - null, |
|
263 | - $c->getUserMountCache(), |
|
264 | - $this->getLogger(), |
|
265 | - $this->getUserManager() |
|
266 | - ); |
|
267 | - $connector = new HookConnector($root, $view); |
|
268 | - $connector->viewToNode(); |
|
269 | - |
|
270 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
271 | - $previewConnector->connectWatcher(); |
|
272 | - |
|
273 | - return $root; |
|
274 | - }); |
|
275 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
276 | - |
|
277 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
278 | - return new LazyRoot(function () use ($c) { |
|
279 | - return $c->query('RootFolder'); |
|
280 | - }); |
|
281 | - }); |
|
282 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
283 | - |
|
284 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
285 | - $config = $c->getConfig(); |
|
286 | - return new \OC\User\Manager($config); |
|
287 | - }); |
|
288 | - $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
289 | - $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
290 | - |
|
291 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
292 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
293 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
294 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
295 | - }); |
|
296 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
297 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
298 | - }); |
|
299 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
300 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
301 | - }); |
|
302 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
303 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
304 | - }); |
|
305 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
306 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
307 | - }); |
|
308 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
309 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
310 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
311 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
312 | - }); |
|
313 | - return $groupManager; |
|
314 | - }); |
|
315 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
316 | - |
|
317 | - $this->registerService(Store::class, function (Server $c) { |
|
318 | - $session = $c->getSession(); |
|
319 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
320 | - $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
321 | - } else { |
|
322 | - $tokenProvider = null; |
|
323 | - } |
|
324 | - $logger = $c->getLogger(); |
|
325 | - return new Store($session, $logger, $tokenProvider); |
|
326 | - }); |
|
327 | - $this->registerAlias(IStore::class, Store::class); |
|
328 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
329 | - $dbConnection = $c->getDatabaseConnection(); |
|
330 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
331 | - }); |
|
332 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
333 | - $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
334 | - $crypto = $c->getCrypto(); |
|
335 | - $config = $c->getConfig(); |
|
336 | - $logger = $c->getLogger(); |
|
337 | - $timeFactory = new TimeFactory(); |
|
338 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
339 | - }); |
|
340 | - $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
341 | - |
|
342 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
343 | - $manager = $c->getUserManager(); |
|
344 | - $session = new \OC\Session\Memory(''); |
|
345 | - $timeFactory = new TimeFactory(); |
|
346 | - // Token providers might require a working database. This code |
|
347 | - // might however be called when ownCloud is not yet setup. |
|
348 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
349 | - $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
350 | - } else { |
|
351 | - $defaultTokenProvider = null; |
|
352 | - } |
|
353 | - |
|
354 | - $dispatcher = $c->getEventDispatcher(); |
|
355 | - |
|
356 | - $userSession = new \OC\User\Session( |
|
357 | - $manager, |
|
358 | - $session, |
|
359 | - $timeFactory, |
|
360 | - $defaultTokenProvider, |
|
361 | - $c->getConfig(), |
|
362 | - $c->getSecureRandom(), |
|
363 | - $c->getLockdownManager(), |
|
364 | - $c->getLogger() |
|
365 | - ); |
|
366 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
367 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
368 | - }); |
|
369 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
370 | - /** @var $user \OC\User\User */ |
|
371 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
372 | - }); |
|
373 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
374 | - /** @var $user \OC\User\User */ |
|
375 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
376 | - $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
377 | - }); |
|
378 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
379 | - /** @var $user \OC\User\User */ |
|
380 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
381 | - }); |
|
382 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
383 | - /** @var $user \OC\User\User */ |
|
384 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
385 | - }); |
|
386 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
387 | - /** @var $user \OC\User\User */ |
|
388 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
389 | - }); |
|
390 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
391 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
392 | - }); |
|
393 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
394 | - /** @var $user \OC\User\User */ |
|
395 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
396 | - }); |
|
397 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
398 | - /** @var $user \OC\User\User */ |
|
399 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
400 | - }); |
|
401 | - $userSession->listen('\OC\User', 'logout', function () { |
|
402 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
403 | - }); |
|
404 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
405 | - /** @var $user \OC\User\User */ |
|
406 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
407 | - $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
408 | - }); |
|
409 | - return $userSession; |
|
410 | - }); |
|
411 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
412 | - |
|
413 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
414 | - return new \OC\Authentication\TwoFactorAuth\Manager( |
|
415 | - $c->getAppManager(), |
|
416 | - $c->getSession(), |
|
417 | - $c->getConfig(), |
|
418 | - $c->getActivityManager(), |
|
419 | - $c->getLogger(), |
|
420 | - $c->query(\OC\Authentication\Token\IProvider::class), |
|
421 | - $c->query(ITimeFactory::class), |
|
422 | - $c->query(EventDispatcherInterface::class) |
|
423 | - ); |
|
424 | - }); |
|
425 | - |
|
426 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
427 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
428 | - |
|
429 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
430 | - return new \OC\AllConfig( |
|
431 | - $c->getSystemConfig() |
|
432 | - ); |
|
433 | - }); |
|
434 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
435 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
436 | - |
|
437 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
438 | - return new \OC\SystemConfig($config); |
|
439 | - }); |
|
440 | - |
|
441 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
442 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
443 | - }); |
|
444 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
445 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
446 | - |
|
447 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
448 | - return new \OC\L10N\Factory( |
|
449 | - $c->getConfig(), |
|
450 | - $c->getRequest(), |
|
451 | - $c->getUserSession(), |
|
452 | - \OC::$SERVERROOT |
|
453 | - ); |
|
454 | - }); |
|
455 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
456 | - |
|
457 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
458 | - $config = $c->getConfig(); |
|
459 | - $cacheFactory = $c->getMemCacheFactory(); |
|
460 | - $request = $c->getRequest(); |
|
461 | - return new \OC\URLGenerator( |
|
462 | - $config, |
|
463 | - $cacheFactory, |
|
464 | - $request |
|
465 | - ); |
|
466 | - }); |
|
467 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
468 | - |
|
469 | - $this->registerService('AppHelper', function ($c) { |
|
470 | - return new \OC\AppHelper(); |
|
471 | - }); |
|
472 | - $this->registerAlias('AppFetcher', AppFetcher::class); |
|
473 | - $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
474 | - |
|
475 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
476 | - return new Cache\File(); |
|
477 | - }); |
|
478 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
479 | - |
|
480 | - $this->registerService(Factory::class, function (Server $c) { |
|
481 | - |
|
482 | - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
483 | - '\\OC\\Memcache\\ArrayCache', |
|
484 | - '\\OC\\Memcache\\ArrayCache', |
|
485 | - '\\OC\\Memcache\\ArrayCache' |
|
486 | - ); |
|
487 | - $config = $c->getConfig(); |
|
488 | - $request = $c->getRequest(); |
|
489 | - $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
490 | - |
|
491 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
492 | - $v = \OC_App::getAppVersions(); |
|
493 | - $v['core'] = implode(',', \OC_Util::getVersion()); |
|
494 | - $version = implode(',', $v); |
|
495 | - $instanceId = \OC_Util::getInstanceId(); |
|
496 | - $path = \OC::$SERVERROOT; |
|
497 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl()); |
|
498 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
499 | - $config->getSystemValue('memcache.local', null), |
|
500 | - $config->getSystemValue('memcache.distributed', null), |
|
501 | - $config->getSystemValue('memcache.locking', null) |
|
502 | - ); |
|
503 | - } |
|
504 | - return $arrayCacheFactory; |
|
505 | - |
|
506 | - }); |
|
507 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
508 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
509 | - |
|
510 | - $this->registerService('RedisFactory', function (Server $c) { |
|
511 | - $systemConfig = $c->getSystemConfig(); |
|
512 | - return new RedisFactory($systemConfig); |
|
513 | - }); |
|
514 | - |
|
515 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
516 | - return new \OC\Activity\Manager( |
|
517 | - $c->getRequest(), |
|
518 | - $c->getUserSession(), |
|
519 | - $c->getConfig(), |
|
520 | - $c->query(IValidator::class) |
|
521 | - ); |
|
522 | - }); |
|
523 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
524 | - |
|
525 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
526 | - return new \OC\Activity\EventMerger( |
|
527 | - $c->getL10N('lib') |
|
528 | - ); |
|
529 | - }); |
|
530 | - $this->registerAlias(IValidator::class, Validator::class); |
|
531 | - |
|
532 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
533 | - return new AvatarManager( |
|
534 | - $c->query(\OC\User\Manager::class), |
|
535 | - $c->getAppDataDir('avatar'), |
|
536 | - $c->getL10N('lib'), |
|
537 | - $c->getLogger(), |
|
538 | - $c->getConfig() |
|
539 | - ); |
|
540 | - }); |
|
541 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
542 | - |
|
543 | - $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
544 | - |
|
545 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
546 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
547 | - $logger = Log::getLogClass($logType); |
|
548 | - call_user_func(array($logger, 'init')); |
|
549 | - $config = $this->getSystemConfig(); |
|
550 | - $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
551 | - |
|
552 | - return new Log($logger, $config, null, $registry); |
|
553 | - }); |
|
554 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
555 | - |
|
556 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
557 | - $config = $c->getConfig(); |
|
558 | - return new \OC\BackgroundJob\JobList( |
|
559 | - $c->getDatabaseConnection(), |
|
560 | - $config, |
|
561 | - new TimeFactory() |
|
562 | - ); |
|
563 | - }); |
|
564 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
565 | - |
|
566 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
567 | - $cacheFactory = $c->getMemCacheFactory(); |
|
568 | - $logger = $c->getLogger(); |
|
569 | - if ($cacheFactory->isAvailableLowLatency()) { |
|
570 | - $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
571 | - } else { |
|
572 | - $router = new \OC\Route\Router($logger); |
|
573 | - } |
|
574 | - return $router; |
|
575 | - }); |
|
576 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
577 | - |
|
578 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
579 | - return new Search(); |
|
580 | - }); |
|
581 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
582 | - |
|
583 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) { |
|
584 | - return new \OC\Security\RateLimiting\Limiter( |
|
585 | - $this->getUserSession(), |
|
586 | - $this->getRequest(), |
|
587 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
588 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
589 | - ); |
|
590 | - }); |
|
591 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
592 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
593 | - $this->getMemCacheFactory(), |
|
594 | - new \OC\AppFramework\Utility\TimeFactory() |
|
595 | - ); |
|
596 | - }); |
|
597 | - |
|
598 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
599 | - return new SecureRandom(); |
|
600 | - }); |
|
601 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
602 | - |
|
603 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
604 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
605 | - }); |
|
606 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
607 | - |
|
608 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
609 | - return new Hasher($c->getConfig()); |
|
610 | - }); |
|
611 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
612 | - |
|
613 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
614 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
615 | - }); |
|
616 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
617 | - |
|
618 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
619 | - $systemConfig = $c->getSystemConfig(); |
|
620 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
621 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
622 | - if (!$factory->isValidType($type)) { |
|
623 | - throw new \OC\DatabaseException('Invalid database type'); |
|
624 | - } |
|
625 | - $connectionParams = $factory->createConnectionParams(); |
|
626 | - $connection = $factory->getConnection($type, $connectionParams); |
|
627 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
628 | - return $connection; |
|
629 | - }); |
|
630 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
631 | - |
|
632 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
633 | - $config = $c->getConfig(); |
|
634 | - return new HTTPHelper( |
|
635 | - $config, |
|
636 | - $c->getHTTPClientService() |
|
637 | - ); |
|
638 | - }); |
|
639 | - |
|
640 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
641 | - $user = \OC_User::getUser(); |
|
642 | - $uid = $user ? $user : null; |
|
643 | - return new ClientService( |
|
644 | - $c->getConfig(), |
|
645 | - new \OC\Security\CertificateManager( |
|
646 | - $uid, |
|
647 | - new View(), |
|
648 | - $c->getConfig(), |
|
649 | - $c->getLogger(), |
|
650 | - $c->getSecureRandom() |
|
651 | - ) |
|
652 | - ); |
|
653 | - }); |
|
654 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
655 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
656 | - $eventLogger = new EventLogger(); |
|
657 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
658 | - // In debug mode, module is being activated by default |
|
659 | - $eventLogger->activate(); |
|
660 | - } |
|
661 | - return $eventLogger; |
|
662 | - }); |
|
663 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
664 | - |
|
665 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
666 | - $queryLogger = new QueryLogger(); |
|
667 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
668 | - // In debug mode, module is being activated by default |
|
669 | - $queryLogger->activate(); |
|
670 | - } |
|
671 | - return $queryLogger; |
|
672 | - }); |
|
673 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
674 | - |
|
675 | - $this->registerService(TempManager::class, function (Server $c) { |
|
676 | - return new TempManager( |
|
677 | - $c->getLogger(), |
|
678 | - $c->getConfig() |
|
679 | - ); |
|
680 | - }); |
|
681 | - $this->registerAlias('TempManager', TempManager::class); |
|
682 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
683 | - |
|
684 | - $this->registerService(AppManager::class, function (Server $c) { |
|
685 | - return new \OC\App\AppManager( |
|
686 | - $c->getUserSession(), |
|
687 | - $c->query(\OC\AppConfig::class), |
|
688 | - $c->getGroupManager(), |
|
689 | - $c->getMemCacheFactory(), |
|
690 | - $c->getEventDispatcher() |
|
691 | - ); |
|
692 | - }); |
|
693 | - $this->registerAlias('AppManager', AppManager::class); |
|
694 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
695 | - |
|
696 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
697 | - return new DateTimeZone( |
|
698 | - $c->getConfig(), |
|
699 | - $c->getSession() |
|
700 | - ); |
|
701 | - }); |
|
702 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
703 | - |
|
704 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
705 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
706 | - |
|
707 | - return new DateTimeFormatter( |
|
708 | - $c->getDateTimeZone()->getTimeZone(), |
|
709 | - $c->getL10N('lib', $language) |
|
710 | - ); |
|
711 | - }); |
|
712 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
713 | - |
|
714 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
715 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
716 | - $listener = new UserMountCacheListener($mountCache); |
|
717 | - $listener->listen($c->getUserManager()); |
|
718 | - return $mountCache; |
|
719 | - }); |
|
720 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
721 | - |
|
722 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
723 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
724 | - $mountCache = $c->query('UserMountCache'); |
|
725 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
726 | - |
|
727 | - // builtin providers |
|
728 | - |
|
729 | - $config = $c->getConfig(); |
|
730 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
731 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
732 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
733 | - |
|
734 | - return $manager; |
|
735 | - }); |
|
736 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
737 | - |
|
738 | - $this->registerService('IniWrapper', function ($c) { |
|
739 | - return new IniGetWrapper(); |
|
740 | - }); |
|
741 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
742 | - $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
743 | - if ($busClass) { |
|
744 | - list($app, $class) = explode('::', $busClass, 2); |
|
745 | - if ($c->getAppManager()->isInstalled($app)) { |
|
746 | - \OC_App::loadApp($app); |
|
747 | - return $c->query($class); |
|
748 | - } else { |
|
749 | - throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
750 | - } |
|
751 | - } else { |
|
752 | - $jobList = $c->getJobList(); |
|
753 | - return new CronBus($jobList); |
|
754 | - } |
|
755 | - }); |
|
756 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
757 | - return new TrustedDomainHelper($this->getConfig()); |
|
758 | - }); |
|
759 | - $this->registerService('Throttler', function (Server $c) { |
|
760 | - return new Throttler( |
|
761 | - $c->getDatabaseConnection(), |
|
762 | - new TimeFactory(), |
|
763 | - $c->getLogger(), |
|
764 | - $c->getConfig() |
|
765 | - ); |
|
766 | - }); |
|
767 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
768 | - // IConfig and IAppManager requires a working database. This code |
|
769 | - // might however be called when ownCloud is not yet setup. |
|
770 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
771 | - $config = $c->getConfig(); |
|
772 | - $appManager = $c->getAppManager(); |
|
773 | - } else { |
|
774 | - $config = null; |
|
775 | - $appManager = null; |
|
776 | - } |
|
777 | - |
|
778 | - return new Checker( |
|
779 | - new EnvironmentHelper(), |
|
780 | - new FileAccessHelper(), |
|
781 | - new AppLocator(), |
|
782 | - $config, |
|
783 | - $c->getMemCacheFactory(), |
|
784 | - $appManager, |
|
785 | - $c->getTempManager() |
|
786 | - ); |
|
787 | - }); |
|
788 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
789 | - if (isset($this['urlParams'])) { |
|
790 | - $urlParams = $this['urlParams']; |
|
791 | - } else { |
|
792 | - $urlParams = []; |
|
793 | - } |
|
794 | - |
|
795 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
796 | - && in_array('fakeinput', stream_get_wrappers()) |
|
797 | - ) { |
|
798 | - $stream = 'fakeinput://data'; |
|
799 | - } else { |
|
800 | - $stream = 'php://input'; |
|
801 | - } |
|
802 | - |
|
803 | - return new Request( |
|
804 | - [ |
|
805 | - 'get' => $_GET, |
|
806 | - 'post' => $_POST, |
|
807 | - 'files' => $_FILES, |
|
808 | - 'server' => $_SERVER, |
|
809 | - 'env' => $_ENV, |
|
810 | - 'cookies' => $_COOKIE, |
|
811 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
812 | - ? $_SERVER['REQUEST_METHOD'] |
|
813 | - : null, |
|
814 | - 'urlParams' => $urlParams, |
|
815 | - ], |
|
816 | - $this->getSecureRandom(), |
|
817 | - $this->getConfig(), |
|
818 | - $this->getCsrfTokenManager(), |
|
819 | - $stream |
|
820 | - ); |
|
821 | - }); |
|
822 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
823 | - |
|
824 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
825 | - return new Mailer( |
|
826 | - $c->getConfig(), |
|
827 | - $c->getLogger(), |
|
828 | - $c->query(Defaults::class), |
|
829 | - $c->getURLGenerator(), |
|
830 | - $c->getL10N('lib') |
|
831 | - ); |
|
832 | - }); |
|
833 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
834 | - |
|
835 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
836 | - $config = $c->getConfig(); |
|
837 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
838 | - if (is_null($factoryClass)) { |
|
839 | - throw new \Exception('ldapProviderFactory not set'); |
|
840 | - } |
|
841 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
842 | - $factory = new $factoryClass($this); |
|
843 | - return $factory->getLDAPProvider(); |
|
844 | - }); |
|
845 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
846 | - $ini = $c->getIniWrapper(); |
|
847 | - $config = $c->getConfig(); |
|
848 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
849 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
850 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
851 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
852 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
853 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
854 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
855 | - } |
|
856 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
857 | - } |
|
858 | - return new NoopLockingProvider(); |
|
859 | - }); |
|
860 | - $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
861 | - |
|
862 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
863 | - return new \OC\Files\Mount\Manager(); |
|
864 | - }); |
|
865 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
866 | - |
|
867 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
868 | - return new \OC\Files\Type\Detection( |
|
869 | - $c->getURLGenerator(), |
|
870 | - \OC::$configDir, |
|
871 | - \OC::$SERVERROOT . '/resources/config/' |
|
872 | - ); |
|
873 | - }); |
|
874 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
875 | - |
|
876 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
877 | - return new \OC\Files\Type\Loader( |
|
878 | - $c->getDatabaseConnection() |
|
879 | - ); |
|
880 | - }); |
|
881 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
882 | - $this->registerService(BundleFetcher::class, function () { |
|
883 | - return new BundleFetcher($this->getL10N('lib')); |
|
884 | - }); |
|
885 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
886 | - return new Manager( |
|
887 | - $c->query(IValidator::class) |
|
888 | - ); |
|
889 | - }); |
|
890 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
891 | - |
|
892 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
893 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
894 | - $manager->registerCapability(function () use ($c) { |
|
895 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
896 | - }); |
|
897 | - $manager->registerCapability(function () use ($c) { |
|
898 | - return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
899 | - }); |
|
900 | - return $manager; |
|
901 | - }); |
|
902 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
903 | - |
|
904 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
905 | - $config = $c->getConfig(); |
|
906 | - $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
907 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
908 | - $factory = new $factoryClass($this); |
|
909 | - $manager = $factory->getManager(); |
|
910 | - |
|
911 | - $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
912 | - $manager = $c->getUserManager(); |
|
913 | - $user = $manager->get($id); |
|
914 | - if(is_null($user)) { |
|
915 | - $l = $c->getL10N('core'); |
|
916 | - $displayName = $l->t('Unknown user'); |
|
917 | - } else { |
|
918 | - $displayName = $user->getDisplayName(); |
|
919 | - } |
|
920 | - return $displayName; |
|
921 | - }); |
|
922 | - |
|
923 | - return $manager; |
|
924 | - }); |
|
925 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
926 | - |
|
927 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
928 | - /* |
|
149 | + /** @var string */ |
|
150 | + private $webRoot; |
|
151 | + |
|
152 | + /** |
|
153 | + * @param string $webRoot |
|
154 | + * @param \OC\Config $config |
|
155 | + */ |
|
156 | + public function __construct($webRoot, \OC\Config $config) { |
|
157 | + parent::__construct(); |
|
158 | + $this->webRoot = $webRoot; |
|
159 | + |
|
160 | + $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
161 | + return $c; |
|
162 | + }); |
|
163 | + |
|
164 | + $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
165 | + $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
166 | + |
|
167 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
168 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
169 | + |
|
170 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
171 | + |
|
172 | + |
|
173 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
174 | + return new PreviewManager( |
|
175 | + $c->getConfig(), |
|
176 | + $c->getRootFolder(), |
|
177 | + $c->getAppDataDir('preview'), |
|
178 | + $c->getEventDispatcher(), |
|
179 | + $c->getSession()->get('user_id') |
|
180 | + ); |
|
181 | + }); |
|
182 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
183 | + |
|
184 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
185 | + return new \OC\Preview\Watcher( |
|
186 | + $c->getAppDataDir('preview') |
|
187 | + ); |
|
188 | + }); |
|
189 | + |
|
190 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
191 | + $view = new View(); |
|
192 | + $util = new Encryption\Util( |
|
193 | + $view, |
|
194 | + $c->getUserManager(), |
|
195 | + $c->getGroupManager(), |
|
196 | + $c->getConfig() |
|
197 | + ); |
|
198 | + return new Encryption\Manager( |
|
199 | + $c->getConfig(), |
|
200 | + $c->getLogger(), |
|
201 | + $c->getL10N('core'), |
|
202 | + new View(), |
|
203 | + $util, |
|
204 | + new ArrayCache() |
|
205 | + ); |
|
206 | + }); |
|
207 | + |
|
208 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
209 | + $util = new Encryption\Util( |
|
210 | + new View(), |
|
211 | + $c->getUserManager(), |
|
212 | + $c->getGroupManager(), |
|
213 | + $c->getConfig() |
|
214 | + ); |
|
215 | + return new Encryption\File( |
|
216 | + $util, |
|
217 | + $c->getRootFolder(), |
|
218 | + $c->getShareManager() |
|
219 | + ); |
|
220 | + }); |
|
221 | + |
|
222 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
223 | + $view = new View(); |
|
224 | + $util = new Encryption\Util( |
|
225 | + $view, |
|
226 | + $c->getUserManager(), |
|
227 | + $c->getGroupManager(), |
|
228 | + $c->getConfig() |
|
229 | + ); |
|
230 | + |
|
231 | + return new Encryption\Keys\Storage($view, $util); |
|
232 | + }); |
|
233 | + $this->registerService('TagMapper', function (Server $c) { |
|
234 | + return new TagMapper($c->getDatabaseConnection()); |
|
235 | + }); |
|
236 | + |
|
237 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
238 | + $tagMapper = $c->query('TagMapper'); |
|
239 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
240 | + }); |
|
241 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
242 | + |
|
243 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
244 | + $config = $c->getConfig(); |
|
245 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
246 | + return new $factoryClass($this); |
|
247 | + }); |
|
248 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
249 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
250 | + }); |
|
251 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
252 | + |
|
253 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
254 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
255 | + }); |
|
256 | + $this->registerService('RootFolder', function (Server $c) { |
|
257 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
258 | + $view = new View(); |
|
259 | + $root = new Root( |
|
260 | + $manager, |
|
261 | + $view, |
|
262 | + null, |
|
263 | + $c->getUserMountCache(), |
|
264 | + $this->getLogger(), |
|
265 | + $this->getUserManager() |
|
266 | + ); |
|
267 | + $connector = new HookConnector($root, $view); |
|
268 | + $connector->viewToNode(); |
|
269 | + |
|
270 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
271 | + $previewConnector->connectWatcher(); |
|
272 | + |
|
273 | + return $root; |
|
274 | + }); |
|
275 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
276 | + |
|
277 | + $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
278 | + return new LazyRoot(function () use ($c) { |
|
279 | + return $c->query('RootFolder'); |
|
280 | + }); |
|
281 | + }); |
|
282 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
283 | + |
|
284 | + $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
285 | + $config = $c->getConfig(); |
|
286 | + return new \OC\User\Manager($config); |
|
287 | + }); |
|
288 | + $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
289 | + $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
290 | + |
|
291 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
292 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
293 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
294 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
295 | + }); |
|
296 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
297 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
298 | + }); |
|
299 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
300 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
301 | + }); |
|
302 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
303 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
304 | + }); |
|
305 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
306 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
307 | + }); |
|
308 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
309 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
310 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
311 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
312 | + }); |
|
313 | + return $groupManager; |
|
314 | + }); |
|
315 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
316 | + |
|
317 | + $this->registerService(Store::class, function (Server $c) { |
|
318 | + $session = $c->getSession(); |
|
319 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
320 | + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
321 | + } else { |
|
322 | + $tokenProvider = null; |
|
323 | + } |
|
324 | + $logger = $c->getLogger(); |
|
325 | + return new Store($session, $logger, $tokenProvider); |
|
326 | + }); |
|
327 | + $this->registerAlias(IStore::class, Store::class); |
|
328 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
329 | + $dbConnection = $c->getDatabaseConnection(); |
|
330 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
331 | + }); |
|
332 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
333 | + $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
334 | + $crypto = $c->getCrypto(); |
|
335 | + $config = $c->getConfig(); |
|
336 | + $logger = $c->getLogger(); |
|
337 | + $timeFactory = new TimeFactory(); |
|
338 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
339 | + }); |
|
340 | + $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
341 | + |
|
342 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
343 | + $manager = $c->getUserManager(); |
|
344 | + $session = new \OC\Session\Memory(''); |
|
345 | + $timeFactory = new TimeFactory(); |
|
346 | + // Token providers might require a working database. This code |
|
347 | + // might however be called when ownCloud is not yet setup. |
|
348 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
349 | + $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
350 | + } else { |
|
351 | + $defaultTokenProvider = null; |
|
352 | + } |
|
353 | + |
|
354 | + $dispatcher = $c->getEventDispatcher(); |
|
355 | + |
|
356 | + $userSession = new \OC\User\Session( |
|
357 | + $manager, |
|
358 | + $session, |
|
359 | + $timeFactory, |
|
360 | + $defaultTokenProvider, |
|
361 | + $c->getConfig(), |
|
362 | + $c->getSecureRandom(), |
|
363 | + $c->getLockdownManager(), |
|
364 | + $c->getLogger() |
|
365 | + ); |
|
366 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
367 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
368 | + }); |
|
369 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
370 | + /** @var $user \OC\User\User */ |
|
371 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
372 | + }); |
|
373 | + $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
374 | + /** @var $user \OC\User\User */ |
|
375 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
376 | + $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
377 | + }); |
|
378 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
379 | + /** @var $user \OC\User\User */ |
|
380 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
381 | + }); |
|
382 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
383 | + /** @var $user \OC\User\User */ |
|
384 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
385 | + }); |
|
386 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
387 | + /** @var $user \OC\User\User */ |
|
388 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
389 | + }); |
|
390 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
391 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
392 | + }); |
|
393 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
394 | + /** @var $user \OC\User\User */ |
|
395 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
396 | + }); |
|
397 | + $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
398 | + /** @var $user \OC\User\User */ |
|
399 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
400 | + }); |
|
401 | + $userSession->listen('\OC\User', 'logout', function () { |
|
402 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
403 | + }); |
|
404 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
405 | + /** @var $user \OC\User\User */ |
|
406 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
407 | + $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
408 | + }); |
|
409 | + return $userSession; |
|
410 | + }); |
|
411 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
412 | + |
|
413 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
414 | + return new \OC\Authentication\TwoFactorAuth\Manager( |
|
415 | + $c->getAppManager(), |
|
416 | + $c->getSession(), |
|
417 | + $c->getConfig(), |
|
418 | + $c->getActivityManager(), |
|
419 | + $c->getLogger(), |
|
420 | + $c->query(\OC\Authentication\Token\IProvider::class), |
|
421 | + $c->query(ITimeFactory::class), |
|
422 | + $c->query(EventDispatcherInterface::class) |
|
423 | + ); |
|
424 | + }); |
|
425 | + |
|
426 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
427 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
428 | + |
|
429 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
430 | + return new \OC\AllConfig( |
|
431 | + $c->getSystemConfig() |
|
432 | + ); |
|
433 | + }); |
|
434 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
435 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
436 | + |
|
437 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
438 | + return new \OC\SystemConfig($config); |
|
439 | + }); |
|
440 | + |
|
441 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
442 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
443 | + }); |
|
444 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
445 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
446 | + |
|
447 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
448 | + return new \OC\L10N\Factory( |
|
449 | + $c->getConfig(), |
|
450 | + $c->getRequest(), |
|
451 | + $c->getUserSession(), |
|
452 | + \OC::$SERVERROOT |
|
453 | + ); |
|
454 | + }); |
|
455 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
456 | + |
|
457 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
458 | + $config = $c->getConfig(); |
|
459 | + $cacheFactory = $c->getMemCacheFactory(); |
|
460 | + $request = $c->getRequest(); |
|
461 | + return new \OC\URLGenerator( |
|
462 | + $config, |
|
463 | + $cacheFactory, |
|
464 | + $request |
|
465 | + ); |
|
466 | + }); |
|
467 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
468 | + |
|
469 | + $this->registerService('AppHelper', function ($c) { |
|
470 | + return new \OC\AppHelper(); |
|
471 | + }); |
|
472 | + $this->registerAlias('AppFetcher', AppFetcher::class); |
|
473 | + $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
474 | + |
|
475 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
476 | + return new Cache\File(); |
|
477 | + }); |
|
478 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
479 | + |
|
480 | + $this->registerService(Factory::class, function (Server $c) { |
|
481 | + |
|
482 | + $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
483 | + '\\OC\\Memcache\\ArrayCache', |
|
484 | + '\\OC\\Memcache\\ArrayCache', |
|
485 | + '\\OC\\Memcache\\ArrayCache' |
|
486 | + ); |
|
487 | + $config = $c->getConfig(); |
|
488 | + $request = $c->getRequest(); |
|
489 | + $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
490 | + |
|
491 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
492 | + $v = \OC_App::getAppVersions(); |
|
493 | + $v['core'] = implode(',', \OC_Util::getVersion()); |
|
494 | + $version = implode(',', $v); |
|
495 | + $instanceId = \OC_Util::getInstanceId(); |
|
496 | + $path = \OC::$SERVERROOT; |
|
497 | + $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl()); |
|
498 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
499 | + $config->getSystemValue('memcache.local', null), |
|
500 | + $config->getSystemValue('memcache.distributed', null), |
|
501 | + $config->getSystemValue('memcache.locking', null) |
|
502 | + ); |
|
503 | + } |
|
504 | + return $arrayCacheFactory; |
|
505 | + |
|
506 | + }); |
|
507 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
508 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
509 | + |
|
510 | + $this->registerService('RedisFactory', function (Server $c) { |
|
511 | + $systemConfig = $c->getSystemConfig(); |
|
512 | + return new RedisFactory($systemConfig); |
|
513 | + }); |
|
514 | + |
|
515 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
516 | + return new \OC\Activity\Manager( |
|
517 | + $c->getRequest(), |
|
518 | + $c->getUserSession(), |
|
519 | + $c->getConfig(), |
|
520 | + $c->query(IValidator::class) |
|
521 | + ); |
|
522 | + }); |
|
523 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
524 | + |
|
525 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
526 | + return new \OC\Activity\EventMerger( |
|
527 | + $c->getL10N('lib') |
|
528 | + ); |
|
529 | + }); |
|
530 | + $this->registerAlias(IValidator::class, Validator::class); |
|
531 | + |
|
532 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
533 | + return new AvatarManager( |
|
534 | + $c->query(\OC\User\Manager::class), |
|
535 | + $c->getAppDataDir('avatar'), |
|
536 | + $c->getL10N('lib'), |
|
537 | + $c->getLogger(), |
|
538 | + $c->getConfig() |
|
539 | + ); |
|
540 | + }); |
|
541 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
542 | + |
|
543 | + $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
544 | + |
|
545 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
546 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
547 | + $logger = Log::getLogClass($logType); |
|
548 | + call_user_func(array($logger, 'init')); |
|
549 | + $config = $this->getSystemConfig(); |
|
550 | + $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
551 | + |
|
552 | + return new Log($logger, $config, null, $registry); |
|
553 | + }); |
|
554 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
555 | + |
|
556 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
557 | + $config = $c->getConfig(); |
|
558 | + return new \OC\BackgroundJob\JobList( |
|
559 | + $c->getDatabaseConnection(), |
|
560 | + $config, |
|
561 | + new TimeFactory() |
|
562 | + ); |
|
563 | + }); |
|
564 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
565 | + |
|
566 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
567 | + $cacheFactory = $c->getMemCacheFactory(); |
|
568 | + $logger = $c->getLogger(); |
|
569 | + if ($cacheFactory->isAvailableLowLatency()) { |
|
570 | + $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
571 | + } else { |
|
572 | + $router = new \OC\Route\Router($logger); |
|
573 | + } |
|
574 | + return $router; |
|
575 | + }); |
|
576 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
577 | + |
|
578 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
579 | + return new Search(); |
|
580 | + }); |
|
581 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
582 | + |
|
583 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) { |
|
584 | + return new \OC\Security\RateLimiting\Limiter( |
|
585 | + $this->getUserSession(), |
|
586 | + $this->getRequest(), |
|
587 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
588 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
589 | + ); |
|
590 | + }); |
|
591 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
592 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
593 | + $this->getMemCacheFactory(), |
|
594 | + new \OC\AppFramework\Utility\TimeFactory() |
|
595 | + ); |
|
596 | + }); |
|
597 | + |
|
598 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
599 | + return new SecureRandom(); |
|
600 | + }); |
|
601 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
602 | + |
|
603 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
604 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
605 | + }); |
|
606 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
607 | + |
|
608 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
609 | + return new Hasher($c->getConfig()); |
|
610 | + }); |
|
611 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
612 | + |
|
613 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
614 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
615 | + }); |
|
616 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
617 | + |
|
618 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
619 | + $systemConfig = $c->getSystemConfig(); |
|
620 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
621 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
622 | + if (!$factory->isValidType($type)) { |
|
623 | + throw new \OC\DatabaseException('Invalid database type'); |
|
624 | + } |
|
625 | + $connectionParams = $factory->createConnectionParams(); |
|
626 | + $connection = $factory->getConnection($type, $connectionParams); |
|
627 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
628 | + return $connection; |
|
629 | + }); |
|
630 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
631 | + |
|
632 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
633 | + $config = $c->getConfig(); |
|
634 | + return new HTTPHelper( |
|
635 | + $config, |
|
636 | + $c->getHTTPClientService() |
|
637 | + ); |
|
638 | + }); |
|
639 | + |
|
640 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
641 | + $user = \OC_User::getUser(); |
|
642 | + $uid = $user ? $user : null; |
|
643 | + return new ClientService( |
|
644 | + $c->getConfig(), |
|
645 | + new \OC\Security\CertificateManager( |
|
646 | + $uid, |
|
647 | + new View(), |
|
648 | + $c->getConfig(), |
|
649 | + $c->getLogger(), |
|
650 | + $c->getSecureRandom() |
|
651 | + ) |
|
652 | + ); |
|
653 | + }); |
|
654 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
655 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
656 | + $eventLogger = new EventLogger(); |
|
657 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
658 | + // In debug mode, module is being activated by default |
|
659 | + $eventLogger->activate(); |
|
660 | + } |
|
661 | + return $eventLogger; |
|
662 | + }); |
|
663 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
664 | + |
|
665 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
666 | + $queryLogger = new QueryLogger(); |
|
667 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
668 | + // In debug mode, module is being activated by default |
|
669 | + $queryLogger->activate(); |
|
670 | + } |
|
671 | + return $queryLogger; |
|
672 | + }); |
|
673 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
674 | + |
|
675 | + $this->registerService(TempManager::class, function (Server $c) { |
|
676 | + return new TempManager( |
|
677 | + $c->getLogger(), |
|
678 | + $c->getConfig() |
|
679 | + ); |
|
680 | + }); |
|
681 | + $this->registerAlias('TempManager', TempManager::class); |
|
682 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
683 | + |
|
684 | + $this->registerService(AppManager::class, function (Server $c) { |
|
685 | + return new \OC\App\AppManager( |
|
686 | + $c->getUserSession(), |
|
687 | + $c->query(\OC\AppConfig::class), |
|
688 | + $c->getGroupManager(), |
|
689 | + $c->getMemCacheFactory(), |
|
690 | + $c->getEventDispatcher() |
|
691 | + ); |
|
692 | + }); |
|
693 | + $this->registerAlias('AppManager', AppManager::class); |
|
694 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
695 | + |
|
696 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
697 | + return new DateTimeZone( |
|
698 | + $c->getConfig(), |
|
699 | + $c->getSession() |
|
700 | + ); |
|
701 | + }); |
|
702 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
703 | + |
|
704 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
705 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
706 | + |
|
707 | + return new DateTimeFormatter( |
|
708 | + $c->getDateTimeZone()->getTimeZone(), |
|
709 | + $c->getL10N('lib', $language) |
|
710 | + ); |
|
711 | + }); |
|
712 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
713 | + |
|
714 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
715 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
716 | + $listener = new UserMountCacheListener($mountCache); |
|
717 | + $listener->listen($c->getUserManager()); |
|
718 | + return $mountCache; |
|
719 | + }); |
|
720 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
721 | + |
|
722 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
723 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
724 | + $mountCache = $c->query('UserMountCache'); |
|
725 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
726 | + |
|
727 | + // builtin providers |
|
728 | + |
|
729 | + $config = $c->getConfig(); |
|
730 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
731 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
732 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
733 | + |
|
734 | + return $manager; |
|
735 | + }); |
|
736 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
737 | + |
|
738 | + $this->registerService('IniWrapper', function ($c) { |
|
739 | + return new IniGetWrapper(); |
|
740 | + }); |
|
741 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
742 | + $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
743 | + if ($busClass) { |
|
744 | + list($app, $class) = explode('::', $busClass, 2); |
|
745 | + if ($c->getAppManager()->isInstalled($app)) { |
|
746 | + \OC_App::loadApp($app); |
|
747 | + return $c->query($class); |
|
748 | + } else { |
|
749 | + throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
750 | + } |
|
751 | + } else { |
|
752 | + $jobList = $c->getJobList(); |
|
753 | + return new CronBus($jobList); |
|
754 | + } |
|
755 | + }); |
|
756 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
757 | + return new TrustedDomainHelper($this->getConfig()); |
|
758 | + }); |
|
759 | + $this->registerService('Throttler', function (Server $c) { |
|
760 | + return new Throttler( |
|
761 | + $c->getDatabaseConnection(), |
|
762 | + new TimeFactory(), |
|
763 | + $c->getLogger(), |
|
764 | + $c->getConfig() |
|
765 | + ); |
|
766 | + }); |
|
767 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
768 | + // IConfig and IAppManager requires a working database. This code |
|
769 | + // might however be called when ownCloud is not yet setup. |
|
770 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
771 | + $config = $c->getConfig(); |
|
772 | + $appManager = $c->getAppManager(); |
|
773 | + } else { |
|
774 | + $config = null; |
|
775 | + $appManager = null; |
|
776 | + } |
|
777 | + |
|
778 | + return new Checker( |
|
779 | + new EnvironmentHelper(), |
|
780 | + new FileAccessHelper(), |
|
781 | + new AppLocator(), |
|
782 | + $config, |
|
783 | + $c->getMemCacheFactory(), |
|
784 | + $appManager, |
|
785 | + $c->getTempManager() |
|
786 | + ); |
|
787 | + }); |
|
788 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
789 | + if (isset($this['urlParams'])) { |
|
790 | + $urlParams = $this['urlParams']; |
|
791 | + } else { |
|
792 | + $urlParams = []; |
|
793 | + } |
|
794 | + |
|
795 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
796 | + && in_array('fakeinput', stream_get_wrappers()) |
|
797 | + ) { |
|
798 | + $stream = 'fakeinput://data'; |
|
799 | + } else { |
|
800 | + $stream = 'php://input'; |
|
801 | + } |
|
802 | + |
|
803 | + return new Request( |
|
804 | + [ |
|
805 | + 'get' => $_GET, |
|
806 | + 'post' => $_POST, |
|
807 | + 'files' => $_FILES, |
|
808 | + 'server' => $_SERVER, |
|
809 | + 'env' => $_ENV, |
|
810 | + 'cookies' => $_COOKIE, |
|
811 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
812 | + ? $_SERVER['REQUEST_METHOD'] |
|
813 | + : null, |
|
814 | + 'urlParams' => $urlParams, |
|
815 | + ], |
|
816 | + $this->getSecureRandom(), |
|
817 | + $this->getConfig(), |
|
818 | + $this->getCsrfTokenManager(), |
|
819 | + $stream |
|
820 | + ); |
|
821 | + }); |
|
822 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
823 | + |
|
824 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
825 | + return new Mailer( |
|
826 | + $c->getConfig(), |
|
827 | + $c->getLogger(), |
|
828 | + $c->query(Defaults::class), |
|
829 | + $c->getURLGenerator(), |
|
830 | + $c->getL10N('lib') |
|
831 | + ); |
|
832 | + }); |
|
833 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
834 | + |
|
835 | + $this->registerService('LDAPProvider', function (Server $c) { |
|
836 | + $config = $c->getConfig(); |
|
837 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
838 | + if (is_null($factoryClass)) { |
|
839 | + throw new \Exception('ldapProviderFactory not set'); |
|
840 | + } |
|
841 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
842 | + $factory = new $factoryClass($this); |
|
843 | + return $factory->getLDAPProvider(); |
|
844 | + }); |
|
845 | + $this->registerService(ILockingProvider::class, function (Server $c) { |
|
846 | + $ini = $c->getIniWrapper(); |
|
847 | + $config = $c->getConfig(); |
|
848 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
849 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
850 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
851 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
852 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
853 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
854 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
855 | + } |
|
856 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
857 | + } |
|
858 | + return new NoopLockingProvider(); |
|
859 | + }); |
|
860 | + $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
861 | + |
|
862 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
863 | + return new \OC\Files\Mount\Manager(); |
|
864 | + }); |
|
865 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
866 | + |
|
867 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
868 | + return new \OC\Files\Type\Detection( |
|
869 | + $c->getURLGenerator(), |
|
870 | + \OC::$configDir, |
|
871 | + \OC::$SERVERROOT . '/resources/config/' |
|
872 | + ); |
|
873 | + }); |
|
874 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
875 | + |
|
876 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
877 | + return new \OC\Files\Type\Loader( |
|
878 | + $c->getDatabaseConnection() |
|
879 | + ); |
|
880 | + }); |
|
881 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
882 | + $this->registerService(BundleFetcher::class, function () { |
|
883 | + return new BundleFetcher($this->getL10N('lib')); |
|
884 | + }); |
|
885 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
886 | + return new Manager( |
|
887 | + $c->query(IValidator::class) |
|
888 | + ); |
|
889 | + }); |
|
890 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
891 | + |
|
892 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
893 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
894 | + $manager->registerCapability(function () use ($c) { |
|
895 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
896 | + }); |
|
897 | + $manager->registerCapability(function () use ($c) { |
|
898 | + return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
899 | + }); |
|
900 | + return $manager; |
|
901 | + }); |
|
902 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
903 | + |
|
904 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
905 | + $config = $c->getConfig(); |
|
906 | + $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
907 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
908 | + $factory = new $factoryClass($this); |
|
909 | + $manager = $factory->getManager(); |
|
910 | + |
|
911 | + $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
912 | + $manager = $c->getUserManager(); |
|
913 | + $user = $manager->get($id); |
|
914 | + if(is_null($user)) { |
|
915 | + $l = $c->getL10N('core'); |
|
916 | + $displayName = $l->t('Unknown user'); |
|
917 | + } else { |
|
918 | + $displayName = $user->getDisplayName(); |
|
919 | + } |
|
920 | + return $displayName; |
|
921 | + }); |
|
922 | + |
|
923 | + return $manager; |
|
924 | + }); |
|
925 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
926 | + |
|
927 | + $this->registerService('ThemingDefaults', function (Server $c) { |
|
928 | + /* |
|
929 | 929 | * Dark magic for autoloader. |
930 | 930 | * If we do a class_exists it will try to load the class which will |
931 | 931 | * make composer cache the result. Resulting in errors when enabling |
932 | 932 | * the theming app. |
933 | 933 | */ |
934 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
935 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
936 | - $classExists = true; |
|
937 | - } else { |
|
938 | - $classExists = false; |
|
939 | - } |
|
940 | - |
|
941 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
942 | - return new ThemingDefaults( |
|
943 | - $c->getConfig(), |
|
944 | - $c->getL10N('theming'), |
|
945 | - $c->getURLGenerator(), |
|
946 | - $c->getAppDataDir('theming'), |
|
947 | - $c->getMemCacheFactory(), |
|
948 | - new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming')), |
|
949 | - $this->getAppManager() |
|
950 | - ); |
|
951 | - } |
|
952 | - return new \OC_Defaults(); |
|
953 | - }); |
|
954 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
955 | - /** @var Factory $cacheFactory */ |
|
956 | - $cacheFactory = $c->query(Factory::class); |
|
957 | - return new SCSSCacher( |
|
958 | - $c->getLogger(), |
|
959 | - $c->query(\OC\Files\AppData\Factory::class), |
|
960 | - $c->getURLGenerator(), |
|
961 | - $c->getConfig(), |
|
962 | - $c->getThemingDefaults(), |
|
963 | - \OC::$SERVERROOT, |
|
964 | - $cacheFactory->createDistributed('SCSS') |
|
965 | - ); |
|
966 | - }); |
|
967 | - $this->registerService(EventDispatcher::class, function () { |
|
968 | - return new EventDispatcher(); |
|
969 | - }); |
|
970 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
971 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
972 | - |
|
973 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
974 | - // FIXME: Instantiiated here due to cyclic dependency |
|
975 | - $request = new Request( |
|
976 | - [ |
|
977 | - 'get' => $_GET, |
|
978 | - 'post' => $_POST, |
|
979 | - 'files' => $_FILES, |
|
980 | - 'server' => $_SERVER, |
|
981 | - 'env' => $_ENV, |
|
982 | - 'cookies' => $_COOKIE, |
|
983 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
984 | - ? $_SERVER['REQUEST_METHOD'] |
|
985 | - : null, |
|
986 | - ], |
|
987 | - $c->getSecureRandom(), |
|
988 | - $c->getConfig() |
|
989 | - ); |
|
990 | - |
|
991 | - return new CryptoWrapper( |
|
992 | - $c->getConfig(), |
|
993 | - $c->getCrypto(), |
|
994 | - $c->getSecureRandom(), |
|
995 | - $request |
|
996 | - ); |
|
997 | - }); |
|
998 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
999 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
1000 | - |
|
1001 | - return new CsrfTokenManager( |
|
1002 | - $tokenGenerator, |
|
1003 | - $c->query(SessionStorage::class) |
|
1004 | - ); |
|
1005 | - }); |
|
1006 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
1007 | - return new SessionStorage($c->getSession()); |
|
1008 | - }); |
|
1009 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1010 | - return new ContentSecurityPolicyManager(); |
|
1011 | - }); |
|
1012 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
1013 | - |
|
1014 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1015 | - return new ContentSecurityPolicyNonceManager( |
|
1016 | - $c->getCsrfTokenManager(), |
|
1017 | - $c->getRequest() |
|
1018 | - ); |
|
1019 | - }); |
|
1020 | - |
|
1021 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1022 | - $config = $c->getConfig(); |
|
1023 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
1024 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
1025 | - $factory = new $factoryClass($this); |
|
1026 | - |
|
1027 | - $manager = new \OC\Share20\Manager( |
|
1028 | - $c->getLogger(), |
|
1029 | - $c->getConfig(), |
|
1030 | - $c->getSecureRandom(), |
|
1031 | - $c->getHasher(), |
|
1032 | - $c->getMountManager(), |
|
1033 | - $c->getGroupManager(), |
|
1034 | - $c->getL10N('lib'), |
|
1035 | - $c->getL10NFactory(), |
|
1036 | - $factory, |
|
1037 | - $c->getUserManager(), |
|
1038 | - $c->getLazyRootFolder(), |
|
1039 | - $c->getEventDispatcher(), |
|
1040 | - $c->getMailer(), |
|
1041 | - $c->getURLGenerator(), |
|
1042 | - $c->getThemingDefaults() |
|
1043 | - ); |
|
1044 | - |
|
1045 | - return $manager; |
|
1046 | - }); |
|
1047 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
1048 | - |
|
1049 | - $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
1050 | - $instance = new Collaboration\Collaborators\Search($c); |
|
1051 | - |
|
1052 | - // register default plugins |
|
1053 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
1054 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
1055 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
1056 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
1057 | - |
|
1058 | - return $instance; |
|
1059 | - }); |
|
1060 | - $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
1061 | - |
|
1062 | - $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
1063 | - |
|
1064 | - $this->registerService('SettingsManager', function (Server $c) { |
|
1065 | - $manager = new \OC\Settings\Manager( |
|
1066 | - $c->getLogger(), |
|
1067 | - $c->getDatabaseConnection(), |
|
1068 | - $c->getL10N('lib'), |
|
1069 | - $c->getConfig(), |
|
1070 | - $c->getEncryptionManager(), |
|
1071 | - $c->getUserManager(), |
|
1072 | - $c->getLockingProvider(), |
|
1073 | - $c->getRequest(), |
|
1074 | - $c->getURLGenerator(), |
|
1075 | - $c->query(AccountManager::class), |
|
1076 | - $c->getGroupManager(), |
|
1077 | - $c->getL10NFactory(), |
|
1078 | - $c->getAppManager() |
|
1079 | - ); |
|
1080 | - return $manager; |
|
1081 | - }); |
|
1082 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1083 | - return new \OC\Files\AppData\Factory( |
|
1084 | - $c->getRootFolder(), |
|
1085 | - $c->getSystemConfig() |
|
1086 | - ); |
|
1087 | - }); |
|
1088 | - |
|
1089 | - $this->registerService('LockdownManager', function (Server $c) { |
|
1090 | - return new LockdownManager(function () use ($c) { |
|
1091 | - return $c->getSession(); |
|
1092 | - }); |
|
1093 | - }); |
|
1094 | - |
|
1095 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1096 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
1097 | - }); |
|
1098 | - |
|
1099 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1100 | - return new CloudIdManager(); |
|
1101 | - }); |
|
1102 | - |
|
1103 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1104 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1105 | - |
|
1106 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1107 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1108 | - |
|
1109 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1110 | - return new Defaults( |
|
1111 | - $c->getThemingDefaults() |
|
1112 | - ); |
|
1113 | - }); |
|
1114 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1115 | - |
|
1116 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1117 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1118 | - }); |
|
1119 | - |
|
1120 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
1121 | - return new ShareHelper( |
|
1122 | - $c->query(\OCP\Share\IManager::class) |
|
1123 | - ); |
|
1124 | - }); |
|
1125 | - |
|
1126 | - $this->registerService(Installer::class, function(Server $c) { |
|
1127 | - return new Installer( |
|
1128 | - $c->getAppFetcher(), |
|
1129 | - $c->getHTTPClientService(), |
|
1130 | - $c->getTempManager(), |
|
1131 | - $c->getLogger(), |
|
1132 | - $c->getConfig() |
|
1133 | - ); |
|
1134 | - }); |
|
1135 | - |
|
1136 | - $this->registerService(IApiFactory::class, function(Server $c) { |
|
1137 | - return new ApiFactory($c->getHTTPClientService()); |
|
1138 | - }); |
|
1139 | - |
|
1140 | - $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
1141 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
1142 | - return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
1143 | - }); |
|
1144 | - |
|
1145 | - $this->registerService(IContactsStore::class, function(Server $c) { |
|
1146 | - return new ContactsStore( |
|
1147 | - $c->getContactsManager(), |
|
1148 | - $c->getConfig(), |
|
1149 | - $c->getUserManager(), |
|
1150 | - $c->getGroupManager() |
|
1151 | - ); |
|
1152 | - }); |
|
1153 | - $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
1154 | - |
|
1155 | - $this->connectDispatcher(); |
|
1156 | - } |
|
1157 | - |
|
1158 | - /** |
|
1159 | - * @return \OCP\Calendar\IManager |
|
1160 | - */ |
|
1161 | - public function getCalendarManager() { |
|
1162 | - return $this->query('CalendarManager'); |
|
1163 | - } |
|
1164 | - |
|
1165 | - private function connectDispatcher() { |
|
1166 | - $dispatcher = $this->getEventDispatcher(); |
|
1167 | - |
|
1168 | - // Delete avatar on user deletion |
|
1169 | - $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
1170 | - $logger = $this->getLogger(); |
|
1171 | - $manager = $this->getAvatarManager(); |
|
1172 | - /** @var IUser $user */ |
|
1173 | - $user = $e->getSubject(); |
|
1174 | - |
|
1175 | - try { |
|
1176 | - $avatar = $manager->getAvatar($user->getUID()); |
|
1177 | - $avatar->remove(); |
|
1178 | - } catch (NotFoundException $e) { |
|
1179 | - // no avatar to remove |
|
1180 | - } catch (\Exception $e) { |
|
1181 | - // Ignore exceptions |
|
1182 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1183 | - } |
|
1184 | - }); |
|
1185 | - |
|
1186 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1187 | - $manager = $this->getAvatarManager(); |
|
1188 | - /** @var IUser $user */ |
|
1189 | - $user = $e->getSubject(); |
|
1190 | - $feature = $e->getArgument('feature'); |
|
1191 | - $oldValue = $e->getArgument('oldValue'); |
|
1192 | - $value = $e->getArgument('value'); |
|
1193 | - |
|
1194 | - try { |
|
1195 | - $avatar = $manager->getAvatar($user->getUID()); |
|
1196 | - $avatar->userChanged($feature, $oldValue, $value); |
|
1197 | - } catch (NotFoundException $e) { |
|
1198 | - // no avatar to remove |
|
1199 | - } |
|
1200 | - }); |
|
1201 | - } |
|
1202 | - |
|
1203 | - /** |
|
1204 | - * @return \OCP\Contacts\IManager |
|
1205 | - */ |
|
1206 | - public function getContactsManager() { |
|
1207 | - return $this->query('ContactsManager'); |
|
1208 | - } |
|
1209 | - |
|
1210 | - /** |
|
1211 | - * @return \OC\Encryption\Manager |
|
1212 | - */ |
|
1213 | - public function getEncryptionManager() { |
|
1214 | - return $this->query('EncryptionManager'); |
|
1215 | - } |
|
1216 | - |
|
1217 | - /** |
|
1218 | - * @return \OC\Encryption\File |
|
1219 | - */ |
|
1220 | - public function getEncryptionFilesHelper() { |
|
1221 | - return $this->query('EncryptionFileHelper'); |
|
1222 | - } |
|
1223 | - |
|
1224 | - /** |
|
1225 | - * @return \OCP\Encryption\Keys\IStorage |
|
1226 | - */ |
|
1227 | - public function getEncryptionKeyStorage() { |
|
1228 | - return $this->query('EncryptionKeyStorage'); |
|
1229 | - } |
|
1230 | - |
|
1231 | - /** |
|
1232 | - * The current request object holding all information about the request |
|
1233 | - * currently being processed is returned from this method. |
|
1234 | - * In case the current execution was not initiated by a web request null is returned |
|
1235 | - * |
|
1236 | - * @return \OCP\IRequest |
|
1237 | - */ |
|
1238 | - public function getRequest() { |
|
1239 | - return $this->query('Request'); |
|
1240 | - } |
|
1241 | - |
|
1242 | - /** |
|
1243 | - * Returns the preview manager which can create preview images for a given file |
|
1244 | - * |
|
1245 | - * @return \OCP\IPreview |
|
1246 | - */ |
|
1247 | - public function getPreviewManager() { |
|
1248 | - return $this->query('PreviewManager'); |
|
1249 | - } |
|
1250 | - |
|
1251 | - /** |
|
1252 | - * Returns the tag manager which can get and set tags for different object types |
|
1253 | - * |
|
1254 | - * @see \OCP\ITagManager::load() |
|
1255 | - * @return \OCP\ITagManager |
|
1256 | - */ |
|
1257 | - public function getTagManager() { |
|
1258 | - return $this->query('TagManager'); |
|
1259 | - } |
|
1260 | - |
|
1261 | - /** |
|
1262 | - * Returns the system-tag manager |
|
1263 | - * |
|
1264 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1265 | - * |
|
1266 | - * @since 9.0.0 |
|
1267 | - */ |
|
1268 | - public function getSystemTagManager() { |
|
1269 | - return $this->query('SystemTagManager'); |
|
1270 | - } |
|
1271 | - |
|
1272 | - /** |
|
1273 | - * Returns the system-tag object mapper |
|
1274 | - * |
|
1275 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1276 | - * |
|
1277 | - * @since 9.0.0 |
|
1278 | - */ |
|
1279 | - public function getSystemTagObjectMapper() { |
|
1280 | - return $this->query('SystemTagObjectMapper'); |
|
1281 | - } |
|
1282 | - |
|
1283 | - /** |
|
1284 | - * Returns the avatar manager, used for avatar functionality |
|
1285 | - * |
|
1286 | - * @return \OCP\IAvatarManager |
|
1287 | - */ |
|
1288 | - public function getAvatarManager() { |
|
1289 | - return $this->query('AvatarManager'); |
|
1290 | - } |
|
1291 | - |
|
1292 | - /** |
|
1293 | - * Returns the root folder of ownCloud's data directory |
|
1294 | - * |
|
1295 | - * @return \OCP\Files\IRootFolder |
|
1296 | - */ |
|
1297 | - public function getRootFolder() { |
|
1298 | - return $this->query('LazyRootFolder'); |
|
1299 | - } |
|
1300 | - |
|
1301 | - /** |
|
1302 | - * Returns the root folder of ownCloud's data directory |
|
1303 | - * This is the lazy variant so this gets only initialized once it |
|
1304 | - * is actually used. |
|
1305 | - * |
|
1306 | - * @return \OCP\Files\IRootFolder |
|
1307 | - */ |
|
1308 | - public function getLazyRootFolder() { |
|
1309 | - return $this->query('LazyRootFolder'); |
|
1310 | - } |
|
1311 | - |
|
1312 | - /** |
|
1313 | - * Returns a view to ownCloud's files folder |
|
1314 | - * |
|
1315 | - * @param string $userId user ID |
|
1316 | - * @return \OCP\Files\Folder|null |
|
1317 | - */ |
|
1318 | - public function getUserFolder($userId = null) { |
|
1319 | - if ($userId === null) { |
|
1320 | - $user = $this->getUserSession()->getUser(); |
|
1321 | - if (!$user) { |
|
1322 | - return null; |
|
1323 | - } |
|
1324 | - $userId = $user->getUID(); |
|
1325 | - } |
|
1326 | - $root = $this->getRootFolder(); |
|
1327 | - return $root->getUserFolder($userId); |
|
1328 | - } |
|
1329 | - |
|
1330 | - /** |
|
1331 | - * Returns an app-specific view in ownClouds data directory |
|
1332 | - * |
|
1333 | - * @return \OCP\Files\Folder |
|
1334 | - * @deprecated since 9.2.0 use IAppData |
|
1335 | - */ |
|
1336 | - public function getAppFolder() { |
|
1337 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1338 | - $root = $this->getRootFolder(); |
|
1339 | - if (!$root->nodeExists($dir)) { |
|
1340 | - $folder = $root->newFolder($dir); |
|
1341 | - } else { |
|
1342 | - $folder = $root->get($dir); |
|
1343 | - } |
|
1344 | - return $folder; |
|
1345 | - } |
|
1346 | - |
|
1347 | - /** |
|
1348 | - * @return \OC\User\Manager |
|
1349 | - */ |
|
1350 | - public function getUserManager() { |
|
1351 | - return $this->query('UserManager'); |
|
1352 | - } |
|
1353 | - |
|
1354 | - /** |
|
1355 | - * @return \OC\Group\Manager |
|
1356 | - */ |
|
1357 | - public function getGroupManager() { |
|
1358 | - return $this->query('GroupManager'); |
|
1359 | - } |
|
1360 | - |
|
1361 | - /** |
|
1362 | - * @return \OC\User\Session |
|
1363 | - */ |
|
1364 | - public function getUserSession() { |
|
1365 | - return $this->query('UserSession'); |
|
1366 | - } |
|
1367 | - |
|
1368 | - /** |
|
1369 | - * @return \OCP\ISession |
|
1370 | - */ |
|
1371 | - public function getSession() { |
|
1372 | - return $this->query('UserSession')->getSession(); |
|
1373 | - } |
|
1374 | - |
|
1375 | - /** |
|
1376 | - * @param \OCP\ISession $session |
|
1377 | - */ |
|
1378 | - public function setSession(\OCP\ISession $session) { |
|
1379 | - $this->query(SessionStorage::class)->setSession($session); |
|
1380 | - $this->query('UserSession')->setSession($session); |
|
1381 | - $this->query(Store::class)->setSession($session); |
|
1382 | - } |
|
1383 | - |
|
1384 | - /** |
|
1385 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1386 | - */ |
|
1387 | - public function getTwoFactorAuthManager() { |
|
1388 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1389 | - } |
|
1390 | - |
|
1391 | - /** |
|
1392 | - * @return \OC\NavigationManager |
|
1393 | - */ |
|
1394 | - public function getNavigationManager() { |
|
1395 | - return $this->query('NavigationManager'); |
|
1396 | - } |
|
1397 | - |
|
1398 | - /** |
|
1399 | - * @return \OCP\IConfig |
|
1400 | - */ |
|
1401 | - public function getConfig() { |
|
1402 | - return $this->query('AllConfig'); |
|
1403 | - } |
|
1404 | - |
|
1405 | - /** |
|
1406 | - * @return \OC\SystemConfig |
|
1407 | - */ |
|
1408 | - public function getSystemConfig() { |
|
1409 | - return $this->query('SystemConfig'); |
|
1410 | - } |
|
1411 | - |
|
1412 | - /** |
|
1413 | - * Returns the app config manager |
|
1414 | - * |
|
1415 | - * @return \OCP\IAppConfig |
|
1416 | - */ |
|
1417 | - public function getAppConfig() { |
|
1418 | - return $this->query('AppConfig'); |
|
1419 | - } |
|
1420 | - |
|
1421 | - /** |
|
1422 | - * @return \OCP\L10N\IFactory |
|
1423 | - */ |
|
1424 | - public function getL10NFactory() { |
|
1425 | - return $this->query('L10NFactory'); |
|
1426 | - } |
|
1427 | - |
|
1428 | - /** |
|
1429 | - * get an L10N instance |
|
1430 | - * |
|
1431 | - * @param string $app appid |
|
1432 | - * @param string $lang |
|
1433 | - * @return IL10N |
|
1434 | - */ |
|
1435 | - public function getL10N($app, $lang = null) { |
|
1436 | - return $this->getL10NFactory()->get($app, $lang); |
|
1437 | - } |
|
1438 | - |
|
1439 | - /** |
|
1440 | - * @return \OCP\IURLGenerator |
|
1441 | - */ |
|
1442 | - public function getURLGenerator() { |
|
1443 | - return $this->query('URLGenerator'); |
|
1444 | - } |
|
1445 | - |
|
1446 | - /** |
|
1447 | - * @return \OCP\IHelper |
|
1448 | - */ |
|
1449 | - public function getHelper() { |
|
1450 | - return $this->query('AppHelper'); |
|
1451 | - } |
|
1452 | - |
|
1453 | - /** |
|
1454 | - * @return AppFetcher |
|
1455 | - */ |
|
1456 | - public function getAppFetcher() { |
|
1457 | - return $this->query(AppFetcher::class); |
|
1458 | - } |
|
1459 | - |
|
1460 | - /** |
|
1461 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1462 | - * getMemCacheFactory() instead. |
|
1463 | - * |
|
1464 | - * @return \OCP\ICache |
|
1465 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1466 | - */ |
|
1467 | - public function getCache() { |
|
1468 | - return $this->query('UserCache'); |
|
1469 | - } |
|
1470 | - |
|
1471 | - /** |
|
1472 | - * Returns an \OCP\CacheFactory instance |
|
1473 | - * |
|
1474 | - * @return \OCP\ICacheFactory |
|
1475 | - */ |
|
1476 | - public function getMemCacheFactory() { |
|
1477 | - return $this->query('MemCacheFactory'); |
|
1478 | - } |
|
1479 | - |
|
1480 | - /** |
|
1481 | - * Returns an \OC\RedisFactory instance |
|
1482 | - * |
|
1483 | - * @return \OC\RedisFactory |
|
1484 | - */ |
|
1485 | - public function getGetRedisFactory() { |
|
1486 | - return $this->query('RedisFactory'); |
|
1487 | - } |
|
1488 | - |
|
1489 | - |
|
1490 | - /** |
|
1491 | - * Returns the current session |
|
1492 | - * |
|
1493 | - * @return \OCP\IDBConnection |
|
1494 | - */ |
|
1495 | - public function getDatabaseConnection() { |
|
1496 | - return $this->query('DatabaseConnection'); |
|
1497 | - } |
|
1498 | - |
|
1499 | - /** |
|
1500 | - * Returns the activity manager |
|
1501 | - * |
|
1502 | - * @return \OCP\Activity\IManager |
|
1503 | - */ |
|
1504 | - public function getActivityManager() { |
|
1505 | - return $this->query('ActivityManager'); |
|
1506 | - } |
|
1507 | - |
|
1508 | - /** |
|
1509 | - * Returns an job list for controlling background jobs |
|
1510 | - * |
|
1511 | - * @return \OCP\BackgroundJob\IJobList |
|
1512 | - */ |
|
1513 | - public function getJobList() { |
|
1514 | - return $this->query('JobList'); |
|
1515 | - } |
|
1516 | - |
|
1517 | - /** |
|
1518 | - * Returns a logger instance |
|
1519 | - * |
|
1520 | - * @return \OCP\ILogger |
|
1521 | - */ |
|
1522 | - public function getLogger() { |
|
1523 | - return $this->query('Logger'); |
|
1524 | - } |
|
1525 | - |
|
1526 | - /** |
|
1527 | - * Returns a router for generating and matching urls |
|
1528 | - * |
|
1529 | - * @return \OCP\Route\IRouter |
|
1530 | - */ |
|
1531 | - public function getRouter() { |
|
1532 | - return $this->query('Router'); |
|
1533 | - } |
|
1534 | - |
|
1535 | - /** |
|
1536 | - * Returns a search instance |
|
1537 | - * |
|
1538 | - * @return \OCP\ISearch |
|
1539 | - */ |
|
1540 | - public function getSearch() { |
|
1541 | - return $this->query('Search'); |
|
1542 | - } |
|
1543 | - |
|
1544 | - /** |
|
1545 | - * Returns a SecureRandom instance |
|
1546 | - * |
|
1547 | - * @return \OCP\Security\ISecureRandom |
|
1548 | - */ |
|
1549 | - public function getSecureRandom() { |
|
1550 | - return $this->query('SecureRandom'); |
|
1551 | - } |
|
1552 | - |
|
1553 | - /** |
|
1554 | - * Returns a Crypto instance |
|
1555 | - * |
|
1556 | - * @return \OCP\Security\ICrypto |
|
1557 | - */ |
|
1558 | - public function getCrypto() { |
|
1559 | - return $this->query('Crypto'); |
|
1560 | - } |
|
1561 | - |
|
1562 | - /** |
|
1563 | - * Returns a Hasher instance |
|
1564 | - * |
|
1565 | - * @return \OCP\Security\IHasher |
|
1566 | - */ |
|
1567 | - public function getHasher() { |
|
1568 | - return $this->query('Hasher'); |
|
1569 | - } |
|
1570 | - |
|
1571 | - /** |
|
1572 | - * Returns a CredentialsManager instance |
|
1573 | - * |
|
1574 | - * @return \OCP\Security\ICredentialsManager |
|
1575 | - */ |
|
1576 | - public function getCredentialsManager() { |
|
1577 | - return $this->query('CredentialsManager'); |
|
1578 | - } |
|
1579 | - |
|
1580 | - /** |
|
1581 | - * Returns an instance of the HTTP helper class |
|
1582 | - * |
|
1583 | - * @deprecated Use getHTTPClientService() |
|
1584 | - * @return \OC\HTTPHelper |
|
1585 | - */ |
|
1586 | - public function getHTTPHelper() { |
|
1587 | - return $this->query('HTTPHelper'); |
|
1588 | - } |
|
1589 | - |
|
1590 | - /** |
|
1591 | - * Get the certificate manager for the user |
|
1592 | - * |
|
1593 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1594 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1595 | - */ |
|
1596 | - public function getCertificateManager($userId = '') { |
|
1597 | - if ($userId === '') { |
|
1598 | - $userSession = $this->getUserSession(); |
|
1599 | - $user = $userSession->getUser(); |
|
1600 | - if (is_null($user)) { |
|
1601 | - return null; |
|
1602 | - } |
|
1603 | - $userId = $user->getUID(); |
|
1604 | - } |
|
1605 | - return new CertificateManager( |
|
1606 | - $userId, |
|
1607 | - new View(), |
|
1608 | - $this->getConfig(), |
|
1609 | - $this->getLogger(), |
|
1610 | - $this->getSecureRandom() |
|
1611 | - ); |
|
1612 | - } |
|
1613 | - |
|
1614 | - /** |
|
1615 | - * Returns an instance of the HTTP client service |
|
1616 | - * |
|
1617 | - * @return \OCP\Http\Client\IClientService |
|
1618 | - */ |
|
1619 | - public function getHTTPClientService() { |
|
1620 | - return $this->query('HttpClientService'); |
|
1621 | - } |
|
1622 | - |
|
1623 | - /** |
|
1624 | - * Create a new event source |
|
1625 | - * |
|
1626 | - * @return \OCP\IEventSource |
|
1627 | - */ |
|
1628 | - public function createEventSource() { |
|
1629 | - return new \OC_EventSource(); |
|
1630 | - } |
|
1631 | - |
|
1632 | - /** |
|
1633 | - * Get the active event logger |
|
1634 | - * |
|
1635 | - * The returned logger only logs data when debug mode is enabled |
|
1636 | - * |
|
1637 | - * @return \OCP\Diagnostics\IEventLogger |
|
1638 | - */ |
|
1639 | - public function getEventLogger() { |
|
1640 | - return $this->query('EventLogger'); |
|
1641 | - } |
|
1642 | - |
|
1643 | - /** |
|
1644 | - * Get the active query logger |
|
1645 | - * |
|
1646 | - * The returned logger only logs data when debug mode is enabled |
|
1647 | - * |
|
1648 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1649 | - */ |
|
1650 | - public function getQueryLogger() { |
|
1651 | - return $this->query('QueryLogger'); |
|
1652 | - } |
|
1653 | - |
|
1654 | - /** |
|
1655 | - * Get the manager for temporary files and folders |
|
1656 | - * |
|
1657 | - * @return \OCP\ITempManager |
|
1658 | - */ |
|
1659 | - public function getTempManager() { |
|
1660 | - return $this->query('TempManager'); |
|
1661 | - } |
|
1662 | - |
|
1663 | - /** |
|
1664 | - * Get the app manager |
|
1665 | - * |
|
1666 | - * @return \OCP\App\IAppManager |
|
1667 | - */ |
|
1668 | - public function getAppManager() { |
|
1669 | - return $this->query('AppManager'); |
|
1670 | - } |
|
1671 | - |
|
1672 | - /** |
|
1673 | - * Creates a new mailer |
|
1674 | - * |
|
1675 | - * @return \OCP\Mail\IMailer |
|
1676 | - */ |
|
1677 | - public function getMailer() { |
|
1678 | - return $this->query('Mailer'); |
|
1679 | - } |
|
1680 | - |
|
1681 | - /** |
|
1682 | - * Get the webroot |
|
1683 | - * |
|
1684 | - * @return string |
|
1685 | - */ |
|
1686 | - public function getWebRoot() { |
|
1687 | - return $this->webRoot; |
|
1688 | - } |
|
1689 | - |
|
1690 | - /** |
|
1691 | - * @return \OC\OCSClient |
|
1692 | - */ |
|
1693 | - public function getOcsClient() { |
|
1694 | - return $this->query('OcsClient'); |
|
1695 | - } |
|
1696 | - |
|
1697 | - /** |
|
1698 | - * @return \OCP\IDateTimeZone |
|
1699 | - */ |
|
1700 | - public function getDateTimeZone() { |
|
1701 | - return $this->query('DateTimeZone'); |
|
1702 | - } |
|
1703 | - |
|
1704 | - /** |
|
1705 | - * @return \OCP\IDateTimeFormatter |
|
1706 | - */ |
|
1707 | - public function getDateTimeFormatter() { |
|
1708 | - return $this->query('DateTimeFormatter'); |
|
1709 | - } |
|
1710 | - |
|
1711 | - /** |
|
1712 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1713 | - */ |
|
1714 | - public function getMountProviderCollection() { |
|
1715 | - return $this->query('MountConfigManager'); |
|
1716 | - } |
|
1717 | - |
|
1718 | - /** |
|
1719 | - * Get the IniWrapper |
|
1720 | - * |
|
1721 | - * @return IniGetWrapper |
|
1722 | - */ |
|
1723 | - public function getIniWrapper() { |
|
1724 | - return $this->query('IniWrapper'); |
|
1725 | - } |
|
1726 | - |
|
1727 | - /** |
|
1728 | - * @return \OCP\Command\IBus |
|
1729 | - */ |
|
1730 | - public function getCommandBus() { |
|
1731 | - return $this->query('AsyncCommandBus'); |
|
1732 | - } |
|
1733 | - |
|
1734 | - /** |
|
1735 | - * Get the trusted domain helper |
|
1736 | - * |
|
1737 | - * @return TrustedDomainHelper |
|
1738 | - */ |
|
1739 | - public function getTrustedDomainHelper() { |
|
1740 | - return $this->query('TrustedDomainHelper'); |
|
1741 | - } |
|
1742 | - |
|
1743 | - /** |
|
1744 | - * Get the locking provider |
|
1745 | - * |
|
1746 | - * @return \OCP\Lock\ILockingProvider |
|
1747 | - * @since 8.1.0 |
|
1748 | - */ |
|
1749 | - public function getLockingProvider() { |
|
1750 | - return $this->query('LockingProvider'); |
|
1751 | - } |
|
1752 | - |
|
1753 | - /** |
|
1754 | - * @return \OCP\Files\Mount\IMountManager |
|
1755 | - **/ |
|
1756 | - function getMountManager() { |
|
1757 | - return $this->query('MountManager'); |
|
1758 | - } |
|
1759 | - |
|
1760 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1761 | - function getUserMountCache() { |
|
1762 | - return $this->query('UserMountCache'); |
|
1763 | - } |
|
1764 | - |
|
1765 | - /** |
|
1766 | - * Get the MimeTypeDetector |
|
1767 | - * |
|
1768 | - * @return \OCP\Files\IMimeTypeDetector |
|
1769 | - */ |
|
1770 | - public function getMimeTypeDetector() { |
|
1771 | - return $this->query('MimeTypeDetector'); |
|
1772 | - } |
|
1773 | - |
|
1774 | - /** |
|
1775 | - * Get the MimeTypeLoader |
|
1776 | - * |
|
1777 | - * @return \OCP\Files\IMimeTypeLoader |
|
1778 | - */ |
|
1779 | - public function getMimeTypeLoader() { |
|
1780 | - return $this->query('MimeTypeLoader'); |
|
1781 | - } |
|
1782 | - |
|
1783 | - /** |
|
1784 | - * Get the manager of all the capabilities |
|
1785 | - * |
|
1786 | - * @return \OC\CapabilitiesManager |
|
1787 | - */ |
|
1788 | - public function getCapabilitiesManager() { |
|
1789 | - return $this->query('CapabilitiesManager'); |
|
1790 | - } |
|
1791 | - |
|
1792 | - /** |
|
1793 | - * Get the EventDispatcher |
|
1794 | - * |
|
1795 | - * @return EventDispatcherInterface |
|
1796 | - * @since 8.2.0 |
|
1797 | - */ |
|
1798 | - public function getEventDispatcher() { |
|
1799 | - return $this->query('EventDispatcher'); |
|
1800 | - } |
|
1801 | - |
|
1802 | - /** |
|
1803 | - * Get the Notification Manager |
|
1804 | - * |
|
1805 | - * @return \OCP\Notification\IManager |
|
1806 | - * @since 8.2.0 |
|
1807 | - */ |
|
1808 | - public function getNotificationManager() { |
|
1809 | - return $this->query('NotificationManager'); |
|
1810 | - } |
|
1811 | - |
|
1812 | - /** |
|
1813 | - * @return \OCP\Comments\ICommentsManager |
|
1814 | - */ |
|
1815 | - public function getCommentsManager() { |
|
1816 | - return $this->query('CommentsManager'); |
|
1817 | - } |
|
1818 | - |
|
1819 | - /** |
|
1820 | - * @return \OCA\Theming\ThemingDefaults |
|
1821 | - */ |
|
1822 | - public function getThemingDefaults() { |
|
1823 | - return $this->query('ThemingDefaults'); |
|
1824 | - } |
|
1825 | - |
|
1826 | - /** |
|
1827 | - * @return \OC\IntegrityCheck\Checker |
|
1828 | - */ |
|
1829 | - public function getIntegrityCodeChecker() { |
|
1830 | - return $this->query('IntegrityCodeChecker'); |
|
1831 | - } |
|
1832 | - |
|
1833 | - /** |
|
1834 | - * @return \OC\Session\CryptoWrapper |
|
1835 | - */ |
|
1836 | - public function getSessionCryptoWrapper() { |
|
1837 | - return $this->query('CryptoWrapper'); |
|
1838 | - } |
|
1839 | - |
|
1840 | - /** |
|
1841 | - * @return CsrfTokenManager |
|
1842 | - */ |
|
1843 | - public function getCsrfTokenManager() { |
|
1844 | - return $this->query('CsrfTokenManager'); |
|
1845 | - } |
|
1846 | - |
|
1847 | - /** |
|
1848 | - * @return Throttler |
|
1849 | - */ |
|
1850 | - public function getBruteForceThrottler() { |
|
1851 | - return $this->query('Throttler'); |
|
1852 | - } |
|
1853 | - |
|
1854 | - /** |
|
1855 | - * @return IContentSecurityPolicyManager |
|
1856 | - */ |
|
1857 | - public function getContentSecurityPolicyManager() { |
|
1858 | - return $this->query('ContentSecurityPolicyManager'); |
|
1859 | - } |
|
1860 | - |
|
1861 | - /** |
|
1862 | - * @return ContentSecurityPolicyNonceManager |
|
1863 | - */ |
|
1864 | - public function getContentSecurityPolicyNonceManager() { |
|
1865 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1866 | - } |
|
1867 | - |
|
1868 | - /** |
|
1869 | - * Not a public API as of 8.2, wait for 9.0 |
|
1870 | - * |
|
1871 | - * @return \OCA\Files_External\Service\BackendService |
|
1872 | - */ |
|
1873 | - public function getStoragesBackendService() { |
|
1874 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1875 | - } |
|
1876 | - |
|
1877 | - /** |
|
1878 | - * Not a public API as of 8.2, wait for 9.0 |
|
1879 | - * |
|
1880 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1881 | - */ |
|
1882 | - public function getGlobalStoragesService() { |
|
1883 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1884 | - } |
|
1885 | - |
|
1886 | - /** |
|
1887 | - * Not a public API as of 8.2, wait for 9.0 |
|
1888 | - * |
|
1889 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1890 | - */ |
|
1891 | - public function getUserGlobalStoragesService() { |
|
1892 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1893 | - } |
|
1894 | - |
|
1895 | - /** |
|
1896 | - * Not a public API as of 8.2, wait for 9.0 |
|
1897 | - * |
|
1898 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1899 | - */ |
|
1900 | - public function getUserStoragesService() { |
|
1901 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1902 | - } |
|
1903 | - |
|
1904 | - /** |
|
1905 | - * @return \OCP\Share\IManager |
|
1906 | - */ |
|
1907 | - public function getShareManager() { |
|
1908 | - return $this->query('ShareManager'); |
|
1909 | - } |
|
1910 | - |
|
1911 | - /** |
|
1912 | - * @return \OCP\Collaboration\Collaborators\ISearch |
|
1913 | - */ |
|
1914 | - public function getCollaboratorSearch() { |
|
1915 | - return $this->query('CollaboratorSearch'); |
|
1916 | - } |
|
1917 | - |
|
1918 | - /** |
|
1919 | - * @return \OCP\Collaboration\AutoComplete\IManager |
|
1920 | - */ |
|
1921 | - public function getAutoCompleteManager(){ |
|
1922 | - return $this->query(IManager::class); |
|
1923 | - } |
|
1924 | - |
|
1925 | - /** |
|
1926 | - * Returns the LDAP Provider |
|
1927 | - * |
|
1928 | - * @return \OCP\LDAP\ILDAPProvider |
|
1929 | - */ |
|
1930 | - public function getLDAPProvider() { |
|
1931 | - return $this->query('LDAPProvider'); |
|
1932 | - } |
|
1933 | - |
|
1934 | - /** |
|
1935 | - * @return \OCP\Settings\IManager |
|
1936 | - */ |
|
1937 | - public function getSettingsManager() { |
|
1938 | - return $this->query('SettingsManager'); |
|
1939 | - } |
|
1940 | - |
|
1941 | - /** |
|
1942 | - * @return \OCP\Files\IAppData |
|
1943 | - */ |
|
1944 | - public function getAppDataDir($app) { |
|
1945 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1946 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1947 | - return $factory->get($app); |
|
1948 | - } |
|
1949 | - |
|
1950 | - /** |
|
1951 | - * @return \OCP\Lockdown\ILockdownManager |
|
1952 | - */ |
|
1953 | - public function getLockdownManager() { |
|
1954 | - return $this->query('LockdownManager'); |
|
1955 | - } |
|
1956 | - |
|
1957 | - /** |
|
1958 | - * @return \OCP\Federation\ICloudIdManager |
|
1959 | - */ |
|
1960 | - public function getCloudIdManager() { |
|
1961 | - return $this->query(ICloudIdManager::class); |
|
1962 | - } |
|
1963 | - |
|
1964 | - /** |
|
1965 | - * @return \OCP\Remote\Api\IApiFactory |
|
1966 | - */ |
|
1967 | - public function getRemoteApiFactory() { |
|
1968 | - return $this->query(IApiFactory::class); |
|
1969 | - } |
|
1970 | - |
|
1971 | - /** |
|
1972 | - * @return \OCP\Remote\IInstanceFactory |
|
1973 | - */ |
|
1974 | - public function getRemoteInstanceFactory() { |
|
1975 | - return $this->query(IInstanceFactory::class); |
|
1976 | - } |
|
934 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
935 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
936 | + $classExists = true; |
|
937 | + } else { |
|
938 | + $classExists = false; |
|
939 | + } |
|
940 | + |
|
941 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
942 | + return new ThemingDefaults( |
|
943 | + $c->getConfig(), |
|
944 | + $c->getL10N('theming'), |
|
945 | + $c->getURLGenerator(), |
|
946 | + $c->getAppDataDir('theming'), |
|
947 | + $c->getMemCacheFactory(), |
|
948 | + new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming')), |
|
949 | + $this->getAppManager() |
|
950 | + ); |
|
951 | + } |
|
952 | + return new \OC_Defaults(); |
|
953 | + }); |
|
954 | + $this->registerService(SCSSCacher::class, function (Server $c) { |
|
955 | + /** @var Factory $cacheFactory */ |
|
956 | + $cacheFactory = $c->query(Factory::class); |
|
957 | + return new SCSSCacher( |
|
958 | + $c->getLogger(), |
|
959 | + $c->query(\OC\Files\AppData\Factory::class), |
|
960 | + $c->getURLGenerator(), |
|
961 | + $c->getConfig(), |
|
962 | + $c->getThemingDefaults(), |
|
963 | + \OC::$SERVERROOT, |
|
964 | + $cacheFactory->createDistributed('SCSS') |
|
965 | + ); |
|
966 | + }); |
|
967 | + $this->registerService(EventDispatcher::class, function () { |
|
968 | + return new EventDispatcher(); |
|
969 | + }); |
|
970 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
971 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
972 | + |
|
973 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
974 | + // FIXME: Instantiiated here due to cyclic dependency |
|
975 | + $request = new Request( |
|
976 | + [ |
|
977 | + 'get' => $_GET, |
|
978 | + 'post' => $_POST, |
|
979 | + 'files' => $_FILES, |
|
980 | + 'server' => $_SERVER, |
|
981 | + 'env' => $_ENV, |
|
982 | + 'cookies' => $_COOKIE, |
|
983 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
984 | + ? $_SERVER['REQUEST_METHOD'] |
|
985 | + : null, |
|
986 | + ], |
|
987 | + $c->getSecureRandom(), |
|
988 | + $c->getConfig() |
|
989 | + ); |
|
990 | + |
|
991 | + return new CryptoWrapper( |
|
992 | + $c->getConfig(), |
|
993 | + $c->getCrypto(), |
|
994 | + $c->getSecureRandom(), |
|
995 | + $request |
|
996 | + ); |
|
997 | + }); |
|
998 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
999 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
1000 | + |
|
1001 | + return new CsrfTokenManager( |
|
1002 | + $tokenGenerator, |
|
1003 | + $c->query(SessionStorage::class) |
|
1004 | + ); |
|
1005 | + }); |
|
1006 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
1007 | + return new SessionStorage($c->getSession()); |
|
1008 | + }); |
|
1009 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1010 | + return new ContentSecurityPolicyManager(); |
|
1011 | + }); |
|
1012 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
1013 | + |
|
1014 | + $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1015 | + return new ContentSecurityPolicyNonceManager( |
|
1016 | + $c->getCsrfTokenManager(), |
|
1017 | + $c->getRequest() |
|
1018 | + ); |
|
1019 | + }); |
|
1020 | + |
|
1021 | + $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1022 | + $config = $c->getConfig(); |
|
1023 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
1024 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
1025 | + $factory = new $factoryClass($this); |
|
1026 | + |
|
1027 | + $manager = new \OC\Share20\Manager( |
|
1028 | + $c->getLogger(), |
|
1029 | + $c->getConfig(), |
|
1030 | + $c->getSecureRandom(), |
|
1031 | + $c->getHasher(), |
|
1032 | + $c->getMountManager(), |
|
1033 | + $c->getGroupManager(), |
|
1034 | + $c->getL10N('lib'), |
|
1035 | + $c->getL10NFactory(), |
|
1036 | + $factory, |
|
1037 | + $c->getUserManager(), |
|
1038 | + $c->getLazyRootFolder(), |
|
1039 | + $c->getEventDispatcher(), |
|
1040 | + $c->getMailer(), |
|
1041 | + $c->getURLGenerator(), |
|
1042 | + $c->getThemingDefaults() |
|
1043 | + ); |
|
1044 | + |
|
1045 | + return $manager; |
|
1046 | + }); |
|
1047 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
1048 | + |
|
1049 | + $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
1050 | + $instance = new Collaboration\Collaborators\Search($c); |
|
1051 | + |
|
1052 | + // register default plugins |
|
1053 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
1054 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
1055 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
1056 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
1057 | + |
|
1058 | + return $instance; |
|
1059 | + }); |
|
1060 | + $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
1061 | + |
|
1062 | + $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
1063 | + |
|
1064 | + $this->registerService('SettingsManager', function (Server $c) { |
|
1065 | + $manager = new \OC\Settings\Manager( |
|
1066 | + $c->getLogger(), |
|
1067 | + $c->getDatabaseConnection(), |
|
1068 | + $c->getL10N('lib'), |
|
1069 | + $c->getConfig(), |
|
1070 | + $c->getEncryptionManager(), |
|
1071 | + $c->getUserManager(), |
|
1072 | + $c->getLockingProvider(), |
|
1073 | + $c->getRequest(), |
|
1074 | + $c->getURLGenerator(), |
|
1075 | + $c->query(AccountManager::class), |
|
1076 | + $c->getGroupManager(), |
|
1077 | + $c->getL10NFactory(), |
|
1078 | + $c->getAppManager() |
|
1079 | + ); |
|
1080 | + return $manager; |
|
1081 | + }); |
|
1082 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1083 | + return new \OC\Files\AppData\Factory( |
|
1084 | + $c->getRootFolder(), |
|
1085 | + $c->getSystemConfig() |
|
1086 | + ); |
|
1087 | + }); |
|
1088 | + |
|
1089 | + $this->registerService('LockdownManager', function (Server $c) { |
|
1090 | + return new LockdownManager(function () use ($c) { |
|
1091 | + return $c->getSession(); |
|
1092 | + }); |
|
1093 | + }); |
|
1094 | + |
|
1095 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1096 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
1097 | + }); |
|
1098 | + |
|
1099 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1100 | + return new CloudIdManager(); |
|
1101 | + }); |
|
1102 | + |
|
1103 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1104 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1105 | + |
|
1106 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1107 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1108 | + |
|
1109 | + $this->registerService(Defaults::class, function (Server $c) { |
|
1110 | + return new Defaults( |
|
1111 | + $c->getThemingDefaults() |
|
1112 | + ); |
|
1113 | + }); |
|
1114 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1115 | + |
|
1116 | + $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1117 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1118 | + }); |
|
1119 | + |
|
1120 | + $this->registerService(IShareHelper::class, function (Server $c) { |
|
1121 | + return new ShareHelper( |
|
1122 | + $c->query(\OCP\Share\IManager::class) |
|
1123 | + ); |
|
1124 | + }); |
|
1125 | + |
|
1126 | + $this->registerService(Installer::class, function(Server $c) { |
|
1127 | + return new Installer( |
|
1128 | + $c->getAppFetcher(), |
|
1129 | + $c->getHTTPClientService(), |
|
1130 | + $c->getTempManager(), |
|
1131 | + $c->getLogger(), |
|
1132 | + $c->getConfig() |
|
1133 | + ); |
|
1134 | + }); |
|
1135 | + |
|
1136 | + $this->registerService(IApiFactory::class, function(Server $c) { |
|
1137 | + return new ApiFactory($c->getHTTPClientService()); |
|
1138 | + }); |
|
1139 | + |
|
1140 | + $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
1141 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
1142 | + return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
1143 | + }); |
|
1144 | + |
|
1145 | + $this->registerService(IContactsStore::class, function(Server $c) { |
|
1146 | + return new ContactsStore( |
|
1147 | + $c->getContactsManager(), |
|
1148 | + $c->getConfig(), |
|
1149 | + $c->getUserManager(), |
|
1150 | + $c->getGroupManager() |
|
1151 | + ); |
|
1152 | + }); |
|
1153 | + $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
1154 | + |
|
1155 | + $this->connectDispatcher(); |
|
1156 | + } |
|
1157 | + |
|
1158 | + /** |
|
1159 | + * @return \OCP\Calendar\IManager |
|
1160 | + */ |
|
1161 | + public function getCalendarManager() { |
|
1162 | + return $this->query('CalendarManager'); |
|
1163 | + } |
|
1164 | + |
|
1165 | + private function connectDispatcher() { |
|
1166 | + $dispatcher = $this->getEventDispatcher(); |
|
1167 | + |
|
1168 | + // Delete avatar on user deletion |
|
1169 | + $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
1170 | + $logger = $this->getLogger(); |
|
1171 | + $manager = $this->getAvatarManager(); |
|
1172 | + /** @var IUser $user */ |
|
1173 | + $user = $e->getSubject(); |
|
1174 | + |
|
1175 | + try { |
|
1176 | + $avatar = $manager->getAvatar($user->getUID()); |
|
1177 | + $avatar->remove(); |
|
1178 | + } catch (NotFoundException $e) { |
|
1179 | + // no avatar to remove |
|
1180 | + } catch (\Exception $e) { |
|
1181 | + // Ignore exceptions |
|
1182 | + $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1183 | + } |
|
1184 | + }); |
|
1185 | + |
|
1186 | + $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1187 | + $manager = $this->getAvatarManager(); |
|
1188 | + /** @var IUser $user */ |
|
1189 | + $user = $e->getSubject(); |
|
1190 | + $feature = $e->getArgument('feature'); |
|
1191 | + $oldValue = $e->getArgument('oldValue'); |
|
1192 | + $value = $e->getArgument('value'); |
|
1193 | + |
|
1194 | + try { |
|
1195 | + $avatar = $manager->getAvatar($user->getUID()); |
|
1196 | + $avatar->userChanged($feature, $oldValue, $value); |
|
1197 | + } catch (NotFoundException $e) { |
|
1198 | + // no avatar to remove |
|
1199 | + } |
|
1200 | + }); |
|
1201 | + } |
|
1202 | + |
|
1203 | + /** |
|
1204 | + * @return \OCP\Contacts\IManager |
|
1205 | + */ |
|
1206 | + public function getContactsManager() { |
|
1207 | + return $this->query('ContactsManager'); |
|
1208 | + } |
|
1209 | + |
|
1210 | + /** |
|
1211 | + * @return \OC\Encryption\Manager |
|
1212 | + */ |
|
1213 | + public function getEncryptionManager() { |
|
1214 | + return $this->query('EncryptionManager'); |
|
1215 | + } |
|
1216 | + |
|
1217 | + /** |
|
1218 | + * @return \OC\Encryption\File |
|
1219 | + */ |
|
1220 | + public function getEncryptionFilesHelper() { |
|
1221 | + return $this->query('EncryptionFileHelper'); |
|
1222 | + } |
|
1223 | + |
|
1224 | + /** |
|
1225 | + * @return \OCP\Encryption\Keys\IStorage |
|
1226 | + */ |
|
1227 | + public function getEncryptionKeyStorage() { |
|
1228 | + return $this->query('EncryptionKeyStorage'); |
|
1229 | + } |
|
1230 | + |
|
1231 | + /** |
|
1232 | + * The current request object holding all information about the request |
|
1233 | + * currently being processed is returned from this method. |
|
1234 | + * In case the current execution was not initiated by a web request null is returned |
|
1235 | + * |
|
1236 | + * @return \OCP\IRequest |
|
1237 | + */ |
|
1238 | + public function getRequest() { |
|
1239 | + return $this->query('Request'); |
|
1240 | + } |
|
1241 | + |
|
1242 | + /** |
|
1243 | + * Returns the preview manager which can create preview images for a given file |
|
1244 | + * |
|
1245 | + * @return \OCP\IPreview |
|
1246 | + */ |
|
1247 | + public function getPreviewManager() { |
|
1248 | + return $this->query('PreviewManager'); |
|
1249 | + } |
|
1250 | + |
|
1251 | + /** |
|
1252 | + * Returns the tag manager which can get and set tags for different object types |
|
1253 | + * |
|
1254 | + * @see \OCP\ITagManager::load() |
|
1255 | + * @return \OCP\ITagManager |
|
1256 | + */ |
|
1257 | + public function getTagManager() { |
|
1258 | + return $this->query('TagManager'); |
|
1259 | + } |
|
1260 | + |
|
1261 | + /** |
|
1262 | + * Returns the system-tag manager |
|
1263 | + * |
|
1264 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1265 | + * |
|
1266 | + * @since 9.0.0 |
|
1267 | + */ |
|
1268 | + public function getSystemTagManager() { |
|
1269 | + return $this->query('SystemTagManager'); |
|
1270 | + } |
|
1271 | + |
|
1272 | + /** |
|
1273 | + * Returns the system-tag object mapper |
|
1274 | + * |
|
1275 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1276 | + * |
|
1277 | + * @since 9.0.0 |
|
1278 | + */ |
|
1279 | + public function getSystemTagObjectMapper() { |
|
1280 | + return $this->query('SystemTagObjectMapper'); |
|
1281 | + } |
|
1282 | + |
|
1283 | + /** |
|
1284 | + * Returns the avatar manager, used for avatar functionality |
|
1285 | + * |
|
1286 | + * @return \OCP\IAvatarManager |
|
1287 | + */ |
|
1288 | + public function getAvatarManager() { |
|
1289 | + return $this->query('AvatarManager'); |
|
1290 | + } |
|
1291 | + |
|
1292 | + /** |
|
1293 | + * Returns the root folder of ownCloud's data directory |
|
1294 | + * |
|
1295 | + * @return \OCP\Files\IRootFolder |
|
1296 | + */ |
|
1297 | + public function getRootFolder() { |
|
1298 | + return $this->query('LazyRootFolder'); |
|
1299 | + } |
|
1300 | + |
|
1301 | + /** |
|
1302 | + * Returns the root folder of ownCloud's data directory |
|
1303 | + * This is the lazy variant so this gets only initialized once it |
|
1304 | + * is actually used. |
|
1305 | + * |
|
1306 | + * @return \OCP\Files\IRootFolder |
|
1307 | + */ |
|
1308 | + public function getLazyRootFolder() { |
|
1309 | + return $this->query('LazyRootFolder'); |
|
1310 | + } |
|
1311 | + |
|
1312 | + /** |
|
1313 | + * Returns a view to ownCloud's files folder |
|
1314 | + * |
|
1315 | + * @param string $userId user ID |
|
1316 | + * @return \OCP\Files\Folder|null |
|
1317 | + */ |
|
1318 | + public function getUserFolder($userId = null) { |
|
1319 | + if ($userId === null) { |
|
1320 | + $user = $this->getUserSession()->getUser(); |
|
1321 | + if (!$user) { |
|
1322 | + return null; |
|
1323 | + } |
|
1324 | + $userId = $user->getUID(); |
|
1325 | + } |
|
1326 | + $root = $this->getRootFolder(); |
|
1327 | + return $root->getUserFolder($userId); |
|
1328 | + } |
|
1329 | + |
|
1330 | + /** |
|
1331 | + * Returns an app-specific view in ownClouds data directory |
|
1332 | + * |
|
1333 | + * @return \OCP\Files\Folder |
|
1334 | + * @deprecated since 9.2.0 use IAppData |
|
1335 | + */ |
|
1336 | + public function getAppFolder() { |
|
1337 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1338 | + $root = $this->getRootFolder(); |
|
1339 | + if (!$root->nodeExists($dir)) { |
|
1340 | + $folder = $root->newFolder($dir); |
|
1341 | + } else { |
|
1342 | + $folder = $root->get($dir); |
|
1343 | + } |
|
1344 | + return $folder; |
|
1345 | + } |
|
1346 | + |
|
1347 | + /** |
|
1348 | + * @return \OC\User\Manager |
|
1349 | + */ |
|
1350 | + public function getUserManager() { |
|
1351 | + return $this->query('UserManager'); |
|
1352 | + } |
|
1353 | + |
|
1354 | + /** |
|
1355 | + * @return \OC\Group\Manager |
|
1356 | + */ |
|
1357 | + public function getGroupManager() { |
|
1358 | + return $this->query('GroupManager'); |
|
1359 | + } |
|
1360 | + |
|
1361 | + /** |
|
1362 | + * @return \OC\User\Session |
|
1363 | + */ |
|
1364 | + public function getUserSession() { |
|
1365 | + return $this->query('UserSession'); |
|
1366 | + } |
|
1367 | + |
|
1368 | + /** |
|
1369 | + * @return \OCP\ISession |
|
1370 | + */ |
|
1371 | + public function getSession() { |
|
1372 | + return $this->query('UserSession')->getSession(); |
|
1373 | + } |
|
1374 | + |
|
1375 | + /** |
|
1376 | + * @param \OCP\ISession $session |
|
1377 | + */ |
|
1378 | + public function setSession(\OCP\ISession $session) { |
|
1379 | + $this->query(SessionStorage::class)->setSession($session); |
|
1380 | + $this->query('UserSession')->setSession($session); |
|
1381 | + $this->query(Store::class)->setSession($session); |
|
1382 | + } |
|
1383 | + |
|
1384 | + /** |
|
1385 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1386 | + */ |
|
1387 | + public function getTwoFactorAuthManager() { |
|
1388 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1389 | + } |
|
1390 | + |
|
1391 | + /** |
|
1392 | + * @return \OC\NavigationManager |
|
1393 | + */ |
|
1394 | + public function getNavigationManager() { |
|
1395 | + return $this->query('NavigationManager'); |
|
1396 | + } |
|
1397 | + |
|
1398 | + /** |
|
1399 | + * @return \OCP\IConfig |
|
1400 | + */ |
|
1401 | + public function getConfig() { |
|
1402 | + return $this->query('AllConfig'); |
|
1403 | + } |
|
1404 | + |
|
1405 | + /** |
|
1406 | + * @return \OC\SystemConfig |
|
1407 | + */ |
|
1408 | + public function getSystemConfig() { |
|
1409 | + return $this->query('SystemConfig'); |
|
1410 | + } |
|
1411 | + |
|
1412 | + /** |
|
1413 | + * Returns the app config manager |
|
1414 | + * |
|
1415 | + * @return \OCP\IAppConfig |
|
1416 | + */ |
|
1417 | + public function getAppConfig() { |
|
1418 | + return $this->query('AppConfig'); |
|
1419 | + } |
|
1420 | + |
|
1421 | + /** |
|
1422 | + * @return \OCP\L10N\IFactory |
|
1423 | + */ |
|
1424 | + public function getL10NFactory() { |
|
1425 | + return $this->query('L10NFactory'); |
|
1426 | + } |
|
1427 | + |
|
1428 | + /** |
|
1429 | + * get an L10N instance |
|
1430 | + * |
|
1431 | + * @param string $app appid |
|
1432 | + * @param string $lang |
|
1433 | + * @return IL10N |
|
1434 | + */ |
|
1435 | + public function getL10N($app, $lang = null) { |
|
1436 | + return $this->getL10NFactory()->get($app, $lang); |
|
1437 | + } |
|
1438 | + |
|
1439 | + /** |
|
1440 | + * @return \OCP\IURLGenerator |
|
1441 | + */ |
|
1442 | + public function getURLGenerator() { |
|
1443 | + return $this->query('URLGenerator'); |
|
1444 | + } |
|
1445 | + |
|
1446 | + /** |
|
1447 | + * @return \OCP\IHelper |
|
1448 | + */ |
|
1449 | + public function getHelper() { |
|
1450 | + return $this->query('AppHelper'); |
|
1451 | + } |
|
1452 | + |
|
1453 | + /** |
|
1454 | + * @return AppFetcher |
|
1455 | + */ |
|
1456 | + public function getAppFetcher() { |
|
1457 | + return $this->query(AppFetcher::class); |
|
1458 | + } |
|
1459 | + |
|
1460 | + /** |
|
1461 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1462 | + * getMemCacheFactory() instead. |
|
1463 | + * |
|
1464 | + * @return \OCP\ICache |
|
1465 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1466 | + */ |
|
1467 | + public function getCache() { |
|
1468 | + return $this->query('UserCache'); |
|
1469 | + } |
|
1470 | + |
|
1471 | + /** |
|
1472 | + * Returns an \OCP\CacheFactory instance |
|
1473 | + * |
|
1474 | + * @return \OCP\ICacheFactory |
|
1475 | + */ |
|
1476 | + public function getMemCacheFactory() { |
|
1477 | + return $this->query('MemCacheFactory'); |
|
1478 | + } |
|
1479 | + |
|
1480 | + /** |
|
1481 | + * Returns an \OC\RedisFactory instance |
|
1482 | + * |
|
1483 | + * @return \OC\RedisFactory |
|
1484 | + */ |
|
1485 | + public function getGetRedisFactory() { |
|
1486 | + return $this->query('RedisFactory'); |
|
1487 | + } |
|
1488 | + |
|
1489 | + |
|
1490 | + /** |
|
1491 | + * Returns the current session |
|
1492 | + * |
|
1493 | + * @return \OCP\IDBConnection |
|
1494 | + */ |
|
1495 | + public function getDatabaseConnection() { |
|
1496 | + return $this->query('DatabaseConnection'); |
|
1497 | + } |
|
1498 | + |
|
1499 | + /** |
|
1500 | + * Returns the activity manager |
|
1501 | + * |
|
1502 | + * @return \OCP\Activity\IManager |
|
1503 | + */ |
|
1504 | + public function getActivityManager() { |
|
1505 | + return $this->query('ActivityManager'); |
|
1506 | + } |
|
1507 | + |
|
1508 | + /** |
|
1509 | + * Returns an job list for controlling background jobs |
|
1510 | + * |
|
1511 | + * @return \OCP\BackgroundJob\IJobList |
|
1512 | + */ |
|
1513 | + public function getJobList() { |
|
1514 | + return $this->query('JobList'); |
|
1515 | + } |
|
1516 | + |
|
1517 | + /** |
|
1518 | + * Returns a logger instance |
|
1519 | + * |
|
1520 | + * @return \OCP\ILogger |
|
1521 | + */ |
|
1522 | + public function getLogger() { |
|
1523 | + return $this->query('Logger'); |
|
1524 | + } |
|
1525 | + |
|
1526 | + /** |
|
1527 | + * Returns a router for generating and matching urls |
|
1528 | + * |
|
1529 | + * @return \OCP\Route\IRouter |
|
1530 | + */ |
|
1531 | + public function getRouter() { |
|
1532 | + return $this->query('Router'); |
|
1533 | + } |
|
1534 | + |
|
1535 | + /** |
|
1536 | + * Returns a search instance |
|
1537 | + * |
|
1538 | + * @return \OCP\ISearch |
|
1539 | + */ |
|
1540 | + public function getSearch() { |
|
1541 | + return $this->query('Search'); |
|
1542 | + } |
|
1543 | + |
|
1544 | + /** |
|
1545 | + * Returns a SecureRandom instance |
|
1546 | + * |
|
1547 | + * @return \OCP\Security\ISecureRandom |
|
1548 | + */ |
|
1549 | + public function getSecureRandom() { |
|
1550 | + return $this->query('SecureRandom'); |
|
1551 | + } |
|
1552 | + |
|
1553 | + /** |
|
1554 | + * Returns a Crypto instance |
|
1555 | + * |
|
1556 | + * @return \OCP\Security\ICrypto |
|
1557 | + */ |
|
1558 | + public function getCrypto() { |
|
1559 | + return $this->query('Crypto'); |
|
1560 | + } |
|
1561 | + |
|
1562 | + /** |
|
1563 | + * Returns a Hasher instance |
|
1564 | + * |
|
1565 | + * @return \OCP\Security\IHasher |
|
1566 | + */ |
|
1567 | + public function getHasher() { |
|
1568 | + return $this->query('Hasher'); |
|
1569 | + } |
|
1570 | + |
|
1571 | + /** |
|
1572 | + * Returns a CredentialsManager instance |
|
1573 | + * |
|
1574 | + * @return \OCP\Security\ICredentialsManager |
|
1575 | + */ |
|
1576 | + public function getCredentialsManager() { |
|
1577 | + return $this->query('CredentialsManager'); |
|
1578 | + } |
|
1579 | + |
|
1580 | + /** |
|
1581 | + * Returns an instance of the HTTP helper class |
|
1582 | + * |
|
1583 | + * @deprecated Use getHTTPClientService() |
|
1584 | + * @return \OC\HTTPHelper |
|
1585 | + */ |
|
1586 | + public function getHTTPHelper() { |
|
1587 | + return $this->query('HTTPHelper'); |
|
1588 | + } |
|
1589 | + |
|
1590 | + /** |
|
1591 | + * Get the certificate manager for the user |
|
1592 | + * |
|
1593 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1594 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1595 | + */ |
|
1596 | + public function getCertificateManager($userId = '') { |
|
1597 | + if ($userId === '') { |
|
1598 | + $userSession = $this->getUserSession(); |
|
1599 | + $user = $userSession->getUser(); |
|
1600 | + if (is_null($user)) { |
|
1601 | + return null; |
|
1602 | + } |
|
1603 | + $userId = $user->getUID(); |
|
1604 | + } |
|
1605 | + return new CertificateManager( |
|
1606 | + $userId, |
|
1607 | + new View(), |
|
1608 | + $this->getConfig(), |
|
1609 | + $this->getLogger(), |
|
1610 | + $this->getSecureRandom() |
|
1611 | + ); |
|
1612 | + } |
|
1613 | + |
|
1614 | + /** |
|
1615 | + * Returns an instance of the HTTP client service |
|
1616 | + * |
|
1617 | + * @return \OCP\Http\Client\IClientService |
|
1618 | + */ |
|
1619 | + public function getHTTPClientService() { |
|
1620 | + return $this->query('HttpClientService'); |
|
1621 | + } |
|
1622 | + |
|
1623 | + /** |
|
1624 | + * Create a new event source |
|
1625 | + * |
|
1626 | + * @return \OCP\IEventSource |
|
1627 | + */ |
|
1628 | + public function createEventSource() { |
|
1629 | + return new \OC_EventSource(); |
|
1630 | + } |
|
1631 | + |
|
1632 | + /** |
|
1633 | + * Get the active event logger |
|
1634 | + * |
|
1635 | + * The returned logger only logs data when debug mode is enabled |
|
1636 | + * |
|
1637 | + * @return \OCP\Diagnostics\IEventLogger |
|
1638 | + */ |
|
1639 | + public function getEventLogger() { |
|
1640 | + return $this->query('EventLogger'); |
|
1641 | + } |
|
1642 | + |
|
1643 | + /** |
|
1644 | + * Get the active query logger |
|
1645 | + * |
|
1646 | + * The returned logger only logs data when debug mode is enabled |
|
1647 | + * |
|
1648 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1649 | + */ |
|
1650 | + public function getQueryLogger() { |
|
1651 | + return $this->query('QueryLogger'); |
|
1652 | + } |
|
1653 | + |
|
1654 | + /** |
|
1655 | + * Get the manager for temporary files and folders |
|
1656 | + * |
|
1657 | + * @return \OCP\ITempManager |
|
1658 | + */ |
|
1659 | + public function getTempManager() { |
|
1660 | + return $this->query('TempManager'); |
|
1661 | + } |
|
1662 | + |
|
1663 | + /** |
|
1664 | + * Get the app manager |
|
1665 | + * |
|
1666 | + * @return \OCP\App\IAppManager |
|
1667 | + */ |
|
1668 | + public function getAppManager() { |
|
1669 | + return $this->query('AppManager'); |
|
1670 | + } |
|
1671 | + |
|
1672 | + /** |
|
1673 | + * Creates a new mailer |
|
1674 | + * |
|
1675 | + * @return \OCP\Mail\IMailer |
|
1676 | + */ |
|
1677 | + public function getMailer() { |
|
1678 | + return $this->query('Mailer'); |
|
1679 | + } |
|
1680 | + |
|
1681 | + /** |
|
1682 | + * Get the webroot |
|
1683 | + * |
|
1684 | + * @return string |
|
1685 | + */ |
|
1686 | + public function getWebRoot() { |
|
1687 | + return $this->webRoot; |
|
1688 | + } |
|
1689 | + |
|
1690 | + /** |
|
1691 | + * @return \OC\OCSClient |
|
1692 | + */ |
|
1693 | + public function getOcsClient() { |
|
1694 | + return $this->query('OcsClient'); |
|
1695 | + } |
|
1696 | + |
|
1697 | + /** |
|
1698 | + * @return \OCP\IDateTimeZone |
|
1699 | + */ |
|
1700 | + public function getDateTimeZone() { |
|
1701 | + return $this->query('DateTimeZone'); |
|
1702 | + } |
|
1703 | + |
|
1704 | + /** |
|
1705 | + * @return \OCP\IDateTimeFormatter |
|
1706 | + */ |
|
1707 | + public function getDateTimeFormatter() { |
|
1708 | + return $this->query('DateTimeFormatter'); |
|
1709 | + } |
|
1710 | + |
|
1711 | + /** |
|
1712 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1713 | + */ |
|
1714 | + public function getMountProviderCollection() { |
|
1715 | + return $this->query('MountConfigManager'); |
|
1716 | + } |
|
1717 | + |
|
1718 | + /** |
|
1719 | + * Get the IniWrapper |
|
1720 | + * |
|
1721 | + * @return IniGetWrapper |
|
1722 | + */ |
|
1723 | + public function getIniWrapper() { |
|
1724 | + return $this->query('IniWrapper'); |
|
1725 | + } |
|
1726 | + |
|
1727 | + /** |
|
1728 | + * @return \OCP\Command\IBus |
|
1729 | + */ |
|
1730 | + public function getCommandBus() { |
|
1731 | + return $this->query('AsyncCommandBus'); |
|
1732 | + } |
|
1733 | + |
|
1734 | + /** |
|
1735 | + * Get the trusted domain helper |
|
1736 | + * |
|
1737 | + * @return TrustedDomainHelper |
|
1738 | + */ |
|
1739 | + public function getTrustedDomainHelper() { |
|
1740 | + return $this->query('TrustedDomainHelper'); |
|
1741 | + } |
|
1742 | + |
|
1743 | + /** |
|
1744 | + * Get the locking provider |
|
1745 | + * |
|
1746 | + * @return \OCP\Lock\ILockingProvider |
|
1747 | + * @since 8.1.0 |
|
1748 | + */ |
|
1749 | + public function getLockingProvider() { |
|
1750 | + return $this->query('LockingProvider'); |
|
1751 | + } |
|
1752 | + |
|
1753 | + /** |
|
1754 | + * @return \OCP\Files\Mount\IMountManager |
|
1755 | + **/ |
|
1756 | + function getMountManager() { |
|
1757 | + return $this->query('MountManager'); |
|
1758 | + } |
|
1759 | + |
|
1760 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1761 | + function getUserMountCache() { |
|
1762 | + return $this->query('UserMountCache'); |
|
1763 | + } |
|
1764 | + |
|
1765 | + /** |
|
1766 | + * Get the MimeTypeDetector |
|
1767 | + * |
|
1768 | + * @return \OCP\Files\IMimeTypeDetector |
|
1769 | + */ |
|
1770 | + public function getMimeTypeDetector() { |
|
1771 | + return $this->query('MimeTypeDetector'); |
|
1772 | + } |
|
1773 | + |
|
1774 | + /** |
|
1775 | + * Get the MimeTypeLoader |
|
1776 | + * |
|
1777 | + * @return \OCP\Files\IMimeTypeLoader |
|
1778 | + */ |
|
1779 | + public function getMimeTypeLoader() { |
|
1780 | + return $this->query('MimeTypeLoader'); |
|
1781 | + } |
|
1782 | + |
|
1783 | + /** |
|
1784 | + * Get the manager of all the capabilities |
|
1785 | + * |
|
1786 | + * @return \OC\CapabilitiesManager |
|
1787 | + */ |
|
1788 | + public function getCapabilitiesManager() { |
|
1789 | + return $this->query('CapabilitiesManager'); |
|
1790 | + } |
|
1791 | + |
|
1792 | + /** |
|
1793 | + * Get the EventDispatcher |
|
1794 | + * |
|
1795 | + * @return EventDispatcherInterface |
|
1796 | + * @since 8.2.0 |
|
1797 | + */ |
|
1798 | + public function getEventDispatcher() { |
|
1799 | + return $this->query('EventDispatcher'); |
|
1800 | + } |
|
1801 | + |
|
1802 | + /** |
|
1803 | + * Get the Notification Manager |
|
1804 | + * |
|
1805 | + * @return \OCP\Notification\IManager |
|
1806 | + * @since 8.2.0 |
|
1807 | + */ |
|
1808 | + public function getNotificationManager() { |
|
1809 | + return $this->query('NotificationManager'); |
|
1810 | + } |
|
1811 | + |
|
1812 | + /** |
|
1813 | + * @return \OCP\Comments\ICommentsManager |
|
1814 | + */ |
|
1815 | + public function getCommentsManager() { |
|
1816 | + return $this->query('CommentsManager'); |
|
1817 | + } |
|
1818 | + |
|
1819 | + /** |
|
1820 | + * @return \OCA\Theming\ThemingDefaults |
|
1821 | + */ |
|
1822 | + public function getThemingDefaults() { |
|
1823 | + return $this->query('ThemingDefaults'); |
|
1824 | + } |
|
1825 | + |
|
1826 | + /** |
|
1827 | + * @return \OC\IntegrityCheck\Checker |
|
1828 | + */ |
|
1829 | + public function getIntegrityCodeChecker() { |
|
1830 | + return $this->query('IntegrityCodeChecker'); |
|
1831 | + } |
|
1832 | + |
|
1833 | + /** |
|
1834 | + * @return \OC\Session\CryptoWrapper |
|
1835 | + */ |
|
1836 | + public function getSessionCryptoWrapper() { |
|
1837 | + return $this->query('CryptoWrapper'); |
|
1838 | + } |
|
1839 | + |
|
1840 | + /** |
|
1841 | + * @return CsrfTokenManager |
|
1842 | + */ |
|
1843 | + public function getCsrfTokenManager() { |
|
1844 | + return $this->query('CsrfTokenManager'); |
|
1845 | + } |
|
1846 | + |
|
1847 | + /** |
|
1848 | + * @return Throttler |
|
1849 | + */ |
|
1850 | + public function getBruteForceThrottler() { |
|
1851 | + return $this->query('Throttler'); |
|
1852 | + } |
|
1853 | + |
|
1854 | + /** |
|
1855 | + * @return IContentSecurityPolicyManager |
|
1856 | + */ |
|
1857 | + public function getContentSecurityPolicyManager() { |
|
1858 | + return $this->query('ContentSecurityPolicyManager'); |
|
1859 | + } |
|
1860 | + |
|
1861 | + /** |
|
1862 | + * @return ContentSecurityPolicyNonceManager |
|
1863 | + */ |
|
1864 | + public function getContentSecurityPolicyNonceManager() { |
|
1865 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1866 | + } |
|
1867 | + |
|
1868 | + /** |
|
1869 | + * Not a public API as of 8.2, wait for 9.0 |
|
1870 | + * |
|
1871 | + * @return \OCA\Files_External\Service\BackendService |
|
1872 | + */ |
|
1873 | + public function getStoragesBackendService() { |
|
1874 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1875 | + } |
|
1876 | + |
|
1877 | + /** |
|
1878 | + * Not a public API as of 8.2, wait for 9.0 |
|
1879 | + * |
|
1880 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1881 | + */ |
|
1882 | + public function getGlobalStoragesService() { |
|
1883 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1884 | + } |
|
1885 | + |
|
1886 | + /** |
|
1887 | + * Not a public API as of 8.2, wait for 9.0 |
|
1888 | + * |
|
1889 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1890 | + */ |
|
1891 | + public function getUserGlobalStoragesService() { |
|
1892 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1893 | + } |
|
1894 | + |
|
1895 | + /** |
|
1896 | + * Not a public API as of 8.2, wait for 9.0 |
|
1897 | + * |
|
1898 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1899 | + */ |
|
1900 | + public function getUserStoragesService() { |
|
1901 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1902 | + } |
|
1903 | + |
|
1904 | + /** |
|
1905 | + * @return \OCP\Share\IManager |
|
1906 | + */ |
|
1907 | + public function getShareManager() { |
|
1908 | + return $this->query('ShareManager'); |
|
1909 | + } |
|
1910 | + |
|
1911 | + /** |
|
1912 | + * @return \OCP\Collaboration\Collaborators\ISearch |
|
1913 | + */ |
|
1914 | + public function getCollaboratorSearch() { |
|
1915 | + return $this->query('CollaboratorSearch'); |
|
1916 | + } |
|
1917 | + |
|
1918 | + /** |
|
1919 | + * @return \OCP\Collaboration\AutoComplete\IManager |
|
1920 | + */ |
|
1921 | + public function getAutoCompleteManager(){ |
|
1922 | + return $this->query(IManager::class); |
|
1923 | + } |
|
1924 | + |
|
1925 | + /** |
|
1926 | + * Returns the LDAP Provider |
|
1927 | + * |
|
1928 | + * @return \OCP\LDAP\ILDAPProvider |
|
1929 | + */ |
|
1930 | + public function getLDAPProvider() { |
|
1931 | + return $this->query('LDAPProvider'); |
|
1932 | + } |
|
1933 | + |
|
1934 | + /** |
|
1935 | + * @return \OCP\Settings\IManager |
|
1936 | + */ |
|
1937 | + public function getSettingsManager() { |
|
1938 | + return $this->query('SettingsManager'); |
|
1939 | + } |
|
1940 | + |
|
1941 | + /** |
|
1942 | + * @return \OCP\Files\IAppData |
|
1943 | + */ |
|
1944 | + public function getAppDataDir($app) { |
|
1945 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1946 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1947 | + return $factory->get($app); |
|
1948 | + } |
|
1949 | + |
|
1950 | + /** |
|
1951 | + * @return \OCP\Lockdown\ILockdownManager |
|
1952 | + */ |
|
1953 | + public function getLockdownManager() { |
|
1954 | + return $this->query('LockdownManager'); |
|
1955 | + } |
|
1956 | + |
|
1957 | + /** |
|
1958 | + * @return \OCP\Federation\ICloudIdManager |
|
1959 | + */ |
|
1960 | + public function getCloudIdManager() { |
|
1961 | + return $this->query(ICloudIdManager::class); |
|
1962 | + } |
|
1963 | + |
|
1964 | + /** |
|
1965 | + * @return \OCP\Remote\Api\IApiFactory |
|
1966 | + */ |
|
1967 | + public function getRemoteApiFactory() { |
|
1968 | + return $this->query(IApiFactory::class); |
|
1969 | + } |
|
1970 | + |
|
1971 | + /** |
|
1972 | + * @return \OCP\Remote\IInstanceFactory |
|
1973 | + */ |
|
1974 | + public function getRemoteInstanceFactory() { |
|
1975 | + return $this->query(IInstanceFactory::class); |
|
1976 | + } |
|
1977 | 1977 | } |
@@ -49,356 +49,356 @@ |
||
49 | 49 | use OCP\Util; |
50 | 50 | |
51 | 51 | class Manager implements IManager { |
52 | - /** @var ILogger */ |
|
53 | - private $log; |
|
54 | - /** @var IDBConnection */ |
|
55 | - private $dbc; |
|
56 | - /** @var IL10N */ |
|
57 | - private $l; |
|
58 | - /** @var IConfig */ |
|
59 | - private $config; |
|
60 | - /** @var EncryptionManager */ |
|
61 | - private $encryptionManager; |
|
62 | - /** @var IUserManager */ |
|
63 | - private $userManager; |
|
64 | - /** @var ILockingProvider */ |
|
65 | - private $lockingProvider; |
|
66 | - /** @var IRequest */ |
|
67 | - private $request; |
|
68 | - /** @var IURLGenerator */ |
|
69 | - private $url; |
|
70 | - /** @var AccountManager */ |
|
71 | - private $accountManager; |
|
72 | - /** @var IGroupManager */ |
|
73 | - private $groupManager; |
|
74 | - /** @var IFactory */ |
|
75 | - private $l10nFactory; |
|
76 | - /** @var IAppManager */ |
|
77 | - private $appManager; |
|
78 | - |
|
79 | - /** |
|
80 | - * @param ILogger $log |
|
81 | - * @param IDBConnection $dbc |
|
82 | - * @param IL10N $l |
|
83 | - * @param IConfig $config |
|
84 | - * @param EncryptionManager $encryptionManager |
|
85 | - * @param IUserManager $userManager |
|
86 | - * @param ILockingProvider $lockingProvider |
|
87 | - * @param IRequest $request |
|
88 | - * @param IURLGenerator $url |
|
89 | - * @param AccountManager $accountManager |
|
90 | - * @param IGroupManager $groupManager |
|
91 | - * @param IFactory $l10nFactory |
|
92 | - * @param IAppManager $appManager |
|
93 | - */ |
|
94 | - public function __construct( |
|
95 | - ILogger $log, |
|
96 | - IDBConnection $dbc, |
|
97 | - IL10N $l, |
|
98 | - IConfig $config, |
|
99 | - EncryptionManager $encryptionManager, |
|
100 | - IUserManager $userManager, |
|
101 | - ILockingProvider $lockingProvider, |
|
102 | - IRequest $request, |
|
103 | - IURLGenerator $url, |
|
104 | - AccountManager $accountManager, |
|
105 | - IGroupManager $groupManager, |
|
106 | - IFactory $l10nFactory, |
|
107 | - IAppManager $appManager |
|
108 | - ) { |
|
109 | - $this->log = $log; |
|
110 | - $this->dbc = $dbc; |
|
111 | - $this->l = $l; |
|
112 | - $this->config = $config; |
|
113 | - $this->encryptionManager = $encryptionManager; |
|
114 | - $this->userManager = $userManager; |
|
115 | - $this->lockingProvider = $lockingProvider; |
|
116 | - $this->request = $request; |
|
117 | - $this->url = $url; |
|
118 | - $this->accountManager = $accountManager; |
|
119 | - $this->groupManager = $groupManager; |
|
120 | - $this->l10nFactory = $l10nFactory; |
|
121 | - $this->appManager = $appManager; |
|
122 | - } |
|
123 | - |
|
124 | - /** @var array */ |
|
125 | - protected $sectionClasses = []; |
|
126 | - |
|
127 | - /** @var array */ |
|
128 | - protected $sections = []; |
|
129 | - |
|
130 | - /** |
|
131 | - * @param string $type 'admin' or 'personal' |
|
132 | - * @param string $section Class must implement OCP\Settings\ISection |
|
133 | - * @return void |
|
134 | - */ |
|
135 | - public function registerSection(string $type, string $section) { |
|
136 | - $this->sectionClasses[$section] = $type; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * @param string $type 'admin' or 'personal' |
|
141 | - * @return ISection[] |
|
142 | - */ |
|
143 | - protected function getSections(string $type): array { |
|
144 | - if (!isset($this->sections[$type])) { |
|
145 | - $this->sections[$type] = []; |
|
146 | - } |
|
147 | - |
|
148 | - foreach ($this->sectionClasses as $class => $sectionType) { |
|
149 | - try { |
|
150 | - /** @var ISection $section */ |
|
151 | - $section = \OC::$server->query($class); |
|
152 | - } catch (QueryException $e) { |
|
153 | - $this->log->logException($e, ['level' => Util::INFO]); |
|
154 | - continue; |
|
155 | - } |
|
156 | - |
|
157 | - if (!$section instanceof ISection) { |
|
158 | - $this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => Util::INFO]); |
|
159 | - continue; |
|
160 | - } |
|
161 | - |
|
162 | - $this->sections[$sectionType][$section->getID()] = $section; |
|
163 | - |
|
164 | - unset($this->sectionClasses[$class]); |
|
165 | - } |
|
166 | - |
|
167 | - return $this->sections[$type]; |
|
168 | - } |
|
169 | - |
|
170 | - /** @var array */ |
|
171 | - protected $settingClasses = []; |
|
172 | - |
|
173 | - /** @var array */ |
|
174 | - protected $settings = []; |
|
175 | - |
|
176 | - /** |
|
177 | - * @param string $type 'admin' or 'personal' |
|
178 | - * @param string $setting Class must implement OCP\Settings\ISetting |
|
179 | - * @return void |
|
180 | - */ |
|
181 | - public function registerSetting(string $type, string $setting) { |
|
182 | - $this->settingClasses[$setting] = $type; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @param string $type 'admin' or 'personal' |
|
187 | - * @param string $section |
|
188 | - * @return ISettings[] |
|
189 | - */ |
|
190 | - protected function getSettings(string $type, string $section): array { |
|
191 | - if (!isset($this->settings[$type])) { |
|
192 | - $this->settings[$type] = []; |
|
193 | - } |
|
194 | - if (!isset($this->settings[$type][$section])) { |
|
195 | - $this->settings[$type][$section] = []; |
|
196 | - } |
|
197 | - |
|
198 | - foreach ($this->settingClasses as $class => $settingsType) { |
|
199 | - try { |
|
200 | - /** @var ISettings $setting */ |
|
201 | - $setting = \OC::$server->query($class); |
|
202 | - } catch (QueryException $e) { |
|
203 | - $this->log->logException($e, ['level' => Util::INFO]); |
|
204 | - continue; |
|
205 | - } |
|
206 | - |
|
207 | - if (!$setting instanceof ISettings) { |
|
208 | - $this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => Util::INFO]); |
|
209 | - continue; |
|
210 | - } |
|
211 | - |
|
212 | - if (!isset($this->settings[$settingsType][$setting->getSection()])) { |
|
213 | - $this->settings[$settingsType][$setting->getSection()] = []; |
|
214 | - } |
|
215 | - $this->settings[$settingsType][$setting->getSection()][] = $setting; |
|
216 | - |
|
217 | - unset($this->settingClasses[$class]); |
|
218 | - } |
|
219 | - |
|
220 | - return $this->settings[$type][$section]; |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * @inheritdoc |
|
225 | - */ |
|
226 | - public function getAdminSections(): array { |
|
227 | - // built-in sections |
|
228 | - $sections = [ |
|
229 | - 0 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('settings', 'admin.svg'))], |
|
230 | - 5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))], |
|
231 | - 10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
232 | - 45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
233 | - 98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
234 | - 99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0, $this->url->imagePath('settings', 'help.svg'))], |
|
235 | - ]; |
|
236 | - |
|
237 | - $appSections = $this->getSections('admin'); |
|
238 | - |
|
239 | - foreach ($appSections as $section) { |
|
240 | - /** @var ISection $section */ |
|
241 | - if (!isset($sections[$section->getPriority()])) { |
|
242 | - $sections[$section->getPriority()] = []; |
|
243 | - } |
|
244 | - |
|
245 | - $sections[$section->getPriority()][] = $section; |
|
246 | - } |
|
247 | - |
|
248 | - ksort($sections); |
|
249 | - |
|
250 | - return $sections; |
|
251 | - } |
|
252 | - |
|
253 | - /** |
|
254 | - * @param string $section |
|
255 | - * @return ISection[] |
|
256 | - */ |
|
257 | - private function getBuiltInAdminSettings($section): array { |
|
258 | - $forms = []; |
|
259 | - |
|
260 | - if ($section === 'server') { |
|
261 | - /** @var ISettings $form */ |
|
262 | - $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l); |
|
263 | - $forms[$form->getPriority()] = [$form]; |
|
264 | - $form = new Admin\ServerDevNotice(); |
|
265 | - $forms[$form->getPriority()] = [$form]; |
|
266 | - } |
|
267 | - if ($section === 'encryption') { |
|
268 | - /** @var ISettings $form */ |
|
269 | - $form = new Admin\Encryption($this->encryptionManager, $this->userManager); |
|
270 | - $forms[$form->getPriority()] = [$form]; |
|
271 | - } |
|
272 | - if ($section === 'sharing') { |
|
273 | - /** @var ISettings $form */ |
|
274 | - $form = new Admin\Sharing($this->config); |
|
275 | - $forms[$form->getPriority()] = [$form]; |
|
276 | - } |
|
277 | - if ($section === 'additional') { |
|
278 | - /** @var ISettings $form */ |
|
279 | - $form = new Admin\Additional($this->config); |
|
280 | - $forms[$form->getPriority()] = [$form]; |
|
281 | - } |
|
282 | - if ($section === 'tips-tricks') { |
|
283 | - /** @var ISettings $form */ |
|
284 | - $form = new Admin\TipsTricks($this->config); |
|
285 | - $forms[$form->getPriority()] = [$form]; |
|
286 | - } |
|
287 | - |
|
288 | - return $forms; |
|
289 | - } |
|
290 | - |
|
291 | - /** |
|
292 | - * @param string $section |
|
293 | - * @return ISection[] |
|
294 | - */ |
|
295 | - private function getBuiltInPersonalSettings($section): array { |
|
296 | - $forms = []; |
|
297 | - |
|
298 | - if ($section === 'personal-info') { |
|
299 | - /** @var ISettings $form */ |
|
300 | - $form = new Personal\PersonalInfo( |
|
301 | - $this->config, |
|
302 | - $this->userManager, |
|
303 | - $this->groupManager, |
|
304 | - $this->accountManager, |
|
305 | - $this->appManager, |
|
306 | - $this->l10nFactory, |
|
307 | - $this->l |
|
308 | - ); |
|
309 | - $forms[$form->getPriority()] = [$form]; |
|
310 | - } |
|
311 | - if($section === 'security') { |
|
312 | - /** @var ISettings $form */ |
|
313 | - $form = new Personal\Security(); |
|
314 | - $forms[$form->getPriority()] = [$form]; |
|
315 | - } |
|
316 | - if ($section === 'additional') { |
|
317 | - /** @var ISettings $form */ |
|
318 | - $form = new Personal\Additional(); |
|
319 | - $forms[$form->getPriority()] = [$form]; |
|
320 | - } |
|
321 | - |
|
322 | - return $forms; |
|
323 | - } |
|
324 | - |
|
325 | - /** |
|
326 | - * @inheritdoc |
|
327 | - */ |
|
328 | - public function getAdminSettings($section): array { |
|
329 | - $settings = $this->getBuiltInAdminSettings($section); |
|
330 | - $appSettings = $this->getSettings('admin', $section); |
|
331 | - |
|
332 | - foreach ($appSettings as $setting) { |
|
333 | - if (!isset($settings[$setting->getPriority()])) { |
|
334 | - $settings[$setting->getPriority()] = []; |
|
335 | - } |
|
336 | - $settings[$setting->getPriority()][] = $setting; |
|
337 | - } |
|
338 | - |
|
339 | - ksort($settings); |
|
340 | - return $settings; |
|
341 | - } |
|
342 | - |
|
343 | - /** |
|
344 | - * @inheritdoc |
|
345 | - */ |
|
346 | - public function getPersonalSections(): array { |
|
347 | - $sections = [ |
|
348 | - 0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))], |
|
349 | - 5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))], |
|
350 | - 15 => [new Section('sync-clients', $this->l->t('Sync clients'), 0, $this->url->imagePath('settings', 'change.svg'))], |
|
351 | - ]; |
|
352 | - |
|
353 | - $legacyForms = \OC_App::getForms('personal'); |
|
354 | - if(!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) { |
|
355 | - $sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))]; |
|
356 | - } |
|
357 | - |
|
358 | - $appSections = $this->getSections('personal'); |
|
359 | - |
|
360 | - foreach ($appSections as $section) { |
|
361 | - /** @var ISection $section */ |
|
362 | - if (!isset($sections[$section->getPriority()])) { |
|
363 | - $sections[$section->getPriority()] = []; |
|
364 | - } |
|
365 | - |
|
366 | - $sections[$section->getPriority()][] = $section; |
|
367 | - } |
|
368 | - |
|
369 | - ksort($sections); |
|
370 | - |
|
371 | - return $sections; |
|
372 | - } |
|
373 | - |
|
374 | - /** |
|
375 | - * @param string[] $forms |
|
376 | - * @return bool |
|
377 | - */ |
|
378 | - private function hasLegacyPersonalSettingsToRender(array $forms): bool { |
|
379 | - foreach ($forms as $form) { |
|
380 | - if(trim($form) !== '') { |
|
381 | - return true; |
|
382 | - } |
|
383 | - } |
|
384 | - return false; |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * @inheritdoc |
|
389 | - */ |
|
390 | - public function getPersonalSettings($section): array { |
|
391 | - $settings = $this->getBuiltInPersonalSettings($section); |
|
392 | - $appSettings = $this->getSettings('personal', $section); |
|
393 | - |
|
394 | - foreach ($appSettings as $setting) { |
|
395 | - if (!isset($settings[$setting->getPriority()])) { |
|
396 | - $settings[$setting->getPriority()] = []; |
|
397 | - } |
|
398 | - $settings[$setting->getPriority()][] = $setting; |
|
399 | - } |
|
400 | - |
|
401 | - ksort($settings); |
|
402 | - return $settings; |
|
403 | - } |
|
52 | + /** @var ILogger */ |
|
53 | + private $log; |
|
54 | + /** @var IDBConnection */ |
|
55 | + private $dbc; |
|
56 | + /** @var IL10N */ |
|
57 | + private $l; |
|
58 | + /** @var IConfig */ |
|
59 | + private $config; |
|
60 | + /** @var EncryptionManager */ |
|
61 | + private $encryptionManager; |
|
62 | + /** @var IUserManager */ |
|
63 | + private $userManager; |
|
64 | + /** @var ILockingProvider */ |
|
65 | + private $lockingProvider; |
|
66 | + /** @var IRequest */ |
|
67 | + private $request; |
|
68 | + /** @var IURLGenerator */ |
|
69 | + private $url; |
|
70 | + /** @var AccountManager */ |
|
71 | + private $accountManager; |
|
72 | + /** @var IGroupManager */ |
|
73 | + private $groupManager; |
|
74 | + /** @var IFactory */ |
|
75 | + private $l10nFactory; |
|
76 | + /** @var IAppManager */ |
|
77 | + private $appManager; |
|
78 | + |
|
79 | + /** |
|
80 | + * @param ILogger $log |
|
81 | + * @param IDBConnection $dbc |
|
82 | + * @param IL10N $l |
|
83 | + * @param IConfig $config |
|
84 | + * @param EncryptionManager $encryptionManager |
|
85 | + * @param IUserManager $userManager |
|
86 | + * @param ILockingProvider $lockingProvider |
|
87 | + * @param IRequest $request |
|
88 | + * @param IURLGenerator $url |
|
89 | + * @param AccountManager $accountManager |
|
90 | + * @param IGroupManager $groupManager |
|
91 | + * @param IFactory $l10nFactory |
|
92 | + * @param IAppManager $appManager |
|
93 | + */ |
|
94 | + public function __construct( |
|
95 | + ILogger $log, |
|
96 | + IDBConnection $dbc, |
|
97 | + IL10N $l, |
|
98 | + IConfig $config, |
|
99 | + EncryptionManager $encryptionManager, |
|
100 | + IUserManager $userManager, |
|
101 | + ILockingProvider $lockingProvider, |
|
102 | + IRequest $request, |
|
103 | + IURLGenerator $url, |
|
104 | + AccountManager $accountManager, |
|
105 | + IGroupManager $groupManager, |
|
106 | + IFactory $l10nFactory, |
|
107 | + IAppManager $appManager |
|
108 | + ) { |
|
109 | + $this->log = $log; |
|
110 | + $this->dbc = $dbc; |
|
111 | + $this->l = $l; |
|
112 | + $this->config = $config; |
|
113 | + $this->encryptionManager = $encryptionManager; |
|
114 | + $this->userManager = $userManager; |
|
115 | + $this->lockingProvider = $lockingProvider; |
|
116 | + $this->request = $request; |
|
117 | + $this->url = $url; |
|
118 | + $this->accountManager = $accountManager; |
|
119 | + $this->groupManager = $groupManager; |
|
120 | + $this->l10nFactory = $l10nFactory; |
|
121 | + $this->appManager = $appManager; |
|
122 | + } |
|
123 | + |
|
124 | + /** @var array */ |
|
125 | + protected $sectionClasses = []; |
|
126 | + |
|
127 | + /** @var array */ |
|
128 | + protected $sections = []; |
|
129 | + |
|
130 | + /** |
|
131 | + * @param string $type 'admin' or 'personal' |
|
132 | + * @param string $section Class must implement OCP\Settings\ISection |
|
133 | + * @return void |
|
134 | + */ |
|
135 | + public function registerSection(string $type, string $section) { |
|
136 | + $this->sectionClasses[$section] = $type; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * @param string $type 'admin' or 'personal' |
|
141 | + * @return ISection[] |
|
142 | + */ |
|
143 | + protected function getSections(string $type): array { |
|
144 | + if (!isset($this->sections[$type])) { |
|
145 | + $this->sections[$type] = []; |
|
146 | + } |
|
147 | + |
|
148 | + foreach ($this->sectionClasses as $class => $sectionType) { |
|
149 | + try { |
|
150 | + /** @var ISection $section */ |
|
151 | + $section = \OC::$server->query($class); |
|
152 | + } catch (QueryException $e) { |
|
153 | + $this->log->logException($e, ['level' => Util::INFO]); |
|
154 | + continue; |
|
155 | + } |
|
156 | + |
|
157 | + if (!$section instanceof ISection) { |
|
158 | + $this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => Util::INFO]); |
|
159 | + continue; |
|
160 | + } |
|
161 | + |
|
162 | + $this->sections[$sectionType][$section->getID()] = $section; |
|
163 | + |
|
164 | + unset($this->sectionClasses[$class]); |
|
165 | + } |
|
166 | + |
|
167 | + return $this->sections[$type]; |
|
168 | + } |
|
169 | + |
|
170 | + /** @var array */ |
|
171 | + protected $settingClasses = []; |
|
172 | + |
|
173 | + /** @var array */ |
|
174 | + protected $settings = []; |
|
175 | + |
|
176 | + /** |
|
177 | + * @param string $type 'admin' or 'personal' |
|
178 | + * @param string $setting Class must implement OCP\Settings\ISetting |
|
179 | + * @return void |
|
180 | + */ |
|
181 | + public function registerSetting(string $type, string $setting) { |
|
182 | + $this->settingClasses[$setting] = $type; |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * @param string $type 'admin' or 'personal' |
|
187 | + * @param string $section |
|
188 | + * @return ISettings[] |
|
189 | + */ |
|
190 | + protected function getSettings(string $type, string $section): array { |
|
191 | + if (!isset($this->settings[$type])) { |
|
192 | + $this->settings[$type] = []; |
|
193 | + } |
|
194 | + if (!isset($this->settings[$type][$section])) { |
|
195 | + $this->settings[$type][$section] = []; |
|
196 | + } |
|
197 | + |
|
198 | + foreach ($this->settingClasses as $class => $settingsType) { |
|
199 | + try { |
|
200 | + /** @var ISettings $setting */ |
|
201 | + $setting = \OC::$server->query($class); |
|
202 | + } catch (QueryException $e) { |
|
203 | + $this->log->logException($e, ['level' => Util::INFO]); |
|
204 | + continue; |
|
205 | + } |
|
206 | + |
|
207 | + if (!$setting instanceof ISettings) { |
|
208 | + $this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => Util::INFO]); |
|
209 | + continue; |
|
210 | + } |
|
211 | + |
|
212 | + if (!isset($this->settings[$settingsType][$setting->getSection()])) { |
|
213 | + $this->settings[$settingsType][$setting->getSection()] = []; |
|
214 | + } |
|
215 | + $this->settings[$settingsType][$setting->getSection()][] = $setting; |
|
216 | + |
|
217 | + unset($this->settingClasses[$class]); |
|
218 | + } |
|
219 | + |
|
220 | + return $this->settings[$type][$section]; |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * @inheritdoc |
|
225 | + */ |
|
226 | + public function getAdminSections(): array { |
|
227 | + // built-in sections |
|
228 | + $sections = [ |
|
229 | + 0 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('settings', 'admin.svg'))], |
|
230 | + 5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))], |
|
231 | + 10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
232 | + 45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
233 | + 98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
234 | + 99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0, $this->url->imagePath('settings', 'help.svg'))], |
|
235 | + ]; |
|
236 | + |
|
237 | + $appSections = $this->getSections('admin'); |
|
238 | + |
|
239 | + foreach ($appSections as $section) { |
|
240 | + /** @var ISection $section */ |
|
241 | + if (!isset($sections[$section->getPriority()])) { |
|
242 | + $sections[$section->getPriority()] = []; |
|
243 | + } |
|
244 | + |
|
245 | + $sections[$section->getPriority()][] = $section; |
|
246 | + } |
|
247 | + |
|
248 | + ksort($sections); |
|
249 | + |
|
250 | + return $sections; |
|
251 | + } |
|
252 | + |
|
253 | + /** |
|
254 | + * @param string $section |
|
255 | + * @return ISection[] |
|
256 | + */ |
|
257 | + private function getBuiltInAdminSettings($section): array { |
|
258 | + $forms = []; |
|
259 | + |
|
260 | + if ($section === 'server') { |
|
261 | + /** @var ISettings $form */ |
|
262 | + $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l); |
|
263 | + $forms[$form->getPriority()] = [$form]; |
|
264 | + $form = new Admin\ServerDevNotice(); |
|
265 | + $forms[$form->getPriority()] = [$form]; |
|
266 | + } |
|
267 | + if ($section === 'encryption') { |
|
268 | + /** @var ISettings $form */ |
|
269 | + $form = new Admin\Encryption($this->encryptionManager, $this->userManager); |
|
270 | + $forms[$form->getPriority()] = [$form]; |
|
271 | + } |
|
272 | + if ($section === 'sharing') { |
|
273 | + /** @var ISettings $form */ |
|
274 | + $form = new Admin\Sharing($this->config); |
|
275 | + $forms[$form->getPriority()] = [$form]; |
|
276 | + } |
|
277 | + if ($section === 'additional') { |
|
278 | + /** @var ISettings $form */ |
|
279 | + $form = new Admin\Additional($this->config); |
|
280 | + $forms[$form->getPriority()] = [$form]; |
|
281 | + } |
|
282 | + if ($section === 'tips-tricks') { |
|
283 | + /** @var ISettings $form */ |
|
284 | + $form = new Admin\TipsTricks($this->config); |
|
285 | + $forms[$form->getPriority()] = [$form]; |
|
286 | + } |
|
287 | + |
|
288 | + return $forms; |
|
289 | + } |
|
290 | + |
|
291 | + /** |
|
292 | + * @param string $section |
|
293 | + * @return ISection[] |
|
294 | + */ |
|
295 | + private function getBuiltInPersonalSettings($section): array { |
|
296 | + $forms = []; |
|
297 | + |
|
298 | + if ($section === 'personal-info') { |
|
299 | + /** @var ISettings $form */ |
|
300 | + $form = new Personal\PersonalInfo( |
|
301 | + $this->config, |
|
302 | + $this->userManager, |
|
303 | + $this->groupManager, |
|
304 | + $this->accountManager, |
|
305 | + $this->appManager, |
|
306 | + $this->l10nFactory, |
|
307 | + $this->l |
|
308 | + ); |
|
309 | + $forms[$form->getPriority()] = [$form]; |
|
310 | + } |
|
311 | + if($section === 'security') { |
|
312 | + /** @var ISettings $form */ |
|
313 | + $form = new Personal\Security(); |
|
314 | + $forms[$form->getPriority()] = [$form]; |
|
315 | + } |
|
316 | + if ($section === 'additional') { |
|
317 | + /** @var ISettings $form */ |
|
318 | + $form = new Personal\Additional(); |
|
319 | + $forms[$form->getPriority()] = [$form]; |
|
320 | + } |
|
321 | + |
|
322 | + return $forms; |
|
323 | + } |
|
324 | + |
|
325 | + /** |
|
326 | + * @inheritdoc |
|
327 | + */ |
|
328 | + public function getAdminSettings($section): array { |
|
329 | + $settings = $this->getBuiltInAdminSettings($section); |
|
330 | + $appSettings = $this->getSettings('admin', $section); |
|
331 | + |
|
332 | + foreach ($appSettings as $setting) { |
|
333 | + if (!isset($settings[$setting->getPriority()])) { |
|
334 | + $settings[$setting->getPriority()] = []; |
|
335 | + } |
|
336 | + $settings[$setting->getPriority()][] = $setting; |
|
337 | + } |
|
338 | + |
|
339 | + ksort($settings); |
|
340 | + return $settings; |
|
341 | + } |
|
342 | + |
|
343 | + /** |
|
344 | + * @inheritdoc |
|
345 | + */ |
|
346 | + public function getPersonalSections(): array { |
|
347 | + $sections = [ |
|
348 | + 0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))], |
|
349 | + 5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))], |
|
350 | + 15 => [new Section('sync-clients', $this->l->t('Sync clients'), 0, $this->url->imagePath('settings', 'change.svg'))], |
|
351 | + ]; |
|
352 | + |
|
353 | + $legacyForms = \OC_App::getForms('personal'); |
|
354 | + if(!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) { |
|
355 | + $sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))]; |
|
356 | + } |
|
357 | + |
|
358 | + $appSections = $this->getSections('personal'); |
|
359 | + |
|
360 | + foreach ($appSections as $section) { |
|
361 | + /** @var ISection $section */ |
|
362 | + if (!isset($sections[$section->getPriority()])) { |
|
363 | + $sections[$section->getPriority()] = []; |
|
364 | + } |
|
365 | + |
|
366 | + $sections[$section->getPriority()][] = $section; |
|
367 | + } |
|
368 | + |
|
369 | + ksort($sections); |
|
370 | + |
|
371 | + return $sections; |
|
372 | + } |
|
373 | + |
|
374 | + /** |
|
375 | + * @param string[] $forms |
|
376 | + * @return bool |
|
377 | + */ |
|
378 | + private function hasLegacyPersonalSettingsToRender(array $forms): bool { |
|
379 | + foreach ($forms as $form) { |
|
380 | + if(trim($form) !== '') { |
|
381 | + return true; |
|
382 | + } |
|
383 | + } |
|
384 | + return false; |
|
385 | + } |
|
386 | + |
|
387 | + /** |
|
388 | + * @inheritdoc |
|
389 | + */ |
|
390 | + public function getPersonalSettings($section): array { |
|
391 | + $settings = $this->getBuiltInPersonalSettings($section); |
|
392 | + $appSettings = $this->getSettings('personal', $section); |
|
393 | + |
|
394 | + foreach ($appSettings as $setting) { |
|
395 | + if (!isset($settings[$setting->getPriority()])) { |
|
396 | + $settings[$setting->getPriority()] = []; |
|
397 | + } |
|
398 | + $settings[$setting->getPriority()][] = $setting; |
|
399 | + } |
|
400 | + |
|
401 | + ksort($settings); |
|
402 | + return $settings; |
|
403 | + } |
|
404 | 404 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | ); |
309 | 309 | $forms[$form->getPriority()] = [$form]; |
310 | 310 | } |
311 | - if($section === 'security') { |
|
311 | + if ($section === 'security') { |
|
312 | 312 | /** @var ISettings $form */ |
313 | 313 | $form = new Personal\Security(); |
314 | 314 | $forms[$form->getPriority()] = [$form]; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | ]; |
352 | 352 | |
353 | 353 | $legacyForms = \OC_App::getForms('personal'); |
354 | - if(!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) { |
|
354 | + if (!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) { |
|
355 | 355 | $sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))]; |
356 | 356 | } |
357 | 357 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | */ |
378 | 378 | private function hasLegacyPersonalSettingsToRender(array $forms): bool { |
379 | 379 | foreach ($forms as $form) { |
380 | - if(trim($form) !== '') { |
|
380 | + if (trim($form) !== '') { |
|
381 | 381 | return true; |
382 | 382 | } |
383 | 383 | } |
@@ -63,1206 +63,1206 @@ |
||
63 | 63 | * upgrading and removing apps. |
64 | 64 | */ |
65 | 65 | class OC_App { |
66 | - static private $appVersion = []; |
|
67 | - static private $adminForms = array(); |
|
68 | - static private $personalForms = array(); |
|
69 | - static private $appInfo = array(); |
|
70 | - static private $appTypes = array(); |
|
71 | - static private $loadedApps = array(); |
|
72 | - static private $altLogin = array(); |
|
73 | - static private $alreadyRegistered = []; |
|
74 | - const officialApp = 200; |
|
75 | - |
|
76 | - /** |
|
77 | - * clean the appId |
|
78 | - * |
|
79 | - * @param string|boolean $app AppId that needs to be cleaned |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public static function cleanAppId($app) { |
|
83 | - return str_replace(array('\0', '/', '\\', '..'), '', $app); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Check if an app is loaded |
|
88 | - * |
|
89 | - * @param string $app |
|
90 | - * @return bool |
|
91 | - */ |
|
92 | - public static function isAppLoaded($app) { |
|
93 | - return in_array($app, self::$loadedApps, true); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * loads all apps |
|
98 | - * |
|
99 | - * @param string[] | string | null $types |
|
100 | - * @return bool |
|
101 | - * |
|
102 | - * This function walks through the ownCloud directory and loads all apps |
|
103 | - * it can find. A directory contains an app if the file /appinfo/info.xml |
|
104 | - * exists. |
|
105 | - * |
|
106 | - * if $types is set, only apps of those types will be loaded |
|
107 | - */ |
|
108 | - public static function loadApps($types = null) { |
|
109 | - if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) { |
|
110 | - return false; |
|
111 | - } |
|
112 | - // Load the enabled apps here |
|
113 | - $apps = self::getEnabledApps(); |
|
114 | - |
|
115 | - // Add each apps' folder as allowed class path |
|
116 | - foreach($apps as $app) { |
|
117 | - $path = self::getAppPath($app); |
|
118 | - if($path !== false) { |
|
119 | - self::registerAutoloading($app, $path); |
|
120 | - } |
|
121 | - } |
|
122 | - |
|
123 | - // prevent app.php from printing output |
|
124 | - ob_start(); |
|
125 | - foreach ($apps as $app) { |
|
126 | - if ((is_null($types) or self::isType($app, $types)) && !in_array($app, self::$loadedApps)) { |
|
127 | - self::loadApp($app); |
|
128 | - } |
|
129 | - } |
|
130 | - ob_end_clean(); |
|
131 | - |
|
132 | - return true; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * load a single app |
|
137 | - * |
|
138 | - * @param string $app |
|
139 | - */ |
|
140 | - public static function loadApp($app) { |
|
141 | - self::$loadedApps[] = $app; |
|
142 | - $appPath = self::getAppPath($app); |
|
143 | - if($appPath === false) { |
|
144 | - return; |
|
145 | - } |
|
146 | - |
|
147 | - // in case someone calls loadApp() directly |
|
148 | - self::registerAutoloading($app, $appPath); |
|
149 | - |
|
150 | - if (is_file($appPath . '/appinfo/app.php')) { |
|
151 | - \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app); |
|
152 | - self::requireAppFile($app); |
|
153 | - if (self::isType($app, array('authentication'))) { |
|
154 | - // since authentication apps affect the "is app enabled for group" check, |
|
155 | - // the enabled apps cache needs to be cleared to make sure that the |
|
156 | - // next time getEnableApps() is called it will also include apps that were |
|
157 | - // enabled for groups |
|
158 | - self::$enabledAppsCache = array(); |
|
159 | - } |
|
160 | - \OC::$server->getEventLogger()->end('load_app_' . $app); |
|
161 | - } |
|
162 | - |
|
163 | - $info = self::getAppInfo($app); |
|
164 | - if (!empty($info['activity']['filters'])) { |
|
165 | - foreach ($info['activity']['filters'] as $filter) { |
|
166 | - \OC::$server->getActivityManager()->registerFilter($filter); |
|
167 | - } |
|
168 | - } |
|
169 | - if (!empty($info['activity']['settings'])) { |
|
170 | - foreach ($info['activity']['settings'] as $setting) { |
|
171 | - \OC::$server->getActivityManager()->registerSetting($setting); |
|
172 | - } |
|
173 | - } |
|
174 | - if (!empty($info['activity']['providers'])) { |
|
175 | - foreach ($info['activity']['providers'] as $provider) { |
|
176 | - \OC::$server->getActivityManager()->registerProvider($provider); |
|
177 | - } |
|
178 | - } |
|
179 | - |
|
180 | - if (!empty($info['settings']['admin'])) { |
|
181 | - foreach ($info['settings']['admin'] as $setting) { |
|
182 | - \OC::$server->getSettingsManager()->registerSetting('admin', $setting); |
|
183 | - } |
|
184 | - } |
|
185 | - if (!empty($info['settings']['admin-section'])) { |
|
186 | - foreach ($info['settings']['admin-section'] as $section) { |
|
187 | - \OC::$server->getSettingsManager()->registerSection('admin', $section); |
|
188 | - } |
|
189 | - } |
|
190 | - if (!empty($info['settings']['personal'])) { |
|
191 | - foreach ($info['settings']['personal'] as $setting) { |
|
192 | - \OC::$server->getSettingsManager()->registerSetting('personal', $setting); |
|
193 | - } |
|
194 | - } |
|
195 | - if (!empty($info['settings']['personal-section'])) { |
|
196 | - foreach ($info['settings']['personal-section'] as $section) { |
|
197 | - \OC::$server->getSettingsManager()->registerSection('personal', $section); |
|
198 | - } |
|
199 | - } |
|
200 | - |
|
201 | - if (!empty($info['collaboration']['plugins'])) { |
|
202 | - // deal with one or many plugin entries |
|
203 | - $plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ? |
|
204 | - [$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin']; |
|
205 | - foreach ($plugins as $plugin) { |
|
206 | - if($plugin['@attributes']['type'] === 'collaborator-search') { |
|
207 | - $pluginInfo = [ |
|
208 | - 'shareType' => $plugin['@attributes']['share-type'], |
|
209 | - 'class' => $plugin['@value'], |
|
210 | - ]; |
|
211 | - \OC::$server->getCollaboratorSearch()->registerPlugin($pluginInfo); |
|
212 | - } else if ($plugin['@attributes']['type'] === 'autocomplete-sort') { |
|
213 | - \OC::$server->getAutoCompleteManager()->registerSorter($plugin['@value']); |
|
214 | - } |
|
215 | - } |
|
216 | - } |
|
217 | - } |
|
218 | - |
|
219 | - /** |
|
220 | - * @internal |
|
221 | - * @param string $app |
|
222 | - * @param string $path |
|
223 | - */ |
|
224 | - public static function registerAutoloading($app, $path) { |
|
225 | - $key = $app . '-' . $path; |
|
226 | - if(isset(self::$alreadyRegistered[$key])) { |
|
227 | - return; |
|
228 | - } |
|
229 | - |
|
230 | - self::$alreadyRegistered[$key] = true; |
|
231 | - |
|
232 | - // Register on PSR-4 composer autoloader |
|
233 | - $appNamespace = \OC\AppFramework\App::buildAppNamespace($app); |
|
234 | - \OC::$server->registerNamespace($app, $appNamespace); |
|
235 | - |
|
236 | - if (file_exists($path . '/composer/autoload.php')) { |
|
237 | - require_once $path . '/composer/autoload.php'; |
|
238 | - } else { |
|
239 | - \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true); |
|
240 | - // Register on legacy autoloader |
|
241 | - \OC::$loader->addValidRoot($path); |
|
242 | - } |
|
243 | - |
|
244 | - // Register Test namespace only when testing |
|
245 | - if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) { |
|
246 | - \OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true); |
|
247 | - } |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Load app.php from the given app |
|
252 | - * |
|
253 | - * @param string $app app name |
|
254 | - */ |
|
255 | - private static function requireAppFile($app) { |
|
256 | - try { |
|
257 | - // encapsulated here to avoid variable scope conflicts |
|
258 | - require_once $app . '/appinfo/app.php'; |
|
259 | - } catch (Error $ex) { |
|
260 | - \OC::$server->getLogger()->logException($ex); |
|
261 | - if (!\OC::$server->getAppManager()->isShipped($app)) { |
|
262 | - // Only disable apps which are not shipped |
|
263 | - self::disable($app); |
|
264 | - } |
|
265 | - } |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * check if an app is of a specific type |
|
270 | - * |
|
271 | - * @param string $app |
|
272 | - * @param string|array $types |
|
273 | - * @return bool |
|
274 | - */ |
|
275 | - public static function isType($app, $types) { |
|
276 | - if (is_string($types)) { |
|
277 | - $types = array($types); |
|
278 | - } |
|
279 | - $appTypes = self::getAppTypes($app); |
|
280 | - foreach ($types as $type) { |
|
281 | - if (array_search($type, $appTypes) !== false) { |
|
282 | - return true; |
|
283 | - } |
|
284 | - } |
|
285 | - return false; |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * get the types of an app |
|
290 | - * |
|
291 | - * @param string $app |
|
292 | - * @return array |
|
293 | - */ |
|
294 | - private static function getAppTypes($app) { |
|
295 | - //load the cache |
|
296 | - if (count(self::$appTypes) == 0) { |
|
297 | - self::$appTypes = \OC::$server->getAppConfig()->getValues(false, 'types'); |
|
298 | - } |
|
299 | - |
|
300 | - if (isset(self::$appTypes[$app])) { |
|
301 | - return explode(',', self::$appTypes[$app]); |
|
302 | - } else { |
|
303 | - return array(); |
|
304 | - } |
|
305 | - } |
|
306 | - |
|
307 | - /** |
|
308 | - * read app types from info.xml and cache them in the database |
|
309 | - */ |
|
310 | - public static function setAppTypes($app) { |
|
311 | - $appData = self::getAppInfo($app); |
|
312 | - if(!is_array($appData)) { |
|
313 | - return; |
|
314 | - } |
|
315 | - |
|
316 | - if (isset($appData['types'])) { |
|
317 | - $appTypes = implode(',', $appData['types']); |
|
318 | - } else { |
|
319 | - $appTypes = ''; |
|
320 | - $appData['types'] = []; |
|
321 | - } |
|
322 | - |
|
323 | - \OC::$server->getConfig()->setAppValue($app, 'types', $appTypes); |
|
324 | - |
|
325 | - if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) { |
|
326 | - $enabled = \OC::$server->getConfig()->getAppValue($app, 'enabled', 'yes'); |
|
327 | - if ($enabled !== 'yes' && $enabled !== 'no') { |
|
328 | - \OC::$server->getConfig()->setAppValue($app, 'enabled', 'yes'); |
|
329 | - } |
|
330 | - } |
|
331 | - } |
|
332 | - |
|
333 | - /** |
|
334 | - * get all enabled apps |
|
335 | - */ |
|
336 | - protected static $enabledAppsCache = array(); |
|
337 | - |
|
338 | - /** |
|
339 | - * Returns apps enabled for the current user. |
|
340 | - * |
|
341 | - * @param bool $forceRefresh whether to refresh the cache |
|
342 | - * @param bool $all whether to return apps for all users, not only the |
|
343 | - * currently logged in one |
|
344 | - * @return string[] |
|
345 | - */ |
|
346 | - public static function getEnabledApps($forceRefresh = false, $all = false) { |
|
347 | - if (!\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
348 | - return array(); |
|
349 | - } |
|
350 | - // in incognito mode or when logged out, $user will be false, |
|
351 | - // which is also the case during an upgrade |
|
352 | - $appManager = \OC::$server->getAppManager(); |
|
353 | - if ($all) { |
|
354 | - $user = null; |
|
355 | - } else { |
|
356 | - $user = \OC::$server->getUserSession()->getUser(); |
|
357 | - } |
|
358 | - |
|
359 | - if (is_null($user)) { |
|
360 | - $apps = $appManager->getInstalledApps(); |
|
361 | - } else { |
|
362 | - $apps = $appManager->getEnabledAppsForUser($user); |
|
363 | - } |
|
364 | - $apps = array_filter($apps, function ($app) { |
|
365 | - return $app !== 'files';//we add this manually |
|
366 | - }); |
|
367 | - sort($apps); |
|
368 | - array_unshift($apps, 'files'); |
|
369 | - return $apps; |
|
370 | - } |
|
371 | - |
|
372 | - /** |
|
373 | - * checks whether or not an app is enabled |
|
374 | - * |
|
375 | - * @param string $app app |
|
376 | - * @return bool |
|
377 | - * @deprecated 13.0.0 use \OC::$server->getAppManager()->isEnabledForUser($appId) |
|
378 | - * |
|
379 | - * This function checks whether or not an app is enabled. |
|
380 | - */ |
|
381 | - public static function isEnabled($app) { |
|
382 | - return \OC::$server->getAppManager()->isEnabledForUser($app); |
|
383 | - } |
|
384 | - |
|
385 | - /** |
|
386 | - * enables an app |
|
387 | - * |
|
388 | - * @param string $appId |
|
389 | - * @param array $groups (optional) when set, only these groups will have access to the app |
|
390 | - * @throws \Exception |
|
391 | - * @return void |
|
392 | - * |
|
393 | - * This function set an app as enabled in appconfig. |
|
394 | - */ |
|
395 | - public function enable($appId, |
|
396 | - $groups = null) { |
|
397 | - self::$enabledAppsCache = []; // flush |
|
398 | - |
|
399 | - // Check if app is already downloaded |
|
400 | - $installer = \OC::$server->query(Installer::class); |
|
401 | - $isDownloaded = $installer->isDownloaded($appId); |
|
402 | - |
|
403 | - if(!$isDownloaded) { |
|
404 | - $installer->downloadApp($appId); |
|
405 | - } |
|
406 | - |
|
407 | - $installer->installApp($appId); |
|
408 | - |
|
409 | - $appManager = \OC::$server->getAppManager(); |
|
410 | - if (!is_null($groups)) { |
|
411 | - $groupManager = \OC::$server->getGroupManager(); |
|
412 | - $groupsList = []; |
|
413 | - foreach ($groups as $group) { |
|
414 | - $groupItem = $groupManager->get($group); |
|
415 | - if ($groupItem instanceof \OCP\IGroup) { |
|
416 | - $groupsList[] = $groupManager->get($group); |
|
417 | - } |
|
418 | - } |
|
419 | - $appManager->enableAppForGroups($appId, $groupsList); |
|
420 | - } else { |
|
421 | - $appManager->enableApp($appId); |
|
422 | - } |
|
423 | - } |
|
424 | - |
|
425 | - /** |
|
426 | - * @param string $app |
|
427 | - * @return bool |
|
428 | - */ |
|
429 | - public static function removeApp($app) { |
|
430 | - if (\OC::$server->getAppManager()->isShipped($app)) { |
|
431 | - return false; |
|
432 | - } |
|
433 | - |
|
434 | - $installer = \OC::$server->query(Installer::class); |
|
435 | - return $installer->removeApp($app); |
|
436 | - } |
|
437 | - |
|
438 | - /** |
|
439 | - * This function set an app as disabled in appconfig. |
|
440 | - * |
|
441 | - * @param string $app app |
|
442 | - * @throws Exception |
|
443 | - */ |
|
444 | - public static function disable($app) { |
|
445 | - // flush |
|
446 | - self::$enabledAppsCache = array(); |
|
447 | - |
|
448 | - // run uninstall steps |
|
449 | - $appData = OC_App::getAppInfo($app); |
|
450 | - if (!is_null($appData)) { |
|
451 | - OC_App::executeRepairSteps($app, $appData['repair-steps']['uninstall']); |
|
452 | - } |
|
453 | - |
|
454 | - // emit disable hook - needed anymore ? |
|
455 | - \OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app)); |
|
456 | - |
|
457 | - // finally disable it |
|
458 | - $appManager = \OC::$server->getAppManager(); |
|
459 | - $appManager->disableApp($app); |
|
460 | - } |
|
461 | - |
|
462 | - // This is private as well. It simply works, so don't ask for more details |
|
463 | - private static function proceedNavigation($list) { |
|
464 | - usort($list, function($a, $b) { |
|
465 | - if (isset($a['order']) && isset($b['order'])) { |
|
466 | - return ($a['order'] < $b['order']) ? -1 : 1; |
|
467 | - } else if (isset($a['order']) || isset($b['order'])) { |
|
468 | - return isset($a['order']) ? -1 : 1; |
|
469 | - } else { |
|
470 | - return ($a['name'] < $b['name']) ? -1 : 1; |
|
471 | - } |
|
472 | - }); |
|
473 | - |
|
474 | - $activeApp = OC::$server->getNavigationManager()->getActiveEntry(); |
|
475 | - foreach ($list as $index => &$navEntry) { |
|
476 | - if ($navEntry['id'] == $activeApp) { |
|
477 | - $navEntry['active'] = true; |
|
478 | - } else { |
|
479 | - $navEntry['active'] = false; |
|
480 | - } |
|
481 | - } |
|
482 | - unset($navEntry); |
|
483 | - |
|
484 | - return $list; |
|
485 | - } |
|
486 | - |
|
487 | - /** |
|
488 | - * Get the path where to install apps |
|
489 | - * |
|
490 | - * @return string|false |
|
491 | - */ |
|
492 | - public static function getInstallPath() { |
|
493 | - if (\OC::$server->getSystemConfig()->getValue('appstoreenabled', true) == false) { |
|
494 | - return false; |
|
495 | - } |
|
496 | - |
|
497 | - foreach (OC::$APPSROOTS as $dir) { |
|
498 | - if (isset($dir['writable']) && $dir['writable'] === true) { |
|
499 | - return $dir['path']; |
|
500 | - } |
|
501 | - } |
|
502 | - |
|
503 | - \OCP\Util::writeLog('core', 'No application directories are marked as writable.', \OCP\Util::ERROR); |
|
504 | - return null; |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - /** |
|
509 | - * search for an app in all app-directories |
|
510 | - * |
|
511 | - * @param string $appId |
|
512 | - * @return false|string |
|
513 | - */ |
|
514 | - public static function findAppInDirectories($appId) { |
|
515 | - $sanitizedAppId = self::cleanAppId($appId); |
|
516 | - if($sanitizedAppId !== $appId) { |
|
517 | - return false; |
|
518 | - } |
|
519 | - static $app_dir = array(); |
|
520 | - |
|
521 | - if (isset($app_dir[$appId])) { |
|
522 | - return $app_dir[$appId]; |
|
523 | - } |
|
524 | - |
|
525 | - $possibleApps = array(); |
|
526 | - foreach (OC::$APPSROOTS as $dir) { |
|
527 | - if (file_exists($dir['path'] . '/' . $appId)) { |
|
528 | - $possibleApps[] = $dir; |
|
529 | - } |
|
530 | - } |
|
531 | - |
|
532 | - if (empty($possibleApps)) { |
|
533 | - return false; |
|
534 | - } elseif (count($possibleApps) === 1) { |
|
535 | - $dir = array_shift($possibleApps); |
|
536 | - $app_dir[$appId] = $dir; |
|
537 | - return $dir; |
|
538 | - } else { |
|
539 | - $versionToLoad = array(); |
|
540 | - foreach ($possibleApps as $possibleApp) { |
|
541 | - $version = self::getAppVersionByPath($possibleApp['path']); |
|
542 | - if (empty($versionToLoad) || version_compare($version, $versionToLoad['version'], '>')) { |
|
543 | - $versionToLoad = array( |
|
544 | - 'dir' => $possibleApp, |
|
545 | - 'version' => $version, |
|
546 | - ); |
|
547 | - } |
|
548 | - } |
|
549 | - $app_dir[$appId] = $versionToLoad['dir']; |
|
550 | - return $versionToLoad['dir']; |
|
551 | - //TODO - write test |
|
552 | - } |
|
553 | - } |
|
554 | - |
|
555 | - /** |
|
556 | - * Get the directory for the given app. |
|
557 | - * If the app is defined in multiple directories, the first one is taken. (false if not found) |
|
558 | - * |
|
559 | - * @param string $appId |
|
560 | - * @return string|false |
|
561 | - */ |
|
562 | - public static function getAppPath($appId) { |
|
563 | - if ($appId === null || trim($appId) === '') { |
|
564 | - return false; |
|
565 | - } |
|
566 | - |
|
567 | - if (($dir = self::findAppInDirectories($appId)) != false) { |
|
568 | - return $dir['path'] . '/' . $appId; |
|
569 | - } |
|
570 | - return false; |
|
571 | - } |
|
572 | - |
|
573 | - /** |
|
574 | - * Get the path for the given app on the access |
|
575 | - * If the app is defined in multiple directories, the first one is taken. (false if not found) |
|
576 | - * |
|
577 | - * @param string $appId |
|
578 | - * @return string|false |
|
579 | - */ |
|
580 | - public static function getAppWebPath($appId) { |
|
581 | - if (($dir = self::findAppInDirectories($appId)) != false) { |
|
582 | - return OC::$WEBROOT . $dir['url'] . '/' . $appId; |
|
583 | - } |
|
584 | - return false; |
|
585 | - } |
|
586 | - |
|
587 | - /** |
|
588 | - * get the last version of the app from appinfo/info.xml |
|
589 | - * |
|
590 | - * @param string $appId |
|
591 | - * @param bool $useCache |
|
592 | - * @return string |
|
593 | - */ |
|
594 | - public static function getAppVersion($appId, $useCache = true) { |
|
595 | - if($useCache && isset(self::$appVersion[$appId])) { |
|
596 | - return self::$appVersion[$appId]; |
|
597 | - } |
|
598 | - |
|
599 | - $file = self::getAppPath($appId); |
|
600 | - self::$appVersion[$appId] = ($file !== false) ? self::getAppVersionByPath($file) : '0'; |
|
601 | - return self::$appVersion[$appId]; |
|
602 | - } |
|
603 | - |
|
604 | - /** |
|
605 | - * get app's version based on it's path |
|
606 | - * |
|
607 | - * @param string $path |
|
608 | - * @return string |
|
609 | - */ |
|
610 | - public static function getAppVersionByPath($path) { |
|
611 | - $infoFile = $path . '/appinfo/info.xml'; |
|
612 | - $appData = self::getAppInfo($infoFile, true); |
|
613 | - return isset($appData['version']) ? $appData['version'] : ''; |
|
614 | - } |
|
615 | - |
|
616 | - |
|
617 | - /** |
|
618 | - * Read all app metadata from the info.xml file |
|
619 | - * |
|
620 | - * @param string $appId id of the app or the path of the info.xml file |
|
621 | - * @param bool $path |
|
622 | - * @param string $lang |
|
623 | - * @return array|null |
|
624 | - * @note all data is read from info.xml, not just pre-defined fields |
|
625 | - */ |
|
626 | - public static function getAppInfo($appId, $path = false, $lang = null) { |
|
627 | - if ($path) { |
|
628 | - $file = $appId; |
|
629 | - } else { |
|
630 | - if ($lang === null && isset(self::$appInfo[$appId])) { |
|
631 | - return self::$appInfo[$appId]; |
|
632 | - } |
|
633 | - $appPath = self::getAppPath($appId); |
|
634 | - if($appPath === false) { |
|
635 | - return null; |
|
636 | - } |
|
637 | - $file = $appPath . '/appinfo/info.xml'; |
|
638 | - } |
|
639 | - |
|
640 | - $parser = new InfoParser(\OC::$server->getMemCacheFactory()->createLocal('core.appinfo')); |
|
641 | - $data = $parser->parse($file); |
|
642 | - |
|
643 | - if (is_array($data)) { |
|
644 | - $data = OC_App::parseAppInfo($data, $lang); |
|
645 | - } |
|
646 | - if(isset($data['ocsid'])) { |
|
647 | - $storedId = \OC::$server->getConfig()->getAppValue($appId, 'ocsid'); |
|
648 | - if($storedId !== '' && $storedId !== $data['ocsid']) { |
|
649 | - $data['ocsid'] = $storedId; |
|
650 | - } |
|
651 | - } |
|
652 | - |
|
653 | - if ($lang === null) { |
|
654 | - self::$appInfo[$appId] = $data; |
|
655 | - } |
|
656 | - |
|
657 | - return $data; |
|
658 | - } |
|
659 | - |
|
660 | - /** |
|
661 | - * Returns the navigation |
|
662 | - * |
|
663 | - * @return array |
|
664 | - * |
|
665 | - * This function returns an array containing all entries added. The |
|
666 | - * entries are sorted by the key 'order' ascending. Additional to the keys |
|
667 | - * given for each app the following keys exist: |
|
668 | - * - active: boolean, signals if the user is on this navigation entry |
|
669 | - */ |
|
670 | - public static function getNavigation() { |
|
671 | - $entries = OC::$server->getNavigationManager()->getAll(); |
|
672 | - return self::proceedNavigation($entries); |
|
673 | - } |
|
674 | - |
|
675 | - /** |
|
676 | - * Returns the Settings Navigation |
|
677 | - * |
|
678 | - * @return string[] |
|
679 | - * |
|
680 | - * This function returns an array containing all settings pages added. The |
|
681 | - * entries are sorted by the key 'order' ascending. |
|
682 | - */ |
|
683 | - public static function getSettingsNavigation() { |
|
684 | - $entries = OC::$server->getNavigationManager()->getAll('settings'); |
|
685 | - return self::proceedNavigation($entries); |
|
686 | - } |
|
687 | - |
|
688 | - /** |
|
689 | - * get the id of loaded app |
|
690 | - * |
|
691 | - * @return string |
|
692 | - */ |
|
693 | - public static function getCurrentApp() { |
|
694 | - $request = \OC::$server->getRequest(); |
|
695 | - $script = substr($request->getScriptName(), strlen(OC::$WEBROOT) + 1); |
|
696 | - $topFolder = substr($script, 0, strpos($script, '/') ?: 0); |
|
697 | - if (empty($topFolder)) { |
|
698 | - $path_info = $request->getPathInfo(); |
|
699 | - if ($path_info) { |
|
700 | - $topFolder = substr($path_info, 1, strpos($path_info, '/', 1) - 1); |
|
701 | - } |
|
702 | - } |
|
703 | - if ($topFolder == 'apps') { |
|
704 | - $length = strlen($topFolder); |
|
705 | - return substr($script, $length + 1, strpos($script, '/', $length + 1) - $length - 1); |
|
706 | - } else { |
|
707 | - return $topFolder; |
|
708 | - } |
|
709 | - } |
|
710 | - |
|
711 | - /** |
|
712 | - * @param string $type |
|
713 | - * @return array |
|
714 | - */ |
|
715 | - public static function getForms($type) { |
|
716 | - $forms = array(); |
|
717 | - switch ($type) { |
|
718 | - case 'admin': |
|
719 | - $source = self::$adminForms; |
|
720 | - break; |
|
721 | - case 'personal': |
|
722 | - $source = self::$personalForms; |
|
723 | - break; |
|
724 | - default: |
|
725 | - return array(); |
|
726 | - } |
|
727 | - foreach ($source as $form) { |
|
728 | - $forms[] = include $form; |
|
729 | - } |
|
730 | - return $forms; |
|
731 | - } |
|
732 | - |
|
733 | - /** |
|
734 | - * register an admin form to be shown |
|
735 | - * |
|
736 | - * @param string $app |
|
737 | - * @param string $page |
|
738 | - */ |
|
739 | - public static function registerAdmin($app, $page) { |
|
740 | - self::$adminForms[] = $app . '/' . $page . '.php'; |
|
741 | - } |
|
742 | - |
|
743 | - /** |
|
744 | - * register a personal form to be shown |
|
745 | - * @param string $app |
|
746 | - * @param string $page |
|
747 | - */ |
|
748 | - public static function registerPersonal($app, $page) { |
|
749 | - self::$personalForms[] = $app . '/' . $page . '.php'; |
|
750 | - } |
|
751 | - |
|
752 | - /** |
|
753 | - * @param array $entry |
|
754 | - */ |
|
755 | - public static function registerLogIn(array $entry) { |
|
756 | - self::$altLogin[] = $entry; |
|
757 | - } |
|
758 | - |
|
759 | - /** |
|
760 | - * @return array |
|
761 | - */ |
|
762 | - public static function getAlternativeLogIns() { |
|
763 | - return self::$altLogin; |
|
764 | - } |
|
765 | - |
|
766 | - /** |
|
767 | - * get a list of all apps in the apps folder |
|
768 | - * |
|
769 | - * @return array an array of app names (string IDs) |
|
770 | - * @todo: change the name of this method to getInstalledApps, which is more accurate |
|
771 | - */ |
|
772 | - public static function getAllApps() { |
|
773 | - |
|
774 | - $apps = array(); |
|
775 | - |
|
776 | - foreach (OC::$APPSROOTS as $apps_dir) { |
|
777 | - if (!is_readable($apps_dir['path'])) { |
|
778 | - \OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN); |
|
779 | - continue; |
|
780 | - } |
|
781 | - $dh = opendir($apps_dir['path']); |
|
782 | - |
|
783 | - if (is_resource($dh)) { |
|
784 | - while (($file = readdir($dh)) !== false) { |
|
785 | - |
|
786 | - if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) { |
|
787 | - |
|
788 | - $apps[] = $file; |
|
789 | - } |
|
790 | - } |
|
791 | - } |
|
792 | - } |
|
793 | - |
|
794 | - $apps = array_unique($apps); |
|
795 | - |
|
796 | - return $apps; |
|
797 | - } |
|
798 | - |
|
799 | - /** |
|
800 | - * List all apps, this is used in apps.php |
|
801 | - * |
|
802 | - * @return array |
|
803 | - */ |
|
804 | - public function listAllApps() { |
|
805 | - $installedApps = OC_App::getAllApps(); |
|
806 | - |
|
807 | - $appManager = \OC::$server->getAppManager(); |
|
808 | - //we don't want to show configuration for these |
|
809 | - $blacklist = $appManager->getAlwaysEnabledApps(); |
|
810 | - $appList = array(); |
|
811 | - $langCode = \OC::$server->getL10N('core')->getLanguageCode(); |
|
812 | - $urlGenerator = \OC::$server->getURLGenerator(); |
|
813 | - |
|
814 | - foreach ($installedApps as $app) { |
|
815 | - if (array_search($app, $blacklist) === false) { |
|
816 | - |
|
817 | - $info = OC_App::getAppInfo($app, false, $langCode); |
|
818 | - if (!is_array($info)) { |
|
819 | - \OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR); |
|
820 | - continue; |
|
821 | - } |
|
822 | - |
|
823 | - if (!isset($info['name'])) { |
|
824 | - \OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR); |
|
825 | - continue; |
|
826 | - } |
|
827 | - |
|
828 | - $enabled = \OC::$server->getConfig()->getAppValue($app, 'enabled', 'no'); |
|
829 | - $info['groups'] = null; |
|
830 | - if ($enabled === 'yes') { |
|
831 | - $active = true; |
|
832 | - } else if ($enabled === 'no') { |
|
833 | - $active = false; |
|
834 | - } else { |
|
835 | - $active = true; |
|
836 | - $info['groups'] = $enabled; |
|
837 | - } |
|
838 | - |
|
839 | - $info['active'] = $active; |
|
840 | - |
|
841 | - if ($appManager->isShipped($app)) { |
|
842 | - $info['internal'] = true; |
|
843 | - $info['level'] = self::officialApp; |
|
844 | - $info['removable'] = false; |
|
845 | - } else { |
|
846 | - $info['internal'] = false; |
|
847 | - $info['removable'] = true; |
|
848 | - } |
|
849 | - |
|
850 | - $appPath = self::getAppPath($app); |
|
851 | - if($appPath !== false) { |
|
852 | - $appIcon = $appPath . '/img/' . $app . '.svg'; |
|
853 | - if (file_exists($appIcon)) { |
|
854 | - $info['preview'] = $urlGenerator->imagePath($app, $app . '.svg'); |
|
855 | - $info['previewAsIcon'] = true; |
|
856 | - } else { |
|
857 | - $appIcon = $appPath . '/img/app.svg'; |
|
858 | - if (file_exists($appIcon)) { |
|
859 | - $info['preview'] = $urlGenerator->imagePath($app, 'app.svg'); |
|
860 | - $info['previewAsIcon'] = true; |
|
861 | - } |
|
862 | - } |
|
863 | - } |
|
864 | - // fix documentation |
|
865 | - if (isset($info['documentation']) && is_array($info['documentation'])) { |
|
866 | - foreach ($info['documentation'] as $key => $url) { |
|
867 | - // If it is not an absolute URL we assume it is a key |
|
868 | - // i.e. admin-ldap will get converted to go.php?to=admin-ldap |
|
869 | - if (stripos($url, 'https://') !== 0 && stripos($url, 'http://') !== 0) { |
|
870 | - $url = $urlGenerator->linkToDocs($url); |
|
871 | - } |
|
872 | - |
|
873 | - $info['documentation'][$key] = $url; |
|
874 | - } |
|
875 | - } |
|
876 | - |
|
877 | - $info['version'] = OC_App::getAppVersion($app); |
|
878 | - $appList[] = $info; |
|
879 | - } |
|
880 | - } |
|
881 | - |
|
882 | - return $appList; |
|
883 | - } |
|
884 | - |
|
885 | - public static function shouldUpgrade($app) { |
|
886 | - $versions = self::getAppVersions(); |
|
887 | - $currentVersion = OC_App::getAppVersion($app); |
|
888 | - if ($currentVersion && isset($versions[$app])) { |
|
889 | - $installedVersion = $versions[$app]; |
|
890 | - if (!version_compare($currentVersion, $installedVersion, '=')) { |
|
891 | - return true; |
|
892 | - } |
|
893 | - } |
|
894 | - return false; |
|
895 | - } |
|
896 | - |
|
897 | - /** |
|
898 | - * Adjust the number of version parts of $version1 to match |
|
899 | - * the number of version parts of $version2. |
|
900 | - * |
|
901 | - * @param string $version1 version to adjust |
|
902 | - * @param string $version2 version to take the number of parts from |
|
903 | - * @return string shortened $version1 |
|
904 | - */ |
|
905 | - private static function adjustVersionParts($version1, $version2) { |
|
906 | - $version1 = explode('.', $version1); |
|
907 | - $version2 = explode('.', $version2); |
|
908 | - // reduce $version1 to match the number of parts in $version2 |
|
909 | - while (count($version1) > count($version2)) { |
|
910 | - array_pop($version1); |
|
911 | - } |
|
912 | - // if $version1 does not have enough parts, add some |
|
913 | - while (count($version1) < count($version2)) { |
|
914 | - $version1[] = '0'; |
|
915 | - } |
|
916 | - return implode('.', $version1); |
|
917 | - } |
|
918 | - |
|
919 | - /** |
|
920 | - * Check whether the current ownCloud version matches the given |
|
921 | - * application's version requirements. |
|
922 | - * |
|
923 | - * The comparison is made based on the number of parts that the |
|
924 | - * app info version has. For example for ownCloud 6.0.3 if the |
|
925 | - * app info version is expecting version 6.0, the comparison is |
|
926 | - * made on the first two parts of the ownCloud version. |
|
927 | - * This means that it's possible to specify "requiremin" => 6 |
|
928 | - * and "requiremax" => 6 and it will still match ownCloud 6.0.3. |
|
929 | - * |
|
930 | - * @param string $ocVersion ownCloud version to check against |
|
931 | - * @param array $appInfo app info (from xml) |
|
932 | - * |
|
933 | - * @return boolean true if compatible, otherwise false |
|
934 | - */ |
|
935 | - public static function isAppCompatible($ocVersion, $appInfo) { |
|
936 | - $requireMin = ''; |
|
937 | - $requireMax = ''; |
|
938 | - if (isset($appInfo['dependencies']['nextcloud']['@attributes']['min-version'])) { |
|
939 | - $requireMin = $appInfo['dependencies']['nextcloud']['@attributes']['min-version']; |
|
940 | - } elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['min-version'])) { |
|
941 | - $requireMin = $appInfo['dependencies']['owncloud']['@attributes']['min-version']; |
|
942 | - } else if (isset($appInfo['requiremin'])) { |
|
943 | - $requireMin = $appInfo['requiremin']; |
|
944 | - } else if (isset($appInfo['require'])) { |
|
945 | - $requireMin = $appInfo['require']; |
|
946 | - } |
|
947 | - |
|
948 | - if (isset($appInfo['dependencies']['nextcloud']['@attributes']['max-version'])) { |
|
949 | - $requireMax = $appInfo['dependencies']['nextcloud']['@attributes']['max-version']; |
|
950 | - } elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['max-version'])) { |
|
951 | - $requireMax = $appInfo['dependencies']['owncloud']['@attributes']['max-version']; |
|
952 | - } else if (isset($appInfo['requiremax'])) { |
|
953 | - $requireMax = $appInfo['requiremax']; |
|
954 | - } |
|
955 | - |
|
956 | - if (is_array($ocVersion)) { |
|
957 | - $ocVersion = implode('.', $ocVersion); |
|
958 | - } |
|
959 | - |
|
960 | - if (!empty($requireMin) |
|
961 | - && version_compare(self::adjustVersionParts($ocVersion, $requireMin), $requireMin, '<') |
|
962 | - ) { |
|
963 | - |
|
964 | - return false; |
|
965 | - } |
|
966 | - |
|
967 | - if (!empty($requireMax) |
|
968 | - && version_compare(self::adjustVersionParts($ocVersion, $requireMax), $requireMax, '>') |
|
969 | - ) { |
|
970 | - return false; |
|
971 | - } |
|
972 | - |
|
973 | - return true; |
|
974 | - } |
|
975 | - |
|
976 | - /** |
|
977 | - * get the installed version of all apps |
|
978 | - */ |
|
979 | - public static function getAppVersions() { |
|
980 | - static $versions; |
|
981 | - |
|
982 | - if(!$versions) { |
|
983 | - $appConfig = \OC::$server->getAppConfig(); |
|
984 | - $versions = $appConfig->getValues(false, 'installed_version'); |
|
985 | - } |
|
986 | - return $versions; |
|
987 | - } |
|
988 | - |
|
989 | - /** |
|
990 | - * @param string $app |
|
991 | - * @param \OCP\IConfig $config |
|
992 | - * @param \OCP\IL10N $l |
|
993 | - * @return bool |
|
994 | - * |
|
995 | - * @throws Exception if app is not compatible with this version of ownCloud |
|
996 | - * @throws Exception if no app-name was specified |
|
997 | - */ |
|
998 | - public function installApp($app, |
|
999 | - \OCP\IConfig $config, |
|
1000 | - \OCP\IL10N $l) { |
|
1001 | - if ($app !== false) { |
|
1002 | - // check if the app is compatible with this version of ownCloud |
|
1003 | - $info = self::getAppInfo($app); |
|
1004 | - if(!is_array($info)) { |
|
1005 | - throw new \Exception( |
|
1006 | - $l->t('App "%s" cannot be installed because appinfo file cannot be read.', |
|
1007 | - [$info['name']] |
|
1008 | - ) |
|
1009 | - ); |
|
1010 | - } |
|
1011 | - |
|
1012 | - $version = \OCP\Util::getVersion(); |
|
1013 | - if (!self::isAppCompatible($version, $info)) { |
|
1014 | - throw new \Exception( |
|
1015 | - $l->t('App "%s" cannot be installed because it is not compatible with this version of the server.', |
|
1016 | - array($info['name']) |
|
1017 | - ) |
|
1018 | - ); |
|
1019 | - } |
|
1020 | - |
|
1021 | - // check for required dependencies |
|
1022 | - self::checkAppDependencies($config, $l, $info); |
|
1023 | - |
|
1024 | - $config->setAppValue($app, 'enabled', 'yes'); |
|
1025 | - if (isset($appData['id'])) { |
|
1026 | - $config->setAppValue($app, 'ocsid', $appData['id']); |
|
1027 | - } |
|
1028 | - |
|
1029 | - if(isset($info['settings']) && is_array($info['settings'])) { |
|
1030 | - $appPath = self::getAppPath($app); |
|
1031 | - self::registerAutoloading($app, $appPath); |
|
1032 | - \OC::$server->getSettingsManager()->setupSettings($info['settings']); |
|
1033 | - } |
|
1034 | - |
|
1035 | - \OC_Hook::emit('OC_App', 'post_enable', array('app' => $app)); |
|
1036 | - } else { |
|
1037 | - if(empty($appName) ) { |
|
1038 | - throw new \Exception($l->t("No app name specified")); |
|
1039 | - } else { |
|
1040 | - throw new \Exception($l->t("App '%s' could not be installed!", $appName)); |
|
1041 | - } |
|
1042 | - } |
|
1043 | - |
|
1044 | - return $app; |
|
1045 | - } |
|
1046 | - |
|
1047 | - /** |
|
1048 | - * update the database for the app and call the update script |
|
1049 | - * |
|
1050 | - * @param string $appId |
|
1051 | - * @return bool |
|
1052 | - */ |
|
1053 | - public static function updateApp($appId) { |
|
1054 | - $appPath = self::getAppPath($appId); |
|
1055 | - if($appPath === false) { |
|
1056 | - return false; |
|
1057 | - } |
|
1058 | - self::registerAutoloading($appId, $appPath); |
|
1059 | - |
|
1060 | - $appData = self::getAppInfo($appId); |
|
1061 | - self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']); |
|
1062 | - |
|
1063 | - if (file_exists($appPath . '/appinfo/database.xml')) { |
|
1064 | - OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml'); |
|
1065 | - } else { |
|
1066 | - $ms = new MigrationService($appId, \OC::$server->getDatabaseConnection()); |
|
1067 | - $ms->migrate(); |
|
1068 | - } |
|
1069 | - |
|
1070 | - self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']); |
|
1071 | - self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']); |
|
1072 | - unset(self::$appVersion[$appId]); |
|
1073 | - |
|
1074 | - // run upgrade code |
|
1075 | - if (file_exists($appPath . '/appinfo/update.php')) { |
|
1076 | - self::loadApp($appId); |
|
1077 | - include $appPath . '/appinfo/update.php'; |
|
1078 | - } |
|
1079 | - self::setupBackgroundJobs($appData['background-jobs']); |
|
1080 | - if(isset($appData['settings']) && is_array($appData['settings'])) { |
|
1081 | - \OC::$server->getSettingsManager()->setupSettings($appData['settings']); |
|
1082 | - } |
|
1083 | - |
|
1084 | - //set remote/public handlers |
|
1085 | - if (array_key_exists('ocsid', $appData)) { |
|
1086 | - \OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']); |
|
1087 | - } elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) { |
|
1088 | - \OC::$server->getConfig()->deleteAppValue($appId, 'ocsid'); |
|
1089 | - } |
|
1090 | - foreach ($appData['remote'] as $name => $path) { |
|
1091 | - \OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path); |
|
1092 | - } |
|
1093 | - foreach ($appData['public'] as $name => $path) { |
|
1094 | - \OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path); |
|
1095 | - } |
|
1096 | - |
|
1097 | - self::setAppTypes($appId); |
|
1098 | - |
|
1099 | - $version = \OC_App::getAppVersion($appId); |
|
1100 | - \OC::$server->getConfig()->setAppValue($appId, 'installed_version', $version); |
|
1101 | - |
|
1102 | - \OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent( |
|
1103 | - ManagerEvent::EVENT_APP_UPDATE, $appId |
|
1104 | - )); |
|
1105 | - |
|
1106 | - return true; |
|
1107 | - } |
|
1108 | - |
|
1109 | - /** |
|
1110 | - * @param string $appId |
|
1111 | - * @param string[] $steps |
|
1112 | - * @throws \OC\NeedsUpdateException |
|
1113 | - */ |
|
1114 | - public static function executeRepairSteps($appId, array $steps) { |
|
1115 | - if (empty($steps)) { |
|
1116 | - return; |
|
1117 | - } |
|
1118 | - // load the app |
|
1119 | - self::loadApp($appId); |
|
1120 | - |
|
1121 | - $dispatcher = OC::$server->getEventDispatcher(); |
|
1122 | - |
|
1123 | - // load the steps |
|
1124 | - $r = new Repair([], $dispatcher); |
|
1125 | - foreach ($steps as $step) { |
|
1126 | - try { |
|
1127 | - $r->addStep($step); |
|
1128 | - } catch (Exception $ex) { |
|
1129 | - $r->emit('\OC\Repair', 'error', [$ex->getMessage()]); |
|
1130 | - \OC::$server->getLogger()->logException($ex); |
|
1131 | - } |
|
1132 | - } |
|
1133 | - // run the steps |
|
1134 | - $r->run(); |
|
1135 | - } |
|
1136 | - |
|
1137 | - public static function setupBackgroundJobs(array $jobs) { |
|
1138 | - $queue = \OC::$server->getJobList(); |
|
1139 | - foreach ($jobs as $job) { |
|
1140 | - $queue->add($job); |
|
1141 | - } |
|
1142 | - } |
|
1143 | - |
|
1144 | - /** |
|
1145 | - * @param string $appId |
|
1146 | - * @param string[] $steps |
|
1147 | - */ |
|
1148 | - private static function setupLiveMigrations($appId, array $steps) { |
|
1149 | - $queue = \OC::$server->getJobList(); |
|
1150 | - foreach ($steps as $step) { |
|
1151 | - $queue->add('OC\Migration\BackgroundRepair', [ |
|
1152 | - 'app' => $appId, |
|
1153 | - 'step' => $step]); |
|
1154 | - } |
|
1155 | - } |
|
1156 | - |
|
1157 | - /** |
|
1158 | - * @param string $appId |
|
1159 | - * @return \OC\Files\View|false |
|
1160 | - */ |
|
1161 | - public static function getStorage($appId) { |
|
1162 | - if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check |
|
1163 | - if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
1164 | - $view = new \OC\Files\View('/' . OC_User::getUser()); |
|
1165 | - if (!$view->file_exists($appId)) { |
|
1166 | - $view->mkdir($appId); |
|
1167 | - } |
|
1168 | - return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId); |
|
1169 | - } else { |
|
1170 | - \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR); |
|
1171 | - return false; |
|
1172 | - } |
|
1173 | - } else { |
|
1174 | - \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR); |
|
1175 | - return false; |
|
1176 | - } |
|
1177 | - } |
|
1178 | - |
|
1179 | - protected static function findBestL10NOption($options, $lang) { |
|
1180 | - $fallback = $similarLangFallback = $englishFallback = false; |
|
1181 | - |
|
1182 | - $lang = strtolower($lang); |
|
1183 | - $similarLang = $lang; |
|
1184 | - if (strpos($similarLang, '_')) { |
|
1185 | - // For "de_DE" we want to find "de" and the other way around |
|
1186 | - $similarLang = substr($lang, 0, strpos($lang, '_')); |
|
1187 | - } |
|
1188 | - |
|
1189 | - foreach ($options as $option) { |
|
1190 | - if (is_array($option)) { |
|
1191 | - if ($fallback === false) { |
|
1192 | - $fallback = $option['@value']; |
|
1193 | - } |
|
1194 | - |
|
1195 | - if (!isset($option['@attributes']['lang'])) { |
|
1196 | - continue; |
|
1197 | - } |
|
1198 | - |
|
1199 | - $attributeLang = strtolower($option['@attributes']['lang']); |
|
1200 | - if ($attributeLang === $lang) { |
|
1201 | - return $option['@value']; |
|
1202 | - } |
|
1203 | - |
|
1204 | - if ($attributeLang === $similarLang) { |
|
1205 | - $similarLangFallback = $option['@value']; |
|
1206 | - } else if (strpos($attributeLang, $similarLang . '_') === 0) { |
|
1207 | - if ($similarLangFallback === false) { |
|
1208 | - $similarLangFallback = $option['@value']; |
|
1209 | - } |
|
1210 | - } |
|
1211 | - } else { |
|
1212 | - $englishFallback = $option; |
|
1213 | - } |
|
1214 | - } |
|
1215 | - |
|
1216 | - if ($similarLangFallback !== false) { |
|
1217 | - return $similarLangFallback; |
|
1218 | - } else if ($englishFallback !== false) { |
|
1219 | - return $englishFallback; |
|
1220 | - } |
|
1221 | - return (string) $fallback; |
|
1222 | - } |
|
1223 | - |
|
1224 | - /** |
|
1225 | - * parses the app data array and enhanced the 'description' value |
|
1226 | - * |
|
1227 | - * @param array $data the app data |
|
1228 | - * @param string $lang |
|
1229 | - * @return array improved app data |
|
1230 | - */ |
|
1231 | - public static function parseAppInfo(array $data, $lang = null) { |
|
1232 | - |
|
1233 | - if ($lang && isset($data['name']) && is_array($data['name'])) { |
|
1234 | - $data['name'] = self::findBestL10NOption($data['name'], $lang); |
|
1235 | - } |
|
1236 | - if ($lang && isset($data['summary']) && is_array($data['summary'])) { |
|
1237 | - $data['summary'] = self::findBestL10NOption($data['summary'], $lang); |
|
1238 | - } |
|
1239 | - if ($lang && isset($data['description']) && is_array($data['description'])) { |
|
1240 | - $data['description'] = trim(self::findBestL10NOption($data['description'], $lang)); |
|
1241 | - } else if (isset($data['description']) && is_string($data['description'])) { |
|
1242 | - $data['description'] = trim($data['description']); |
|
1243 | - } else { |
|
1244 | - $data['description'] = ''; |
|
1245 | - } |
|
1246 | - |
|
1247 | - return $data; |
|
1248 | - } |
|
1249 | - |
|
1250 | - /** |
|
1251 | - * @param \OCP\IConfig $config |
|
1252 | - * @param \OCP\IL10N $l |
|
1253 | - * @param array $info |
|
1254 | - * @throws \Exception |
|
1255 | - */ |
|
1256 | - public static function checkAppDependencies($config, $l, $info) { |
|
1257 | - $dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l); |
|
1258 | - $missing = $dependencyAnalyzer->analyze($info); |
|
1259 | - if (!empty($missing)) { |
|
1260 | - $missingMsg = implode(PHP_EOL, $missing); |
|
1261 | - throw new \Exception( |
|
1262 | - $l->t('App "%s" cannot be installed because the following dependencies are not fulfilled: %s', |
|
1263 | - [$info['name'], $missingMsg] |
|
1264 | - ) |
|
1265 | - ); |
|
1266 | - } |
|
1267 | - } |
|
66 | + static private $appVersion = []; |
|
67 | + static private $adminForms = array(); |
|
68 | + static private $personalForms = array(); |
|
69 | + static private $appInfo = array(); |
|
70 | + static private $appTypes = array(); |
|
71 | + static private $loadedApps = array(); |
|
72 | + static private $altLogin = array(); |
|
73 | + static private $alreadyRegistered = []; |
|
74 | + const officialApp = 200; |
|
75 | + |
|
76 | + /** |
|
77 | + * clean the appId |
|
78 | + * |
|
79 | + * @param string|boolean $app AppId that needs to be cleaned |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public static function cleanAppId($app) { |
|
83 | + return str_replace(array('\0', '/', '\\', '..'), '', $app); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Check if an app is loaded |
|
88 | + * |
|
89 | + * @param string $app |
|
90 | + * @return bool |
|
91 | + */ |
|
92 | + public static function isAppLoaded($app) { |
|
93 | + return in_array($app, self::$loadedApps, true); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * loads all apps |
|
98 | + * |
|
99 | + * @param string[] | string | null $types |
|
100 | + * @return bool |
|
101 | + * |
|
102 | + * This function walks through the ownCloud directory and loads all apps |
|
103 | + * it can find. A directory contains an app if the file /appinfo/info.xml |
|
104 | + * exists. |
|
105 | + * |
|
106 | + * if $types is set, only apps of those types will be loaded |
|
107 | + */ |
|
108 | + public static function loadApps($types = null) { |
|
109 | + if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) { |
|
110 | + return false; |
|
111 | + } |
|
112 | + // Load the enabled apps here |
|
113 | + $apps = self::getEnabledApps(); |
|
114 | + |
|
115 | + // Add each apps' folder as allowed class path |
|
116 | + foreach($apps as $app) { |
|
117 | + $path = self::getAppPath($app); |
|
118 | + if($path !== false) { |
|
119 | + self::registerAutoloading($app, $path); |
|
120 | + } |
|
121 | + } |
|
122 | + |
|
123 | + // prevent app.php from printing output |
|
124 | + ob_start(); |
|
125 | + foreach ($apps as $app) { |
|
126 | + if ((is_null($types) or self::isType($app, $types)) && !in_array($app, self::$loadedApps)) { |
|
127 | + self::loadApp($app); |
|
128 | + } |
|
129 | + } |
|
130 | + ob_end_clean(); |
|
131 | + |
|
132 | + return true; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * load a single app |
|
137 | + * |
|
138 | + * @param string $app |
|
139 | + */ |
|
140 | + public static function loadApp($app) { |
|
141 | + self::$loadedApps[] = $app; |
|
142 | + $appPath = self::getAppPath($app); |
|
143 | + if($appPath === false) { |
|
144 | + return; |
|
145 | + } |
|
146 | + |
|
147 | + // in case someone calls loadApp() directly |
|
148 | + self::registerAutoloading($app, $appPath); |
|
149 | + |
|
150 | + if (is_file($appPath . '/appinfo/app.php')) { |
|
151 | + \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app); |
|
152 | + self::requireAppFile($app); |
|
153 | + if (self::isType($app, array('authentication'))) { |
|
154 | + // since authentication apps affect the "is app enabled for group" check, |
|
155 | + // the enabled apps cache needs to be cleared to make sure that the |
|
156 | + // next time getEnableApps() is called it will also include apps that were |
|
157 | + // enabled for groups |
|
158 | + self::$enabledAppsCache = array(); |
|
159 | + } |
|
160 | + \OC::$server->getEventLogger()->end('load_app_' . $app); |
|
161 | + } |
|
162 | + |
|
163 | + $info = self::getAppInfo($app); |
|
164 | + if (!empty($info['activity']['filters'])) { |
|
165 | + foreach ($info['activity']['filters'] as $filter) { |
|
166 | + \OC::$server->getActivityManager()->registerFilter($filter); |
|
167 | + } |
|
168 | + } |
|
169 | + if (!empty($info['activity']['settings'])) { |
|
170 | + foreach ($info['activity']['settings'] as $setting) { |
|
171 | + \OC::$server->getActivityManager()->registerSetting($setting); |
|
172 | + } |
|
173 | + } |
|
174 | + if (!empty($info['activity']['providers'])) { |
|
175 | + foreach ($info['activity']['providers'] as $provider) { |
|
176 | + \OC::$server->getActivityManager()->registerProvider($provider); |
|
177 | + } |
|
178 | + } |
|
179 | + |
|
180 | + if (!empty($info['settings']['admin'])) { |
|
181 | + foreach ($info['settings']['admin'] as $setting) { |
|
182 | + \OC::$server->getSettingsManager()->registerSetting('admin', $setting); |
|
183 | + } |
|
184 | + } |
|
185 | + if (!empty($info['settings']['admin-section'])) { |
|
186 | + foreach ($info['settings']['admin-section'] as $section) { |
|
187 | + \OC::$server->getSettingsManager()->registerSection('admin', $section); |
|
188 | + } |
|
189 | + } |
|
190 | + if (!empty($info['settings']['personal'])) { |
|
191 | + foreach ($info['settings']['personal'] as $setting) { |
|
192 | + \OC::$server->getSettingsManager()->registerSetting('personal', $setting); |
|
193 | + } |
|
194 | + } |
|
195 | + if (!empty($info['settings']['personal-section'])) { |
|
196 | + foreach ($info['settings']['personal-section'] as $section) { |
|
197 | + \OC::$server->getSettingsManager()->registerSection('personal', $section); |
|
198 | + } |
|
199 | + } |
|
200 | + |
|
201 | + if (!empty($info['collaboration']['plugins'])) { |
|
202 | + // deal with one or many plugin entries |
|
203 | + $plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ? |
|
204 | + [$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin']; |
|
205 | + foreach ($plugins as $plugin) { |
|
206 | + if($plugin['@attributes']['type'] === 'collaborator-search') { |
|
207 | + $pluginInfo = [ |
|
208 | + 'shareType' => $plugin['@attributes']['share-type'], |
|
209 | + 'class' => $plugin['@value'], |
|
210 | + ]; |
|
211 | + \OC::$server->getCollaboratorSearch()->registerPlugin($pluginInfo); |
|
212 | + } else if ($plugin['@attributes']['type'] === 'autocomplete-sort') { |
|
213 | + \OC::$server->getAutoCompleteManager()->registerSorter($plugin['@value']); |
|
214 | + } |
|
215 | + } |
|
216 | + } |
|
217 | + } |
|
218 | + |
|
219 | + /** |
|
220 | + * @internal |
|
221 | + * @param string $app |
|
222 | + * @param string $path |
|
223 | + */ |
|
224 | + public static function registerAutoloading($app, $path) { |
|
225 | + $key = $app . '-' . $path; |
|
226 | + if(isset(self::$alreadyRegistered[$key])) { |
|
227 | + return; |
|
228 | + } |
|
229 | + |
|
230 | + self::$alreadyRegistered[$key] = true; |
|
231 | + |
|
232 | + // Register on PSR-4 composer autoloader |
|
233 | + $appNamespace = \OC\AppFramework\App::buildAppNamespace($app); |
|
234 | + \OC::$server->registerNamespace($app, $appNamespace); |
|
235 | + |
|
236 | + if (file_exists($path . '/composer/autoload.php')) { |
|
237 | + require_once $path . '/composer/autoload.php'; |
|
238 | + } else { |
|
239 | + \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true); |
|
240 | + // Register on legacy autoloader |
|
241 | + \OC::$loader->addValidRoot($path); |
|
242 | + } |
|
243 | + |
|
244 | + // Register Test namespace only when testing |
|
245 | + if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) { |
|
246 | + \OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true); |
|
247 | + } |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * Load app.php from the given app |
|
252 | + * |
|
253 | + * @param string $app app name |
|
254 | + */ |
|
255 | + private static function requireAppFile($app) { |
|
256 | + try { |
|
257 | + // encapsulated here to avoid variable scope conflicts |
|
258 | + require_once $app . '/appinfo/app.php'; |
|
259 | + } catch (Error $ex) { |
|
260 | + \OC::$server->getLogger()->logException($ex); |
|
261 | + if (!\OC::$server->getAppManager()->isShipped($app)) { |
|
262 | + // Only disable apps which are not shipped |
|
263 | + self::disable($app); |
|
264 | + } |
|
265 | + } |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * check if an app is of a specific type |
|
270 | + * |
|
271 | + * @param string $app |
|
272 | + * @param string|array $types |
|
273 | + * @return bool |
|
274 | + */ |
|
275 | + public static function isType($app, $types) { |
|
276 | + if (is_string($types)) { |
|
277 | + $types = array($types); |
|
278 | + } |
|
279 | + $appTypes = self::getAppTypes($app); |
|
280 | + foreach ($types as $type) { |
|
281 | + if (array_search($type, $appTypes) !== false) { |
|
282 | + return true; |
|
283 | + } |
|
284 | + } |
|
285 | + return false; |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * get the types of an app |
|
290 | + * |
|
291 | + * @param string $app |
|
292 | + * @return array |
|
293 | + */ |
|
294 | + private static function getAppTypes($app) { |
|
295 | + //load the cache |
|
296 | + if (count(self::$appTypes) == 0) { |
|
297 | + self::$appTypes = \OC::$server->getAppConfig()->getValues(false, 'types'); |
|
298 | + } |
|
299 | + |
|
300 | + if (isset(self::$appTypes[$app])) { |
|
301 | + return explode(',', self::$appTypes[$app]); |
|
302 | + } else { |
|
303 | + return array(); |
|
304 | + } |
|
305 | + } |
|
306 | + |
|
307 | + /** |
|
308 | + * read app types from info.xml and cache them in the database |
|
309 | + */ |
|
310 | + public static function setAppTypes($app) { |
|
311 | + $appData = self::getAppInfo($app); |
|
312 | + if(!is_array($appData)) { |
|
313 | + return; |
|
314 | + } |
|
315 | + |
|
316 | + if (isset($appData['types'])) { |
|
317 | + $appTypes = implode(',', $appData['types']); |
|
318 | + } else { |
|
319 | + $appTypes = ''; |
|
320 | + $appData['types'] = []; |
|
321 | + } |
|
322 | + |
|
323 | + \OC::$server->getConfig()->setAppValue($app, 'types', $appTypes); |
|
324 | + |
|
325 | + if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) { |
|
326 | + $enabled = \OC::$server->getConfig()->getAppValue($app, 'enabled', 'yes'); |
|
327 | + if ($enabled !== 'yes' && $enabled !== 'no') { |
|
328 | + \OC::$server->getConfig()->setAppValue($app, 'enabled', 'yes'); |
|
329 | + } |
|
330 | + } |
|
331 | + } |
|
332 | + |
|
333 | + /** |
|
334 | + * get all enabled apps |
|
335 | + */ |
|
336 | + protected static $enabledAppsCache = array(); |
|
337 | + |
|
338 | + /** |
|
339 | + * Returns apps enabled for the current user. |
|
340 | + * |
|
341 | + * @param bool $forceRefresh whether to refresh the cache |
|
342 | + * @param bool $all whether to return apps for all users, not only the |
|
343 | + * currently logged in one |
|
344 | + * @return string[] |
|
345 | + */ |
|
346 | + public static function getEnabledApps($forceRefresh = false, $all = false) { |
|
347 | + if (!\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
348 | + return array(); |
|
349 | + } |
|
350 | + // in incognito mode or when logged out, $user will be false, |
|
351 | + // which is also the case during an upgrade |
|
352 | + $appManager = \OC::$server->getAppManager(); |
|
353 | + if ($all) { |
|
354 | + $user = null; |
|
355 | + } else { |
|
356 | + $user = \OC::$server->getUserSession()->getUser(); |
|
357 | + } |
|
358 | + |
|
359 | + if (is_null($user)) { |
|
360 | + $apps = $appManager->getInstalledApps(); |
|
361 | + } else { |
|
362 | + $apps = $appManager->getEnabledAppsForUser($user); |
|
363 | + } |
|
364 | + $apps = array_filter($apps, function ($app) { |
|
365 | + return $app !== 'files';//we add this manually |
|
366 | + }); |
|
367 | + sort($apps); |
|
368 | + array_unshift($apps, 'files'); |
|
369 | + return $apps; |
|
370 | + } |
|
371 | + |
|
372 | + /** |
|
373 | + * checks whether or not an app is enabled |
|
374 | + * |
|
375 | + * @param string $app app |
|
376 | + * @return bool |
|
377 | + * @deprecated 13.0.0 use \OC::$server->getAppManager()->isEnabledForUser($appId) |
|
378 | + * |
|
379 | + * This function checks whether or not an app is enabled. |
|
380 | + */ |
|
381 | + public static function isEnabled($app) { |
|
382 | + return \OC::$server->getAppManager()->isEnabledForUser($app); |
|
383 | + } |
|
384 | + |
|
385 | + /** |
|
386 | + * enables an app |
|
387 | + * |
|
388 | + * @param string $appId |
|
389 | + * @param array $groups (optional) when set, only these groups will have access to the app |
|
390 | + * @throws \Exception |
|
391 | + * @return void |
|
392 | + * |
|
393 | + * This function set an app as enabled in appconfig. |
|
394 | + */ |
|
395 | + public function enable($appId, |
|
396 | + $groups = null) { |
|
397 | + self::$enabledAppsCache = []; // flush |
|
398 | + |
|
399 | + // Check if app is already downloaded |
|
400 | + $installer = \OC::$server->query(Installer::class); |
|
401 | + $isDownloaded = $installer->isDownloaded($appId); |
|
402 | + |
|
403 | + if(!$isDownloaded) { |
|
404 | + $installer->downloadApp($appId); |
|
405 | + } |
|
406 | + |
|
407 | + $installer->installApp($appId); |
|
408 | + |
|
409 | + $appManager = \OC::$server->getAppManager(); |
|
410 | + if (!is_null($groups)) { |
|
411 | + $groupManager = \OC::$server->getGroupManager(); |
|
412 | + $groupsList = []; |
|
413 | + foreach ($groups as $group) { |
|
414 | + $groupItem = $groupManager->get($group); |
|
415 | + if ($groupItem instanceof \OCP\IGroup) { |
|
416 | + $groupsList[] = $groupManager->get($group); |
|
417 | + } |
|
418 | + } |
|
419 | + $appManager->enableAppForGroups($appId, $groupsList); |
|
420 | + } else { |
|
421 | + $appManager->enableApp($appId); |
|
422 | + } |
|
423 | + } |
|
424 | + |
|
425 | + /** |
|
426 | + * @param string $app |
|
427 | + * @return bool |
|
428 | + */ |
|
429 | + public static function removeApp($app) { |
|
430 | + if (\OC::$server->getAppManager()->isShipped($app)) { |
|
431 | + return false; |
|
432 | + } |
|
433 | + |
|
434 | + $installer = \OC::$server->query(Installer::class); |
|
435 | + return $installer->removeApp($app); |
|
436 | + } |
|
437 | + |
|
438 | + /** |
|
439 | + * This function set an app as disabled in appconfig. |
|
440 | + * |
|
441 | + * @param string $app app |
|
442 | + * @throws Exception |
|
443 | + */ |
|
444 | + public static function disable($app) { |
|
445 | + // flush |
|
446 | + self::$enabledAppsCache = array(); |
|
447 | + |
|
448 | + // run uninstall steps |
|
449 | + $appData = OC_App::getAppInfo($app); |
|
450 | + if (!is_null($appData)) { |
|
451 | + OC_App::executeRepairSteps($app, $appData['repair-steps']['uninstall']); |
|
452 | + } |
|
453 | + |
|
454 | + // emit disable hook - needed anymore ? |
|
455 | + \OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app)); |
|
456 | + |
|
457 | + // finally disable it |
|
458 | + $appManager = \OC::$server->getAppManager(); |
|
459 | + $appManager->disableApp($app); |
|
460 | + } |
|
461 | + |
|
462 | + // This is private as well. It simply works, so don't ask for more details |
|
463 | + private static function proceedNavigation($list) { |
|
464 | + usort($list, function($a, $b) { |
|
465 | + if (isset($a['order']) && isset($b['order'])) { |
|
466 | + return ($a['order'] < $b['order']) ? -1 : 1; |
|
467 | + } else if (isset($a['order']) || isset($b['order'])) { |
|
468 | + return isset($a['order']) ? -1 : 1; |
|
469 | + } else { |
|
470 | + return ($a['name'] < $b['name']) ? -1 : 1; |
|
471 | + } |
|
472 | + }); |
|
473 | + |
|
474 | + $activeApp = OC::$server->getNavigationManager()->getActiveEntry(); |
|
475 | + foreach ($list as $index => &$navEntry) { |
|
476 | + if ($navEntry['id'] == $activeApp) { |
|
477 | + $navEntry['active'] = true; |
|
478 | + } else { |
|
479 | + $navEntry['active'] = false; |
|
480 | + } |
|
481 | + } |
|
482 | + unset($navEntry); |
|
483 | + |
|
484 | + return $list; |
|
485 | + } |
|
486 | + |
|
487 | + /** |
|
488 | + * Get the path where to install apps |
|
489 | + * |
|
490 | + * @return string|false |
|
491 | + */ |
|
492 | + public static function getInstallPath() { |
|
493 | + if (\OC::$server->getSystemConfig()->getValue('appstoreenabled', true) == false) { |
|
494 | + return false; |
|
495 | + } |
|
496 | + |
|
497 | + foreach (OC::$APPSROOTS as $dir) { |
|
498 | + if (isset($dir['writable']) && $dir['writable'] === true) { |
|
499 | + return $dir['path']; |
|
500 | + } |
|
501 | + } |
|
502 | + |
|
503 | + \OCP\Util::writeLog('core', 'No application directories are marked as writable.', \OCP\Util::ERROR); |
|
504 | + return null; |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + /** |
|
509 | + * search for an app in all app-directories |
|
510 | + * |
|
511 | + * @param string $appId |
|
512 | + * @return false|string |
|
513 | + */ |
|
514 | + public static function findAppInDirectories($appId) { |
|
515 | + $sanitizedAppId = self::cleanAppId($appId); |
|
516 | + if($sanitizedAppId !== $appId) { |
|
517 | + return false; |
|
518 | + } |
|
519 | + static $app_dir = array(); |
|
520 | + |
|
521 | + if (isset($app_dir[$appId])) { |
|
522 | + return $app_dir[$appId]; |
|
523 | + } |
|
524 | + |
|
525 | + $possibleApps = array(); |
|
526 | + foreach (OC::$APPSROOTS as $dir) { |
|
527 | + if (file_exists($dir['path'] . '/' . $appId)) { |
|
528 | + $possibleApps[] = $dir; |
|
529 | + } |
|
530 | + } |
|
531 | + |
|
532 | + if (empty($possibleApps)) { |
|
533 | + return false; |
|
534 | + } elseif (count($possibleApps) === 1) { |
|
535 | + $dir = array_shift($possibleApps); |
|
536 | + $app_dir[$appId] = $dir; |
|
537 | + return $dir; |
|
538 | + } else { |
|
539 | + $versionToLoad = array(); |
|
540 | + foreach ($possibleApps as $possibleApp) { |
|
541 | + $version = self::getAppVersionByPath($possibleApp['path']); |
|
542 | + if (empty($versionToLoad) || version_compare($version, $versionToLoad['version'], '>')) { |
|
543 | + $versionToLoad = array( |
|
544 | + 'dir' => $possibleApp, |
|
545 | + 'version' => $version, |
|
546 | + ); |
|
547 | + } |
|
548 | + } |
|
549 | + $app_dir[$appId] = $versionToLoad['dir']; |
|
550 | + return $versionToLoad['dir']; |
|
551 | + //TODO - write test |
|
552 | + } |
|
553 | + } |
|
554 | + |
|
555 | + /** |
|
556 | + * Get the directory for the given app. |
|
557 | + * If the app is defined in multiple directories, the first one is taken. (false if not found) |
|
558 | + * |
|
559 | + * @param string $appId |
|
560 | + * @return string|false |
|
561 | + */ |
|
562 | + public static function getAppPath($appId) { |
|
563 | + if ($appId === null || trim($appId) === '') { |
|
564 | + return false; |
|
565 | + } |
|
566 | + |
|
567 | + if (($dir = self::findAppInDirectories($appId)) != false) { |
|
568 | + return $dir['path'] . '/' . $appId; |
|
569 | + } |
|
570 | + return false; |
|
571 | + } |
|
572 | + |
|
573 | + /** |
|
574 | + * Get the path for the given app on the access |
|
575 | + * If the app is defined in multiple directories, the first one is taken. (false if not found) |
|
576 | + * |
|
577 | + * @param string $appId |
|
578 | + * @return string|false |
|
579 | + */ |
|
580 | + public static function getAppWebPath($appId) { |
|
581 | + if (($dir = self::findAppInDirectories($appId)) != false) { |
|
582 | + return OC::$WEBROOT . $dir['url'] . '/' . $appId; |
|
583 | + } |
|
584 | + return false; |
|
585 | + } |
|
586 | + |
|
587 | + /** |
|
588 | + * get the last version of the app from appinfo/info.xml |
|
589 | + * |
|
590 | + * @param string $appId |
|
591 | + * @param bool $useCache |
|
592 | + * @return string |
|
593 | + */ |
|
594 | + public static function getAppVersion($appId, $useCache = true) { |
|
595 | + if($useCache && isset(self::$appVersion[$appId])) { |
|
596 | + return self::$appVersion[$appId]; |
|
597 | + } |
|
598 | + |
|
599 | + $file = self::getAppPath($appId); |
|
600 | + self::$appVersion[$appId] = ($file !== false) ? self::getAppVersionByPath($file) : '0'; |
|
601 | + return self::$appVersion[$appId]; |
|
602 | + } |
|
603 | + |
|
604 | + /** |
|
605 | + * get app's version based on it's path |
|
606 | + * |
|
607 | + * @param string $path |
|
608 | + * @return string |
|
609 | + */ |
|
610 | + public static function getAppVersionByPath($path) { |
|
611 | + $infoFile = $path . '/appinfo/info.xml'; |
|
612 | + $appData = self::getAppInfo($infoFile, true); |
|
613 | + return isset($appData['version']) ? $appData['version'] : ''; |
|
614 | + } |
|
615 | + |
|
616 | + |
|
617 | + /** |
|
618 | + * Read all app metadata from the info.xml file |
|
619 | + * |
|
620 | + * @param string $appId id of the app or the path of the info.xml file |
|
621 | + * @param bool $path |
|
622 | + * @param string $lang |
|
623 | + * @return array|null |
|
624 | + * @note all data is read from info.xml, not just pre-defined fields |
|
625 | + */ |
|
626 | + public static function getAppInfo($appId, $path = false, $lang = null) { |
|
627 | + if ($path) { |
|
628 | + $file = $appId; |
|
629 | + } else { |
|
630 | + if ($lang === null && isset(self::$appInfo[$appId])) { |
|
631 | + return self::$appInfo[$appId]; |
|
632 | + } |
|
633 | + $appPath = self::getAppPath($appId); |
|
634 | + if($appPath === false) { |
|
635 | + return null; |
|
636 | + } |
|
637 | + $file = $appPath . '/appinfo/info.xml'; |
|
638 | + } |
|
639 | + |
|
640 | + $parser = new InfoParser(\OC::$server->getMemCacheFactory()->createLocal('core.appinfo')); |
|
641 | + $data = $parser->parse($file); |
|
642 | + |
|
643 | + if (is_array($data)) { |
|
644 | + $data = OC_App::parseAppInfo($data, $lang); |
|
645 | + } |
|
646 | + if(isset($data['ocsid'])) { |
|
647 | + $storedId = \OC::$server->getConfig()->getAppValue($appId, 'ocsid'); |
|
648 | + if($storedId !== '' && $storedId !== $data['ocsid']) { |
|
649 | + $data['ocsid'] = $storedId; |
|
650 | + } |
|
651 | + } |
|
652 | + |
|
653 | + if ($lang === null) { |
|
654 | + self::$appInfo[$appId] = $data; |
|
655 | + } |
|
656 | + |
|
657 | + return $data; |
|
658 | + } |
|
659 | + |
|
660 | + /** |
|
661 | + * Returns the navigation |
|
662 | + * |
|
663 | + * @return array |
|
664 | + * |
|
665 | + * This function returns an array containing all entries added. The |
|
666 | + * entries are sorted by the key 'order' ascending. Additional to the keys |
|
667 | + * given for each app the following keys exist: |
|
668 | + * - active: boolean, signals if the user is on this navigation entry |
|
669 | + */ |
|
670 | + public static function getNavigation() { |
|
671 | + $entries = OC::$server->getNavigationManager()->getAll(); |
|
672 | + return self::proceedNavigation($entries); |
|
673 | + } |
|
674 | + |
|
675 | + /** |
|
676 | + * Returns the Settings Navigation |
|
677 | + * |
|
678 | + * @return string[] |
|
679 | + * |
|
680 | + * This function returns an array containing all settings pages added. The |
|
681 | + * entries are sorted by the key 'order' ascending. |
|
682 | + */ |
|
683 | + public static function getSettingsNavigation() { |
|
684 | + $entries = OC::$server->getNavigationManager()->getAll('settings'); |
|
685 | + return self::proceedNavigation($entries); |
|
686 | + } |
|
687 | + |
|
688 | + /** |
|
689 | + * get the id of loaded app |
|
690 | + * |
|
691 | + * @return string |
|
692 | + */ |
|
693 | + public static function getCurrentApp() { |
|
694 | + $request = \OC::$server->getRequest(); |
|
695 | + $script = substr($request->getScriptName(), strlen(OC::$WEBROOT) + 1); |
|
696 | + $topFolder = substr($script, 0, strpos($script, '/') ?: 0); |
|
697 | + if (empty($topFolder)) { |
|
698 | + $path_info = $request->getPathInfo(); |
|
699 | + if ($path_info) { |
|
700 | + $topFolder = substr($path_info, 1, strpos($path_info, '/', 1) - 1); |
|
701 | + } |
|
702 | + } |
|
703 | + if ($topFolder == 'apps') { |
|
704 | + $length = strlen($topFolder); |
|
705 | + return substr($script, $length + 1, strpos($script, '/', $length + 1) - $length - 1); |
|
706 | + } else { |
|
707 | + return $topFolder; |
|
708 | + } |
|
709 | + } |
|
710 | + |
|
711 | + /** |
|
712 | + * @param string $type |
|
713 | + * @return array |
|
714 | + */ |
|
715 | + public static function getForms($type) { |
|
716 | + $forms = array(); |
|
717 | + switch ($type) { |
|
718 | + case 'admin': |
|
719 | + $source = self::$adminForms; |
|
720 | + break; |
|
721 | + case 'personal': |
|
722 | + $source = self::$personalForms; |
|
723 | + break; |
|
724 | + default: |
|
725 | + return array(); |
|
726 | + } |
|
727 | + foreach ($source as $form) { |
|
728 | + $forms[] = include $form; |
|
729 | + } |
|
730 | + return $forms; |
|
731 | + } |
|
732 | + |
|
733 | + /** |
|
734 | + * register an admin form to be shown |
|
735 | + * |
|
736 | + * @param string $app |
|
737 | + * @param string $page |
|
738 | + */ |
|
739 | + public static function registerAdmin($app, $page) { |
|
740 | + self::$adminForms[] = $app . '/' . $page . '.php'; |
|
741 | + } |
|
742 | + |
|
743 | + /** |
|
744 | + * register a personal form to be shown |
|
745 | + * @param string $app |
|
746 | + * @param string $page |
|
747 | + */ |
|
748 | + public static function registerPersonal($app, $page) { |
|
749 | + self::$personalForms[] = $app . '/' . $page . '.php'; |
|
750 | + } |
|
751 | + |
|
752 | + /** |
|
753 | + * @param array $entry |
|
754 | + */ |
|
755 | + public static function registerLogIn(array $entry) { |
|
756 | + self::$altLogin[] = $entry; |
|
757 | + } |
|
758 | + |
|
759 | + /** |
|
760 | + * @return array |
|
761 | + */ |
|
762 | + public static function getAlternativeLogIns() { |
|
763 | + return self::$altLogin; |
|
764 | + } |
|
765 | + |
|
766 | + /** |
|
767 | + * get a list of all apps in the apps folder |
|
768 | + * |
|
769 | + * @return array an array of app names (string IDs) |
|
770 | + * @todo: change the name of this method to getInstalledApps, which is more accurate |
|
771 | + */ |
|
772 | + public static function getAllApps() { |
|
773 | + |
|
774 | + $apps = array(); |
|
775 | + |
|
776 | + foreach (OC::$APPSROOTS as $apps_dir) { |
|
777 | + if (!is_readable($apps_dir['path'])) { |
|
778 | + \OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN); |
|
779 | + continue; |
|
780 | + } |
|
781 | + $dh = opendir($apps_dir['path']); |
|
782 | + |
|
783 | + if (is_resource($dh)) { |
|
784 | + while (($file = readdir($dh)) !== false) { |
|
785 | + |
|
786 | + if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) { |
|
787 | + |
|
788 | + $apps[] = $file; |
|
789 | + } |
|
790 | + } |
|
791 | + } |
|
792 | + } |
|
793 | + |
|
794 | + $apps = array_unique($apps); |
|
795 | + |
|
796 | + return $apps; |
|
797 | + } |
|
798 | + |
|
799 | + /** |
|
800 | + * List all apps, this is used in apps.php |
|
801 | + * |
|
802 | + * @return array |
|
803 | + */ |
|
804 | + public function listAllApps() { |
|
805 | + $installedApps = OC_App::getAllApps(); |
|
806 | + |
|
807 | + $appManager = \OC::$server->getAppManager(); |
|
808 | + //we don't want to show configuration for these |
|
809 | + $blacklist = $appManager->getAlwaysEnabledApps(); |
|
810 | + $appList = array(); |
|
811 | + $langCode = \OC::$server->getL10N('core')->getLanguageCode(); |
|
812 | + $urlGenerator = \OC::$server->getURLGenerator(); |
|
813 | + |
|
814 | + foreach ($installedApps as $app) { |
|
815 | + if (array_search($app, $blacklist) === false) { |
|
816 | + |
|
817 | + $info = OC_App::getAppInfo($app, false, $langCode); |
|
818 | + if (!is_array($info)) { |
|
819 | + \OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR); |
|
820 | + continue; |
|
821 | + } |
|
822 | + |
|
823 | + if (!isset($info['name'])) { |
|
824 | + \OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR); |
|
825 | + continue; |
|
826 | + } |
|
827 | + |
|
828 | + $enabled = \OC::$server->getConfig()->getAppValue($app, 'enabled', 'no'); |
|
829 | + $info['groups'] = null; |
|
830 | + if ($enabled === 'yes') { |
|
831 | + $active = true; |
|
832 | + } else if ($enabled === 'no') { |
|
833 | + $active = false; |
|
834 | + } else { |
|
835 | + $active = true; |
|
836 | + $info['groups'] = $enabled; |
|
837 | + } |
|
838 | + |
|
839 | + $info['active'] = $active; |
|
840 | + |
|
841 | + if ($appManager->isShipped($app)) { |
|
842 | + $info['internal'] = true; |
|
843 | + $info['level'] = self::officialApp; |
|
844 | + $info['removable'] = false; |
|
845 | + } else { |
|
846 | + $info['internal'] = false; |
|
847 | + $info['removable'] = true; |
|
848 | + } |
|
849 | + |
|
850 | + $appPath = self::getAppPath($app); |
|
851 | + if($appPath !== false) { |
|
852 | + $appIcon = $appPath . '/img/' . $app . '.svg'; |
|
853 | + if (file_exists($appIcon)) { |
|
854 | + $info['preview'] = $urlGenerator->imagePath($app, $app . '.svg'); |
|
855 | + $info['previewAsIcon'] = true; |
|
856 | + } else { |
|
857 | + $appIcon = $appPath . '/img/app.svg'; |
|
858 | + if (file_exists($appIcon)) { |
|
859 | + $info['preview'] = $urlGenerator->imagePath($app, 'app.svg'); |
|
860 | + $info['previewAsIcon'] = true; |
|
861 | + } |
|
862 | + } |
|
863 | + } |
|
864 | + // fix documentation |
|
865 | + if (isset($info['documentation']) && is_array($info['documentation'])) { |
|
866 | + foreach ($info['documentation'] as $key => $url) { |
|
867 | + // If it is not an absolute URL we assume it is a key |
|
868 | + // i.e. admin-ldap will get converted to go.php?to=admin-ldap |
|
869 | + if (stripos($url, 'https://') !== 0 && stripos($url, 'http://') !== 0) { |
|
870 | + $url = $urlGenerator->linkToDocs($url); |
|
871 | + } |
|
872 | + |
|
873 | + $info['documentation'][$key] = $url; |
|
874 | + } |
|
875 | + } |
|
876 | + |
|
877 | + $info['version'] = OC_App::getAppVersion($app); |
|
878 | + $appList[] = $info; |
|
879 | + } |
|
880 | + } |
|
881 | + |
|
882 | + return $appList; |
|
883 | + } |
|
884 | + |
|
885 | + public static function shouldUpgrade($app) { |
|
886 | + $versions = self::getAppVersions(); |
|
887 | + $currentVersion = OC_App::getAppVersion($app); |
|
888 | + if ($currentVersion && isset($versions[$app])) { |
|
889 | + $installedVersion = $versions[$app]; |
|
890 | + if (!version_compare($currentVersion, $installedVersion, '=')) { |
|
891 | + return true; |
|
892 | + } |
|
893 | + } |
|
894 | + return false; |
|
895 | + } |
|
896 | + |
|
897 | + /** |
|
898 | + * Adjust the number of version parts of $version1 to match |
|
899 | + * the number of version parts of $version2. |
|
900 | + * |
|
901 | + * @param string $version1 version to adjust |
|
902 | + * @param string $version2 version to take the number of parts from |
|
903 | + * @return string shortened $version1 |
|
904 | + */ |
|
905 | + private static function adjustVersionParts($version1, $version2) { |
|
906 | + $version1 = explode('.', $version1); |
|
907 | + $version2 = explode('.', $version2); |
|
908 | + // reduce $version1 to match the number of parts in $version2 |
|
909 | + while (count($version1) > count($version2)) { |
|
910 | + array_pop($version1); |
|
911 | + } |
|
912 | + // if $version1 does not have enough parts, add some |
|
913 | + while (count($version1) < count($version2)) { |
|
914 | + $version1[] = '0'; |
|
915 | + } |
|
916 | + return implode('.', $version1); |
|
917 | + } |
|
918 | + |
|
919 | + /** |
|
920 | + * Check whether the current ownCloud version matches the given |
|
921 | + * application's version requirements. |
|
922 | + * |
|
923 | + * The comparison is made based on the number of parts that the |
|
924 | + * app info version has. For example for ownCloud 6.0.3 if the |
|
925 | + * app info version is expecting version 6.0, the comparison is |
|
926 | + * made on the first two parts of the ownCloud version. |
|
927 | + * This means that it's possible to specify "requiremin" => 6 |
|
928 | + * and "requiremax" => 6 and it will still match ownCloud 6.0.3. |
|
929 | + * |
|
930 | + * @param string $ocVersion ownCloud version to check against |
|
931 | + * @param array $appInfo app info (from xml) |
|
932 | + * |
|
933 | + * @return boolean true if compatible, otherwise false |
|
934 | + */ |
|
935 | + public static function isAppCompatible($ocVersion, $appInfo) { |
|
936 | + $requireMin = ''; |
|
937 | + $requireMax = ''; |
|
938 | + if (isset($appInfo['dependencies']['nextcloud']['@attributes']['min-version'])) { |
|
939 | + $requireMin = $appInfo['dependencies']['nextcloud']['@attributes']['min-version']; |
|
940 | + } elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['min-version'])) { |
|
941 | + $requireMin = $appInfo['dependencies']['owncloud']['@attributes']['min-version']; |
|
942 | + } else if (isset($appInfo['requiremin'])) { |
|
943 | + $requireMin = $appInfo['requiremin']; |
|
944 | + } else if (isset($appInfo['require'])) { |
|
945 | + $requireMin = $appInfo['require']; |
|
946 | + } |
|
947 | + |
|
948 | + if (isset($appInfo['dependencies']['nextcloud']['@attributes']['max-version'])) { |
|
949 | + $requireMax = $appInfo['dependencies']['nextcloud']['@attributes']['max-version']; |
|
950 | + } elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['max-version'])) { |
|
951 | + $requireMax = $appInfo['dependencies']['owncloud']['@attributes']['max-version']; |
|
952 | + } else if (isset($appInfo['requiremax'])) { |
|
953 | + $requireMax = $appInfo['requiremax']; |
|
954 | + } |
|
955 | + |
|
956 | + if (is_array($ocVersion)) { |
|
957 | + $ocVersion = implode('.', $ocVersion); |
|
958 | + } |
|
959 | + |
|
960 | + if (!empty($requireMin) |
|
961 | + && version_compare(self::adjustVersionParts($ocVersion, $requireMin), $requireMin, '<') |
|
962 | + ) { |
|
963 | + |
|
964 | + return false; |
|
965 | + } |
|
966 | + |
|
967 | + if (!empty($requireMax) |
|
968 | + && version_compare(self::adjustVersionParts($ocVersion, $requireMax), $requireMax, '>') |
|
969 | + ) { |
|
970 | + return false; |
|
971 | + } |
|
972 | + |
|
973 | + return true; |
|
974 | + } |
|
975 | + |
|
976 | + /** |
|
977 | + * get the installed version of all apps |
|
978 | + */ |
|
979 | + public static function getAppVersions() { |
|
980 | + static $versions; |
|
981 | + |
|
982 | + if(!$versions) { |
|
983 | + $appConfig = \OC::$server->getAppConfig(); |
|
984 | + $versions = $appConfig->getValues(false, 'installed_version'); |
|
985 | + } |
|
986 | + return $versions; |
|
987 | + } |
|
988 | + |
|
989 | + /** |
|
990 | + * @param string $app |
|
991 | + * @param \OCP\IConfig $config |
|
992 | + * @param \OCP\IL10N $l |
|
993 | + * @return bool |
|
994 | + * |
|
995 | + * @throws Exception if app is not compatible with this version of ownCloud |
|
996 | + * @throws Exception if no app-name was specified |
|
997 | + */ |
|
998 | + public function installApp($app, |
|
999 | + \OCP\IConfig $config, |
|
1000 | + \OCP\IL10N $l) { |
|
1001 | + if ($app !== false) { |
|
1002 | + // check if the app is compatible with this version of ownCloud |
|
1003 | + $info = self::getAppInfo($app); |
|
1004 | + if(!is_array($info)) { |
|
1005 | + throw new \Exception( |
|
1006 | + $l->t('App "%s" cannot be installed because appinfo file cannot be read.', |
|
1007 | + [$info['name']] |
|
1008 | + ) |
|
1009 | + ); |
|
1010 | + } |
|
1011 | + |
|
1012 | + $version = \OCP\Util::getVersion(); |
|
1013 | + if (!self::isAppCompatible($version, $info)) { |
|
1014 | + throw new \Exception( |
|
1015 | + $l->t('App "%s" cannot be installed because it is not compatible with this version of the server.', |
|
1016 | + array($info['name']) |
|
1017 | + ) |
|
1018 | + ); |
|
1019 | + } |
|
1020 | + |
|
1021 | + // check for required dependencies |
|
1022 | + self::checkAppDependencies($config, $l, $info); |
|
1023 | + |
|
1024 | + $config->setAppValue($app, 'enabled', 'yes'); |
|
1025 | + if (isset($appData['id'])) { |
|
1026 | + $config->setAppValue($app, 'ocsid', $appData['id']); |
|
1027 | + } |
|
1028 | + |
|
1029 | + if(isset($info['settings']) && is_array($info['settings'])) { |
|
1030 | + $appPath = self::getAppPath($app); |
|
1031 | + self::registerAutoloading($app, $appPath); |
|
1032 | + \OC::$server->getSettingsManager()->setupSettings($info['settings']); |
|
1033 | + } |
|
1034 | + |
|
1035 | + \OC_Hook::emit('OC_App', 'post_enable', array('app' => $app)); |
|
1036 | + } else { |
|
1037 | + if(empty($appName) ) { |
|
1038 | + throw new \Exception($l->t("No app name specified")); |
|
1039 | + } else { |
|
1040 | + throw new \Exception($l->t("App '%s' could not be installed!", $appName)); |
|
1041 | + } |
|
1042 | + } |
|
1043 | + |
|
1044 | + return $app; |
|
1045 | + } |
|
1046 | + |
|
1047 | + /** |
|
1048 | + * update the database for the app and call the update script |
|
1049 | + * |
|
1050 | + * @param string $appId |
|
1051 | + * @return bool |
|
1052 | + */ |
|
1053 | + public static function updateApp($appId) { |
|
1054 | + $appPath = self::getAppPath($appId); |
|
1055 | + if($appPath === false) { |
|
1056 | + return false; |
|
1057 | + } |
|
1058 | + self::registerAutoloading($appId, $appPath); |
|
1059 | + |
|
1060 | + $appData = self::getAppInfo($appId); |
|
1061 | + self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']); |
|
1062 | + |
|
1063 | + if (file_exists($appPath . '/appinfo/database.xml')) { |
|
1064 | + OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml'); |
|
1065 | + } else { |
|
1066 | + $ms = new MigrationService($appId, \OC::$server->getDatabaseConnection()); |
|
1067 | + $ms->migrate(); |
|
1068 | + } |
|
1069 | + |
|
1070 | + self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']); |
|
1071 | + self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']); |
|
1072 | + unset(self::$appVersion[$appId]); |
|
1073 | + |
|
1074 | + // run upgrade code |
|
1075 | + if (file_exists($appPath . '/appinfo/update.php')) { |
|
1076 | + self::loadApp($appId); |
|
1077 | + include $appPath . '/appinfo/update.php'; |
|
1078 | + } |
|
1079 | + self::setupBackgroundJobs($appData['background-jobs']); |
|
1080 | + if(isset($appData['settings']) && is_array($appData['settings'])) { |
|
1081 | + \OC::$server->getSettingsManager()->setupSettings($appData['settings']); |
|
1082 | + } |
|
1083 | + |
|
1084 | + //set remote/public handlers |
|
1085 | + if (array_key_exists('ocsid', $appData)) { |
|
1086 | + \OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']); |
|
1087 | + } elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) { |
|
1088 | + \OC::$server->getConfig()->deleteAppValue($appId, 'ocsid'); |
|
1089 | + } |
|
1090 | + foreach ($appData['remote'] as $name => $path) { |
|
1091 | + \OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path); |
|
1092 | + } |
|
1093 | + foreach ($appData['public'] as $name => $path) { |
|
1094 | + \OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path); |
|
1095 | + } |
|
1096 | + |
|
1097 | + self::setAppTypes($appId); |
|
1098 | + |
|
1099 | + $version = \OC_App::getAppVersion($appId); |
|
1100 | + \OC::$server->getConfig()->setAppValue($appId, 'installed_version', $version); |
|
1101 | + |
|
1102 | + \OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent( |
|
1103 | + ManagerEvent::EVENT_APP_UPDATE, $appId |
|
1104 | + )); |
|
1105 | + |
|
1106 | + return true; |
|
1107 | + } |
|
1108 | + |
|
1109 | + /** |
|
1110 | + * @param string $appId |
|
1111 | + * @param string[] $steps |
|
1112 | + * @throws \OC\NeedsUpdateException |
|
1113 | + */ |
|
1114 | + public static function executeRepairSteps($appId, array $steps) { |
|
1115 | + if (empty($steps)) { |
|
1116 | + return; |
|
1117 | + } |
|
1118 | + // load the app |
|
1119 | + self::loadApp($appId); |
|
1120 | + |
|
1121 | + $dispatcher = OC::$server->getEventDispatcher(); |
|
1122 | + |
|
1123 | + // load the steps |
|
1124 | + $r = new Repair([], $dispatcher); |
|
1125 | + foreach ($steps as $step) { |
|
1126 | + try { |
|
1127 | + $r->addStep($step); |
|
1128 | + } catch (Exception $ex) { |
|
1129 | + $r->emit('\OC\Repair', 'error', [$ex->getMessage()]); |
|
1130 | + \OC::$server->getLogger()->logException($ex); |
|
1131 | + } |
|
1132 | + } |
|
1133 | + // run the steps |
|
1134 | + $r->run(); |
|
1135 | + } |
|
1136 | + |
|
1137 | + public static function setupBackgroundJobs(array $jobs) { |
|
1138 | + $queue = \OC::$server->getJobList(); |
|
1139 | + foreach ($jobs as $job) { |
|
1140 | + $queue->add($job); |
|
1141 | + } |
|
1142 | + } |
|
1143 | + |
|
1144 | + /** |
|
1145 | + * @param string $appId |
|
1146 | + * @param string[] $steps |
|
1147 | + */ |
|
1148 | + private static function setupLiveMigrations($appId, array $steps) { |
|
1149 | + $queue = \OC::$server->getJobList(); |
|
1150 | + foreach ($steps as $step) { |
|
1151 | + $queue->add('OC\Migration\BackgroundRepair', [ |
|
1152 | + 'app' => $appId, |
|
1153 | + 'step' => $step]); |
|
1154 | + } |
|
1155 | + } |
|
1156 | + |
|
1157 | + /** |
|
1158 | + * @param string $appId |
|
1159 | + * @return \OC\Files\View|false |
|
1160 | + */ |
|
1161 | + public static function getStorage($appId) { |
|
1162 | + if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check |
|
1163 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
1164 | + $view = new \OC\Files\View('/' . OC_User::getUser()); |
|
1165 | + if (!$view->file_exists($appId)) { |
|
1166 | + $view->mkdir($appId); |
|
1167 | + } |
|
1168 | + return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId); |
|
1169 | + } else { |
|
1170 | + \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR); |
|
1171 | + return false; |
|
1172 | + } |
|
1173 | + } else { |
|
1174 | + \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR); |
|
1175 | + return false; |
|
1176 | + } |
|
1177 | + } |
|
1178 | + |
|
1179 | + protected static function findBestL10NOption($options, $lang) { |
|
1180 | + $fallback = $similarLangFallback = $englishFallback = false; |
|
1181 | + |
|
1182 | + $lang = strtolower($lang); |
|
1183 | + $similarLang = $lang; |
|
1184 | + if (strpos($similarLang, '_')) { |
|
1185 | + // For "de_DE" we want to find "de" and the other way around |
|
1186 | + $similarLang = substr($lang, 0, strpos($lang, '_')); |
|
1187 | + } |
|
1188 | + |
|
1189 | + foreach ($options as $option) { |
|
1190 | + if (is_array($option)) { |
|
1191 | + if ($fallback === false) { |
|
1192 | + $fallback = $option['@value']; |
|
1193 | + } |
|
1194 | + |
|
1195 | + if (!isset($option['@attributes']['lang'])) { |
|
1196 | + continue; |
|
1197 | + } |
|
1198 | + |
|
1199 | + $attributeLang = strtolower($option['@attributes']['lang']); |
|
1200 | + if ($attributeLang === $lang) { |
|
1201 | + return $option['@value']; |
|
1202 | + } |
|
1203 | + |
|
1204 | + if ($attributeLang === $similarLang) { |
|
1205 | + $similarLangFallback = $option['@value']; |
|
1206 | + } else if (strpos($attributeLang, $similarLang . '_') === 0) { |
|
1207 | + if ($similarLangFallback === false) { |
|
1208 | + $similarLangFallback = $option['@value']; |
|
1209 | + } |
|
1210 | + } |
|
1211 | + } else { |
|
1212 | + $englishFallback = $option; |
|
1213 | + } |
|
1214 | + } |
|
1215 | + |
|
1216 | + if ($similarLangFallback !== false) { |
|
1217 | + return $similarLangFallback; |
|
1218 | + } else if ($englishFallback !== false) { |
|
1219 | + return $englishFallback; |
|
1220 | + } |
|
1221 | + return (string) $fallback; |
|
1222 | + } |
|
1223 | + |
|
1224 | + /** |
|
1225 | + * parses the app data array and enhanced the 'description' value |
|
1226 | + * |
|
1227 | + * @param array $data the app data |
|
1228 | + * @param string $lang |
|
1229 | + * @return array improved app data |
|
1230 | + */ |
|
1231 | + public static function parseAppInfo(array $data, $lang = null) { |
|
1232 | + |
|
1233 | + if ($lang && isset($data['name']) && is_array($data['name'])) { |
|
1234 | + $data['name'] = self::findBestL10NOption($data['name'], $lang); |
|
1235 | + } |
|
1236 | + if ($lang && isset($data['summary']) && is_array($data['summary'])) { |
|
1237 | + $data['summary'] = self::findBestL10NOption($data['summary'], $lang); |
|
1238 | + } |
|
1239 | + if ($lang && isset($data['description']) && is_array($data['description'])) { |
|
1240 | + $data['description'] = trim(self::findBestL10NOption($data['description'], $lang)); |
|
1241 | + } else if (isset($data['description']) && is_string($data['description'])) { |
|
1242 | + $data['description'] = trim($data['description']); |
|
1243 | + } else { |
|
1244 | + $data['description'] = ''; |
|
1245 | + } |
|
1246 | + |
|
1247 | + return $data; |
|
1248 | + } |
|
1249 | + |
|
1250 | + /** |
|
1251 | + * @param \OCP\IConfig $config |
|
1252 | + * @param \OCP\IL10N $l |
|
1253 | + * @param array $info |
|
1254 | + * @throws \Exception |
|
1255 | + */ |
|
1256 | + public static function checkAppDependencies($config, $l, $info) { |
|
1257 | + $dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l); |
|
1258 | + $missing = $dependencyAnalyzer->analyze($info); |
|
1259 | + if (!empty($missing)) { |
|
1260 | + $missingMsg = implode(PHP_EOL, $missing); |
|
1261 | + throw new \Exception( |
|
1262 | + $l->t('App "%s" cannot be installed because the following dependencies are not fulfilled: %s', |
|
1263 | + [$info['name'], $missingMsg] |
|
1264 | + ) |
|
1265 | + ); |
|
1266 | + } |
|
1267 | + } |
|
1268 | 1268 | } |
@@ -28,71 +28,71 @@ |
||
28 | 28 | * @since 9.1 |
29 | 29 | */ |
30 | 30 | interface IManager { |
31 | - /** |
|
32 | - * @since 9.1.0 |
|
33 | - */ |
|
34 | - const KEY_ADMIN_SETTINGS = 'admin'; |
|
31 | + /** |
|
32 | + * @since 9.1.0 |
|
33 | + */ |
|
34 | + const KEY_ADMIN_SETTINGS = 'admin'; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @since 9.1.0 |
|
38 | - */ |
|
39 | - const KEY_ADMIN_SECTION = 'admin-section'; |
|
36 | + /** |
|
37 | + * @since 9.1.0 |
|
38 | + */ |
|
39 | + const KEY_ADMIN_SECTION = 'admin-section'; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @since 13.0.0 |
|
43 | - */ |
|
44 | - const KEY_PERSONAL_SETTINGS = 'personal'; |
|
41 | + /** |
|
42 | + * @since 13.0.0 |
|
43 | + */ |
|
44 | + const KEY_PERSONAL_SETTINGS = 'personal'; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @since 13.0.0 |
|
48 | - */ |
|
49 | - const KEY_PERSONAL_SECTION = 'personal-section'; |
|
46 | + /** |
|
47 | + * @since 13.0.0 |
|
48 | + */ |
|
49 | + const KEY_PERSONAL_SECTION = 'personal-section'; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param string $type 'admin' or 'personal' |
|
53 | - * @param string $section Class must implement OCP\Settings\ISection |
|
54 | - * @since 14.0.0 |
|
55 | - */ |
|
56 | - public function registerSection(string $type, string $section); |
|
51 | + /** |
|
52 | + * @param string $type 'admin' or 'personal' |
|
53 | + * @param string $section Class must implement OCP\Settings\ISection |
|
54 | + * @since 14.0.0 |
|
55 | + */ |
|
56 | + public function registerSection(string $type, string $section); |
|
57 | 57 | |
58 | - /** |
|
59 | - * @param string $type 'admin' or 'personal' |
|
60 | - * @param string $setting Class must implement OCP\Settings\ISetting |
|
61 | - * @since 14.0.0 |
|
62 | - */ |
|
63 | - public function registerSetting(string $type, string $setting); |
|
58 | + /** |
|
59 | + * @param string $type 'admin' or 'personal' |
|
60 | + * @param string $setting Class must implement OCP\Settings\ISetting |
|
61 | + * @since 14.0.0 |
|
62 | + */ |
|
63 | + public function registerSetting(string $type, string $setting); |
|
64 | 64 | |
65 | - /** |
|
66 | - * returns a list of the admin sections |
|
67 | - * |
|
68 | - * @return array array of ISection[] where key is the priority |
|
69 | - * @since 9.1.0 |
|
70 | - */ |
|
71 | - public function getAdminSections(): array; |
|
65 | + /** |
|
66 | + * returns a list of the admin sections |
|
67 | + * |
|
68 | + * @return array array of ISection[] where key is the priority |
|
69 | + * @since 9.1.0 |
|
70 | + */ |
|
71 | + public function getAdminSections(): array; |
|
72 | 72 | |
73 | - /** |
|
74 | - * returns a list of the personal sections |
|
75 | - * |
|
76 | - * @return array array of ISection[] where key is the priority |
|
77 | - * @since 13.0.0 |
|
78 | - */ |
|
79 | - public function getPersonalSections(): array; |
|
73 | + /** |
|
74 | + * returns a list of the personal sections |
|
75 | + * |
|
76 | + * @return array array of ISection[] where key is the priority |
|
77 | + * @since 13.0.0 |
|
78 | + */ |
|
79 | + public function getPersonalSections(): array; |
|
80 | 80 | |
81 | - /** |
|
82 | - * returns a list of the admin settings |
|
83 | - * |
|
84 | - * @param string $section the section id for which to load the settings |
|
85 | - * @return array array of IAdmin[] where key is the priority |
|
86 | - * @since 9.1.0 |
|
87 | - */ |
|
88 | - public function getAdminSettings($section): array; |
|
81 | + /** |
|
82 | + * returns a list of the admin settings |
|
83 | + * |
|
84 | + * @param string $section the section id for which to load the settings |
|
85 | + * @return array array of IAdmin[] where key is the priority |
|
86 | + * @since 9.1.0 |
|
87 | + */ |
|
88 | + public function getAdminSettings($section): array; |
|
89 | 89 | |
90 | - /** |
|
91 | - * returns a list of the personal settings |
|
92 | - * |
|
93 | - * @param string $section the section id for which to load the settings |
|
94 | - * @return array array of IPersonal[] where key is the priority |
|
95 | - * @since 13.0.0 |
|
96 | - */ |
|
97 | - public function getPersonalSettings($section): array; |
|
90 | + /** |
|
91 | + * returns a list of the personal settings |
|
92 | + * |
|
93 | + * @param string $section the section id for which to load the settings |
|
94 | + * @return array array of IPersonal[] where key is the priority |
|
95 | + * @since 13.0.0 |
|
96 | + */ |
|
97 | + public function getPersonalSettings($section): array; |
|
98 | 98 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @since 9.1.0 |
38 | 38 | */ |
39 | - const KEY_ADMIN_SECTION = 'admin-section'; |
|
39 | + const KEY_ADMIN_SECTION = 'admin-section'; |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @since 13.0.0 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * @since 13.0.0 |
48 | 48 | */ |
49 | - const KEY_PERSONAL_SECTION = 'personal-section'; |
|
49 | + const KEY_PERSONAL_SECTION = 'personal-section'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @param string $type 'admin' or 'personal' |