@@ -127,1646 +127,1646 @@ |
||
127 | 127 | * TODO: hookup all manager classes |
128 | 128 | */ |
129 | 129 | class Server extends ServerContainer implements IServerContainer { |
130 | - /** @var string */ |
|
131 | - private $webRoot; |
|
132 | - |
|
133 | - /** |
|
134 | - * @param string $webRoot |
|
135 | - * @param \OC\Config $config |
|
136 | - */ |
|
137 | - public function __construct($webRoot, \OC\Config $config) { |
|
138 | - parent::__construct(); |
|
139 | - $this->webRoot = $webRoot; |
|
140 | - |
|
141 | - $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
142 | - return $c; |
|
143 | - }); |
|
144 | - |
|
145 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
146 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
147 | - |
|
148 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
149 | - |
|
150 | - |
|
151 | - |
|
152 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
153 | - return new PreviewManager( |
|
154 | - $c->getConfig(), |
|
155 | - $c->getRootFolder(), |
|
156 | - $c->getAppDataDir('preview'), |
|
157 | - $c->getEventDispatcher(), |
|
158 | - $c->getSession()->get('user_id') |
|
159 | - ); |
|
160 | - }); |
|
161 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
162 | - |
|
163 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
164 | - return new \OC\Preview\Watcher( |
|
165 | - $c->getAppDataDir('preview') |
|
166 | - ); |
|
167 | - }); |
|
168 | - |
|
169 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
170 | - $view = new View(); |
|
171 | - $util = new Encryption\Util( |
|
172 | - $view, |
|
173 | - $c->getUserManager(), |
|
174 | - $c->getGroupManager(), |
|
175 | - $c->getConfig() |
|
176 | - ); |
|
177 | - return new Encryption\Manager( |
|
178 | - $c->getConfig(), |
|
179 | - $c->getLogger(), |
|
180 | - $c->getL10N('core'), |
|
181 | - new View(), |
|
182 | - $util, |
|
183 | - new ArrayCache() |
|
184 | - ); |
|
185 | - }); |
|
186 | - |
|
187 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
188 | - $util = new Encryption\Util( |
|
189 | - new View(), |
|
190 | - $c->getUserManager(), |
|
191 | - $c->getGroupManager(), |
|
192 | - $c->getConfig() |
|
193 | - ); |
|
194 | - return new Encryption\File( |
|
195 | - $util, |
|
196 | - $c->getRootFolder(), |
|
197 | - $c->getShareManager() |
|
198 | - ); |
|
199 | - }); |
|
200 | - |
|
201 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
202 | - $view = new View(); |
|
203 | - $util = new Encryption\Util( |
|
204 | - $view, |
|
205 | - $c->getUserManager(), |
|
206 | - $c->getGroupManager(), |
|
207 | - $c->getConfig() |
|
208 | - ); |
|
209 | - |
|
210 | - return new Encryption\Keys\Storage($view, $util); |
|
211 | - }); |
|
212 | - $this->registerService('TagMapper', function (Server $c) { |
|
213 | - return new TagMapper($c->getDatabaseConnection()); |
|
214 | - }); |
|
215 | - |
|
216 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
217 | - $tagMapper = $c->query('TagMapper'); |
|
218 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
219 | - }); |
|
220 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
221 | - |
|
222 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
223 | - $config = $c->getConfig(); |
|
224 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
225 | - /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
226 | - $factory = new $factoryClass($this); |
|
227 | - return $factory; |
|
228 | - }); |
|
229 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
230 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
231 | - }); |
|
232 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
233 | - |
|
234 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
235 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
236 | - }); |
|
237 | - $this->registerService('RootFolder', function (Server $c) { |
|
238 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
239 | - $view = new View(); |
|
240 | - $root = new Root( |
|
241 | - $manager, |
|
242 | - $view, |
|
243 | - null, |
|
244 | - $c->getUserMountCache(), |
|
245 | - $this->getLogger(), |
|
246 | - $this->getUserManager() |
|
247 | - ); |
|
248 | - $connector = new HookConnector($root, $view); |
|
249 | - $connector->viewToNode(); |
|
250 | - |
|
251 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
252 | - $previewConnector->connectWatcher(); |
|
253 | - |
|
254 | - return $root; |
|
255 | - }); |
|
256 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
257 | - |
|
258 | - $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
259 | - return new LazyRoot(function() use ($c) { |
|
260 | - return $c->query('RootFolder'); |
|
261 | - }); |
|
262 | - }); |
|
263 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
264 | - |
|
265 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
266 | - $config = $c->getConfig(); |
|
267 | - return new \OC\User\Manager($config); |
|
268 | - }); |
|
269 | - $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
270 | - |
|
271 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
272 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
273 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
274 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
275 | - }); |
|
276 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
277 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
278 | - }); |
|
279 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
280 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
281 | - }); |
|
282 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
283 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
284 | - }); |
|
285 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
286 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
287 | - }); |
|
288 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
289 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
290 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
291 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
292 | - }); |
|
293 | - return $groupManager; |
|
294 | - }); |
|
295 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
296 | - |
|
297 | - $this->registerService(Store::class, function(Server $c) { |
|
298 | - $session = $c->getSession(); |
|
299 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
300 | - $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
301 | - } else { |
|
302 | - $tokenProvider = null; |
|
303 | - } |
|
304 | - $logger = $c->getLogger(); |
|
305 | - return new Store($session, $logger, $tokenProvider); |
|
306 | - }); |
|
307 | - $this->registerAlias(IStore::class, Store::class); |
|
308 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
309 | - $dbConnection = $c->getDatabaseConnection(); |
|
310 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
311 | - }); |
|
312 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
313 | - $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
314 | - $crypto = $c->getCrypto(); |
|
315 | - $config = $c->getConfig(); |
|
316 | - $logger = $c->getLogger(); |
|
317 | - $timeFactory = new TimeFactory(); |
|
318 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
319 | - }); |
|
320 | - $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
321 | - |
|
322 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
323 | - $manager = $c->getUserManager(); |
|
324 | - $session = new \OC\Session\Memory(''); |
|
325 | - $timeFactory = new TimeFactory(); |
|
326 | - // Token providers might require a working database. This code |
|
327 | - // might however be called when ownCloud is not yet setup. |
|
328 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
329 | - $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
330 | - } else { |
|
331 | - $defaultTokenProvider = null; |
|
332 | - } |
|
333 | - |
|
334 | - $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
|
335 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
336 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
337 | - }); |
|
338 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
339 | - /** @var $user \OC\User\User */ |
|
340 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
341 | - }); |
|
342 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
343 | - /** @var $user \OC\User\User */ |
|
344 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
345 | - }); |
|
346 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
347 | - /** @var $user \OC\User\User */ |
|
348 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
349 | - }); |
|
350 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
351 | - /** @var $user \OC\User\User */ |
|
352 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
353 | - }); |
|
354 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
355 | - /** @var $user \OC\User\User */ |
|
356 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
357 | - }); |
|
358 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
359 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
360 | - }); |
|
361 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
362 | - /** @var $user \OC\User\User */ |
|
363 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
364 | - }); |
|
365 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
366 | - /** @var $user \OC\User\User */ |
|
367 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
368 | - }); |
|
369 | - $userSession->listen('\OC\User', 'logout', function () { |
|
370 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
371 | - }); |
|
372 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
373 | - /** @var $user \OC\User\User */ |
|
374 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
375 | - }); |
|
376 | - return $userSession; |
|
377 | - }); |
|
378 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
379 | - |
|
380 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
381 | - return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
382 | - }); |
|
383 | - |
|
384 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
385 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
386 | - |
|
387 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
388 | - return new \OC\AllConfig( |
|
389 | - $c->getSystemConfig() |
|
390 | - ); |
|
391 | - }); |
|
392 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
393 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
394 | - |
|
395 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
396 | - return new \OC\SystemConfig($config); |
|
397 | - }); |
|
398 | - |
|
399 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
400 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
401 | - }); |
|
402 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
403 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
404 | - |
|
405 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
406 | - return new \OC\L10N\Factory( |
|
407 | - $c->getConfig(), |
|
408 | - $c->getRequest(), |
|
409 | - $c->getUserSession(), |
|
410 | - \OC::$SERVERROOT |
|
411 | - ); |
|
412 | - }); |
|
413 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
414 | - |
|
415 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
416 | - $config = $c->getConfig(); |
|
417 | - $cacheFactory = $c->getMemCacheFactory(); |
|
418 | - return new \OC\URLGenerator( |
|
419 | - $config, |
|
420 | - $cacheFactory |
|
421 | - ); |
|
422 | - }); |
|
423 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
424 | - |
|
425 | - $this->registerService('AppHelper', function ($c) { |
|
426 | - return new \OC\AppHelper(); |
|
427 | - }); |
|
428 | - $this->registerAlias('AppFetcher', AppFetcher::class); |
|
429 | - $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
430 | - |
|
431 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
432 | - return new Cache\File(); |
|
433 | - }); |
|
434 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
435 | - |
|
436 | - $this->registerService(Factory::class, function (Server $c) { |
|
437 | - $config = $c->getConfig(); |
|
438 | - |
|
439 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
440 | - $v = \OC_App::getAppVersions(); |
|
441 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
442 | - $version = implode(',', $v); |
|
443 | - $instanceId = \OC_Util::getInstanceId(); |
|
444 | - $path = \OC::$SERVERROOT; |
|
445 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
446 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
447 | - $config->getSystemValue('memcache.local', null), |
|
448 | - $config->getSystemValue('memcache.distributed', null), |
|
449 | - $config->getSystemValue('memcache.locking', null) |
|
450 | - ); |
|
451 | - } |
|
452 | - |
|
453 | - return new \OC\Memcache\Factory('', $c->getLogger(), |
|
454 | - '\\OC\\Memcache\\ArrayCache', |
|
455 | - '\\OC\\Memcache\\ArrayCache', |
|
456 | - '\\OC\\Memcache\\ArrayCache' |
|
457 | - ); |
|
458 | - }); |
|
459 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
460 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
461 | - |
|
462 | - $this->registerService('RedisFactory', function (Server $c) { |
|
463 | - $systemConfig = $c->getSystemConfig(); |
|
464 | - return new RedisFactory($systemConfig); |
|
465 | - }); |
|
466 | - |
|
467 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
468 | - return new \OC\Activity\Manager( |
|
469 | - $c->getRequest(), |
|
470 | - $c->getUserSession(), |
|
471 | - $c->getConfig(), |
|
472 | - $c->query(IValidator::class) |
|
473 | - ); |
|
474 | - }); |
|
475 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
476 | - |
|
477 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
478 | - return new \OC\Activity\EventMerger( |
|
479 | - $c->getL10N('lib') |
|
480 | - ); |
|
481 | - }); |
|
482 | - $this->registerAlias(IValidator::class, Validator::class); |
|
483 | - |
|
484 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
485 | - return new AvatarManager( |
|
486 | - $c->getUserManager(), |
|
487 | - $c->getAppDataDir('avatar'), |
|
488 | - $c->getL10N('lib'), |
|
489 | - $c->getLogger(), |
|
490 | - $c->getConfig() |
|
491 | - ); |
|
492 | - }); |
|
493 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
494 | - |
|
495 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
496 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
497 | - $logger = Log::getLogClass($logType); |
|
498 | - call_user_func(array($logger, 'init')); |
|
499 | - |
|
500 | - return new Log($logger); |
|
501 | - }); |
|
502 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
503 | - |
|
504 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
505 | - $config = $c->getConfig(); |
|
506 | - return new \OC\BackgroundJob\JobList( |
|
507 | - $c->getDatabaseConnection(), |
|
508 | - $config, |
|
509 | - new TimeFactory() |
|
510 | - ); |
|
511 | - }); |
|
512 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
513 | - |
|
514 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
515 | - $cacheFactory = $c->getMemCacheFactory(); |
|
516 | - $logger = $c->getLogger(); |
|
517 | - if ($cacheFactory->isAvailable()) { |
|
518 | - $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
519 | - } else { |
|
520 | - $router = new \OC\Route\Router($logger); |
|
521 | - } |
|
522 | - return $router; |
|
523 | - }); |
|
524 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
525 | - |
|
526 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
527 | - return new Search(); |
|
528 | - }); |
|
529 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
530 | - |
|
531 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) { |
|
532 | - return new \OC\Security\RateLimiting\Limiter( |
|
533 | - $this->getUserSession(), |
|
534 | - $this->getRequest(), |
|
535 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
536 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
537 | - ); |
|
538 | - }); |
|
539 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
540 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
541 | - $this->getMemCacheFactory(), |
|
542 | - new \OC\AppFramework\Utility\TimeFactory() |
|
543 | - ); |
|
544 | - }); |
|
545 | - |
|
546 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
547 | - return new SecureRandom(); |
|
548 | - }); |
|
549 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
550 | - |
|
551 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
552 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
553 | - }); |
|
554 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
555 | - |
|
556 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
557 | - return new Hasher($c->getConfig()); |
|
558 | - }); |
|
559 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
560 | - |
|
561 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
562 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
563 | - }); |
|
564 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
565 | - |
|
566 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
567 | - $systemConfig = $c->getSystemConfig(); |
|
568 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
569 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
570 | - if (!$factory->isValidType($type)) { |
|
571 | - throw new \OC\DatabaseException('Invalid database type'); |
|
572 | - } |
|
573 | - $connectionParams = $factory->createConnectionParams(); |
|
574 | - $connection = $factory->getConnection($type, $connectionParams); |
|
575 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
576 | - return $connection; |
|
577 | - }); |
|
578 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
579 | - |
|
580 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
581 | - $config = $c->getConfig(); |
|
582 | - return new HTTPHelper( |
|
583 | - $config, |
|
584 | - $c->getHTTPClientService() |
|
585 | - ); |
|
586 | - }); |
|
587 | - |
|
588 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
589 | - $user = \OC_User::getUser(); |
|
590 | - $uid = $user ? $user : null; |
|
591 | - return new ClientService( |
|
592 | - $c->getConfig(), |
|
593 | - new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
594 | - ); |
|
595 | - }); |
|
596 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
597 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
598 | - $eventLogger = new EventLogger(); |
|
599 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
600 | - // In debug mode, module is being activated by default |
|
601 | - $eventLogger->activate(); |
|
602 | - } |
|
603 | - return $eventLogger; |
|
604 | - }); |
|
605 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
606 | - |
|
607 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
608 | - $queryLogger = new QueryLogger(); |
|
609 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
610 | - // In debug mode, module is being activated by default |
|
611 | - $queryLogger->activate(); |
|
612 | - } |
|
613 | - return $queryLogger; |
|
614 | - }); |
|
615 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
616 | - |
|
617 | - $this->registerService(TempManager::class, function (Server $c) { |
|
618 | - return new TempManager( |
|
619 | - $c->getLogger(), |
|
620 | - $c->getConfig() |
|
621 | - ); |
|
622 | - }); |
|
623 | - $this->registerAlias('TempManager', TempManager::class); |
|
624 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
625 | - |
|
626 | - $this->registerService(AppManager::class, function (Server $c) { |
|
627 | - return new \OC\App\AppManager( |
|
628 | - $c->getUserSession(), |
|
629 | - $c->getAppConfig(), |
|
630 | - $c->getGroupManager(), |
|
631 | - $c->getMemCacheFactory(), |
|
632 | - $c->getEventDispatcher() |
|
633 | - ); |
|
634 | - }); |
|
635 | - $this->registerAlias('AppManager', AppManager::class); |
|
636 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
637 | - |
|
638 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
639 | - return new DateTimeZone( |
|
640 | - $c->getConfig(), |
|
641 | - $c->getSession() |
|
642 | - ); |
|
643 | - }); |
|
644 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
645 | - |
|
646 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
647 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
648 | - |
|
649 | - return new DateTimeFormatter( |
|
650 | - $c->getDateTimeZone()->getTimeZone(), |
|
651 | - $c->getL10N('lib', $language) |
|
652 | - ); |
|
653 | - }); |
|
654 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
655 | - |
|
656 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
657 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
658 | - $listener = new UserMountCacheListener($mountCache); |
|
659 | - $listener->listen($c->getUserManager()); |
|
660 | - return $mountCache; |
|
661 | - }); |
|
662 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
663 | - |
|
664 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
665 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
666 | - $mountCache = $c->query('UserMountCache'); |
|
667 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
668 | - |
|
669 | - // builtin providers |
|
670 | - |
|
671 | - $config = $c->getConfig(); |
|
672 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
673 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
674 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
675 | - |
|
676 | - return $manager; |
|
677 | - }); |
|
678 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
679 | - |
|
680 | - $this->registerService('IniWrapper', function ($c) { |
|
681 | - return new IniGetWrapper(); |
|
682 | - }); |
|
683 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
684 | - $jobList = $c->getJobList(); |
|
685 | - return new AsyncBus($jobList); |
|
686 | - }); |
|
687 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
688 | - return new TrustedDomainHelper($this->getConfig()); |
|
689 | - }); |
|
690 | - $this->registerService('Throttler', function(Server $c) { |
|
691 | - return new Throttler( |
|
692 | - $c->getDatabaseConnection(), |
|
693 | - new TimeFactory(), |
|
694 | - $c->getLogger(), |
|
695 | - $c->getConfig() |
|
696 | - ); |
|
697 | - }); |
|
698 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
699 | - // IConfig and IAppManager requires a working database. This code |
|
700 | - // might however be called when ownCloud is not yet setup. |
|
701 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
702 | - $config = $c->getConfig(); |
|
703 | - $appManager = $c->getAppManager(); |
|
704 | - } else { |
|
705 | - $config = null; |
|
706 | - $appManager = null; |
|
707 | - } |
|
708 | - |
|
709 | - return new Checker( |
|
710 | - new EnvironmentHelper(), |
|
711 | - new FileAccessHelper(), |
|
712 | - new AppLocator(), |
|
713 | - $config, |
|
714 | - $c->getMemCacheFactory(), |
|
715 | - $appManager, |
|
716 | - $c->getTempManager() |
|
717 | - ); |
|
718 | - }); |
|
719 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
720 | - if (isset($this['urlParams'])) { |
|
721 | - $urlParams = $this['urlParams']; |
|
722 | - } else { |
|
723 | - $urlParams = []; |
|
724 | - } |
|
725 | - |
|
726 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
727 | - && in_array('fakeinput', stream_get_wrappers()) |
|
728 | - ) { |
|
729 | - $stream = 'fakeinput://data'; |
|
730 | - } else { |
|
731 | - $stream = 'php://input'; |
|
732 | - } |
|
733 | - |
|
734 | - return new Request( |
|
735 | - [ |
|
736 | - 'get' => $_GET, |
|
737 | - 'post' => $_POST, |
|
738 | - 'files' => $_FILES, |
|
739 | - 'server' => $_SERVER, |
|
740 | - 'env' => $_ENV, |
|
741 | - 'cookies' => $_COOKIE, |
|
742 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
743 | - ? $_SERVER['REQUEST_METHOD'] |
|
744 | - : null, |
|
745 | - 'urlParams' => $urlParams, |
|
746 | - ], |
|
747 | - $this->getSecureRandom(), |
|
748 | - $this->getConfig(), |
|
749 | - $this->getCsrfTokenManager(), |
|
750 | - $stream |
|
751 | - ); |
|
752 | - }); |
|
753 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
754 | - |
|
755 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
756 | - return new Mailer( |
|
757 | - $c->getConfig(), |
|
758 | - $c->getLogger(), |
|
759 | - $c->query(Defaults::class), |
|
760 | - $c->getURLGenerator(), |
|
761 | - $c->getL10N('lib') |
|
762 | - ); |
|
763 | - }); |
|
764 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
765 | - |
|
766 | - $this->registerService('LDAPProvider', function(Server $c) { |
|
767 | - $config = $c->getConfig(); |
|
768 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
769 | - if(is_null($factoryClass)) { |
|
770 | - throw new \Exception('ldapProviderFactory not set'); |
|
771 | - } |
|
772 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
773 | - $factory = new $factoryClass($this); |
|
774 | - return $factory->getLDAPProvider(); |
|
775 | - }); |
|
776 | - $this->registerService('LockingProvider', function (Server $c) { |
|
777 | - $ini = $c->getIniWrapper(); |
|
778 | - $config = $c->getConfig(); |
|
779 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
780 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
781 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
782 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
783 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
784 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
785 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
786 | - } |
|
787 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
788 | - } |
|
789 | - return new NoopLockingProvider(); |
|
790 | - }); |
|
791 | - |
|
792 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
793 | - return new \OC\Files\Mount\Manager(); |
|
794 | - }); |
|
795 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
796 | - |
|
797 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
798 | - return new \OC\Files\Type\Detection( |
|
799 | - $c->getURLGenerator(), |
|
800 | - \OC::$configDir, |
|
801 | - \OC::$SERVERROOT . '/resources/config/' |
|
802 | - ); |
|
803 | - }); |
|
804 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
805 | - |
|
806 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
807 | - return new \OC\Files\Type\Loader( |
|
808 | - $c->getDatabaseConnection() |
|
809 | - ); |
|
810 | - }); |
|
811 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
812 | - $this->registerService(BundleFetcher::class, function () { |
|
813 | - return new BundleFetcher($this->getL10N('lib')); |
|
814 | - }); |
|
815 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
816 | - return new Manager( |
|
817 | - $c->query(IValidator::class) |
|
818 | - ); |
|
819 | - }); |
|
820 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
821 | - |
|
822 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
823 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
824 | - $manager->registerCapability(function () use ($c) { |
|
825 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
826 | - }); |
|
827 | - return $manager; |
|
828 | - }); |
|
829 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
830 | - |
|
831 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
832 | - $config = $c->getConfig(); |
|
833 | - $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
834 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
835 | - $factory = new $factoryClass($this); |
|
836 | - return $factory->getManager(); |
|
837 | - }); |
|
838 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
839 | - |
|
840 | - $this->registerService('ThemingDefaults', function(Server $c) { |
|
841 | - /* |
|
130 | + /** @var string */ |
|
131 | + private $webRoot; |
|
132 | + |
|
133 | + /** |
|
134 | + * @param string $webRoot |
|
135 | + * @param \OC\Config $config |
|
136 | + */ |
|
137 | + public function __construct($webRoot, \OC\Config $config) { |
|
138 | + parent::__construct(); |
|
139 | + $this->webRoot = $webRoot; |
|
140 | + |
|
141 | + $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
142 | + return $c; |
|
143 | + }); |
|
144 | + |
|
145 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
146 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
147 | + |
|
148 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
149 | + |
|
150 | + |
|
151 | + |
|
152 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
153 | + return new PreviewManager( |
|
154 | + $c->getConfig(), |
|
155 | + $c->getRootFolder(), |
|
156 | + $c->getAppDataDir('preview'), |
|
157 | + $c->getEventDispatcher(), |
|
158 | + $c->getSession()->get('user_id') |
|
159 | + ); |
|
160 | + }); |
|
161 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
162 | + |
|
163 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
164 | + return new \OC\Preview\Watcher( |
|
165 | + $c->getAppDataDir('preview') |
|
166 | + ); |
|
167 | + }); |
|
168 | + |
|
169 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
170 | + $view = new View(); |
|
171 | + $util = new Encryption\Util( |
|
172 | + $view, |
|
173 | + $c->getUserManager(), |
|
174 | + $c->getGroupManager(), |
|
175 | + $c->getConfig() |
|
176 | + ); |
|
177 | + return new Encryption\Manager( |
|
178 | + $c->getConfig(), |
|
179 | + $c->getLogger(), |
|
180 | + $c->getL10N('core'), |
|
181 | + new View(), |
|
182 | + $util, |
|
183 | + new ArrayCache() |
|
184 | + ); |
|
185 | + }); |
|
186 | + |
|
187 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
188 | + $util = new Encryption\Util( |
|
189 | + new View(), |
|
190 | + $c->getUserManager(), |
|
191 | + $c->getGroupManager(), |
|
192 | + $c->getConfig() |
|
193 | + ); |
|
194 | + return new Encryption\File( |
|
195 | + $util, |
|
196 | + $c->getRootFolder(), |
|
197 | + $c->getShareManager() |
|
198 | + ); |
|
199 | + }); |
|
200 | + |
|
201 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
202 | + $view = new View(); |
|
203 | + $util = new Encryption\Util( |
|
204 | + $view, |
|
205 | + $c->getUserManager(), |
|
206 | + $c->getGroupManager(), |
|
207 | + $c->getConfig() |
|
208 | + ); |
|
209 | + |
|
210 | + return new Encryption\Keys\Storage($view, $util); |
|
211 | + }); |
|
212 | + $this->registerService('TagMapper', function (Server $c) { |
|
213 | + return new TagMapper($c->getDatabaseConnection()); |
|
214 | + }); |
|
215 | + |
|
216 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
217 | + $tagMapper = $c->query('TagMapper'); |
|
218 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
219 | + }); |
|
220 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
221 | + |
|
222 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
223 | + $config = $c->getConfig(); |
|
224 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
225 | + /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
226 | + $factory = new $factoryClass($this); |
|
227 | + return $factory; |
|
228 | + }); |
|
229 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
230 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
231 | + }); |
|
232 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
233 | + |
|
234 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
235 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
236 | + }); |
|
237 | + $this->registerService('RootFolder', function (Server $c) { |
|
238 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
239 | + $view = new View(); |
|
240 | + $root = new Root( |
|
241 | + $manager, |
|
242 | + $view, |
|
243 | + null, |
|
244 | + $c->getUserMountCache(), |
|
245 | + $this->getLogger(), |
|
246 | + $this->getUserManager() |
|
247 | + ); |
|
248 | + $connector = new HookConnector($root, $view); |
|
249 | + $connector->viewToNode(); |
|
250 | + |
|
251 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
252 | + $previewConnector->connectWatcher(); |
|
253 | + |
|
254 | + return $root; |
|
255 | + }); |
|
256 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
257 | + |
|
258 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
259 | + return new LazyRoot(function() use ($c) { |
|
260 | + return $c->query('RootFolder'); |
|
261 | + }); |
|
262 | + }); |
|
263 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
264 | + |
|
265 | + $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
266 | + $config = $c->getConfig(); |
|
267 | + return new \OC\User\Manager($config); |
|
268 | + }); |
|
269 | + $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
270 | + |
|
271 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
272 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
273 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
274 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
275 | + }); |
|
276 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
277 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
278 | + }); |
|
279 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
280 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
281 | + }); |
|
282 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
283 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
284 | + }); |
|
285 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
286 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
287 | + }); |
|
288 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
289 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
290 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
291 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
292 | + }); |
|
293 | + return $groupManager; |
|
294 | + }); |
|
295 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
296 | + |
|
297 | + $this->registerService(Store::class, function(Server $c) { |
|
298 | + $session = $c->getSession(); |
|
299 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
300 | + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
301 | + } else { |
|
302 | + $tokenProvider = null; |
|
303 | + } |
|
304 | + $logger = $c->getLogger(); |
|
305 | + return new Store($session, $logger, $tokenProvider); |
|
306 | + }); |
|
307 | + $this->registerAlias(IStore::class, Store::class); |
|
308 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
309 | + $dbConnection = $c->getDatabaseConnection(); |
|
310 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
311 | + }); |
|
312 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
313 | + $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
314 | + $crypto = $c->getCrypto(); |
|
315 | + $config = $c->getConfig(); |
|
316 | + $logger = $c->getLogger(); |
|
317 | + $timeFactory = new TimeFactory(); |
|
318 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
319 | + }); |
|
320 | + $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
321 | + |
|
322 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
323 | + $manager = $c->getUserManager(); |
|
324 | + $session = new \OC\Session\Memory(''); |
|
325 | + $timeFactory = new TimeFactory(); |
|
326 | + // Token providers might require a working database. This code |
|
327 | + // might however be called when ownCloud is not yet setup. |
|
328 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
329 | + $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
330 | + } else { |
|
331 | + $defaultTokenProvider = null; |
|
332 | + } |
|
333 | + |
|
334 | + $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
|
335 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
336 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
337 | + }); |
|
338 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
339 | + /** @var $user \OC\User\User */ |
|
340 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
341 | + }); |
|
342 | + $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
343 | + /** @var $user \OC\User\User */ |
|
344 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
345 | + }); |
|
346 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
347 | + /** @var $user \OC\User\User */ |
|
348 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
349 | + }); |
|
350 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
351 | + /** @var $user \OC\User\User */ |
|
352 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
353 | + }); |
|
354 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
355 | + /** @var $user \OC\User\User */ |
|
356 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
357 | + }); |
|
358 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
359 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
360 | + }); |
|
361 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
362 | + /** @var $user \OC\User\User */ |
|
363 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
364 | + }); |
|
365 | + $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
366 | + /** @var $user \OC\User\User */ |
|
367 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
368 | + }); |
|
369 | + $userSession->listen('\OC\User', 'logout', function () { |
|
370 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
371 | + }); |
|
372 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
373 | + /** @var $user \OC\User\User */ |
|
374 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
375 | + }); |
|
376 | + return $userSession; |
|
377 | + }); |
|
378 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
379 | + |
|
380 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
381 | + return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
382 | + }); |
|
383 | + |
|
384 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
385 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
386 | + |
|
387 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
388 | + return new \OC\AllConfig( |
|
389 | + $c->getSystemConfig() |
|
390 | + ); |
|
391 | + }); |
|
392 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
393 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
394 | + |
|
395 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
396 | + return new \OC\SystemConfig($config); |
|
397 | + }); |
|
398 | + |
|
399 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
400 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
401 | + }); |
|
402 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
403 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
404 | + |
|
405 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
406 | + return new \OC\L10N\Factory( |
|
407 | + $c->getConfig(), |
|
408 | + $c->getRequest(), |
|
409 | + $c->getUserSession(), |
|
410 | + \OC::$SERVERROOT |
|
411 | + ); |
|
412 | + }); |
|
413 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
414 | + |
|
415 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
416 | + $config = $c->getConfig(); |
|
417 | + $cacheFactory = $c->getMemCacheFactory(); |
|
418 | + return new \OC\URLGenerator( |
|
419 | + $config, |
|
420 | + $cacheFactory |
|
421 | + ); |
|
422 | + }); |
|
423 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
424 | + |
|
425 | + $this->registerService('AppHelper', function ($c) { |
|
426 | + return new \OC\AppHelper(); |
|
427 | + }); |
|
428 | + $this->registerAlias('AppFetcher', AppFetcher::class); |
|
429 | + $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
430 | + |
|
431 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
432 | + return new Cache\File(); |
|
433 | + }); |
|
434 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
435 | + |
|
436 | + $this->registerService(Factory::class, function (Server $c) { |
|
437 | + $config = $c->getConfig(); |
|
438 | + |
|
439 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
440 | + $v = \OC_App::getAppVersions(); |
|
441 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
442 | + $version = implode(',', $v); |
|
443 | + $instanceId = \OC_Util::getInstanceId(); |
|
444 | + $path = \OC::$SERVERROOT; |
|
445 | + $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
446 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
447 | + $config->getSystemValue('memcache.local', null), |
|
448 | + $config->getSystemValue('memcache.distributed', null), |
|
449 | + $config->getSystemValue('memcache.locking', null) |
|
450 | + ); |
|
451 | + } |
|
452 | + |
|
453 | + return new \OC\Memcache\Factory('', $c->getLogger(), |
|
454 | + '\\OC\\Memcache\\ArrayCache', |
|
455 | + '\\OC\\Memcache\\ArrayCache', |
|
456 | + '\\OC\\Memcache\\ArrayCache' |
|
457 | + ); |
|
458 | + }); |
|
459 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
460 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
461 | + |
|
462 | + $this->registerService('RedisFactory', function (Server $c) { |
|
463 | + $systemConfig = $c->getSystemConfig(); |
|
464 | + return new RedisFactory($systemConfig); |
|
465 | + }); |
|
466 | + |
|
467 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
468 | + return new \OC\Activity\Manager( |
|
469 | + $c->getRequest(), |
|
470 | + $c->getUserSession(), |
|
471 | + $c->getConfig(), |
|
472 | + $c->query(IValidator::class) |
|
473 | + ); |
|
474 | + }); |
|
475 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
476 | + |
|
477 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
478 | + return new \OC\Activity\EventMerger( |
|
479 | + $c->getL10N('lib') |
|
480 | + ); |
|
481 | + }); |
|
482 | + $this->registerAlias(IValidator::class, Validator::class); |
|
483 | + |
|
484 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
485 | + return new AvatarManager( |
|
486 | + $c->getUserManager(), |
|
487 | + $c->getAppDataDir('avatar'), |
|
488 | + $c->getL10N('lib'), |
|
489 | + $c->getLogger(), |
|
490 | + $c->getConfig() |
|
491 | + ); |
|
492 | + }); |
|
493 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
494 | + |
|
495 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
496 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
497 | + $logger = Log::getLogClass($logType); |
|
498 | + call_user_func(array($logger, 'init')); |
|
499 | + |
|
500 | + return new Log($logger); |
|
501 | + }); |
|
502 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
503 | + |
|
504 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
505 | + $config = $c->getConfig(); |
|
506 | + return new \OC\BackgroundJob\JobList( |
|
507 | + $c->getDatabaseConnection(), |
|
508 | + $config, |
|
509 | + new TimeFactory() |
|
510 | + ); |
|
511 | + }); |
|
512 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
513 | + |
|
514 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
515 | + $cacheFactory = $c->getMemCacheFactory(); |
|
516 | + $logger = $c->getLogger(); |
|
517 | + if ($cacheFactory->isAvailable()) { |
|
518 | + $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
519 | + } else { |
|
520 | + $router = new \OC\Route\Router($logger); |
|
521 | + } |
|
522 | + return $router; |
|
523 | + }); |
|
524 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
525 | + |
|
526 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
527 | + return new Search(); |
|
528 | + }); |
|
529 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
530 | + |
|
531 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) { |
|
532 | + return new \OC\Security\RateLimiting\Limiter( |
|
533 | + $this->getUserSession(), |
|
534 | + $this->getRequest(), |
|
535 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
536 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
537 | + ); |
|
538 | + }); |
|
539 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
540 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
541 | + $this->getMemCacheFactory(), |
|
542 | + new \OC\AppFramework\Utility\TimeFactory() |
|
543 | + ); |
|
544 | + }); |
|
545 | + |
|
546 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
547 | + return new SecureRandom(); |
|
548 | + }); |
|
549 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
550 | + |
|
551 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
552 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
553 | + }); |
|
554 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
555 | + |
|
556 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
557 | + return new Hasher($c->getConfig()); |
|
558 | + }); |
|
559 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
560 | + |
|
561 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
562 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
563 | + }); |
|
564 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
565 | + |
|
566 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
567 | + $systemConfig = $c->getSystemConfig(); |
|
568 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
569 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
570 | + if (!$factory->isValidType($type)) { |
|
571 | + throw new \OC\DatabaseException('Invalid database type'); |
|
572 | + } |
|
573 | + $connectionParams = $factory->createConnectionParams(); |
|
574 | + $connection = $factory->getConnection($type, $connectionParams); |
|
575 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
576 | + return $connection; |
|
577 | + }); |
|
578 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
579 | + |
|
580 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
581 | + $config = $c->getConfig(); |
|
582 | + return new HTTPHelper( |
|
583 | + $config, |
|
584 | + $c->getHTTPClientService() |
|
585 | + ); |
|
586 | + }); |
|
587 | + |
|
588 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
589 | + $user = \OC_User::getUser(); |
|
590 | + $uid = $user ? $user : null; |
|
591 | + return new ClientService( |
|
592 | + $c->getConfig(), |
|
593 | + new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
594 | + ); |
|
595 | + }); |
|
596 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
597 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
598 | + $eventLogger = new EventLogger(); |
|
599 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
600 | + // In debug mode, module is being activated by default |
|
601 | + $eventLogger->activate(); |
|
602 | + } |
|
603 | + return $eventLogger; |
|
604 | + }); |
|
605 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
606 | + |
|
607 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
608 | + $queryLogger = new QueryLogger(); |
|
609 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
610 | + // In debug mode, module is being activated by default |
|
611 | + $queryLogger->activate(); |
|
612 | + } |
|
613 | + return $queryLogger; |
|
614 | + }); |
|
615 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
616 | + |
|
617 | + $this->registerService(TempManager::class, function (Server $c) { |
|
618 | + return new TempManager( |
|
619 | + $c->getLogger(), |
|
620 | + $c->getConfig() |
|
621 | + ); |
|
622 | + }); |
|
623 | + $this->registerAlias('TempManager', TempManager::class); |
|
624 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
625 | + |
|
626 | + $this->registerService(AppManager::class, function (Server $c) { |
|
627 | + return new \OC\App\AppManager( |
|
628 | + $c->getUserSession(), |
|
629 | + $c->getAppConfig(), |
|
630 | + $c->getGroupManager(), |
|
631 | + $c->getMemCacheFactory(), |
|
632 | + $c->getEventDispatcher() |
|
633 | + ); |
|
634 | + }); |
|
635 | + $this->registerAlias('AppManager', AppManager::class); |
|
636 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
637 | + |
|
638 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
639 | + return new DateTimeZone( |
|
640 | + $c->getConfig(), |
|
641 | + $c->getSession() |
|
642 | + ); |
|
643 | + }); |
|
644 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
645 | + |
|
646 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
647 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
648 | + |
|
649 | + return new DateTimeFormatter( |
|
650 | + $c->getDateTimeZone()->getTimeZone(), |
|
651 | + $c->getL10N('lib', $language) |
|
652 | + ); |
|
653 | + }); |
|
654 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
655 | + |
|
656 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
657 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
658 | + $listener = new UserMountCacheListener($mountCache); |
|
659 | + $listener->listen($c->getUserManager()); |
|
660 | + return $mountCache; |
|
661 | + }); |
|
662 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
663 | + |
|
664 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
665 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
666 | + $mountCache = $c->query('UserMountCache'); |
|
667 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
668 | + |
|
669 | + // builtin providers |
|
670 | + |
|
671 | + $config = $c->getConfig(); |
|
672 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
673 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
674 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
675 | + |
|
676 | + return $manager; |
|
677 | + }); |
|
678 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
679 | + |
|
680 | + $this->registerService('IniWrapper', function ($c) { |
|
681 | + return new IniGetWrapper(); |
|
682 | + }); |
|
683 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
684 | + $jobList = $c->getJobList(); |
|
685 | + return new AsyncBus($jobList); |
|
686 | + }); |
|
687 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
688 | + return new TrustedDomainHelper($this->getConfig()); |
|
689 | + }); |
|
690 | + $this->registerService('Throttler', function(Server $c) { |
|
691 | + return new Throttler( |
|
692 | + $c->getDatabaseConnection(), |
|
693 | + new TimeFactory(), |
|
694 | + $c->getLogger(), |
|
695 | + $c->getConfig() |
|
696 | + ); |
|
697 | + }); |
|
698 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
699 | + // IConfig and IAppManager requires a working database. This code |
|
700 | + // might however be called when ownCloud is not yet setup. |
|
701 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
702 | + $config = $c->getConfig(); |
|
703 | + $appManager = $c->getAppManager(); |
|
704 | + } else { |
|
705 | + $config = null; |
|
706 | + $appManager = null; |
|
707 | + } |
|
708 | + |
|
709 | + return new Checker( |
|
710 | + new EnvironmentHelper(), |
|
711 | + new FileAccessHelper(), |
|
712 | + new AppLocator(), |
|
713 | + $config, |
|
714 | + $c->getMemCacheFactory(), |
|
715 | + $appManager, |
|
716 | + $c->getTempManager() |
|
717 | + ); |
|
718 | + }); |
|
719 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
720 | + if (isset($this['urlParams'])) { |
|
721 | + $urlParams = $this['urlParams']; |
|
722 | + } else { |
|
723 | + $urlParams = []; |
|
724 | + } |
|
725 | + |
|
726 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
727 | + && in_array('fakeinput', stream_get_wrappers()) |
|
728 | + ) { |
|
729 | + $stream = 'fakeinput://data'; |
|
730 | + } else { |
|
731 | + $stream = 'php://input'; |
|
732 | + } |
|
733 | + |
|
734 | + return new Request( |
|
735 | + [ |
|
736 | + 'get' => $_GET, |
|
737 | + 'post' => $_POST, |
|
738 | + 'files' => $_FILES, |
|
739 | + 'server' => $_SERVER, |
|
740 | + 'env' => $_ENV, |
|
741 | + 'cookies' => $_COOKIE, |
|
742 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
743 | + ? $_SERVER['REQUEST_METHOD'] |
|
744 | + : null, |
|
745 | + 'urlParams' => $urlParams, |
|
746 | + ], |
|
747 | + $this->getSecureRandom(), |
|
748 | + $this->getConfig(), |
|
749 | + $this->getCsrfTokenManager(), |
|
750 | + $stream |
|
751 | + ); |
|
752 | + }); |
|
753 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
754 | + |
|
755 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
756 | + return new Mailer( |
|
757 | + $c->getConfig(), |
|
758 | + $c->getLogger(), |
|
759 | + $c->query(Defaults::class), |
|
760 | + $c->getURLGenerator(), |
|
761 | + $c->getL10N('lib') |
|
762 | + ); |
|
763 | + }); |
|
764 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
765 | + |
|
766 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
767 | + $config = $c->getConfig(); |
|
768 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
769 | + if(is_null($factoryClass)) { |
|
770 | + throw new \Exception('ldapProviderFactory not set'); |
|
771 | + } |
|
772 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
773 | + $factory = new $factoryClass($this); |
|
774 | + return $factory->getLDAPProvider(); |
|
775 | + }); |
|
776 | + $this->registerService('LockingProvider', function (Server $c) { |
|
777 | + $ini = $c->getIniWrapper(); |
|
778 | + $config = $c->getConfig(); |
|
779 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
780 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
781 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
782 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
783 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
784 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
785 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
786 | + } |
|
787 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
788 | + } |
|
789 | + return new NoopLockingProvider(); |
|
790 | + }); |
|
791 | + |
|
792 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
793 | + return new \OC\Files\Mount\Manager(); |
|
794 | + }); |
|
795 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
796 | + |
|
797 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
798 | + return new \OC\Files\Type\Detection( |
|
799 | + $c->getURLGenerator(), |
|
800 | + \OC::$configDir, |
|
801 | + \OC::$SERVERROOT . '/resources/config/' |
|
802 | + ); |
|
803 | + }); |
|
804 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
805 | + |
|
806 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
807 | + return new \OC\Files\Type\Loader( |
|
808 | + $c->getDatabaseConnection() |
|
809 | + ); |
|
810 | + }); |
|
811 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
812 | + $this->registerService(BundleFetcher::class, function () { |
|
813 | + return new BundleFetcher($this->getL10N('lib')); |
|
814 | + }); |
|
815 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
816 | + return new Manager( |
|
817 | + $c->query(IValidator::class) |
|
818 | + ); |
|
819 | + }); |
|
820 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
821 | + |
|
822 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
823 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
824 | + $manager->registerCapability(function () use ($c) { |
|
825 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
826 | + }); |
|
827 | + return $manager; |
|
828 | + }); |
|
829 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
830 | + |
|
831 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
832 | + $config = $c->getConfig(); |
|
833 | + $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
834 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
835 | + $factory = new $factoryClass($this); |
|
836 | + return $factory->getManager(); |
|
837 | + }); |
|
838 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
839 | + |
|
840 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
841 | + /* |
|
842 | 842 | * Dark magic for autoloader. |
843 | 843 | * If we do a class_exists it will try to load the class which will |
844 | 844 | * make composer cache the result. Resulting in errors when enabling |
845 | 845 | * the theming app. |
846 | 846 | */ |
847 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
848 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
849 | - $classExists = true; |
|
850 | - } else { |
|
851 | - $classExists = false; |
|
852 | - } |
|
853 | - |
|
854 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
855 | - return new ThemingDefaults( |
|
856 | - $c->getConfig(), |
|
857 | - $c->getL10N('theming'), |
|
858 | - $c->getURLGenerator(), |
|
859 | - $c->getAppDataDir('theming'), |
|
860 | - $c->getMemCacheFactory(), |
|
861 | - new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming')) |
|
862 | - ); |
|
863 | - } |
|
864 | - return new \OC_Defaults(); |
|
865 | - }); |
|
866 | - $this->registerService(SCSSCacher::class, function(Server $c) { |
|
867 | - /** @var Factory $cacheFactory */ |
|
868 | - $cacheFactory = $c->query(Factory::class); |
|
869 | - return new SCSSCacher( |
|
870 | - $c->getLogger(), |
|
871 | - $c->query(\OC\Files\AppData\Factory::class), |
|
872 | - $c->getURLGenerator(), |
|
873 | - $c->getConfig(), |
|
874 | - $c->getThemingDefaults(), |
|
875 | - \OC::$SERVERROOT, |
|
876 | - $cacheFactory->create('SCSS') |
|
877 | - ); |
|
878 | - }); |
|
879 | - $this->registerService(EventDispatcher::class, function () { |
|
880 | - return new EventDispatcher(); |
|
881 | - }); |
|
882 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
883 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
884 | - |
|
885 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
886 | - // FIXME: Instantiiated here due to cyclic dependency |
|
887 | - $request = new Request( |
|
888 | - [ |
|
889 | - 'get' => $_GET, |
|
890 | - 'post' => $_POST, |
|
891 | - 'files' => $_FILES, |
|
892 | - 'server' => $_SERVER, |
|
893 | - 'env' => $_ENV, |
|
894 | - 'cookies' => $_COOKIE, |
|
895 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
896 | - ? $_SERVER['REQUEST_METHOD'] |
|
897 | - : null, |
|
898 | - ], |
|
899 | - $c->getSecureRandom(), |
|
900 | - $c->getConfig() |
|
901 | - ); |
|
902 | - |
|
903 | - return new CryptoWrapper( |
|
904 | - $c->getConfig(), |
|
905 | - $c->getCrypto(), |
|
906 | - $c->getSecureRandom(), |
|
907 | - $request |
|
908 | - ); |
|
909 | - }); |
|
910 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
911 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
912 | - |
|
913 | - return new CsrfTokenManager( |
|
914 | - $tokenGenerator, |
|
915 | - $c->query(SessionStorage::class) |
|
916 | - ); |
|
917 | - }); |
|
918 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
919 | - return new SessionStorage($c->getSession()); |
|
920 | - }); |
|
921 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
922 | - return new ContentSecurityPolicyManager(); |
|
923 | - }); |
|
924 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
925 | - |
|
926 | - $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
927 | - return new ContentSecurityPolicyNonceManager( |
|
928 | - $c->getCsrfTokenManager(), |
|
929 | - $c->getRequest() |
|
930 | - ); |
|
931 | - }); |
|
932 | - |
|
933 | - $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
934 | - $config = $c->getConfig(); |
|
935 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
936 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
937 | - $factory = new $factoryClass($this); |
|
938 | - |
|
939 | - $manager = new \OC\Share20\Manager( |
|
940 | - $c->getLogger(), |
|
941 | - $c->getConfig(), |
|
942 | - $c->getSecureRandom(), |
|
943 | - $c->getHasher(), |
|
944 | - $c->getMountManager(), |
|
945 | - $c->getGroupManager(), |
|
946 | - $c->getL10N('core'), |
|
947 | - $factory, |
|
948 | - $c->getUserManager(), |
|
949 | - $c->getLazyRootFolder(), |
|
950 | - $c->getEventDispatcher() |
|
951 | - ); |
|
952 | - |
|
953 | - return $manager; |
|
954 | - }); |
|
955 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
956 | - |
|
957 | - $this->registerService('SettingsManager', function(Server $c) { |
|
958 | - $manager = new \OC\Settings\Manager( |
|
959 | - $c->getLogger(), |
|
960 | - $c->getDatabaseConnection(), |
|
961 | - $c->getL10N('lib'), |
|
962 | - $c->getConfig(), |
|
963 | - $c->getEncryptionManager(), |
|
964 | - $c->getUserManager(), |
|
965 | - $c->getLockingProvider(), |
|
966 | - $c->getRequest(), |
|
967 | - new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
968 | - $c->getURLGenerator(), |
|
969 | - $c->query(AccountManager::class), |
|
970 | - $c->getGroupManager(), |
|
971 | - $c->getL10NFactory(), |
|
972 | - $c->getThemingDefaults() |
|
973 | - ); |
|
974 | - return $manager; |
|
975 | - }); |
|
976 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
977 | - return new \OC\Files\AppData\Factory( |
|
978 | - $c->getRootFolder(), |
|
979 | - $c->getSystemConfig() |
|
980 | - ); |
|
981 | - }); |
|
982 | - |
|
983 | - $this->registerService('LockdownManager', function (Server $c) { |
|
984 | - return new LockdownManager(function() use ($c) { |
|
985 | - return $c->getSession(); |
|
986 | - }); |
|
987 | - }); |
|
988 | - |
|
989 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
990 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
991 | - }); |
|
992 | - |
|
993 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
994 | - return new CloudIdManager(); |
|
995 | - }); |
|
996 | - |
|
997 | - /* To trick DI since we don't extend the DIContainer here */ |
|
998 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
999 | - return new CleanPreviewsBackgroundJob( |
|
1000 | - $c->getRootFolder(), |
|
1001 | - $c->getLogger(), |
|
1002 | - $c->getJobList(), |
|
1003 | - new TimeFactory() |
|
1004 | - ); |
|
1005 | - }); |
|
1006 | - |
|
1007 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1008 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1009 | - |
|
1010 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1011 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1012 | - |
|
1013 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1014 | - return new Defaults( |
|
1015 | - $c->getThemingDefaults() |
|
1016 | - ); |
|
1017 | - }); |
|
1018 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1019 | - |
|
1020 | - $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
1021 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1022 | - }); |
|
1023 | - |
|
1024 | - $this->registerService(IShareHelper::class, function(Server $c) { |
|
1025 | - return new ShareHelper( |
|
1026 | - $c->query(\OCP\Share\IManager::class) |
|
1027 | - ); |
|
1028 | - }); |
|
1029 | - } |
|
1030 | - |
|
1031 | - /** |
|
1032 | - * @return \OCP\Contacts\IManager |
|
1033 | - */ |
|
1034 | - public function getContactsManager() { |
|
1035 | - return $this->query('ContactsManager'); |
|
1036 | - } |
|
1037 | - |
|
1038 | - /** |
|
1039 | - * @return \OC\Encryption\Manager |
|
1040 | - */ |
|
1041 | - public function getEncryptionManager() { |
|
1042 | - return $this->query('EncryptionManager'); |
|
1043 | - } |
|
1044 | - |
|
1045 | - /** |
|
1046 | - * @return \OC\Encryption\File |
|
1047 | - */ |
|
1048 | - public function getEncryptionFilesHelper() { |
|
1049 | - return $this->query('EncryptionFileHelper'); |
|
1050 | - } |
|
1051 | - |
|
1052 | - /** |
|
1053 | - * @return \OCP\Encryption\Keys\IStorage |
|
1054 | - */ |
|
1055 | - public function getEncryptionKeyStorage() { |
|
1056 | - return $this->query('EncryptionKeyStorage'); |
|
1057 | - } |
|
1058 | - |
|
1059 | - /** |
|
1060 | - * The current request object holding all information about the request |
|
1061 | - * currently being processed is returned from this method. |
|
1062 | - * In case the current execution was not initiated by a web request null is returned |
|
1063 | - * |
|
1064 | - * @return \OCP\IRequest |
|
1065 | - */ |
|
1066 | - public function getRequest() { |
|
1067 | - return $this->query('Request'); |
|
1068 | - } |
|
1069 | - |
|
1070 | - /** |
|
1071 | - * Returns the preview manager which can create preview images for a given file |
|
1072 | - * |
|
1073 | - * @return \OCP\IPreview |
|
1074 | - */ |
|
1075 | - public function getPreviewManager() { |
|
1076 | - return $this->query('PreviewManager'); |
|
1077 | - } |
|
1078 | - |
|
1079 | - /** |
|
1080 | - * Returns the tag manager which can get and set tags for different object types |
|
1081 | - * |
|
1082 | - * @see \OCP\ITagManager::load() |
|
1083 | - * @return \OCP\ITagManager |
|
1084 | - */ |
|
1085 | - public function getTagManager() { |
|
1086 | - return $this->query('TagManager'); |
|
1087 | - } |
|
1088 | - |
|
1089 | - /** |
|
1090 | - * Returns the system-tag manager |
|
1091 | - * |
|
1092 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1093 | - * |
|
1094 | - * @since 9.0.0 |
|
1095 | - */ |
|
1096 | - public function getSystemTagManager() { |
|
1097 | - return $this->query('SystemTagManager'); |
|
1098 | - } |
|
1099 | - |
|
1100 | - /** |
|
1101 | - * Returns the system-tag object mapper |
|
1102 | - * |
|
1103 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1104 | - * |
|
1105 | - * @since 9.0.0 |
|
1106 | - */ |
|
1107 | - public function getSystemTagObjectMapper() { |
|
1108 | - return $this->query('SystemTagObjectMapper'); |
|
1109 | - } |
|
1110 | - |
|
1111 | - /** |
|
1112 | - * Returns the avatar manager, used for avatar functionality |
|
1113 | - * |
|
1114 | - * @return \OCP\IAvatarManager |
|
1115 | - */ |
|
1116 | - public function getAvatarManager() { |
|
1117 | - return $this->query('AvatarManager'); |
|
1118 | - } |
|
1119 | - |
|
1120 | - /** |
|
1121 | - * Returns the root folder of ownCloud's data directory |
|
1122 | - * |
|
1123 | - * @return \OCP\Files\IRootFolder |
|
1124 | - */ |
|
1125 | - public function getRootFolder() { |
|
1126 | - return $this->query('LazyRootFolder'); |
|
1127 | - } |
|
1128 | - |
|
1129 | - /** |
|
1130 | - * Returns the root folder of ownCloud's data directory |
|
1131 | - * This is the lazy variant so this gets only initialized once it |
|
1132 | - * is actually used. |
|
1133 | - * |
|
1134 | - * @return \OCP\Files\IRootFolder |
|
1135 | - */ |
|
1136 | - public function getLazyRootFolder() { |
|
1137 | - return $this->query('LazyRootFolder'); |
|
1138 | - } |
|
1139 | - |
|
1140 | - /** |
|
1141 | - * Returns a view to ownCloud's files folder |
|
1142 | - * |
|
1143 | - * @param string $userId user ID |
|
1144 | - * @return \OCP\Files\Folder|null |
|
1145 | - */ |
|
1146 | - public function getUserFolder($userId = null) { |
|
1147 | - if ($userId === null) { |
|
1148 | - $user = $this->getUserSession()->getUser(); |
|
1149 | - if (!$user) { |
|
1150 | - return null; |
|
1151 | - } |
|
1152 | - $userId = $user->getUID(); |
|
1153 | - } |
|
1154 | - $root = $this->getRootFolder(); |
|
1155 | - return $root->getUserFolder($userId); |
|
1156 | - } |
|
1157 | - |
|
1158 | - /** |
|
1159 | - * Returns an app-specific view in ownClouds data directory |
|
1160 | - * |
|
1161 | - * @return \OCP\Files\Folder |
|
1162 | - * @deprecated since 9.2.0 use IAppData |
|
1163 | - */ |
|
1164 | - public function getAppFolder() { |
|
1165 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1166 | - $root = $this->getRootFolder(); |
|
1167 | - if (!$root->nodeExists($dir)) { |
|
1168 | - $folder = $root->newFolder($dir); |
|
1169 | - } else { |
|
1170 | - $folder = $root->get($dir); |
|
1171 | - } |
|
1172 | - return $folder; |
|
1173 | - } |
|
1174 | - |
|
1175 | - /** |
|
1176 | - * @return \OC\User\Manager |
|
1177 | - */ |
|
1178 | - public function getUserManager() { |
|
1179 | - return $this->query('UserManager'); |
|
1180 | - } |
|
1181 | - |
|
1182 | - /** |
|
1183 | - * @return \OC\Group\Manager |
|
1184 | - */ |
|
1185 | - public function getGroupManager() { |
|
1186 | - return $this->query('GroupManager'); |
|
1187 | - } |
|
1188 | - |
|
1189 | - /** |
|
1190 | - * @return \OC\User\Session |
|
1191 | - */ |
|
1192 | - public function getUserSession() { |
|
1193 | - return $this->query('UserSession'); |
|
1194 | - } |
|
1195 | - |
|
1196 | - /** |
|
1197 | - * @return \OCP\ISession |
|
1198 | - */ |
|
1199 | - public function getSession() { |
|
1200 | - return $this->query('UserSession')->getSession(); |
|
1201 | - } |
|
1202 | - |
|
1203 | - /** |
|
1204 | - * @param \OCP\ISession $session |
|
1205 | - */ |
|
1206 | - public function setSession(\OCP\ISession $session) { |
|
1207 | - $this->query(SessionStorage::class)->setSession($session); |
|
1208 | - $this->query('UserSession')->setSession($session); |
|
1209 | - $this->query(Store::class)->setSession($session); |
|
1210 | - } |
|
1211 | - |
|
1212 | - /** |
|
1213 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1214 | - */ |
|
1215 | - public function getTwoFactorAuthManager() { |
|
1216 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1217 | - } |
|
1218 | - |
|
1219 | - /** |
|
1220 | - * @return \OC\NavigationManager |
|
1221 | - */ |
|
1222 | - public function getNavigationManager() { |
|
1223 | - return $this->query('NavigationManager'); |
|
1224 | - } |
|
1225 | - |
|
1226 | - /** |
|
1227 | - * @return \OCP\IConfig |
|
1228 | - */ |
|
1229 | - public function getConfig() { |
|
1230 | - return $this->query('AllConfig'); |
|
1231 | - } |
|
1232 | - |
|
1233 | - /** |
|
1234 | - * @internal For internal use only |
|
1235 | - * @return \OC\SystemConfig |
|
1236 | - */ |
|
1237 | - public function getSystemConfig() { |
|
1238 | - return $this->query('SystemConfig'); |
|
1239 | - } |
|
1240 | - |
|
1241 | - /** |
|
1242 | - * Returns the app config manager |
|
1243 | - * |
|
1244 | - * @return \OCP\IAppConfig |
|
1245 | - */ |
|
1246 | - public function getAppConfig() { |
|
1247 | - return $this->query('AppConfig'); |
|
1248 | - } |
|
1249 | - |
|
1250 | - /** |
|
1251 | - * @return \OCP\L10N\IFactory |
|
1252 | - */ |
|
1253 | - public function getL10NFactory() { |
|
1254 | - return $this->query('L10NFactory'); |
|
1255 | - } |
|
1256 | - |
|
1257 | - /** |
|
1258 | - * get an L10N instance |
|
1259 | - * |
|
1260 | - * @param string $app appid |
|
1261 | - * @param string $lang |
|
1262 | - * @return IL10N |
|
1263 | - */ |
|
1264 | - public function getL10N($app, $lang = null) { |
|
1265 | - return $this->getL10NFactory()->get($app, $lang); |
|
1266 | - } |
|
1267 | - |
|
1268 | - /** |
|
1269 | - * @return \OCP\IURLGenerator |
|
1270 | - */ |
|
1271 | - public function getURLGenerator() { |
|
1272 | - return $this->query('URLGenerator'); |
|
1273 | - } |
|
1274 | - |
|
1275 | - /** |
|
1276 | - * @return \OCP\IHelper |
|
1277 | - */ |
|
1278 | - public function getHelper() { |
|
1279 | - return $this->query('AppHelper'); |
|
1280 | - } |
|
1281 | - |
|
1282 | - /** |
|
1283 | - * @return AppFetcher |
|
1284 | - */ |
|
1285 | - public function getAppFetcher() { |
|
1286 | - return $this->query(AppFetcher::class); |
|
1287 | - } |
|
1288 | - |
|
1289 | - /** |
|
1290 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1291 | - * getMemCacheFactory() instead. |
|
1292 | - * |
|
1293 | - * @return \OCP\ICache |
|
1294 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1295 | - */ |
|
1296 | - public function getCache() { |
|
1297 | - return $this->query('UserCache'); |
|
1298 | - } |
|
1299 | - |
|
1300 | - /** |
|
1301 | - * Returns an \OCP\CacheFactory instance |
|
1302 | - * |
|
1303 | - * @return \OCP\ICacheFactory |
|
1304 | - */ |
|
1305 | - public function getMemCacheFactory() { |
|
1306 | - return $this->query('MemCacheFactory'); |
|
1307 | - } |
|
1308 | - |
|
1309 | - /** |
|
1310 | - * Returns an \OC\RedisFactory instance |
|
1311 | - * |
|
1312 | - * @return \OC\RedisFactory |
|
1313 | - */ |
|
1314 | - public function getGetRedisFactory() { |
|
1315 | - return $this->query('RedisFactory'); |
|
1316 | - } |
|
1317 | - |
|
1318 | - |
|
1319 | - /** |
|
1320 | - * Returns the current session |
|
1321 | - * |
|
1322 | - * @return \OCP\IDBConnection |
|
1323 | - */ |
|
1324 | - public function getDatabaseConnection() { |
|
1325 | - return $this->query('DatabaseConnection'); |
|
1326 | - } |
|
1327 | - |
|
1328 | - /** |
|
1329 | - * Returns the activity manager |
|
1330 | - * |
|
1331 | - * @return \OCP\Activity\IManager |
|
1332 | - */ |
|
1333 | - public function getActivityManager() { |
|
1334 | - return $this->query('ActivityManager'); |
|
1335 | - } |
|
1336 | - |
|
1337 | - /** |
|
1338 | - * Returns an job list for controlling background jobs |
|
1339 | - * |
|
1340 | - * @return \OCP\BackgroundJob\IJobList |
|
1341 | - */ |
|
1342 | - public function getJobList() { |
|
1343 | - return $this->query('JobList'); |
|
1344 | - } |
|
1345 | - |
|
1346 | - /** |
|
1347 | - * Returns a logger instance |
|
1348 | - * |
|
1349 | - * @return \OCP\ILogger |
|
1350 | - */ |
|
1351 | - public function getLogger() { |
|
1352 | - return $this->query('Logger'); |
|
1353 | - } |
|
1354 | - |
|
1355 | - /** |
|
1356 | - * Returns a router for generating and matching urls |
|
1357 | - * |
|
1358 | - * @return \OCP\Route\IRouter |
|
1359 | - */ |
|
1360 | - public function getRouter() { |
|
1361 | - return $this->query('Router'); |
|
1362 | - } |
|
1363 | - |
|
1364 | - /** |
|
1365 | - * Returns a search instance |
|
1366 | - * |
|
1367 | - * @return \OCP\ISearch |
|
1368 | - */ |
|
1369 | - public function getSearch() { |
|
1370 | - return $this->query('Search'); |
|
1371 | - } |
|
1372 | - |
|
1373 | - /** |
|
1374 | - * Returns a SecureRandom instance |
|
1375 | - * |
|
1376 | - * @return \OCP\Security\ISecureRandom |
|
1377 | - */ |
|
1378 | - public function getSecureRandom() { |
|
1379 | - return $this->query('SecureRandom'); |
|
1380 | - } |
|
1381 | - |
|
1382 | - /** |
|
1383 | - * Returns a Crypto instance |
|
1384 | - * |
|
1385 | - * @return \OCP\Security\ICrypto |
|
1386 | - */ |
|
1387 | - public function getCrypto() { |
|
1388 | - return $this->query('Crypto'); |
|
1389 | - } |
|
1390 | - |
|
1391 | - /** |
|
1392 | - * Returns a Hasher instance |
|
1393 | - * |
|
1394 | - * @return \OCP\Security\IHasher |
|
1395 | - */ |
|
1396 | - public function getHasher() { |
|
1397 | - return $this->query('Hasher'); |
|
1398 | - } |
|
1399 | - |
|
1400 | - /** |
|
1401 | - * Returns a CredentialsManager instance |
|
1402 | - * |
|
1403 | - * @return \OCP\Security\ICredentialsManager |
|
1404 | - */ |
|
1405 | - public function getCredentialsManager() { |
|
1406 | - return $this->query('CredentialsManager'); |
|
1407 | - } |
|
1408 | - |
|
1409 | - /** |
|
1410 | - * Returns an instance of the HTTP helper class |
|
1411 | - * |
|
1412 | - * @deprecated Use getHTTPClientService() |
|
1413 | - * @return \OC\HTTPHelper |
|
1414 | - */ |
|
1415 | - public function getHTTPHelper() { |
|
1416 | - return $this->query('HTTPHelper'); |
|
1417 | - } |
|
1418 | - |
|
1419 | - /** |
|
1420 | - * Get the certificate manager for the user |
|
1421 | - * |
|
1422 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1423 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1424 | - */ |
|
1425 | - public function getCertificateManager($userId = '') { |
|
1426 | - if ($userId === '') { |
|
1427 | - $userSession = $this->getUserSession(); |
|
1428 | - $user = $userSession->getUser(); |
|
1429 | - if (is_null($user)) { |
|
1430 | - return null; |
|
1431 | - } |
|
1432 | - $userId = $user->getUID(); |
|
1433 | - } |
|
1434 | - return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1435 | - } |
|
1436 | - |
|
1437 | - /** |
|
1438 | - * Returns an instance of the HTTP client service |
|
1439 | - * |
|
1440 | - * @return \OCP\Http\Client\IClientService |
|
1441 | - */ |
|
1442 | - public function getHTTPClientService() { |
|
1443 | - return $this->query('HttpClientService'); |
|
1444 | - } |
|
1445 | - |
|
1446 | - /** |
|
1447 | - * Create a new event source |
|
1448 | - * |
|
1449 | - * @return \OCP\IEventSource |
|
1450 | - */ |
|
1451 | - public function createEventSource() { |
|
1452 | - return new \OC_EventSource(); |
|
1453 | - } |
|
1454 | - |
|
1455 | - /** |
|
1456 | - * Get the active event logger |
|
1457 | - * |
|
1458 | - * The returned logger only logs data when debug mode is enabled |
|
1459 | - * |
|
1460 | - * @return \OCP\Diagnostics\IEventLogger |
|
1461 | - */ |
|
1462 | - public function getEventLogger() { |
|
1463 | - return $this->query('EventLogger'); |
|
1464 | - } |
|
1465 | - |
|
1466 | - /** |
|
1467 | - * Get the active query logger |
|
1468 | - * |
|
1469 | - * The returned logger only logs data when debug mode is enabled |
|
1470 | - * |
|
1471 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1472 | - */ |
|
1473 | - public function getQueryLogger() { |
|
1474 | - return $this->query('QueryLogger'); |
|
1475 | - } |
|
1476 | - |
|
1477 | - /** |
|
1478 | - * Get the manager for temporary files and folders |
|
1479 | - * |
|
1480 | - * @return \OCP\ITempManager |
|
1481 | - */ |
|
1482 | - public function getTempManager() { |
|
1483 | - return $this->query('TempManager'); |
|
1484 | - } |
|
1485 | - |
|
1486 | - /** |
|
1487 | - * Get the app manager |
|
1488 | - * |
|
1489 | - * @return \OCP\App\IAppManager |
|
1490 | - */ |
|
1491 | - public function getAppManager() { |
|
1492 | - return $this->query('AppManager'); |
|
1493 | - } |
|
1494 | - |
|
1495 | - /** |
|
1496 | - * Creates a new mailer |
|
1497 | - * |
|
1498 | - * @return \OCP\Mail\IMailer |
|
1499 | - */ |
|
1500 | - public function getMailer() { |
|
1501 | - return $this->query('Mailer'); |
|
1502 | - } |
|
1503 | - |
|
1504 | - /** |
|
1505 | - * Get the webroot |
|
1506 | - * |
|
1507 | - * @return string |
|
1508 | - */ |
|
1509 | - public function getWebRoot() { |
|
1510 | - return $this->webRoot; |
|
1511 | - } |
|
1512 | - |
|
1513 | - /** |
|
1514 | - * @return \OC\OCSClient |
|
1515 | - */ |
|
1516 | - public function getOcsClient() { |
|
1517 | - return $this->query('OcsClient'); |
|
1518 | - } |
|
1519 | - |
|
1520 | - /** |
|
1521 | - * @return \OCP\IDateTimeZone |
|
1522 | - */ |
|
1523 | - public function getDateTimeZone() { |
|
1524 | - return $this->query('DateTimeZone'); |
|
1525 | - } |
|
1526 | - |
|
1527 | - /** |
|
1528 | - * @return \OCP\IDateTimeFormatter |
|
1529 | - */ |
|
1530 | - public function getDateTimeFormatter() { |
|
1531 | - return $this->query('DateTimeFormatter'); |
|
1532 | - } |
|
1533 | - |
|
1534 | - /** |
|
1535 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1536 | - */ |
|
1537 | - public function getMountProviderCollection() { |
|
1538 | - return $this->query('MountConfigManager'); |
|
1539 | - } |
|
1540 | - |
|
1541 | - /** |
|
1542 | - * Get the IniWrapper |
|
1543 | - * |
|
1544 | - * @return IniGetWrapper |
|
1545 | - */ |
|
1546 | - public function getIniWrapper() { |
|
1547 | - return $this->query('IniWrapper'); |
|
1548 | - } |
|
1549 | - |
|
1550 | - /** |
|
1551 | - * @return \OCP\Command\IBus |
|
1552 | - */ |
|
1553 | - public function getCommandBus() { |
|
1554 | - return $this->query('AsyncCommandBus'); |
|
1555 | - } |
|
1556 | - |
|
1557 | - /** |
|
1558 | - * Get the trusted domain helper |
|
1559 | - * |
|
1560 | - * @return TrustedDomainHelper |
|
1561 | - */ |
|
1562 | - public function getTrustedDomainHelper() { |
|
1563 | - return $this->query('TrustedDomainHelper'); |
|
1564 | - } |
|
1565 | - |
|
1566 | - /** |
|
1567 | - * Get the locking provider |
|
1568 | - * |
|
1569 | - * @return \OCP\Lock\ILockingProvider |
|
1570 | - * @since 8.1.0 |
|
1571 | - */ |
|
1572 | - public function getLockingProvider() { |
|
1573 | - return $this->query('LockingProvider'); |
|
1574 | - } |
|
1575 | - |
|
1576 | - /** |
|
1577 | - * @return \OCP\Files\Mount\IMountManager |
|
1578 | - **/ |
|
1579 | - function getMountManager() { |
|
1580 | - return $this->query('MountManager'); |
|
1581 | - } |
|
1582 | - |
|
1583 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1584 | - function getUserMountCache() { |
|
1585 | - return $this->query('UserMountCache'); |
|
1586 | - } |
|
1587 | - |
|
1588 | - /** |
|
1589 | - * Get the MimeTypeDetector |
|
1590 | - * |
|
1591 | - * @return \OCP\Files\IMimeTypeDetector |
|
1592 | - */ |
|
1593 | - public function getMimeTypeDetector() { |
|
1594 | - return $this->query('MimeTypeDetector'); |
|
1595 | - } |
|
1596 | - |
|
1597 | - /** |
|
1598 | - * Get the MimeTypeLoader |
|
1599 | - * |
|
1600 | - * @return \OCP\Files\IMimeTypeLoader |
|
1601 | - */ |
|
1602 | - public function getMimeTypeLoader() { |
|
1603 | - return $this->query('MimeTypeLoader'); |
|
1604 | - } |
|
1605 | - |
|
1606 | - /** |
|
1607 | - * Get the manager of all the capabilities |
|
1608 | - * |
|
1609 | - * @return \OC\CapabilitiesManager |
|
1610 | - */ |
|
1611 | - public function getCapabilitiesManager() { |
|
1612 | - return $this->query('CapabilitiesManager'); |
|
1613 | - } |
|
1614 | - |
|
1615 | - /** |
|
1616 | - * Get the EventDispatcher |
|
1617 | - * |
|
1618 | - * @return EventDispatcherInterface |
|
1619 | - * @since 8.2.0 |
|
1620 | - */ |
|
1621 | - public function getEventDispatcher() { |
|
1622 | - return $this->query('EventDispatcher'); |
|
1623 | - } |
|
1624 | - |
|
1625 | - /** |
|
1626 | - * Get the Notification Manager |
|
1627 | - * |
|
1628 | - * @return \OCP\Notification\IManager |
|
1629 | - * @since 8.2.0 |
|
1630 | - */ |
|
1631 | - public function getNotificationManager() { |
|
1632 | - return $this->query('NotificationManager'); |
|
1633 | - } |
|
1634 | - |
|
1635 | - /** |
|
1636 | - * @return \OCP\Comments\ICommentsManager |
|
1637 | - */ |
|
1638 | - public function getCommentsManager() { |
|
1639 | - return $this->query('CommentsManager'); |
|
1640 | - } |
|
1641 | - |
|
1642 | - /** |
|
1643 | - * @return \OCA\Theming\ThemingDefaults |
|
1644 | - */ |
|
1645 | - public function getThemingDefaults() { |
|
1646 | - return $this->query('ThemingDefaults'); |
|
1647 | - } |
|
1648 | - |
|
1649 | - /** |
|
1650 | - * @return \OC\IntegrityCheck\Checker |
|
1651 | - */ |
|
1652 | - public function getIntegrityCodeChecker() { |
|
1653 | - return $this->query('IntegrityCodeChecker'); |
|
1654 | - } |
|
1655 | - |
|
1656 | - /** |
|
1657 | - * @return \OC\Session\CryptoWrapper |
|
1658 | - */ |
|
1659 | - public function getSessionCryptoWrapper() { |
|
1660 | - return $this->query('CryptoWrapper'); |
|
1661 | - } |
|
1662 | - |
|
1663 | - /** |
|
1664 | - * @return CsrfTokenManager |
|
1665 | - */ |
|
1666 | - public function getCsrfTokenManager() { |
|
1667 | - return $this->query('CsrfTokenManager'); |
|
1668 | - } |
|
1669 | - |
|
1670 | - /** |
|
1671 | - * @return Throttler |
|
1672 | - */ |
|
1673 | - public function getBruteForceThrottler() { |
|
1674 | - return $this->query('Throttler'); |
|
1675 | - } |
|
1676 | - |
|
1677 | - /** |
|
1678 | - * @return IContentSecurityPolicyManager |
|
1679 | - */ |
|
1680 | - public function getContentSecurityPolicyManager() { |
|
1681 | - return $this->query('ContentSecurityPolicyManager'); |
|
1682 | - } |
|
1683 | - |
|
1684 | - /** |
|
1685 | - * @return ContentSecurityPolicyNonceManager |
|
1686 | - */ |
|
1687 | - public function getContentSecurityPolicyNonceManager() { |
|
1688 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1689 | - } |
|
1690 | - |
|
1691 | - /** |
|
1692 | - * Not a public API as of 8.2, wait for 9.0 |
|
1693 | - * |
|
1694 | - * @return \OCA\Files_External\Service\BackendService |
|
1695 | - */ |
|
1696 | - public function getStoragesBackendService() { |
|
1697 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1698 | - } |
|
1699 | - |
|
1700 | - /** |
|
1701 | - * Not a public API as of 8.2, wait for 9.0 |
|
1702 | - * |
|
1703 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1704 | - */ |
|
1705 | - public function getGlobalStoragesService() { |
|
1706 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1707 | - } |
|
1708 | - |
|
1709 | - /** |
|
1710 | - * Not a public API as of 8.2, wait for 9.0 |
|
1711 | - * |
|
1712 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1713 | - */ |
|
1714 | - public function getUserGlobalStoragesService() { |
|
1715 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1716 | - } |
|
1717 | - |
|
1718 | - /** |
|
1719 | - * Not a public API as of 8.2, wait for 9.0 |
|
1720 | - * |
|
1721 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1722 | - */ |
|
1723 | - public function getUserStoragesService() { |
|
1724 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1725 | - } |
|
1726 | - |
|
1727 | - /** |
|
1728 | - * @return \OCP\Share\IManager |
|
1729 | - */ |
|
1730 | - public function getShareManager() { |
|
1731 | - return $this->query('ShareManager'); |
|
1732 | - } |
|
1733 | - |
|
1734 | - /** |
|
1735 | - * Returns the LDAP Provider |
|
1736 | - * |
|
1737 | - * @return \OCP\LDAP\ILDAPProvider |
|
1738 | - */ |
|
1739 | - public function getLDAPProvider() { |
|
1740 | - return $this->query('LDAPProvider'); |
|
1741 | - } |
|
1742 | - |
|
1743 | - /** |
|
1744 | - * @return \OCP\Settings\IManager |
|
1745 | - */ |
|
1746 | - public function getSettingsManager() { |
|
1747 | - return $this->query('SettingsManager'); |
|
1748 | - } |
|
1749 | - |
|
1750 | - /** |
|
1751 | - * @return \OCP\Files\IAppData |
|
1752 | - */ |
|
1753 | - public function getAppDataDir($app) { |
|
1754 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1755 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1756 | - return $factory->get($app); |
|
1757 | - } |
|
1758 | - |
|
1759 | - /** |
|
1760 | - * @return \OCP\Lockdown\ILockdownManager |
|
1761 | - */ |
|
1762 | - public function getLockdownManager() { |
|
1763 | - return $this->query('LockdownManager'); |
|
1764 | - } |
|
1765 | - |
|
1766 | - /** |
|
1767 | - * @return \OCP\Federation\ICloudIdManager |
|
1768 | - */ |
|
1769 | - public function getCloudIdManager() { |
|
1770 | - return $this->query(ICloudIdManager::class); |
|
1771 | - } |
|
847 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
848 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
849 | + $classExists = true; |
|
850 | + } else { |
|
851 | + $classExists = false; |
|
852 | + } |
|
853 | + |
|
854 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
855 | + return new ThemingDefaults( |
|
856 | + $c->getConfig(), |
|
857 | + $c->getL10N('theming'), |
|
858 | + $c->getURLGenerator(), |
|
859 | + $c->getAppDataDir('theming'), |
|
860 | + $c->getMemCacheFactory(), |
|
861 | + new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming')) |
|
862 | + ); |
|
863 | + } |
|
864 | + return new \OC_Defaults(); |
|
865 | + }); |
|
866 | + $this->registerService(SCSSCacher::class, function(Server $c) { |
|
867 | + /** @var Factory $cacheFactory */ |
|
868 | + $cacheFactory = $c->query(Factory::class); |
|
869 | + return new SCSSCacher( |
|
870 | + $c->getLogger(), |
|
871 | + $c->query(\OC\Files\AppData\Factory::class), |
|
872 | + $c->getURLGenerator(), |
|
873 | + $c->getConfig(), |
|
874 | + $c->getThemingDefaults(), |
|
875 | + \OC::$SERVERROOT, |
|
876 | + $cacheFactory->create('SCSS') |
|
877 | + ); |
|
878 | + }); |
|
879 | + $this->registerService(EventDispatcher::class, function () { |
|
880 | + return new EventDispatcher(); |
|
881 | + }); |
|
882 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
883 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
884 | + |
|
885 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
886 | + // FIXME: Instantiiated here due to cyclic dependency |
|
887 | + $request = new Request( |
|
888 | + [ |
|
889 | + 'get' => $_GET, |
|
890 | + 'post' => $_POST, |
|
891 | + 'files' => $_FILES, |
|
892 | + 'server' => $_SERVER, |
|
893 | + 'env' => $_ENV, |
|
894 | + 'cookies' => $_COOKIE, |
|
895 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
896 | + ? $_SERVER['REQUEST_METHOD'] |
|
897 | + : null, |
|
898 | + ], |
|
899 | + $c->getSecureRandom(), |
|
900 | + $c->getConfig() |
|
901 | + ); |
|
902 | + |
|
903 | + return new CryptoWrapper( |
|
904 | + $c->getConfig(), |
|
905 | + $c->getCrypto(), |
|
906 | + $c->getSecureRandom(), |
|
907 | + $request |
|
908 | + ); |
|
909 | + }); |
|
910 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
911 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
912 | + |
|
913 | + return new CsrfTokenManager( |
|
914 | + $tokenGenerator, |
|
915 | + $c->query(SessionStorage::class) |
|
916 | + ); |
|
917 | + }); |
|
918 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
919 | + return new SessionStorage($c->getSession()); |
|
920 | + }); |
|
921 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
922 | + return new ContentSecurityPolicyManager(); |
|
923 | + }); |
|
924 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
925 | + |
|
926 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
927 | + return new ContentSecurityPolicyNonceManager( |
|
928 | + $c->getCsrfTokenManager(), |
|
929 | + $c->getRequest() |
|
930 | + ); |
|
931 | + }); |
|
932 | + |
|
933 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
934 | + $config = $c->getConfig(); |
|
935 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
936 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
937 | + $factory = new $factoryClass($this); |
|
938 | + |
|
939 | + $manager = new \OC\Share20\Manager( |
|
940 | + $c->getLogger(), |
|
941 | + $c->getConfig(), |
|
942 | + $c->getSecureRandom(), |
|
943 | + $c->getHasher(), |
|
944 | + $c->getMountManager(), |
|
945 | + $c->getGroupManager(), |
|
946 | + $c->getL10N('core'), |
|
947 | + $factory, |
|
948 | + $c->getUserManager(), |
|
949 | + $c->getLazyRootFolder(), |
|
950 | + $c->getEventDispatcher() |
|
951 | + ); |
|
952 | + |
|
953 | + return $manager; |
|
954 | + }); |
|
955 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
956 | + |
|
957 | + $this->registerService('SettingsManager', function(Server $c) { |
|
958 | + $manager = new \OC\Settings\Manager( |
|
959 | + $c->getLogger(), |
|
960 | + $c->getDatabaseConnection(), |
|
961 | + $c->getL10N('lib'), |
|
962 | + $c->getConfig(), |
|
963 | + $c->getEncryptionManager(), |
|
964 | + $c->getUserManager(), |
|
965 | + $c->getLockingProvider(), |
|
966 | + $c->getRequest(), |
|
967 | + new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
968 | + $c->getURLGenerator(), |
|
969 | + $c->query(AccountManager::class), |
|
970 | + $c->getGroupManager(), |
|
971 | + $c->getL10NFactory(), |
|
972 | + $c->getThemingDefaults() |
|
973 | + ); |
|
974 | + return $manager; |
|
975 | + }); |
|
976 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
977 | + return new \OC\Files\AppData\Factory( |
|
978 | + $c->getRootFolder(), |
|
979 | + $c->getSystemConfig() |
|
980 | + ); |
|
981 | + }); |
|
982 | + |
|
983 | + $this->registerService('LockdownManager', function (Server $c) { |
|
984 | + return new LockdownManager(function() use ($c) { |
|
985 | + return $c->getSession(); |
|
986 | + }); |
|
987 | + }); |
|
988 | + |
|
989 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
990 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
991 | + }); |
|
992 | + |
|
993 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
994 | + return new CloudIdManager(); |
|
995 | + }); |
|
996 | + |
|
997 | + /* To trick DI since we don't extend the DIContainer here */ |
|
998 | + $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
999 | + return new CleanPreviewsBackgroundJob( |
|
1000 | + $c->getRootFolder(), |
|
1001 | + $c->getLogger(), |
|
1002 | + $c->getJobList(), |
|
1003 | + new TimeFactory() |
|
1004 | + ); |
|
1005 | + }); |
|
1006 | + |
|
1007 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1008 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1009 | + |
|
1010 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1011 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1012 | + |
|
1013 | + $this->registerService(Defaults::class, function (Server $c) { |
|
1014 | + return new Defaults( |
|
1015 | + $c->getThemingDefaults() |
|
1016 | + ); |
|
1017 | + }); |
|
1018 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1019 | + |
|
1020 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
1021 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1022 | + }); |
|
1023 | + |
|
1024 | + $this->registerService(IShareHelper::class, function(Server $c) { |
|
1025 | + return new ShareHelper( |
|
1026 | + $c->query(\OCP\Share\IManager::class) |
|
1027 | + ); |
|
1028 | + }); |
|
1029 | + } |
|
1030 | + |
|
1031 | + /** |
|
1032 | + * @return \OCP\Contacts\IManager |
|
1033 | + */ |
|
1034 | + public function getContactsManager() { |
|
1035 | + return $this->query('ContactsManager'); |
|
1036 | + } |
|
1037 | + |
|
1038 | + /** |
|
1039 | + * @return \OC\Encryption\Manager |
|
1040 | + */ |
|
1041 | + public function getEncryptionManager() { |
|
1042 | + return $this->query('EncryptionManager'); |
|
1043 | + } |
|
1044 | + |
|
1045 | + /** |
|
1046 | + * @return \OC\Encryption\File |
|
1047 | + */ |
|
1048 | + public function getEncryptionFilesHelper() { |
|
1049 | + return $this->query('EncryptionFileHelper'); |
|
1050 | + } |
|
1051 | + |
|
1052 | + /** |
|
1053 | + * @return \OCP\Encryption\Keys\IStorage |
|
1054 | + */ |
|
1055 | + public function getEncryptionKeyStorage() { |
|
1056 | + return $this->query('EncryptionKeyStorage'); |
|
1057 | + } |
|
1058 | + |
|
1059 | + /** |
|
1060 | + * The current request object holding all information about the request |
|
1061 | + * currently being processed is returned from this method. |
|
1062 | + * In case the current execution was not initiated by a web request null is returned |
|
1063 | + * |
|
1064 | + * @return \OCP\IRequest |
|
1065 | + */ |
|
1066 | + public function getRequest() { |
|
1067 | + return $this->query('Request'); |
|
1068 | + } |
|
1069 | + |
|
1070 | + /** |
|
1071 | + * Returns the preview manager which can create preview images for a given file |
|
1072 | + * |
|
1073 | + * @return \OCP\IPreview |
|
1074 | + */ |
|
1075 | + public function getPreviewManager() { |
|
1076 | + return $this->query('PreviewManager'); |
|
1077 | + } |
|
1078 | + |
|
1079 | + /** |
|
1080 | + * Returns the tag manager which can get and set tags for different object types |
|
1081 | + * |
|
1082 | + * @see \OCP\ITagManager::load() |
|
1083 | + * @return \OCP\ITagManager |
|
1084 | + */ |
|
1085 | + public function getTagManager() { |
|
1086 | + return $this->query('TagManager'); |
|
1087 | + } |
|
1088 | + |
|
1089 | + /** |
|
1090 | + * Returns the system-tag manager |
|
1091 | + * |
|
1092 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1093 | + * |
|
1094 | + * @since 9.0.0 |
|
1095 | + */ |
|
1096 | + public function getSystemTagManager() { |
|
1097 | + return $this->query('SystemTagManager'); |
|
1098 | + } |
|
1099 | + |
|
1100 | + /** |
|
1101 | + * Returns the system-tag object mapper |
|
1102 | + * |
|
1103 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1104 | + * |
|
1105 | + * @since 9.0.0 |
|
1106 | + */ |
|
1107 | + public function getSystemTagObjectMapper() { |
|
1108 | + return $this->query('SystemTagObjectMapper'); |
|
1109 | + } |
|
1110 | + |
|
1111 | + /** |
|
1112 | + * Returns the avatar manager, used for avatar functionality |
|
1113 | + * |
|
1114 | + * @return \OCP\IAvatarManager |
|
1115 | + */ |
|
1116 | + public function getAvatarManager() { |
|
1117 | + return $this->query('AvatarManager'); |
|
1118 | + } |
|
1119 | + |
|
1120 | + /** |
|
1121 | + * Returns the root folder of ownCloud's data directory |
|
1122 | + * |
|
1123 | + * @return \OCP\Files\IRootFolder |
|
1124 | + */ |
|
1125 | + public function getRootFolder() { |
|
1126 | + return $this->query('LazyRootFolder'); |
|
1127 | + } |
|
1128 | + |
|
1129 | + /** |
|
1130 | + * Returns the root folder of ownCloud's data directory |
|
1131 | + * This is the lazy variant so this gets only initialized once it |
|
1132 | + * is actually used. |
|
1133 | + * |
|
1134 | + * @return \OCP\Files\IRootFolder |
|
1135 | + */ |
|
1136 | + public function getLazyRootFolder() { |
|
1137 | + return $this->query('LazyRootFolder'); |
|
1138 | + } |
|
1139 | + |
|
1140 | + /** |
|
1141 | + * Returns a view to ownCloud's files folder |
|
1142 | + * |
|
1143 | + * @param string $userId user ID |
|
1144 | + * @return \OCP\Files\Folder|null |
|
1145 | + */ |
|
1146 | + public function getUserFolder($userId = null) { |
|
1147 | + if ($userId === null) { |
|
1148 | + $user = $this->getUserSession()->getUser(); |
|
1149 | + if (!$user) { |
|
1150 | + return null; |
|
1151 | + } |
|
1152 | + $userId = $user->getUID(); |
|
1153 | + } |
|
1154 | + $root = $this->getRootFolder(); |
|
1155 | + return $root->getUserFolder($userId); |
|
1156 | + } |
|
1157 | + |
|
1158 | + /** |
|
1159 | + * Returns an app-specific view in ownClouds data directory |
|
1160 | + * |
|
1161 | + * @return \OCP\Files\Folder |
|
1162 | + * @deprecated since 9.2.0 use IAppData |
|
1163 | + */ |
|
1164 | + public function getAppFolder() { |
|
1165 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1166 | + $root = $this->getRootFolder(); |
|
1167 | + if (!$root->nodeExists($dir)) { |
|
1168 | + $folder = $root->newFolder($dir); |
|
1169 | + } else { |
|
1170 | + $folder = $root->get($dir); |
|
1171 | + } |
|
1172 | + return $folder; |
|
1173 | + } |
|
1174 | + |
|
1175 | + /** |
|
1176 | + * @return \OC\User\Manager |
|
1177 | + */ |
|
1178 | + public function getUserManager() { |
|
1179 | + return $this->query('UserManager'); |
|
1180 | + } |
|
1181 | + |
|
1182 | + /** |
|
1183 | + * @return \OC\Group\Manager |
|
1184 | + */ |
|
1185 | + public function getGroupManager() { |
|
1186 | + return $this->query('GroupManager'); |
|
1187 | + } |
|
1188 | + |
|
1189 | + /** |
|
1190 | + * @return \OC\User\Session |
|
1191 | + */ |
|
1192 | + public function getUserSession() { |
|
1193 | + return $this->query('UserSession'); |
|
1194 | + } |
|
1195 | + |
|
1196 | + /** |
|
1197 | + * @return \OCP\ISession |
|
1198 | + */ |
|
1199 | + public function getSession() { |
|
1200 | + return $this->query('UserSession')->getSession(); |
|
1201 | + } |
|
1202 | + |
|
1203 | + /** |
|
1204 | + * @param \OCP\ISession $session |
|
1205 | + */ |
|
1206 | + public function setSession(\OCP\ISession $session) { |
|
1207 | + $this->query(SessionStorage::class)->setSession($session); |
|
1208 | + $this->query('UserSession')->setSession($session); |
|
1209 | + $this->query(Store::class)->setSession($session); |
|
1210 | + } |
|
1211 | + |
|
1212 | + /** |
|
1213 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1214 | + */ |
|
1215 | + public function getTwoFactorAuthManager() { |
|
1216 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1217 | + } |
|
1218 | + |
|
1219 | + /** |
|
1220 | + * @return \OC\NavigationManager |
|
1221 | + */ |
|
1222 | + public function getNavigationManager() { |
|
1223 | + return $this->query('NavigationManager'); |
|
1224 | + } |
|
1225 | + |
|
1226 | + /** |
|
1227 | + * @return \OCP\IConfig |
|
1228 | + */ |
|
1229 | + public function getConfig() { |
|
1230 | + return $this->query('AllConfig'); |
|
1231 | + } |
|
1232 | + |
|
1233 | + /** |
|
1234 | + * @internal For internal use only |
|
1235 | + * @return \OC\SystemConfig |
|
1236 | + */ |
|
1237 | + public function getSystemConfig() { |
|
1238 | + return $this->query('SystemConfig'); |
|
1239 | + } |
|
1240 | + |
|
1241 | + /** |
|
1242 | + * Returns the app config manager |
|
1243 | + * |
|
1244 | + * @return \OCP\IAppConfig |
|
1245 | + */ |
|
1246 | + public function getAppConfig() { |
|
1247 | + return $this->query('AppConfig'); |
|
1248 | + } |
|
1249 | + |
|
1250 | + /** |
|
1251 | + * @return \OCP\L10N\IFactory |
|
1252 | + */ |
|
1253 | + public function getL10NFactory() { |
|
1254 | + return $this->query('L10NFactory'); |
|
1255 | + } |
|
1256 | + |
|
1257 | + /** |
|
1258 | + * get an L10N instance |
|
1259 | + * |
|
1260 | + * @param string $app appid |
|
1261 | + * @param string $lang |
|
1262 | + * @return IL10N |
|
1263 | + */ |
|
1264 | + public function getL10N($app, $lang = null) { |
|
1265 | + return $this->getL10NFactory()->get($app, $lang); |
|
1266 | + } |
|
1267 | + |
|
1268 | + /** |
|
1269 | + * @return \OCP\IURLGenerator |
|
1270 | + */ |
|
1271 | + public function getURLGenerator() { |
|
1272 | + return $this->query('URLGenerator'); |
|
1273 | + } |
|
1274 | + |
|
1275 | + /** |
|
1276 | + * @return \OCP\IHelper |
|
1277 | + */ |
|
1278 | + public function getHelper() { |
|
1279 | + return $this->query('AppHelper'); |
|
1280 | + } |
|
1281 | + |
|
1282 | + /** |
|
1283 | + * @return AppFetcher |
|
1284 | + */ |
|
1285 | + public function getAppFetcher() { |
|
1286 | + return $this->query(AppFetcher::class); |
|
1287 | + } |
|
1288 | + |
|
1289 | + /** |
|
1290 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1291 | + * getMemCacheFactory() instead. |
|
1292 | + * |
|
1293 | + * @return \OCP\ICache |
|
1294 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1295 | + */ |
|
1296 | + public function getCache() { |
|
1297 | + return $this->query('UserCache'); |
|
1298 | + } |
|
1299 | + |
|
1300 | + /** |
|
1301 | + * Returns an \OCP\CacheFactory instance |
|
1302 | + * |
|
1303 | + * @return \OCP\ICacheFactory |
|
1304 | + */ |
|
1305 | + public function getMemCacheFactory() { |
|
1306 | + return $this->query('MemCacheFactory'); |
|
1307 | + } |
|
1308 | + |
|
1309 | + /** |
|
1310 | + * Returns an \OC\RedisFactory instance |
|
1311 | + * |
|
1312 | + * @return \OC\RedisFactory |
|
1313 | + */ |
|
1314 | + public function getGetRedisFactory() { |
|
1315 | + return $this->query('RedisFactory'); |
|
1316 | + } |
|
1317 | + |
|
1318 | + |
|
1319 | + /** |
|
1320 | + * Returns the current session |
|
1321 | + * |
|
1322 | + * @return \OCP\IDBConnection |
|
1323 | + */ |
|
1324 | + public function getDatabaseConnection() { |
|
1325 | + return $this->query('DatabaseConnection'); |
|
1326 | + } |
|
1327 | + |
|
1328 | + /** |
|
1329 | + * Returns the activity manager |
|
1330 | + * |
|
1331 | + * @return \OCP\Activity\IManager |
|
1332 | + */ |
|
1333 | + public function getActivityManager() { |
|
1334 | + return $this->query('ActivityManager'); |
|
1335 | + } |
|
1336 | + |
|
1337 | + /** |
|
1338 | + * Returns an job list for controlling background jobs |
|
1339 | + * |
|
1340 | + * @return \OCP\BackgroundJob\IJobList |
|
1341 | + */ |
|
1342 | + public function getJobList() { |
|
1343 | + return $this->query('JobList'); |
|
1344 | + } |
|
1345 | + |
|
1346 | + /** |
|
1347 | + * Returns a logger instance |
|
1348 | + * |
|
1349 | + * @return \OCP\ILogger |
|
1350 | + */ |
|
1351 | + public function getLogger() { |
|
1352 | + return $this->query('Logger'); |
|
1353 | + } |
|
1354 | + |
|
1355 | + /** |
|
1356 | + * Returns a router for generating and matching urls |
|
1357 | + * |
|
1358 | + * @return \OCP\Route\IRouter |
|
1359 | + */ |
|
1360 | + public function getRouter() { |
|
1361 | + return $this->query('Router'); |
|
1362 | + } |
|
1363 | + |
|
1364 | + /** |
|
1365 | + * Returns a search instance |
|
1366 | + * |
|
1367 | + * @return \OCP\ISearch |
|
1368 | + */ |
|
1369 | + public function getSearch() { |
|
1370 | + return $this->query('Search'); |
|
1371 | + } |
|
1372 | + |
|
1373 | + /** |
|
1374 | + * Returns a SecureRandom instance |
|
1375 | + * |
|
1376 | + * @return \OCP\Security\ISecureRandom |
|
1377 | + */ |
|
1378 | + public function getSecureRandom() { |
|
1379 | + return $this->query('SecureRandom'); |
|
1380 | + } |
|
1381 | + |
|
1382 | + /** |
|
1383 | + * Returns a Crypto instance |
|
1384 | + * |
|
1385 | + * @return \OCP\Security\ICrypto |
|
1386 | + */ |
|
1387 | + public function getCrypto() { |
|
1388 | + return $this->query('Crypto'); |
|
1389 | + } |
|
1390 | + |
|
1391 | + /** |
|
1392 | + * Returns a Hasher instance |
|
1393 | + * |
|
1394 | + * @return \OCP\Security\IHasher |
|
1395 | + */ |
|
1396 | + public function getHasher() { |
|
1397 | + return $this->query('Hasher'); |
|
1398 | + } |
|
1399 | + |
|
1400 | + /** |
|
1401 | + * Returns a CredentialsManager instance |
|
1402 | + * |
|
1403 | + * @return \OCP\Security\ICredentialsManager |
|
1404 | + */ |
|
1405 | + public function getCredentialsManager() { |
|
1406 | + return $this->query('CredentialsManager'); |
|
1407 | + } |
|
1408 | + |
|
1409 | + /** |
|
1410 | + * Returns an instance of the HTTP helper class |
|
1411 | + * |
|
1412 | + * @deprecated Use getHTTPClientService() |
|
1413 | + * @return \OC\HTTPHelper |
|
1414 | + */ |
|
1415 | + public function getHTTPHelper() { |
|
1416 | + return $this->query('HTTPHelper'); |
|
1417 | + } |
|
1418 | + |
|
1419 | + /** |
|
1420 | + * Get the certificate manager for the user |
|
1421 | + * |
|
1422 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1423 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1424 | + */ |
|
1425 | + public function getCertificateManager($userId = '') { |
|
1426 | + if ($userId === '') { |
|
1427 | + $userSession = $this->getUserSession(); |
|
1428 | + $user = $userSession->getUser(); |
|
1429 | + if (is_null($user)) { |
|
1430 | + return null; |
|
1431 | + } |
|
1432 | + $userId = $user->getUID(); |
|
1433 | + } |
|
1434 | + return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1435 | + } |
|
1436 | + |
|
1437 | + /** |
|
1438 | + * Returns an instance of the HTTP client service |
|
1439 | + * |
|
1440 | + * @return \OCP\Http\Client\IClientService |
|
1441 | + */ |
|
1442 | + public function getHTTPClientService() { |
|
1443 | + return $this->query('HttpClientService'); |
|
1444 | + } |
|
1445 | + |
|
1446 | + /** |
|
1447 | + * Create a new event source |
|
1448 | + * |
|
1449 | + * @return \OCP\IEventSource |
|
1450 | + */ |
|
1451 | + public function createEventSource() { |
|
1452 | + return new \OC_EventSource(); |
|
1453 | + } |
|
1454 | + |
|
1455 | + /** |
|
1456 | + * Get the active event logger |
|
1457 | + * |
|
1458 | + * The returned logger only logs data when debug mode is enabled |
|
1459 | + * |
|
1460 | + * @return \OCP\Diagnostics\IEventLogger |
|
1461 | + */ |
|
1462 | + public function getEventLogger() { |
|
1463 | + return $this->query('EventLogger'); |
|
1464 | + } |
|
1465 | + |
|
1466 | + /** |
|
1467 | + * Get the active query logger |
|
1468 | + * |
|
1469 | + * The returned logger only logs data when debug mode is enabled |
|
1470 | + * |
|
1471 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1472 | + */ |
|
1473 | + public function getQueryLogger() { |
|
1474 | + return $this->query('QueryLogger'); |
|
1475 | + } |
|
1476 | + |
|
1477 | + /** |
|
1478 | + * Get the manager for temporary files and folders |
|
1479 | + * |
|
1480 | + * @return \OCP\ITempManager |
|
1481 | + */ |
|
1482 | + public function getTempManager() { |
|
1483 | + return $this->query('TempManager'); |
|
1484 | + } |
|
1485 | + |
|
1486 | + /** |
|
1487 | + * Get the app manager |
|
1488 | + * |
|
1489 | + * @return \OCP\App\IAppManager |
|
1490 | + */ |
|
1491 | + public function getAppManager() { |
|
1492 | + return $this->query('AppManager'); |
|
1493 | + } |
|
1494 | + |
|
1495 | + /** |
|
1496 | + * Creates a new mailer |
|
1497 | + * |
|
1498 | + * @return \OCP\Mail\IMailer |
|
1499 | + */ |
|
1500 | + public function getMailer() { |
|
1501 | + return $this->query('Mailer'); |
|
1502 | + } |
|
1503 | + |
|
1504 | + /** |
|
1505 | + * Get the webroot |
|
1506 | + * |
|
1507 | + * @return string |
|
1508 | + */ |
|
1509 | + public function getWebRoot() { |
|
1510 | + return $this->webRoot; |
|
1511 | + } |
|
1512 | + |
|
1513 | + /** |
|
1514 | + * @return \OC\OCSClient |
|
1515 | + */ |
|
1516 | + public function getOcsClient() { |
|
1517 | + return $this->query('OcsClient'); |
|
1518 | + } |
|
1519 | + |
|
1520 | + /** |
|
1521 | + * @return \OCP\IDateTimeZone |
|
1522 | + */ |
|
1523 | + public function getDateTimeZone() { |
|
1524 | + return $this->query('DateTimeZone'); |
|
1525 | + } |
|
1526 | + |
|
1527 | + /** |
|
1528 | + * @return \OCP\IDateTimeFormatter |
|
1529 | + */ |
|
1530 | + public function getDateTimeFormatter() { |
|
1531 | + return $this->query('DateTimeFormatter'); |
|
1532 | + } |
|
1533 | + |
|
1534 | + /** |
|
1535 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1536 | + */ |
|
1537 | + public function getMountProviderCollection() { |
|
1538 | + return $this->query('MountConfigManager'); |
|
1539 | + } |
|
1540 | + |
|
1541 | + /** |
|
1542 | + * Get the IniWrapper |
|
1543 | + * |
|
1544 | + * @return IniGetWrapper |
|
1545 | + */ |
|
1546 | + public function getIniWrapper() { |
|
1547 | + return $this->query('IniWrapper'); |
|
1548 | + } |
|
1549 | + |
|
1550 | + /** |
|
1551 | + * @return \OCP\Command\IBus |
|
1552 | + */ |
|
1553 | + public function getCommandBus() { |
|
1554 | + return $this->query('AsyncCommandBus'); |
|
1555 | + } |
|
1556 | + |
|
1557 | + /** |
|
1558 | + * Get the trusted domain helper |
|
1559 | + * |
|
1560 | + * @return TrustedDomainHelper |
|
1561 | + */ |
|
1562 | + public function getTrustedDomainHelper() { |
|
1563 | + return $this->query('TrustedDomainHelper'); |
|
1564 | + } |
|
1565 | + |
|
1566 | + /** |
|
1567 | + * Get the locking provider |
|
1568 | + * |
|
1569 | + * @return \OCP\Lock\ILockingProvider |
|
1570 | + * @since 8.1.0 |
|
1571 | + */ |
|
1572 | + public function getLockingProvider() { |
|
1573 | + return $this->query('LockingProvider'); |
|
1574 | + } |
|
1575 | + |
|
1576 | + /** |
|
1577 | + * @return \OCP\Files\Mount\IMountManager |
|
1578 | + **/ |
|
1579 | + function getMountManager() { |
|
1580 | + return $this->query('MountManager'); |
|
1581 | + } |
|
1582 | + |
|
1583 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1584 | + function getUserMountCache() { |
|
1585 | + return $this->query('UserMountCache'); |
|
1586 | + } |
|
1587 | + |
|
1588 | + /** |
|
1589 | + * Get the MimeTypeDetector |
|
1590 | + * |
|
1591 | + * @return \OCP\Files\IMimeTypeDetector |
|
1592 | + */ |
|
1593 | + public function getMimeTypeDetector() { |
|
1594 | + return $this->query('MimeTypeDetector'); |
|
1595 | + } |
|
1596 | + |
|
1597 | + /** |
|
1598 | + * Get the MimeTypeLoader |
|
1599 | + * |
|
1600 | + * @return \OCP\Files\IMimeTypeLoader |
|
1601 | + */ |
|
1602 | + public function getMimeTypeLoader() { |
|
1603 | + return $this->query('MimeTypeLoader'); |
|
1604 | + } |
|
1605 | + |
|
1606 | + /** |
|
1607 | + * Get the manager of all the capabilities |
|
1608 | + * |
|
1609 | + * @return \OC\CapabilitiesManager |
|
1610 | + */ |
|
1611 | + public function getCapabilitiesManager() { |
|
1612 | + return $this->query('CapabilitiesManager'); |
|
1613 | + } |
|
1614 | + |
|
1615 | + /** |
|
1616 | + * Get the EventDispatcher |
|
1617 | + * |
|
1618 | + * @return EventDispatcherInterface |
|
1619 | + * @since 8.2.0 |
|
1620 | + */ |
|
1621 | + public function getEventDispatcher() { |
|
1622 | + return $this->query('EventDispatcher'); |
|
1623 | + } |
|
1624 | + |
|
1625 | + /** |
|
1626 | + * Get the Notification Manager |
|
1627 | + * |
|
1628 | + * @return \OCP\Notification\IManager |
|
1629 | + * @since 8.2.0 |
|
1630 | + */ |
|
1631 | + public function getNotificationManager() { |
|
1632 | + return $this->query('NotificationManager'); |
|
1633 | + } |
|
1634 | + |
|
1635 | + /** |
|
1636 | + * @return \OCP\Comments\ICommentsManager |
|
1637 | + */ |
|
1638 | + public function getCommentsManager() { |
|
1639 | + return $this->query('CommentsManager'); |
|
1640 | + } |
|
1641 | + |
|
1642 | + /** |
|
1643 | + * @return \OCA\Theming\ThemingDefaults |
|
1644 | + */ |
|
1645 | + public function getThemingDefaults() { |
|
1646 | + return $this->query('ThemingDefaults'); |
|
1647 | + } |
|
1648 | + |
|
1649 | + /** |
|
1650 | + * @return \OC\IntegrityCheck\Checker |
|
1651 | + */ |
|
1652 | + public function getIntegrityCodeChecker() { |
|
1653 | + return $this->query('IntegrityCodeChecker'); |
|
1654 | + } |
|
1655 | + |
|
1656 | + /** |
|
1657 | + * @return \OC\Session\CryptoWrapper |
|
1658 | + */ |
|
1659 | + public function getSessionCryptoWrapper() { |
|
1660 | + return $this->query('CryptoWrapper'); |
|
1661 | + } |
|
1662 | + |
|
1663 | + /** |
|
1664 | + * @return CsrfTokenManager |
|
1665 | + */ |
|
1666 | + public function getCsrfTokenManager() { |
|
1667 | + return $this->query('CsrfTokenManager'); |
|
1668 | + } |
|
1669 | + |
|
1670 | + /** |
|
1671 | + * @return Throttler |
|
1672 | + */ |
|
1673 | + public function getBruteForceThrottler() { |
|
1674 | + return $this->query('Throttler'); |
|
1675 | + } |
|
1676 | + |
|
1677 | + /** |
|
1678 | + * @return IContentSecurityPolicyManager |
|
1679 | + */ |
|
1680 | + public function getContentSecurityPolicyManager() { |
|
1681 | + return $this->query('ContentSecurityPolicyManager'); |
|
1682 | + } |
|
1683 | + |
|
1684 | + /** |
|
1685 | + * @return ContentSecurityPolicyNonceManager |
|
1686 | + */ |
|
1687 | + public function getContentSecurityPolicyNonceManager() { |
|
1688 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1689 | + } |
|
1690 | + |
|
1691 | + /** |
|
1692 | + * Not a public API as of 8.2, wait for 9.0 |
|
1693 | + * |
|
1694 | + * @return \OCA\Files_External\Service\BackendService |
|
1695 | + */ |
|
1696 | + public function getStoragesBackendService() { |
|
1697 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1698 | + } |
|
1699 | + |
|
1700 | + /** |
|
1701 | + * Not a public API as of 8.2, wait for 9.0 |
|
1702 | + * |
|
1703 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1704 | + */ |
|
1705 | + public function getGlobalStoragesService() { |
|
1706 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1707 | + } |
|
1708 | + |
|
1709 | + /** |
|
1710 | + * Not a public API as of 8.2, wait for 9.0 |
|
1711 | + * |
|
1712 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1713 | + */ |
|
1714 | + public function getUserGlobalStoragesService() { |
|
1715 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1716 | + } |
|
1717 | + |
|
1718 | + /** |
|
1719 | + * Not a public API as of 8.2, wait for 9.0 |
|
1720 | + * |
|
1721 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1722 | + */ |
|
1723 | + public function getUserStoragesService() { |
|
1724 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1725 | + } |
|
1726 | + |
|
1727 | + /** |
|
1728 | + * @return \OCP\Share\IManager |
|
1729 | + */ |
|
1730 | + public function getShareManager() { |
|
1731 | + return $this->query('ShareManager'); |
|
1732 | + } |
|
1733 | + |
|
1734 | + /** |
|
1735 | + * Returns the LDAP Provider |
|
1736 | + * |
|
1737 | + * @return \OCP\LDAP\ILDAPProvider |
|
1738 | + */ |
|
1739 | + public function getLDAPProvider() { |
|
1740 | + return $this->query('LDAPProvider'); |
|
1741 | + } |
|
1742 | + |
|
1743 | + /** |
|
1744 | + * @return \OCP\Settings\IManager |
|
1745 | + */ |
|
1746 | + public function getSettingsManager() { |
|
1747 | + return $this->query('SettingsManager'); |
|
1748 | + } |
|
1749 | + |
|
1750 | + /** |
|
1751 | + * @return \OCP\Files\IAppData |
|
1752 | + */ |
|
1753 | + public function getAppDataDir($app) { |
|
1754 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1755 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1756 | + return $factory->get($app); |
|
1757 | + } |
|
1758 | + |
|
1759 | + /** |
|
1760 | + * @return \OCP\Lockdown\ILockdownManager |
|
1761 | + */ |
|
1762 | + public function getLockdownManager() { |
|
1763 | + return $this->query('LockdownManager'); |
|
1764 | + } |
|
1765 | + |
|
1766 | + /** |
|
1767 | + * @return \OCP\Federation\ICloudIdManager |
|
1768 | + */ |
|
1769 | + public function getCloudIdManager() { |
|
1770 | + return $this->query(ICloudIdManager::class); |
|
1771 | + } |
|
1772 | 1772 | } |
@@ -41,241 +41,241 @@ |
||
41 | 41 | */ |
42 | 42 | |
43 | 43 | class NavigationManager implements INavigationManager { |
44 | - protected $entries = []; |
|
45 | - protected $closureEntries = []; |
|
46 | - protected $activeEntry; |
|
47 | - /** @var bool */ |
|
48 | - protected $init = false; |
|
49 | - /** @var IAppManager|AppManager */ |
|
50 | - protected $appManager; |
|
51 | - /** @var IURLGenerator */ |
|
52 | - private $urlGenerator; |
|
53 | - /** @var IFactory */ |
|
54 | - private $l10nFac; |
|
55 | - /** @var IUserSession */ |
|
56 | - private $userSession; |
|
57 | - /** @var IGroupManager|Manager */ |
|
58 | - private $groupManager; |
|
59 | - /** @var IConfig */ |
|
60 | - private $config; |
|
44 | + protected $entries = []; |
|
45 | + protected $closureEntries = []; |
|
46 | + protected $activeEntry; |
|
47 | + /** @var bool */ |
|
48 | + protected $init = false; |
|
49 | + /** @var IAppManager|AppManager */ |
|
50 | + protected $appManager; |
|
51 | + /** @var IURLGenerator */ |
|
52 | + private $urlGenerator; |
|
53 | + /** @var IFactory */ |
|
54 | + private $l10nFac; |
|
55 | + /** @var IUserSession */ |
|
56 | + private $userSession; |
|
57 | + /** @var IGroupManager|Manager */ |
|
58 | + private $groupManager; |
|
59 | + /** @var IConfig */ |
|
60 | + private $config; |
|
61 | 61 | |
62 | - public function __construct(IAppManager $appManager, |
|
63 | - IURLGenerator $urlGenerator, |
|
64 | - IFactory $l10nFac, |
|
65 | - IUserSession $userSession, |
|
66 | - IGroupManager $groupManager, |
|
67 | - IConfig $config) { |
|
68 | - $this->appManager = $appManager; |
|
69 | - $this->urlGenerator = $urlGenerator; |
|
70 | - $this->l10nFac = $l10nFac; |
|
71 | - $this->userSession = $userSession; |
|
72 | - $this->groupManager = $groupManager; |
|
73 | - $this->config = $config; |
|
74 | - } |
|
62 | + public function __construct(IAppManager $appManager, |
|
63 | + IURLGenerator $urlGenerator, |
|
64 | + IFactory $l10nFac, |
|
65 | + IUserSession $userSession, |
|
66 | + IGroupManager $groupManager, |
|
67 | + IConfig $config) { |
|
68 | + $this->appManager = $appManager; |
|
69 | + $this->urlGenerator = $urlGenerator; |
|
70 | + $this->l10nFac = $l10nFac; |
|
71 | + $this->userSession = $userSession; |
|
72 | + $this->groupManager = $groupManager; |
|
73 | + $this->config = $config; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Creates a new navigation entry |
|
78 | - * |
|
79 | - * @param array|\Closure $entry Array containing: id, name, order, icon and href key |
|
80 | - * The use of a closure is preferred, because it will avoid |
|
81 | - * loading the routing of your app, unless required. |
|
82 | - * @return void |
|
83 | - */ |
|
84 | - public function add($entry) { |
|
85 | - if ($entry instanceof \Closure) { |
|
86 | - $this->closureEntries[] = $entry; |
|
87 | - return; |
|
88 | - } |
|
76 | + /** |
|
77 | + * Creates a new navigation entry |
|
78 | + * |
|
79 | + * @param array|\Closure $entry Array containing: id, name, order, icon and href key |
|
80 | + * The use of a closure is preferred, because it will avoid |
|
81 | + * loading the routing of your app, unless required. |
|
82 | + * @return void |
|
83 | + */ |
|
84 | + public function add($entry) { |
|
85 | + if ($entry instanceof \Closure) { |
|
86 | + $this->closureEntries[] = $entry; |
|
87 | + return; |
|
88 | + } |
|
89 | 89 | |
90 | - $entry['active'] = false; |
|
91 | - if(!isset($entry['icon'])) { |
|
92 | - $entry['icon'] = ''; |
|
93 | - } |
|
94 | - if(!isset($entry['type'])) { |
|
95 | - $entry['type'] = 'link'; |
|
96 | - } |
|
97 | - $this->entries[] = $entry; |
|
98 | - } |
|
90 | + $entry['active'] = false; |
|
91 | + if(!isset($entry['icon'])) { |
|
92 | + $entry['icon'] = ''; |
|
93 | + } |
|
94 | + if(!isset($entry['type'])) { |
|
95 | + $entry['type'] = 'link'; |
|
96 | + } |
|
97 | + $this->entries[] = $entry; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * returns all the added Menu entries |
|
102 | - * @param string $type |
|
103 | - * @return array an array of the added entries |
|
104 | - */ |
|
105 | - public function getAll($type = 'link') { |
|
106 | - $this->init(); |
|
107 | - foreach ($this->closureEntries as $c) { |
|
108 | - $this->add($c()); |
|
109 | - } |
|
110 | - $this->closureEntries = array(); |
|
100 | + /** |
|
101 | + * returns all the added Menu entries |
|
102 | + * @param string $type |
|
103 | + * @return array an array of the added entries |
|
104 | + */ |
|
105 | + public function getAll($type = 'link') { |
|
106 | + $this->init(); |
|
107 | + foreach ($this->closureEntries as $c) { |
|
108 | + $this->add($c()); |
|
109 | + } |
|
110 | + $this->closureEntries = array(); |
|
111 | 111 | |
112 | - if ($type === 'all') { |
|
113 | - return $this->entries; |
|
114 | - } |
|
112 | + if ($type === 'all') { |
|
113 | + return $this->entries; |
|
114 | + } |
|
115 | 115 | |
116 | - return array_filter($this->entries, function($entry) use ($type) { |
|
117 | - return $entry['type'] === $type; |
|
118 | - }); |
|
119 | - } |
|
116 | + return array_filter($this->entries, function($entry) use ($type) { |
|
117 | + return $entry['type'] === $type; |
|
118 | + }); |
|
119 | + } |
|
120 | 120 | |
121 | - /** |
|
122 | - * removes all the entries |
|
123 | - */ |
|
124 | - public function clear($loadDefaultLinks = true) { |
|
125 | - $this->entries = []; |
|
126 | - $this->closureEntries = []; |
|
127 | - $this->init = !$loadDefaultLinks; |
|
128 | - } |
|
121 | + /** |
|
122 | + * removes all the entries |
|
123 | + */ |
|
124 | + public function clear($loadDefaultLinks = true) { |
|
125 | + $this->entries = []; |
|
126 | + $this->closureEntries = []; |
|
127 | + $this->init = !$loadDefaultLinks; |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Sets the current navigation entry of the currently running app |
|
132 | - * @param string $id of the app entry to activate (from added $entry) |
|
133 | - */ |
|
134 | - public function setActiveEntry($id) { |
|
135 | - $this->activeEntry = $id; |
|
136 | - } |
|
130 | + /** |
|
131 | + * Sets the current navigation entry of the currently running app |
|
132 | + * @param string $id of the app entry to activate (from added $entry) |
|
133 | + */ |
|
134 | + public function setActiveEntry($id) { |
|
135 | + $this->activeEntry = $id; |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * gets the active Menu entry |
|
140 | - * @return string id or empty string |
|
141 | - * |
|
142 | - * This function returns the id of the active navigation entry (set by |
|
143 | - * setActiveEntry |
|
144 | - */ |
|
145 | - public function getActiveEntry() { |
|
146 | - return $this->activeEntry; |
|
147 | - } |
|
138 | + /** |
|
139 | + * gets the active Menu entry |
|
140 | + * @return string id or empty string |
|
141 | + * |
|
142 | + * This function returns the id of the active navigation entry (set by |
|
143 | + * setActiveEntry |
|
144 | + */ |
|
145 | + public function getActiveEntry() { |
|
146 | + return $this->activeEntry; |
|
147 | + } |
|
148 | 148 | |
149 | - private function init() { |
|
150 | - if ($this->init) { |
|
151 | - return; |
|
152 | - } |
|
153 | - $this->init = true; |
|
149 | + private function init() { |
|
150 | + if ($this->init) { |
|
151 | + return; |
|
152 | + } |
|
153 | + $this->init = true; |
|
154 | 154 | |
155 | - $l = $this->l10nFac->get('lib'); |
|
156 | - if ($this->config->getSystemValue('knowledgebaseenabled', true)) { |
|
157 | - $this->add([ |
|
158 | - 'type' => 'settings', |
|
159 | - 'id' => 'help', |
|
160 | - 'order' => 5, |
|
161 | - 'href' => $this->urlGenerator->linkToRoute('settings_help'), |
|
162 | - 'name' => $l->t('Help'), |
|
163 | - 'icon' => $this->urlGenerator->imagePath('settings', 'help.svg'), |
|
164 | - ]); |
|
165 | - } |
|
155 | + $l = $this->l10nFac->get('lib'); |
|
156 | + if ($this->config->getSystemValue('knowledgebaseenabled', true)) { |
|
157 | + $this->add([ |
|
158 | + 'type' => 'settings', |
|
159 | + 'id' => 'help', |
|
160 | + 'order' => 5, |
|
161 | + 'href' => $this->urlGenerator->linkToRoute('settings_help'), |
|
162 | + 'name' => $l->t('Help'), |
|
163 | + 'icon' => $this->urlGenerator->imagePath('settings', 'help.svg'), |
|
164 | + ]); |
|
165 | + } |
|
166 | 166 | |
167 | - if ($this->userSession->isLoggedIn()) { |
|
168 | - if ($this->isAdmin()) { |
|
169 | - // App management |
|
170 | - $this->add([ |
|
171 | - 'type' => 'settings', |
|
172 | - 'id' => 'core_apps', |
|
173 | - 'order' => 3, |
|
174 | - 'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'), |
|
175 | - 'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'), |
|
176 | - 'name' => $l->t('Apps'), |
|
177 | - ]); |
|
178 | - } |
|
167 | + if ($this->userSession->isLoggedIn()) { |
|
168 | + if ($this->isAdmin()) { |
|
169 | + // App management |
|
170 | + $this->add([ |
|
171 | + 'type' => 'settings', |
|
172 | + 'id' => 'core_apps', |
|
173 | + 'order' => 3, |
|
174 | + 'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'), |
|
175 | + 'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'), |
|
176 | + 'name' => $l->t('Apps'), |
|
177 | + ]); |
|
178 | + } |
|
179 | 179 | |
180 | - // Personal and (if applicable) admin settings |
|
181 | - $this->add([ |
|
182 | - 'type' => 'settings', |
|
183 | - 'id' => 'settings', |
|
184 | - 'order' => 1, |
|
185 | - 'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'), |
|
186 | - 'name' => $l->t('Settings'), |
|
187 | - 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'), |
|
188 | - ]); |
|
180 | + // Personal and (if applicable) admin settings |
|
181 | + $this->add([ |
|
182 | + 'type' => 'settings', |
|
183 | + 'id' => 'settings', |
|
184 | + 'order' => 1, |
|
185 | + 'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'), |
|
186 | + 'name' => $l->t('Settings'), |
|
187 | + 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'), |
|
188 | + ]); |
|
189 | 189 | |
190 | - // Logout |
|
191 | - $this->add([ |
|
192 | - 'type' => 'settings', |
|
193 | - 'id' => 'logout', |
|
194 | - 'order' => 99999, |
|
195 | - 'href' => $this->urlGenerator->linkToRouteAbsolute( |
|
196 | - 'core.login.logout', |
|
197 | - ['requesttoken' => \OCP\Util::callRegister()] |
|
198 | - ), |
|
199 | - 'name' => $l->t('Log out'), |
|
200 | - 'icon' => $this->urlGenerator->imagePath('core', 'actions/logout.svg'), |
|
201 | - ]); |
|
190 | + // Logout |
|
191 | + $this->add([ |
|
192 | + 'type' => 'settings', |
|
193 | + 'id' => 'logout', |
|
194 | + 'order' => 99999, |
|
195 | + 'href' => $this->urlGenerator->linkToRouteAbsolute( |
|
196 | + 'core.login.logout', |
|
197 | + ['requesttoken' => \OCP\Util::callRegister()] |
|
198 | + ), |
|
199 | + 'name' => $l->t('Log out'), |
|
200 | + 'icon' => $this->urlGenerator->imagePath('core', 'actions/logout.svg'), |
|
201 | + ]); |
|
202 | 202 | |
203 | - if ($this->isSubadmin()) { |
|
204 | - // User management |
|
205 | - $this->add([ |
|
206 | - 'type' => 'settings', |
|
207 | - 'id' => 'core_users', |
|
208 | - 'order' => 4, |
|
209 | - 'href' => $this->urlGenerator->linkToRoute('settings_users'), |
|
210 | - 'name' => $l->t('Users'), |
|
211 | - 'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'), |
|
212 | - ]); |
|
213 | - } |
|
214 | - } |
|
203 | + if ($this->isSubadmin()) { |
|
204 | + // User management |
|
205 | + $this->add([ |
|
206 | + 'type' => 'settings', |
|
207 | + 'id' => 'core_users', |
|
208 | + 'order' => 4, |
|
209 | + 'href' => $this->urlGenerator->linkToRoute('settings_users'), |
|
210 | + 'name' => $l->t('Users'), |
|
211 | + 'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'), |
|
212 | + ]); |
|
213 | + } |
|
214 | + } |
|
215 | 215 | |
216 | - if ($this->appManager === 'null') { |
|
217 | - return; |
|
218 | - } |
|
219 | - foreach ($this->appManager->getInstalledApps() as $app) { |
|
220 | - // load plugins and collections from info.xml |
|
221 | - $info = $this->appManager->getAppInfo($app); |
|
222 | - if (empty($info['navigations'])) { |
|
223 | - continue; |
|
224 | - } |
|
225 | - foreach ($info['navigations'] as $nav) { |
|
226 | - if (!isset($nav['name'])) { |
|
227 | - continue; |
|
228 | - } |
|
229 | - if (!isset($nav['route'])) { |
|
230 | - continue; |
|
231 | - } |
|
232 | - $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all'; |
|
233 | - if ($role === 'admin' && !$this->isAdmin()) { |
|
234 | - continue; |
|
235 | - } |
|
236 | - $l = $this->l10nFac->get($app); |
|
237 | - $id = isset($nav['id']) ? $nav['id'] : $app; |
|
238 | - $order = isset($nav['order']) ? $nav['order'] : 100; |
|
239 | - $type = isset($nav['type']) ? $nav['type'] : 'link'; |
|
240 | - $route = $this->urlGenerator->linkToRoute($nav['route']); |
|
241 | - $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg'; |
|
242 | - foreach ([$icon, "$app.svg"] as $i) { |
|
243 | - try { |
|
244 | - $icon = $this->urlGenerator->imagePath($app, $i); |
|
245 | - break; |
|
246 | - } catch (\RuntimeException $ex) { |
|
247 | - // no icon? - ignore it then |
|
248 | - } |
|
249 | - } |
|
250 | - if ($icon === null) { |
|
251 | - $icon = $this->urlGenerator->imagePath('core', 'default-app-icon'); |
|
252 | - } |
|
216 | + if ($this->appManager === 'null') { |
|
217 | + return; |
|
218 | + } |
|
219 | + foreach ($this->appManager->getInstalledApps() as $app) { |
|
220 | + // load plugins and collections from info.xml |
|
221 | + $info = $this->appManager->getAppInfo($app); |
|
222 | + if (empty($info['navigations'])) { |
|
223 | + continue; |
|
224 | + } |
|
225 | + foreach ($info['navigations'] as $nav) { |
|
226 | + if (!isset($nav['name'])) { |
|
227 | + continue; |
|
228 | + } |
|
229 | + if (!isset($nav['route'])) { |
|
230 | + continue; |
|
231 | + } |
|
232 | + $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all'; |
|
233 | + if ($role === 'admin' && !$this->isAdmin()) { |
|
234 | + continue; |
|
235 | + } |
|
236 | + $l = $this->l10nFac->get($app); |
|
237 | + $id = isset($nav['id']) ? $nav['id'] : $app; |
|
238 | + $order = isset($nav['order']) ? $nav['order'] : 100; |
|
239 | + $type = isset($nav['type']) ? $nav['type'] : 'link'; |
|
240 | + $route = $this->urlGenerator->linkToRoute($nav['route']); |
|
241 | + $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg'; |
|
242 | + foreach ([$icon, "$app.svg"] as $i) { |
|
243 | + try { |
|
244 | + $icon = $this->urlGenerator->imagePath($app, $i); |
|
245 | + break; |
|
246 | + } catch (\RuntimeException $ex) { |
|
247 | + // no icon? - ignore it then |
|
248 | + } |
|
249 | + } |
|
250 | + if ($icon === null) { |
|
251 | + $icon = $this->urlGenerator->imagePath('core', 'default-app-icon'); |
|
252 | + } |
|
253 | 253 | |
254 | - $this->add([ |
|
255 | - 'id' => $id, |
|
256 | - 'order' => $order, |
|
257 | - 'href' => $route, |
|
258 | - 'icon' => $icon, |
|
259 | - 'type' => $type, |
|
260 | - 'name' => $l->t($nav['name']), |
|
261 | - ]); |
|
262 | - } |
|
263 | - } |
|
264 | - } |
|
254 | + $this->add([ |
|
255 | + 'id' => $id, |
|
256 | + 'order' => $order, |
|
257 | + 'href' => $route, |
|
258 | + 'icon' => $icon, |
|
259 | + 'type' => $type, |
|
260 | + 'name' => $l->t($nav['name']), |
|
261 | + ]); |
|
262 | + } |
|
263 | + } |
|
264 | + } |
|
265 | 265 | |
266 | - private function isAdmin() { |
|
267 | - $user = $this->userSession->getUser(); |
|
268 | - if ($user !== null) { |
|
269 | - return $this->groupManager->isAdmin($user->getUID()); |
|
270 | - } |
|
271 | - return false; |
|
272 | - } |
|
266 | + private function isAdmin() { |
|
267 | + $user = $this->userSession->getUser(); |
|
268 | + if ($user !== null) { |
|
269 | + return $this->groupManager->isAdmin($user->getUID()); |
|
270 | + } |
|
271 | + return false; |
|
272 | + } |
|
273 | 273 | |
274 | - private function isSubadmin() { |
|
275 | - $user = $this->userSession->getUser(); |
|
276 | - if ($user !== null) { |
|
277 | - return $this->groupManager->getSubAdmin()->isSubAdmin($user); |
|
278 | - } |
|
279 | - return false; |
|
280 | - } |
|
274 | + private function isSubadmin() { |
|
275 | + $user = $this->userSession->getUser(); |
|
276 | + if ($user !== null) { |
|
277 | + return $this->groupManager->getSubAdmin()->isSubAdmin($user); |
|
278 | + } |
|
279 | + return false; |
|
280 | + } |
|
281 | 281 | } |
@@ -27,99 +27,99 @@ |
||
27 | 27 | * @since 9.1 |
28 | 28 | */ |
29 | 29 | interface IManager { |
30 | - /** |
|
31 | - * @since 9.1.0 |
|
32 | - */ |
|
33 | - const KEY_ADMIN_SETTINGS = 'admin'; |
|
30 | + /** |
|
31 | + * @since 9.1.0 |
|
32 | + */ |
|
33 | + const KEY_ADMIN_SETTINGS = 'admin'; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @since 9.1.0 |
|
37 | - */ |
|
38 | - const KEY_ADMIN_SECTION = 'admin-section'; |
|
35 | + /** |
|
36 | + * @since 9.1.0 |
|
37 | + */ |
|
38 | + const KEY_ADMIN_SECTION = 'admin-section'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @since 12.0.0 |
|
42 | - */ |
|
43 | - const KEY_PERSONAL_SETTINGS = 'personal'; |
|
40 | + /** |
|
41 | + * @since 12.0.0 |
|
42 | + */ |
|
43 | + const KEY_PERSONAL_SETTINGS = 'personal'; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @since 12.0.0 |
|
47 | - */ |
|
48 | - const KEY_PERSONAL_SECTION = 'personal-section'; |
|
45 | + /** |
|
46 | + * @since 12.0.0 |
|
47 | + */ |
|
48 | + const KEY_PERSONAL_SECTION = 'personal-section'; |
|
49 | 49 | |
50 | - /** |
|
51 | - * sets up settings according to data specified by an apps info.xml, within |
|
52 | - * the <settings> element. |
|
53 | - * |
|
54 | - * @param array $settings an associative array, allowed keys are as specified |
|
55 | - * by the KEY_ constant of this interface. The value |
|
56 | - * must always be a class name, implement either |
|
57 | - * IAdmin or ISection. I.e. only one section and admin |
|
58 | - * setting can be configured per app. |
|
59 | - * @since 9.1.0 |
|
60 | - */ |
|
61 | - public function setupSettings(array $settings); |
|
50 | + /** |
|
51 | + * sets up settings according to data specified by an apps info.xml, within |
|
52 | + * the <settings> element. |
|
53 | + * |
|
54 | + * @param array $settings an associative array, allowed keys are as specified |
|
55 | + * by the KEY_ constant of this interface. The value |
|
56 | + * must always be a class name, implement either |
|
57 | + * IAdmin or ISection. I.e. only one section and admin |
|
58 | + * setting can be configured per app. |
|
59 | + * @since 9.1.0 |
|
60 | + */ |
|
61 | + public function setupSettings(array $settings); |
|
62 | 62 | |
63 | - /** |
|
64 | - * attempts to remove an apps section and/or settings entry. A listener is |
|
65 | - * added centrally making sure that this method is called ones an app was |
|
66 | - * disabled. |
|
67 | - * |
|
68 | - * What this does not help with is when applications change their settings |
|
69 | - * or section classes during their life time. New entries will be added, |
|
70 | - * but inactive ones will still reside in the database. |
|
71 | - * |
|
72 | - * @param string $appId |
|
73 | - * @since 9.1.0 |
|
74 | - */ |
|
75 | - public function onAppDisabled($appId); |
|
63 | + /** |
|
64 | + * attempts to remove an apps section and/or settings entry. A listener is |
|
65 | + * added centrally making sure that this method is called ones an app was |
|
66 | + * disabled. |
|
67 | + * |
|
68 | + * What this does not help with is when applications change their settings |
|
69 | + * or section classes during their life time. New entries will be added, |
|
70 | + * but inactive ones will still reside in the database. |
|
71 | + * |
|
72 | + * @param string $appId |
|
73 | + * @since 9.1.0 |
|
74 | + */ |
|
75 | + public function onAppDisabled($appId); |
|
76 | 76 | |
77 | - /** |
|
78 | - * The method should check all registered classes whether they are still |
|
79 | - * instantiable and remove them, if not. This method is called by a |
|
80 | - * background job once, after one or more apps were updated. |
|
81 | - * |
|
82 | - * An app`s info.xml can change during an update and make it unknown whether |
|
83 | - * a registered class name was changed or not. An old one would just stay |
|
84 | - * registered. Another case is if an admin takes a radical approach and |
|
85 | - * simply removes an app from the app folder. These unregular checks will |
|
86 | - * take care of such situations. |
|
87 | - * |
|
88 | - * @since 9.1.0 |
|
89 | - */ |
|
90 | - public function checkForOrphanedClassNames(); |
|
77 | + /** |
|
78 | + * The method should check all registered classes whether they are still |
|
79 | + * instantiable and remove them, if not. This method is called by a |
|
80 | + * background job once, after one or more apps were updated. |
|
81 | + * |
|
82 | + * An app`s info.xml can change during an update and make it unknown whether |
|
83 | + * a registered class name was changed or not. An old one would just stay |
|
84 | + * registered. Another case is if an admin takes a radical approach and |
|
85 | + * simply removes an app from the app folder. These unregular checks will |
|
86 | + * take care of such situations. |
|
87 | + * |
|
88 | + * @since 9.1.0 |
|
89 | + */ |
|
90 | + public function checkForOrphanedClassNames(); |
|
91 | 91 | |
92 | - /** |
|
93 | - * returns a list of the admin sections |
|
94 | - * |
|
95 | - * @return array array of ISection[] where key is the priority |
|
96 | - * @since 9.1.0 |
|
97 | - */ |
|
98 | - public function getAdminSections(); |
|
92 | + /** |
|
93 | + * returns a list of the admin sections |
|
94 | + * |
|
95 | + * @return array array of ISection[] where key is the priority |
|
96 | + * @since 9.1.0 |
|
97 | + */ |
|
98 | + public function getAdminSections(); |
|
99 | 99 | |
100 | - /** |
|
101 | - * returns a list of the personal sections |
|
102 | - * |
|
103 | - * @return array array of ISection[] where key is the priority |
|
104 | - * @since 12.0.0 |
|
105 | - */ |
|
106 | - public function getPersonalSections(); |
|
100 | + /** |
|
101 | + * returns a list of the personal sections |
|
102 | + * |
|
103 | + * @return array array of ISection[] where key is the priority |
|
104 | + * @since 12.0.0 |
|
105 | + */ |
|
106 | + public function getPersonalSections(); |
|
107 | 107 | |
108 | - /** |
|
109 | - * returns a list of the admin settings |
|
110 | - * |
|
111 | - * @param string $section the section id for which to load the settings |
|
112 | - * @return array array of IAdmin[] where key is the priority |
|
113 | - * @since 9.1.0 |
|
114 | - */ |
|
115 | - public function getAdminSettings($section); |
|
108 | + /** |
|
109 | + * returns a list of the admin settings |
|
110 | + * |
|
111 | + * @param string $section the section id for which to load the settings |
|
112 | + * @return array array of IAdmin[] where key is the priority |
|
113 | + * @since 9.1.0 |
|
114 | + */ |
|
115 | + public function getAdminSettings($section); |
|
116 | 116 | |
117 | - /** |
|
118 | - * returns a list of the personal settings |
|
119 | - * |
|
120 | - * @param string $section the section id for which to load the settings |
|
121 | - * @return array array of IPersonal[] where key is the priority |
|
122 | - * @since 12.0.0 |
|
123 | - */ |
|
124 | - public function getPersonalSettings($section); |
|
117 | + /** |
|
118 | + * returns a list of the personal settings |
|
119 | + * |
|
120 | + * @param string $section the section id for which to load the settings |
|
121 | + * @return array array of IPersonal[] where key is the priority |
|
122 | + * @since 12.0.0 |
|
123 | + */ |
|
124 | + public function getPersonalSettings($section); |
|
125 | 125 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @since 9.1.0 |
37 | 37 | */ |
38 | - const KEY_ADMIN_SECTION = 'admin-section'; |
|
38 | + const KEY_ADMIN_SECTION = 'admin-section'; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @since 12.0.0 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @since 12.0.0 |
47 | 47 | */ |
48 | - const KEY_PERSONAL_SECTION = 'personal-section'; |
|
48 | + const KEY_PERSONAL_SECTION = 'personal-section'; |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * sets up settings according to data specified by an apps info.xml, within |
@@ -21,10 +21,10 @@ |
||
21 | 21 | * |
22 | 22 | */ |
23 | 23 | script('settings', [ |
24 | - 'authtoken', |
|
25 | - 'authtoken_collection', |
|
26 | - 'authtoken_view', |
|
27 | - 'settings/authtoken-init' |
|
24 | + 'authtoken', |
|
25 | + 'authtoken_collection', |
|
26 | + 'authtoken_view', |
|
27 | + 'settings/authtoken-init' |
|
28 | 28 | ]); |
29 | 29 | |
30 | 30 | ?> |
@@ -30,13 +30,13 @@ |
||
30 | 30 | ?> |
31 | 31 | |
32 | 32 | <div id="apppasswords" class="section"> |
33 | - <h2><?php p($l->t('App passwords'));?></h2> |
|
34 | - <p class="settings-hint"><?php p($l->t('Here you can generate individual passwords for apps so you don’t have to give out your password. You can revoke them individually too.'));?></p> |
|
33 | + <h2><?php p($l->t('App passwords')); ?></h2> |
|
34 | + <p class="settings-hint"><?php p($l->t('Here you can generate individual passwords for apps so you don’t have to give out your password. You can revoke them individually too.')); ?></p> |
|
35 | 35 | <table class="icon-loading"> |
36 | 36 | <thead class="hidden-when-empty"> |
37 | 37 | <tr> |
38 | - <th><?php p($l->t('Name'));?></th> |
|
39 | - <th><?php p($l->t('Last activity'));?></th> |
|
38 | + <th><?php p($l->t('Name')); ?></th> |
|
39 | + <th><?php p($l->t('Last activity')); ?></th> |
|
40 | 40 | <th></th> |
41 | 41 | </tr> |
42 | 42 | </thead> |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | /** @var array $_ */ |
26 | 26 | |
27 | 27 | script('settings', [ |
28 | - 'usersettings', |
|
29 | - 'federationsettingsview', |
|
30 | - 'federationscopemenu', |
|
31 | - 'settings/personalInfo', |
|
28 | + 'usersettings', |
|
29 | + 'federationsettingsview', |
|
30 | + 'federationscopemenu', |
|
31 | + 'settings/personalInfo', |
|
32 | 32 | ]); |
33 | 33 | vendor_script('strengthify/jquery.strengthify'); |
34 | 34 | vendor_style('strengthify/strengthify'); |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | <p id="quotatext"> |
47 | 47 | <?php if ($_['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED): ?> |
48 | 48 | <?php print_unescaped($l->t('You are using <strong>%s</strong> of <strong>%s</strong>', |
49 | - [$_['usage'], $_['total_space']]));?> |
|
49 | + [$_['usage'], $_['total_space']]));?> |
|
50 | 50 | <?php else: ?> |
51 | 51 | <?php print_unescaped($l->t('You are using <strong>%s</strong> of <strong>%s</strong> (<strong>%s %%</strong>)', |
52 | - [$_['usage'], $_['total_space'], $_['usage_relative']]));?> |
|
52 | + [$_['usage'], $_['total_space'], $_['usage_relative']]));?> |
|
53 | 53 | <?php endif ?> |
54 | 54 | </p> |
55 | 55 | </div> |
@@ -118,17 +118,17 @@ discard block |
||
118 | 118 | <div class="verify <?php if ($_['email'] === '' || $_['emailScope'] !== 'public') p('hidden'); ?>"> |
119 | 119 | <img id="verify-email" title="<?php p($_['emailMessage']); ?>" data-status="<?php p($_['emailVerification']) ?>" src=" |
120 | 120 | <?php |
121 | - switch($_['emailVerification']) { |
|
122 | - case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
123 | - p(image_path('core', 'actions/verifying.svg')); |
|
124 | - break; |
|
125 | - case \OC\Accounts\AccountManager::VERIFIED: |
|
126 | - p(image_path('core', 'actions/verified.svg')); |
|
127 | - break; |
|
128 | - default: |
|
129 | - p(image_path('core', 'actions/verify.svg')); |
|
130 | - } |
|
131 | - ?>"> |
|
121 | + switch($_['emailVerification']) { |
|
122 | + case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
123 | + p(image_path('core', 'actions/verifying.svg')); |
|
124 | + break; |
|
125 | + case \OC\Accounts\AccountManager::VERIFIED: |
|
126 | + p(image_path('core', 'actions/verified.svg')); |
|
127 | + break; |
|
128 | + default: |
|
129 | + p(image_path('core', 'actions/verify.svg')); |
|
130 | + } |
|
131 | + ?>"> |
|
132 | 132 | </div> |
133 | 133 | <input type="email" name="email" id="email" value="<?php p($_['email']); ?>" |
134 | 134 | <?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
@@ -185,17 +185,17 @@ discard block |
||
185 | 185 | <div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') p('hidden'); ?>"> |
186 | 186 | <img id="verify-website" title="<?php p($_['websiteMessage']); ?>" data-status="<?php p($_['websiteVerification']) ?>" src=" |
187 | 187 | <?php |
188 | - switch($_['websiteVerification']) { |
|
189 | - case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
190 | - p(image_path('core', 'actions/verifying.svg')); |
|
191 | - break; |
|
192 | - case \OC\Accounts\AccountManager::VERIFIED: |
|
193 | - p(image_path('core', 'actions/verified.svg')); |
|
194 | - break; |
|
195 | - default: |
|
196 | - p(image_path('core', 'actions/verify.svg')); |
|
197 | - } |
|
198 | - ?>" |
|
188 | + switch($_['websiteVerification']) { |
|
189 | + case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
190 | + p(image_path('core', 'actions/verifying.svg')); |
|
191 | + break; |
|
192 | + case \OC\Accounts\AccountManager::VERIFIED: |
|
193 | + p(image_path('core', 'actions/verified.svg')); |
|
194 | + break; |
|
195 | + default: |
|
196 | + p(image_path('core', 'actions/verify.svg')); |
|
197 | + } |
|
198 | + ?>" |
|
199 | 199 | <?php if($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
200 | 200 | > |
201 | 201 | <div class="verification-dialog popovermenu bubble menu"> |
@@ -222,17 +222,17 @@ discard block |
||
222 | 222 | <div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') p('hidden'); ?>"> |
223 | 223 | <img id="verify-twitter" title="<?php p($_['twitterMessage']); ?>" data-status="<?php p($_['twitterVerification']) ?>" src=" |
224 | 224 | <?php |
225 | - switch($_['twitterVerification']) { |
|
226 | - case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
227 | - p(image_path('core', 'actions/verifying.svg')); |
|
228 | - break; |
|
229 | - case \OC\Accounts\AccountManager::VERIFIED: |
|
230 | - p(image_path('core', 'actions/verified.svg')); |
|
231 | - break; |
|
232 | - default: |
|
233 | - p(image_path('core', 'actions/verify.svg')); |
|
234 | - } |
|
235 | - ?>" |
|
225 | + switch($_['twitterVerification']) { |
|
226 | + case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
227 | + p(image_path('core', 'actions/verifying.svg')); |
|
228 | + break; |
|
229 | + case \OC\Accounts\AccountManager::VERIFIED: |
|
230 | + p(image_path('core', 'actions/verified.svg')); |
|
231 | + break; |
|
232 | + default: |
|
233 | + p(image_path('core', 'actions/verify.svg')); |
|
234 | + } |
|
235 | + ?>" |
|
236 | 236 | <?php if($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
237 | 237 | > |
238 | 238 | <div class="verification-dialog popovermenu bubble menu"> |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | |
266 | 266 | <?php |
267 | 267 | if($_['passwordChangeSupported']) { |
268 | - script('jquery-showpassword'); |
|
269 | - ?> |
|
268 | + script('jquery-showpassword'); |
|
269 | + ?> |
|
270 | 270 | <form id="passwordform" class="section"> |
271 | 271 | <h2 class="inlineblock"><?php p($l->t('Password'));?></h2> |
272 | 272 | <div id="password-error-msg" class="msg success inlineblock" style="display: none;">Saved</div> |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | ?> |
42 | 42 | |
43 | 43 | <div id="quota" class="section"> |
44 | - <div style="width:<?php p($_['usage_relative']);?>%" |
|
45 | - <?php if($_['usage_relative'] > 80): ?> class="quota-warning" <?php endif; ?>> |
|
44 | + <div style="width:<?php p($_['usage_relative']); ?>%" |
|
45 | + <?php if ($_['usage_relative'] > 80): ?> class="quota-warning" <?php endif; ?>> |
|
46 | 46 | <p id="quotatext"> |
47 | 47 | <?php if ($_['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED): ?> |
48 | 48 | <?php print_unescaped($l->t('You are using <strong>%s</strong> of <strong>%s</strong>', |
49 | - [$_['usage'], $_['total_space']]));?> |
|
49 | + [$_['usage'], $_['total_space']])); ?> |
|
50 | 50 | <?php else: ?> |
51 | 51 | <?php print_unescaped($l->t('You are using <strong>%s</strong> of <strong>%s</strong> (<strong>%s %%</strong>)', |
52 | - [$_['usage'], $_['total_space'], $_['usage_relative']]));?> |
|
52 | + [$_['usage'], $_['total_space'], $_['usage_relative']])); ?> |
|
53 | 53 | <?php endif ?> |
54 | 54 | </p> |
55 | 55 | </div> |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | </div> |
84 | 84 | </div> |
85 | 85 | <span class="icon-checkmark hidden"/> |
86 | - <?php if($_['lookupServerUploadEnabled']) { ?> |
|
86 | + <?php if ($_['lookupServerUploadEnabled']) { ?> |
|
87 | 87 | <input type="hidden" id="avatarscope" value="<?php p($_['avatarScope']) ?>"> |
88 | 88 | <?php } ?> |
89 | 89 | </form> |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | <span class="icon-password"/> |
98 | 98 | </h2> |
99 | 99 | <input type="text" id="displayname" name="displayname" |
100 | - <?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
|
100 | + <?php if (!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
|
101 | 101 | value="<?php p($_['displayName']) ?>" |
102 | 102 | autocomplete="on" autocapitalize="none" autocorrect="off" /> |
103 | - <?php if(!$_['displayNameChangeSupported']) { ?> |
|
104 | - <span><?php if(isset($_['displayName']) && !empty($_['displayName'])) { p($_['displayName']); } else { p($l->t('No display name set')); } ?></span> |
|
103 | + <?php if (!$_['displayNameChangeSupported']) { ?> |
|
104 | + <span><?php if (isset($_['displayName']) && !empty($_['displayName'])) { p($_['displayName']); } else { p($l->t('No display name set')); } ?></span> |
|
105 | 105 | <?php } ?> |
106 | 106 | <span class="icon-checkmark hidden"/> |
107 | - <?php if($_['lookupServerUploadEnabled']) { ?> |
|
107 | + <?php if ($_['lookupServerUploadEnabled']) { ?> |
|
108 | 108 | <input type="hidden" id="displaynamescope" value="<?php p($_['displayNameScope']) ?>"> |
109 | 109 | <?php } ?> |
110 | 110 | </form> |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | <label for="email"><?php p($l->t('Email')); ?></label> |
116 | 116 | <span class="icon-password"/> |
117 | 117 | </h2> |
118 | - <div class="verify <?php if ($_['email'] === '' || $_['emailScope'] !== 'public') p('hidden'); ?>"> |
|
118 | + <div class="verify <?php if ($_['email'] === '' || $_['emailScope'] !== 'public') p('hidden'); ?>"> |
|
119 | 119 | <img id="verify-email" title="<?php p($_['emailMessage']); ?>" data-status="<?php p($_['emailVerification']) ?>" src=" |
120 | 120 | <?php |
121 | - switch($_['emailVerification']) { |
|
121 | + switch ($_['emailVerification']) { |
|
122 | 122 | case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
123 | 123 | p(image_path('core', 'actions/verifying.svg')); |
124 | 124 | break; |
@@ -131,23 +131,23 @@ discard block |
||
131 | 131 | ?>"> |
132 | 132 | </div> |
133 | 133 | <input type="email" name="email" id="email" value="<?php p($_['email']); ?>" |
134 | - <?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
|
134 | + <?php if (!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
|
135 | 135 | placeholder="<?php p($l->t('Your email address')); ?>" |
136 | 136 | autocomplete="on" autocapitalize="none" autocorrect="off" /> |
137 | - <?php if(!$_['displayNameChangeSupported']) { ?> |
|
138 | - <span><?php if(isset($_['email']) && !empty($_['email'])) { p($_['email']); } else { p($l->t('No email address set')); }?></span> |
|
137 | + <?php if (!$_['displayNameChangeSupported']) { ?> |
|
138 | + <span><?php if (isset($_['email']) && !empty($_['email'])) { p($_['email']); } else { p($l->t('No email address set')); }?></span> |
|
139 | 139 | <?php } ?> |
140 | - <?php if($_['displayNameChangeSupported']) { ?> |
|
140 | + <?php if ($_['displayNameChangeSupported']) { ?> |
|
141 | 141 | <br /> |
142 | 142 | <em><?php p($l->t('For password reset and notifications')); ?></em> |
143 | 143 | <?php } ?> |
144 | 144 | <span class="icon-checkmark hidden"/> |
145 | - <?php if($_['lookupServerUploadEnabled']) { ?> |
|
145 | + <?php if ($_['lookupServerUploadEnabled']) { ?> |
|
146 | 146 | <input type="hidden" id="emailscope" value="<?php p($_['emailScope']) ?>"> |
147 | 147 | <?php } ?> |
148 | 148 | </form> |
149 | 149 | </div> |
150 | - <?php if($_['lookupServerUploadEnabled']) { ?> |
|
150 | + <?php if ($_['lookupServerUploadEnabled']) { ?> |
|
151 | 151 | <div class="personal-settings-setting-box"> |
152 | 152 | <form id="phoneform" class="section"> |
153 | 153 | <h2> |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | <label for="website"><?php p($l->t('Website')); ?></label> |
183 | 183 | <span class="icon-password"/> |
184 | 184 | </h2> |
185 | - <div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') p('hidden'); ?>"> |
|
185 | + <div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') p('hidden'); ?>"> |
|
186 | 186 | <img id="verify-website" title="<?php p($_['websiteMessage']); ?>" data-status="<?php p($_['websiteVerification']) ?>" src=" |
187 | 187 | <?php |
188 | - switch($_['websiteVerification']) { |
|
188 | + switch ($_['websiteVerification']) { |
|
189 | 189 | case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
190 | 190 | p(image_path('core', 'actions/verifying.svg')); |
191 | 191 | break; |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | p(image_path('core', 'actions/verify.svg')); |
197 | 197 | } |
198 | 198 | ?>" |
199 | - <?php if($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
|
199 | + <?php if ($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
|
200 | 200 | > |
201 | 201 | <div class="verification-dialog popovermenu bubble menu"> |
202 | 202 | <div class="verification-dialog-content"> |
203 | 203 | <p class="explainVerification"></p> |
204 | 204 | <p class="verificationCode"></p> |
205 | - <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.'));?></p> |
|
205 | + <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.')); ?></p> |
|
206 | 206 | </div> |
207 | 207 | </div> |
208 | 208 | </div> |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | <label for="twitter"><?php p($l->t('Twitter')); ?></label> |
220 | 220 | <span class="icon-password"/> |
221 | 221 | </h2> |
222 | - <div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') p('hidden'); ?>"> |
|
222 | + <div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') p('hidden'); ?>"> |
|
223 | 223 | <img id="verify-twitter" title="<?php p($_['twitterMessage']); ?>" data-status="<?php p($_['twitterVerification']) ?>" src=" |
224 | 224 | <?php |
225 | - switch($_['twitterVerification']) { |
|
225 | + switch ($_['twitterVerification']) { |
|
226 | 226 | case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
227 | 227 | p(image_path('core', 'actions/verifying.svg')); |
228 | 228 | break; |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | p(image_path('core', 'actions/verify.svg')); |
234 | 234 | } |
235 | 235 | ?>" |
236 | - <?php if($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
|
236 | + <?php if ($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
|
237 | 237 | > |
238 | 238 | <div class="verification-dialog popovermenu bubble menu"> |
239 | 239 | <div class="verification-dialog-content"> |
240 | 240 | <p class="explainVerification"></p> |
241 | 241 | <p class="verificationCode"></p> |
242 | - <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.'));?></p> |
|
242 | + <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.')); ?></p> |
|
243 | 243 | </div> |
244 | 244 | </div> |
245 | 245 | </div> |
@@ -264,19 +264,19 @@ discard block |
||
264 | 264 | </div> |
265 | 265 | |
266 | 266 | <?php |
267 | -if($_['passwordChangeSupported']) { |
|
267 | +if ($_['passwordChangeSupported']) { |
|
268 | 268 | script('jquery-showpassword'); |
269 | 269 | ?> |
270 | 270 | <form id="passwordform" class="section"> |
271 | - <h2 class="inlineblock"><?php p($l->t('Password'));?></h2> |
|
271 | + <h2 class="inlineblock"><?php p($l->t('Password')); ?></h2> |
|
272 | 272 | <div id="password-error-msg" class="msg success inlineblock" style="display: none;">Saved</div> |
273 | 273 | <br> |
274 | 274 | <label for="pass1" class="hidden-visually"><?php p($l->t('Current password')); ?>: </label> |
275 | 275 | <input type="password" id="pass1" name="oldpassword" |
276 | - placeholder="<?php p($l->t('Current password'));?>" |
|
276 | + placeholder="<?php p($l->t('Current password')); ?>" |
|
277 | 277 | autocomplete="off" autocapitalize="none" autocorrect="off" /> |
278 | 278 | <div class="personal-show-container"> |
279 | - <label for="pass2" class="hidden-visually"><?php p($l->t('New password'));?>: </label> |
|
279 | + <label for="pass2" class="hidden-visually"><?php p($l->t('New password')); ?>: </label> |
|
280 | 280 | <input type="password" id="pass2" name="newpassword" |
281 | 281 | placeholder="<?php p($l->t('New password')); ?>" |
282 | 282 | data-typetoggle="#personal-show" |
@@ -292,26 +292,26 @@ discard block |
||
292 | 292 | |
293 | 293 | <form id="language" class="section"> |
294 | 294 | <h2> |
295 | - <label for="languageinput"><?php p($l->t('Language'));?></label> |
|
295 | + <label for="languageinput"><?php p($l->t('Language')); ?></label> |
|
296 | 296 | </h2> |
297 | - <select id="languageinput" name="lang" data-placeholder="<?php p($l->t('Language'));?>"> |
|
298 | - <option value="<?php p($_['activelanguage']['code']);?>"> |
|
299 | - <?php p($_['activelanguage']['name']);?> |
|
297 | + <select id="languageinput" name="lang" data-placeholder="<?php p($l->t('Language')); ?>"> |
|
298 | + <option value="<?php p($_['activelanguage']['code']); ?>"> |
|
299 | + <?php p($_['activelanguage']['name']); ?> |
|
300 | 300 | </option> |
301 | - <?php foreach($_['commonlanguages'] as $language):?> |
|
302 | - <option value="<?php p($language['code']);?>"> |
|
303 | - <?php p($language['name']);?> |
|
301 | + <?php foreach ($_['commonlanguages'] as $language):?> |
|
302 | + <option value="<?php p($language['code']); ?>"> |
|
303 | + <?php p($language['name']); ?> |
|
304 | 304 | </option> |
305 | - <?php endforeach;?> |
|
305 | + <?php endforeach; ?> |
|
306 | 306 | <optgroup label="––––––––––"></optgroup> |
307 | - <?php foreach($_['languages'] as $language):?> |
|
308 | - <option value="<?php p($language['code']);?>"> |
|
309 | - <?php p($language['name']);?> |
|
307 | + <?php foreach ($_['languages'] as $language):?> |
|
308 | + <option value="<?php p($language['code']); ?>"> |
|
309 | + <?php p($language['name']); ?> |
|
310 | 310 | </option> |
311 | - <?php endforeach;?> |
|
311 | + <?php endforeach; ?> |
|
312 | 312 | </select> |
313 | 313 | <a href="https://www.transifex.com/nextcloud/nextcloud/" |
314 | 314 | target="_blank" rel="noreferrer"> |
315 | - <em><?php p($l->t('Help translate'));?></em> |
|
315 | + <em><?php p($l->t('Help translate')); ?></em> |
|
316 | 316 | </a> |
317 | 317 | </form> |
@@ -47,9 +47,12 @@ discard block |
||
47 | 47 | <?php if ($_['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED): ?> |
48 | 48 | <?php print_unescaped($l->t('You are using <strong>%s</strong> of <strong>%s</strong>', |
49 | 49 | [$_['usage'], $_['total_space']]));?> |
50 | - <?php else: ?> |
|
50 | + <?php else { |
|
51 | + : ?> |
|
51 | 52 | <?php print_unescaped($l->t('You are using <strong>%s</strong> of <strong>%s</strong> (<strong>%s %%</strong>)', |
52 | - [$_['usage'], $_['total_space'], $_['usage_relative']]));?> |
|
53 | + [$_['usage'], $_['total_space'], $_['usage_relative']])); |
|
54 | +} |
|
55 | +?> |
|
53 | 56 | <?php endif ?> |
54 | 57 | </p> |
55 | 58 | </div> |
@@ -71,8 +74,11 @@ discard block |
||
71 | 74 | <div class="hidden button icon-delete svg" id="removeavatar" title="<?php p($l->t('Remove image')); ?>"></div> |
72 | 75 | <input type="file" name="files[]" id="uploadavatar" class="hiddenuploadfield"> |
73 | 76 | <p><em><?php p($l->t('png or jpg, max. 20 MB')); ?></em></p> |
74 | - <?php else: ?> |
|
75 | - <?php p($l->t('Picture provided by original account')); ?> |
|
77 | + <?php else { |
|
78 | + : ?> |
|
79 | + <?php p($l->t('Picture provided by original account')); |
|
80 | +} |
|
81 | +?> |
|
76 | 82 | <?php endif; ?> |
77 | 83 | </div> |
78 | 84 | |
@@ -115,7 +121,10 @@ discard block |
||
115 | 121 | <label for="email"><?php p($l->t('Email')); ?></label> |
116 | 122 | <span class="icon-password"/> |
117 | 123 | </h2> |
118 | - <div class="verify <?php if ($_['email'] === '' || $_['emailScope'] !== 'public') p('hidden'); ?>"> |
|
124 | + <div class="verify <?php if ($_['email'] === '' || $_['emailScope'] !== 'public') { |
|
125 | + p('hidden'); |
|
126 | +} |
|
127 | +?>"> |
|
119 | 128 | <img id="verify-email" title="<?php p($_['emailMessage']); ?>" data-status="<?php p($_['emailVerification']) ?>" src=" |
120 | 129 | <?php |
121 | 130 | switch($_['emailVerification']) { |
@@ -182,7 +191,10 @@ discard block |
||
182 | 191 | <label for="website"><?php p($l->t('Website')); ?></label> |
183 | 192 | <span class="icon-password"/> |
184 | 193 | </h2> |
185 | - <div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') p('hidden'); ?>"> |
|
194 | + <div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') { |
|
195 | + p('hidden'); |
|
196 | +} |
|
197 | +?>"> |
|
186 | 198 | <img id="verify-website" title="<?php p($_['websiteMessage']); ?>" data-status="<?php p($_['websiteVerification']) ?>" src=" |
187 | 199 | <?php |
188 | 200 | switch($_['websiteVerification']) { |
@@ -196,13 +208,16 @@ discard block |
||
196 | 208 | p(image_path('core', 'actions/verify.svg')); |
197 | 209 | } |
198 | 210 | ?>" |
199 | - <?php if($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
|
211 | + <?php if($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) { |
|
212 | + print_unescaped(' class="verify-action"') ?> |
|
200 | 213 | > |
201 | 214 | <div class="verification-dialog popovermenu bubble menu"> |
202 | 215 | <div class="verification-dialog-content"> |
203 | 216 | <p class="explainVerification"></p> |
204 | 217 | <p class="verificationCode"></p> |
205 | - <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.'));?></p> |
|
218 | + <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.')); |
|
219 | +} |
|
220 | +?></p> |
|
206 | 221 | </div> |
207 | 222 | </div> |
208 | 223 | </div> |
@@ -219,7 +234,10 @@ discard block |
||
219 | 234 | <label for="twitter"><?php p($l->t('Twitter')); ?></label> |
220 | 235 | <span class="icon-password"/> |
221 | 236 | </h2> |
222 | - <div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') p('hidden'); ?>"> |
|
237 | + <div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') { |
|
238 | + p('hidden'); |
|
239 | +} |
|
240 | +?>"> |
|
223 | 241 | <img id="verify-twitter" title="<?php p($_['twitterMessage']); ?>" data-status="<?php p($_['twitterVerification']) ?>" src=" |
224 | 242 | <?php |
225 | 243 | switch($_['twitterVerification']) { |
@@ -233,13 +251,16 @@ discard block |
||
233 | 251 | p(image_path('core', 'actions/verify.svg')); |
234 | 252 | } |
235 | 253 | ?>" |
236 | - <?php if($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?> |
|
254 | + <?php if($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) { |
|
255 | + print_unescaped(' class="verify-action"') ?> |
|
237 | 256 | > |
238 | 257 | <div class="verification-dialog popovermenu bubble menu"> |
239 | 258 | <div class="verification-dialog-content"> |
240 | 259 | <p class="explainVerification"></p> |
241 | 260 | <p class="verificationCode"></p> |
242 | - <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.'));?></p> |
|
261 | + <p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.')); |
|
262 | +} |
|
263 | +?></p> |
|
243 | 264 | </div> |
244 | 265 | </div> |
245 | 266 | </div> |
@@ -22,10 +22,10 @@ |
||
22 | 22 | */ |
23 | 23 | |
24 | 24 | script('settings', [ |
25 | - 'authtoken', |
|
26 | - 'authtoken_collection', |
|
27 | - 'authtoken_view', |
|
28 | - 'settings/authtoken-init' |
|
25 | + 'authtoken', |
|
26 | + 'authtoken_collection', |
|
27 | + 'authtoken_view', |
|
28 | + 'settings/authtoken-init' |
|
29 | 29 | ]); |
30 | 30 | |
31 | 31 | ?> |
@@ -32,13 +32,13 @@ |
||
32 | 32 | |
33 | 33 | |
34 | 34 | <div id="sessions" class="section"> |
35 | - <h2><?php p($l->t('Sessions'));?></h2> |
|
36 | -<p class="settings-hint hidden-when-empty"><?php p($l->t('Web, desktop and mobile clients currently logged in to your account.'));?></p> |
|
35 | + <h2><?php p($l->t('Sessions')); ?></h2> |
|
36 | +<p class="settings-hint hidden-when-empty"><?php p($l->t('Web, desktop and mobile clients currently logged in to your account.')); ?></p> |
|
37 | 37 | <table class="icon-loading"> |
38 | 38 | <thead class="token-list-header"> |
39 | 39 | <tr> |
40 | - <th><?php p($l->t('Device'));?></th> |
|
41 | - <th><?php p($l->t('Last activity'));?></th> |
|
40 | + <th><?php p($l->t('Device')); ?></th> |
|
41 | + <th><?php p($l->t('Last activity')); ?></th> |
|
42 | 42 | <th></th> |
43 | 43 | </tr> |
44 | 44 | </thead> |
@@ -42,15 +42,15 @@ |
||
42 | 42 | |
43 | 43 | <p> |
44 | 44 | <?php print_unescaped(str_replace( |
45 | - [ |
|
46 | - '{contributeopen}', |
|
47 | - '{linkclose}', |
|
48 | - ], |
|
49 | - [ |
|
50 | - '<a href="https://nextcloud.com/contribute" target="_blank" rel="noreferrer">', |
|
51 | - '</a>', |
|
52 | - ], |
|
53 | - $l->t('If you want to support the project {contributeopen}join development{linkclose} or {contributeopen}spread the word{linkclose}!'))); ?> |
|
45 | + [ |
|
46 | + '{contributeopen}', |
|
47 | + '{linkclose}', |
|
48 | + ], |
|
49 | + [ |
|
50 | + '<a href="https://nextcloud.com/contribute" target="_blank" rel="noreferrer">', |
|
51 | + '</a>', |
|
52 | + ], |
|
53 | + $l->t('If you want to support the project {contributeopen}join development{linkclose} or {contributeopen}spread the word{linkclose}!'))); ?> |
|
54 | 54 | </p> |
55 | 55 | |
56 | 56 | <?php if(OC_APP::isEnabled('firstrunwizard')) {?> |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | ?> |
27 | 27 | |
28 | 28 | <div id="clientsbox" class="section clientsbox"> |
29 | - <h2><?php p($l->t('Get the apps to sync your files'));?></h2> |
|
29 | + <h2><?php p($l->t('Get the apps to sync your files')); ?></h2> |
|
30 | 30 | <a href="<?php p($_['clients']['desktop']); ?>" rel="noreferrer" target="_blank"> |
31 | 31 | <img src="<?php print_unescaped(image_path('core', 'desktopapp.svg')); ?>" |
32 | - alt="<?php p($l->t('Desktop client'));?>" /> |
|
32 | + alt="<?php p($l->t('Desktop client')); ?>" /> |
|
33 | 33 | </a> |
34 | 34 | <a href="<?php p($_['clients']['android']); ?>" rel="noreferrer" target="_blank"> |
35 | 35 | <img src="<?php print_unescaped(image_path('core', 'googleplay.png')); ?>" |
36 | - alt="<?php p($l->t('Android app'));?>" /> |
|
36 | + alt="<?php p($l->t('Android app')); ?>" /> |
|
37 | 37 | </a> |
38 | 38 | <a href="<?php p($_['clients']['ios']); ?>" rel="noreferrer" target="_blank"> |
39 | 39 | <img src="<?php print_unescaped(image_path('core', 'appstore.svg')); ?>" |
40 | - alt="<?php p($l->t('iOS app'));?>" /> |
|
40 | + alt="<?php p($l->t('iOS app')); ?>" /> |
|
41 | 41 | </a> |
42 | 42 | |
43 | 43 | <p> |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $l->t('If you want to support the project {contributeopen}join development{linkclose} or {contributeopen}spread the word{linkclose}!'))); ?> |
54 | 54 | </p> |
55 | 55 | |
56 | - <?php if(OC_APP::isEnabled('firstrunwizard')) {?> |
|
57 | - <p><a class="button" href="#" id="showWizard"><?php p($l->t('Show First Run Wizard again'));?></a></p> |
|
56 | + <?php if (OC_APP::isEnabled('firstrunwizard')) {?> |
|
57 | + <p><a class="button" href="#" id="showWizard"><?php p($l->t('Show First Run Wizard again')); ?></a></p> |
|
58 | 58 | <?php }?> |
59 | 59 | </div> |
@@ -29,31 +29,31 @@ |
||
29 | 29 | |
30 | 30 | class Additional implements ISettings { |
31 | 31 | |
32 | - /** |
|
33 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
34 | - * @since 9.1 |
|
35 | - */ |
|
36 | - public function getForm() { |
|
37 | - return new TemplateResponse('settings', 'settings/empty'); |
|
38 | - } |
|
32 | + /** |
|
33 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
34 | + * @since 9.1 |
|
35 | + */ |
|
36 | + public function getForm() { |
|
37 | + return new TemplateResponse('settings', 'settings/empty'); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string the section ID, e.g. 'sharing' |
|
42 | - * @since 9.1 |
|
43 | - */ |
|
44 | - public function getSection() { |
|
45 | - return 'additional'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string the section ID, e.g. 'sharing' |
|
42 | + * @since 9.1 |
|
43 | + */ |
|
44 | + public function getSection() { |
|
45 | + return 'additional'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return int whether the form should be rather on the top or bottom of |
|
50 | - * the admin section. The forms are arranged in ascending order of the |
|
51 | - * priority values. It is required to return a value between 0 and 100. |
|
52 | - * |
|
53 | - * E.g.: 70 |
|
54 | - * @since 9.1 |
|
55 | - */ |
|
56 | - public function getPriority() { |
|
57 | - return '5'; |
|
58 | - } |
|
48 | + /** |
|
49 | + * @return int whether the form should be rather on the top or bottom of |
|
50 | + * the admin section. The forms are arranged in ascending order of the |
|
51 | + * priority values. It is required to return a value between 0 and 100. |
|
52 | + * |
|
53 | + * E.g.: 70 |
|
54 | + * @since 9.1 |
|
55 | + */ |
|
56 | + public function getPriority() { |
|
57 | + return '5'; |
|
58 | + } |
|
59 | 59 | } |
@@ -31,78 +31,78 @@ |
||
31 | 31 | use OCP\Template; |
32 | 32 | |
33 | 33 | class PersonalSettingsController extends Controller { |
34 | - use CommonSettingsTrait { |
|
35 | - getSettings as private; |
|
36 | - } |
|
34 | + use CommonSettingsTrait { |
|
35 | + getSettings as private; |
|
36 | + } |
|
37 | 37 | |
38 | - /** @var INavigationManager */ |
|
39 | - private $navigationManager; |
|
38 | + /** @var INavigationManager */ |
|
39 | + private $navigationManager; |
|
40 | 40 | |
41 | - public function __construct( |
|
42 | - $appName, |
|
43 | - IRequest $request, |
|
44 | - INavigationManager $navigationManager, |
|
45 | - ISettingsManager $settingsManager |
|
46 | - ) { |
|
47 | - parent::__construct($appName, $request); |
|
48 | - $this->navigationManager = $navigationManager; |
|
49 | - $this->settingsManager = $settingsManager; |
|
50 | - } |
|
41 | + public function __construct( |
|
42 | + $appName, |
|
43 | + IRequest $request, |
|
44 | + INavigationManager $navigationManager, |
|
45 | + ISettingsManager $settingsManager |
|
46 | + ) { |
|
47 | + parent::__construct($appName, $request); |
|
48 | + $this->navigationManager = $navigationManager; |
|
49 | + $this->settingsManager = $settingsManager; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param string $section |
|
54 | - * @return TemplateResponse |
|
55 | - * |
|
56 | - * @NoCSRFRequired |
|
57 | - * @NoAdminRequired |
|
58 | - * @NoSubadminRequired |
|
59 | - */ |
|
60 | - public function index($section) { |
|
61 | - $this->navigationManager->setActiveEntry('personal'); |
|
62 | - return $this->getIndexResponse($section); |
|
63 | - } |
|
52 | + /** |
|
53 | + * @param string $section |
|
54 | + * @return TemplateResponse |
|
55 | + * |
|
56 | + * @NoCSRFRequired |
|
57 | + * @NoAdminRequired |
|
58 | + * @NoSubadminRequired |
|
59 | + */ |
|
60 | + public function index($section) { |
|
61 | + $this->navigationManager->setActiveEntry('personal'); |
|
62 | + return $this->getIndexResponse($section); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @param string $section |
|
67 | - * @return array |
|
68 | - */ |
|
69 | - private function getSettings($section) { |
|
70 | - // PhpStorm shows this as unused, but is required by CommonSettingsTrait |
|
71 | - $settings = $this->settingsManager->getPersonalSettings($section); |
|
72 | - $formatted = $this->formatSettings($settings); |
|
73 | - if($section === 'additional') { |
|
74 | - $formatted['content'] .= $this->getLegacyForms(); |
|
75 | - } |
|
76 | - return $formatted; |
|
77 | - } |
|
65 | + /** |
|
66 | + * @param string $section |
|
67 | + * @return array |
|
68 | + */ |
|
69 | + private function getSettings($section) { |
|
70 | + // PhpStorm shows this as unused, but is required by CommonSettingsTrait |
|
71 | + $settings = $this->settingsManager->getPersonalSettings($section); |
|
72 | + $formatted = $this->formatSettings($settings); |
|
73 | + if($section === 'additional') { |
|
74 | + $formatted['content'] .= $this->getLegacyForms(); |
|
75 | + } |
|
76 | + return $formatted; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @return bool|string |
|
81 | - */ |
|
82 | - private function getLegacyForms() { |
|
83 | - $forms = \OC_App::getForms('personal'); |
|
79 | + /** |
|
80 | + * @return bool|string |
|
81 | + */ |
|
82 | + private function getLegacyForms() { |
|
83 | + $forms = \OC_App::getForms('personal'); |
|
84 | 84 | |
85 | - $forms = array_map(function ($form) { |
|
86 | - if (preg_match('%(<h2(?P<class>[^>]*)>.*?</h2>)%i', $form, $regs)) { |
|
87 | - $sectionName = str_replace('<h2' . $regs['class'] . '>', '', $regs[0]); |
|
88 | - $sectionName = str_replace('</h2>', '', $sectionName); |
|
89 | - $anchor = strtolower($sectionName); |
|
90 | - $anchor = str_replace(' ', '-', $anchor); |
|
85 | + $forms = array_map(function ($form) { |
|
86 | + if (preg_match('%(<h2(?P<class>[^>]*)>.*?</h2>)%i', $form, $regs)) { |
|
87 | + $sectionName = str_replace('<h2' . $regs['class'] . '>', '', $regs[0]); |
|
88 | + $sectionName = str_replace('</h2>', '', $sectionName); |
|
89 | + $anchor = strtolower($sectionName); |
|
90 | + $anchor = str_replace(' ', '-', $anchor); |
|
91 | 91 | |
92 | - return array( |
|
93 | - 'anchor' => $anchor, |
|
94 | - 'section-name' => $sectionName, |
|
95 | - 'form' => $form |
|
96 | - ); |
|
97 | - } |
|
98 | - return array( |
|
99 | - 'form' => $form |
|
100 | - ); |
|
101 | - }, $forms); |
|
92 | + return array( |
|
93 | + 'anchor' => $anchor, |
|
94 | + 'section-name' => $sectionName, |
|
95 | + 'form' => $form |
|
96 | + ); |
|
97 | + } |
|
98 | + return array( |
|
99 | + 'form' => $form |
|
100 | + ); |
|
101 | + }, $forms); |
|
102 | 102 | |
103 | - $out = new Template('settings', 'settings/additional'); |
|
104 | - $out->assign('forms', $forms); |
|
103 | + $out = new Template('settings', 'settings/additional'); |
|
104 | + $out->assign('forms', $forms); |
|
105 | 105 | |
106 | - return $out->fetchPage(); |
|
107 | - } |
|
106 | + return $out->fetchPage(); |
|
107 | + } |
|
108 | 108 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | // PhpStorm shows this as unused, but is required by CommonSettingsTrait |
71 | 71 | $settings = $this->settingsManager->getPersonalSettings($section); |
72 | 72 | $formatted = $this->formatSettings($settings); |
73 | - if($section === 'additional') { |
|
73 | + if ($section === 'additional') { |
|
74 | 74 | $formatted['content'] .= $this->getLegacyForms(); |
75 | 75 | } |
76 | 76 | return $formatted; |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | private function getLegacyForms() { |
83 | 83 | $forms = \OC_App::getForms('personal'); |
84 | 84 | |
85 | - $forms = array_map(function ($form) { |
|
85 | + $forms = array_map(function($form) { |
|
86 | 86 | if (preg_match('%(<h2(?P<class>[^>]*)>.*?</h2>)%i', $form, $regs)) { |
87 | - $sectionName = str_replace('<h2' . $regs['class'] . '>', '', $regs[0]); |
|
87 | + $sectionName = str_replace('<h2'.$regs['class'].'>', '', $regs[0]); |
|
88 | 88 | $sectionName = str_replace('</h2>', '', $sectionName); |
89 | 89 | $anchor = strtolower($sectionName); |
90 | 90 | $anchor = str_replace(' ', '-', $anchor); |