@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
131 | 131 | $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
132 | 132 | |
133 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
133 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
134 | 134 | return new PreviewManager( |
135 | 135 | $c->getConfig(), |
136 | 136 | $c->getRootFolder(), |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | }); |
142 | 142 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
143 | 143 | |
144 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
144 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
145 | 145 | return new \OC\Preview\Watcher( |
146 | 146 | $c->getAppDataDir('preview') |
147 | 147 | ); |
148 | 148 | }); |
149 | 149 | |
150 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
150 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
151 | 151 | $view = new View(); |
152 | 152 | $util = new Encryption\Util( |
153 | 153 | $view, |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | ); |
166 | 166 | }); |
167 | 167 | |
168 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
168 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
169 | 169 | $util = new Encryption\Util( |
170 | 170 | new View(), |
171 | 171 | $c->getUserManager(), |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | return new Encryption\File($util); |
176 | 176 | }); |
177 | 177 | |
178 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
178 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
179 | 179 | $view = new View(); |
180 | 180 | $util = new Encryption\Util( |
181 | 181 | $view, |
@@ -186,32 +186,32 @@ discard block |
||
186 | 186 | |
187 | 187 | return new Encryption\Keys\Storage($view, $util); |
188 | 188 | }); |
189 | - $this->registerService('TagMapper', function (Server $c) { |
|
189 | + $this->registerService('TagMapper', function(Server $c) { |
|
190 | 190 | return new TagMapper($c->getDatabaseConnection()); |
191 | 191 | }); |
192 | 192 | |
193 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
193 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
194 | 194 | $tagMapper = $c->query('TagMapper'); |
195 | 195 | return new TagManager($tagMapper, $c->getUserSession()); |
196 | 196 | }); |
197 | 197 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
198 | 198 | |
199 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
199 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
200 | 200 | $config = $c->getConfig(); |
201 | 201 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
202 | 202 | /** @var \OC\SystemTag\ManagerFactory $factory */ |
203 | 203 | $factory = new $factoryClass($this); |
204 | 204 | return $factory; |
205 | 205 | }); |
206 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
206 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
207 | 207 | return $c->query('SystemTagManagerFactory')->getManager(); |
208 | 208 | }); |
209 | 209 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
210 | 210 | |
211 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
211 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
212 | 212 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
213 | 213 | }); |
214 | - $this->registerService('RootFolder', function (Server $c) { |
|
214 | + $this->registerService('RootFolder', function(Server $c) { |
|
215 | 215 | $manager = \OC\Files\Filesystem::getMountManager(null); |
216 | 216 | $view = new View(); |
217 | 217 | $root = new Root( |
@@ -239,30 +239,30 @@ discard block |
||
239 | 239 | }); |
240 | 240 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
241 | 241 | |
242 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
242 | + $this->registerService(\OCP\IUserManager::class, function(Server $c) { |
|
243 | 243 | $config = $c->getConfig(); |
244 | 244 | return new \OC\User\Manager($config); |
245 | 245 | }); |
246 | 246 | $this->registerAlias('UserManager', \OCP\IUserManager::class); |
247 | 247 | |
248 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
248 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
249 | 249 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
250 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
250 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
251 | 251 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
252 | 252 | }); |
253 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
253 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
254 | 254 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
255 | 255 | }); |
256 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
256 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
257 | 257 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
258 | 258 | }); |
259 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
259 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
260 | 260 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
261 | 261 | }); |
262 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
262 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
263 | 263 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
264 | 264 | }); |
265 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
265 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
266 | 266 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
267 | 267 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
268 | 268 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -282,11 +282,11 @@ discard block |
||
282 | 282 | return new Store($session, $logger, $tokenProvider); |
283 | 283 | }); |
284 | 284 | $this->registerAlias(IStore::class, Store::class); |
285 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
285 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) { |
|
286 | 286 | $dbConnection = $c->getDatabaseConnection(); |
287 | 287 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
288 | 288 | }); |
289 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
289 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) { |
|
290 | 290 | $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
291 | 291 | $crypto = $c->getCrypto(); |
292 | 292 | $config = $c->getConfig(); |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | }); |
297 | 297 | $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
298 | 298 | |
299 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
299 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
300 | 300 | $manager = $c->getUserManager(); |
301 | 301 | $session = new \OC\Session\Memory(''); |
302 | 302 | $timeFactory = new TimeFactory(); |
@@ -309,40 +309,40 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
312 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
312 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
313 | 313 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
314 | 314 | }); |
315 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
315 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
316 | 316 | /** @var $user \OC\User\User */ |
317 | 317 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
318 | 318 | }); |
319 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
319 | + $userSession->listen('\OC\User', 'preDelete', function($user) { |
|
320 | 320 | /** @var $user \OC\User\User */ |
321 | 321 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
322 | 322 | }); |
323 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
323 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
324 | 324 | /** @var $user \OC\User\User */ |
325 | 325 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
326 | 326 | }); |
327 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
327 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
328 | 328 | /** @var $user \OC\User\User */ |
329 | 329 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
330 | 330 | }); |
331 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
331 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
332 | 332 | /** @var $user \OC\User\User */ |
333 | 333 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
334 | 334 | }); |
335 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
335 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
336 | 336 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
337 | 337 | }); |
338 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
338 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
339 | 339 | /** @var $user \OC\User\User */ |
340 | 340 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
341 | 341 | }); |
342 | - $userSession->listen('\OC\User', 'logout', function () { |
|
342 | + $userSession->listen('\OC\User', 'logout', function() { |
|
343 | 343 | \OC_Hook::emit('OC_User', 'logout', array()); |
344 | 344 | }); |
345 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
345 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value) { |
|
346 | 346 | /** @var $user \OC\User\User */ |
347 | 347 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
348 | 348 | }); |
@@ -350,14 +350,14 @@ discard block |
||
350 | 350 | }); |
351 | 351 | $this->registerAlias('UserSession', \OCP\IUserSession::class); |
352 | 352 | |
353 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
353 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
354 | 354 | return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
355 | 355 | }); |
356 | 356 | |
357 | 357 | $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
358 | 358 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
359 | 359 | |
360 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
360 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
361 | 361 | return new \OC\AllConfig( |
362 | 362 | $c->getSystemConfig() |
363 | 363 | ); |
@@ -365,17 +365,17 @@ discard block |
||
365 | 365 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
366 | 366 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
367 | 367 | |
368 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
368 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
369 | 369 | return new \OC\SystemConfig($config); |
370 | 370 | }); |
371 | 371 | |
372 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
372 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
373 | 373 | return new \OC\AppConfig($c->getDatabaseConnection()); |
374 | 374 | }); |
375 | 375 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
376 | 376 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
377 | 377 | |
378 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
378 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
379 | 379 | return new \OC\L10N\Factory( |
380 | 380 | $c->getConfig(), |
381 | 381 | $c->getRequest(), |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | }); |
386 | 386 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
387 | 387 | |
388 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
388 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
389 | 389 | $config = $c->getConfig(); |
390 | 390 | $cacheFactory = $c->getMemCacheFactory(); |
391 | 391 | return new \OC\URLGenerator( |
@@ -395,10 +395,10 @@ discard block |
||
395 | 395 | }); |
396 | 396 | $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
397 | 397 | |
398 | - $this->registerService('AppHelper', function ($c) { |
|
398 | + $this->registerService('AppHelper', function($c) { |
|
399 | 399 | return new \OC\AppHelper(); |
400 | 400 | }); |
401 | - $this->registerService('AppFetcher', function ($c) { |
|
401 | + $this->registerService('AppFetcher', function($c) { |
|
402 | 402 | return new AppFetcher( |
403 | 403 | $this->getAppDataDir('appstore'), |
404 | 404 | $this->getHTTPClientService(), |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $this->getConfig() |
407 | 407 | ); |
408 | 408 | }); |
409 | - $this->registerService('CategoryFetcher', function ($c) { |
|
409 | + $this->registerService('CategoryFetcher', function($c) { |
|
410 | 410 | return new CategoryFetcher( |
411 | 411 | $this->getAppDataDir('appstore'), |
412 | 412 | $this->getHTTPClientService(), |
@@ -415,21 +415,21 @@ discard block |
||
415 | 415 | ); |
416 | 416 | }); |
417 | 417 | |
418 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
418 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
419 | 419 | return new Cache\File(); |
420 | 420 | }); |
421 | 421 | $this->registerAlias('UserCache', \OCP\ICache::class); |
422 | 422 | |
423 | - $this->registerService(Factory::class, function (Server $c) { |
|
423 | + $this->registerService(Factory::class, function(Server $c) { |
|
424 | 424 | $config = $c->getConfig(); |
425 | 425 | |
426 | 426 | if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
427 | 427 | $v = \OC_App::getAppVersions(); |
428 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
428 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT.'/version.php')); |
|
429 | 429 | $version = implode(',', $v); |
430 | 430 | $instanceId = \OC_Util::getInstanceId(); |
431 | 431 | $path = \OC::$SERVERROOT; |
432 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
432 | + $prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.\OC::$WEBROOT); |
|
433 | 433 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
434 | 434 | $config->getSystemValue('memcache.local', null), |
435 | 435 | $config->getSystemValue('memcache.distributed', null), |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | $this->registerAlias('MemCacheFactory', Factory::class); |
447 | 447 | $this->registerAlias(ICacheFactory::class, Factory::class); |
448 | 448 | |
449 | - $this->registerService('RedisFactory', function (Server $c) { |
|
449 | + $this->registerService('RedisFactory', function(Server $c) { |
|
450 | 450 | $systemConfig = $c->getSystemConfig(); |
451 | 451 | return new RedisFactory($systemConfig); |
452 | 452 | }); |
453 | 453 | |
454 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
454 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
455 | 455 | return new \OC\Activity\Manager( |
456 | 456 | $c->getRequest(), |
457 | 457 | $c->getUserSession(), |
@@ -461,14 +461,14 @@ discard block |
||
461 | 461 | }); |
462 | 462 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
463 | 463 | |
464 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
464 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
465 | 465 | return new \OC\Activity\EventMerger( |
466 | 466 | $c->getL10N('lib') |
467 | 467 | ); |
468 | 468 | }); |
469 | 469 | $this->registerAlias(IValidator::class, Validator::class); |
470 | 470 | |
471 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
471 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
472 | 472 | return new AvatarManager( |
473 | 473 | $c->getUserManager(), |
474 | 474 | $c->getAppDataDir('avatar'), |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | }); |
480 | 480 | $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
481 | 481 | |
482 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
482 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
483 | 483 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
484 | 484 | $logger = Log::getLogClass($logType); |
485 | 485 | call_user_func(array($logger, 'init')); |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | }); |
489 | 489 | $this->registerAlias('Logger', \OCP\ILogger::class); |
490 | 490 | |
491 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
491 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
492 | 492 | $config = $c->getConfig(); |
493 | 493 | return new \OC\BackgroundJob\JobList( |
494 | 494 | $c->getDatabaseConnection(), |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | }); |
499 | 499 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
500 | 500 | |
501 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
501 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
502 | 502 | $cacheFactory = $c->getMemCacheFactory(); |
503 | 503 | $logger = $c->getLogger(); |
504 | 504 | if ($cacheFactory->isAvailable()) { |
@@ -510,32 +510,32 @@ discard block |
||
510 | 510 | }); |
511 | 511 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
512 | 512 | |
513 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
513 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
514 | 514 | return new Search(); |
515 | 515 | }); |
516 | 516 | $this->registerAlias('Search', \OCP\ISearch::class); |
517 | 517 | |
518 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
518 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
519 | 519 | return new SecureRandom(); |
520 | 520 | }); |
521 | 521 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
522 | 522 | |
523 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
523 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
524 | 524 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
525 | 525 | }); |
526 | 526 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
527 | 527 | |
528 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
528 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
529 | 529 | return new Hasher($c->getConfig()); |
530 | 530 | }); |
531 | 531 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
532 | 532 | |
533 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
533 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
534 | 534 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
535 | 535 | }); |
536 | 536 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
537 | 537 | |
538 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
538 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
539 | 539 | $systemConfig = $c->getSystemConfig(); |
540 | 540 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
541 | 541 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | }); |
550 | 550 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
551 | 551 | |
552 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
552 | + $this->registerService('HTTPHelper', function(Server $c) { |
|
553 | 553 | $config = $c->getConfig(); |
554 | 554 | return new HTTPHelper( |
555 | 555 | $config, |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | ); |
558 | 558 | }); |
559 | 559 | |
560 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
560 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
561 | 561 | $user = \OC_User::getUser(); |
562 | 562 | $uid = $user ? $user : null; |
563 | 563 | return new ClientService( |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | }); |
568 | 568 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
569 | 569 | |
570 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
570 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
571 | 571 | if ($c->getSystemConfig()->getValue('debug', false)) { |
572 | 572 | return new EventLogger(); |
573 | 573 | } else { |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | }); |
577 | 577 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
578 | 578 | |
579 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
579 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
580 | 580 | if ($c->getSystemConfig()->getValue('debug', false)) { |
581 | 581 | return new QueryLogger(); |
582 | 582 | } else { |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | }); |
586 | 586 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
587 | 587 | |
588 | - $this->registerService(TempManager::class, function (Server $c) { |
|
588 | + $this->registerService(TempManager::class, function(Server $c) { |
|
589 | 589 | return new TempManager( |
590 | 590 | $c->getLogger(), |
591 | 591 | $c->getConfig() |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | $this->registerAlias('TempManager', TempManager::class); |
595 | 595 | $this->registerAlias(ITempManager::class, TempManager::class); |
596 | 596 | |
597 | - $this->registerService(AppManager::class, function (Server $c) { |
|
597 | + $this->registerService(AppManager::class, function(Server $c) { |
|
598 | 598 | return new \OC\App\AppManager( |
599 | 599 | $c->getUserSession(), |
600 | 600 | $c->getAppConfig(), |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | $this->registerAlias('AppManager', AppManager::class); |
607 | 607 | $this->registerAlias(IAppManager::class, AppManager::class); |
608 | 608 | |
609 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
609 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
610 | 610 | return new DateTimeZone( |
611 | 611 | $c->getConfig(), |
612 | 612 | $c->getSession() |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | }); |
615 | 615 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
616 | 616 | |
617 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
617 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
618 | 618 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
619 | 619 | |
620 | 620 | return new DateTimeFormatter( |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | }); |
625 | 625 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
626 | 626 | |
627 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
627 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
628 | 628 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
629 | 629 | $listener = new UserMountCacheListener($mountCache); |
630 | 630 | $listener->listen($c->getUserManager()); |
@@ -632,10 +632,10 @@ discard block |
||
632 | 632 | }); |
633 | 633 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
634 | 634 | |
635 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
635 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
636 | 636 | $loader = \OC\Files\Filesystem::getLoader(); |
637 | 637 | $mountCache = $c->query('UserMountCache'); |
638 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
638 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
639 | 639 | |
640 | 640 | // builtin providers |
641 | 641 | |
@@ -648,14 +648,14 @@ discard block |
||
648 | 648 | }); |
649 | 649 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
650 | 650 | |
651 | - $this->registerService('IniWrapper', function ($c) { |
|
651 | + $this->registerService('IniWrapper', function($c) { |
|
652 | 652 | return new IniGetWrapper(); |
653 | 653 | }); |
654 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
654 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
655 | 655 | $jobList = $c->getJobList(); |
656 | 656 | return new AsyncBus($jobList); |
657 | 657 | }); |
658 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
658 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
659 | 659 | return new TrustedDomainHelper($this->getConfig()); |
660 | 660 | }); |
661 | 661 | $this->registerService('Throttler', function(Server $c) { |
@@ -666,10 +666,10 @@ discard block |
||
666 | 666 | $c->getConfig() |
667 | 667 | ); |
668 | 668 | }); |
669 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
669 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
670 | 670 | // IConfig and IAppManager requires a working database. This code |
671 | 671 | // might however be called when ownCloud is not yet setup. |
672 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
672 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
673 | 673 | $config = $c->getConfig(); |
674 | 674 | $appManager = $c->getAppManager(); |
675 | 675 | } else { |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | $c->getTempManager() |
688 | 688 | ); |
689 | 689 | }); |
690 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
690 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
691 | 691 | if (isset($this['urlParams'])) { |
692 | 692 | $urlParams = $this['urlParams']; |
693 | 693 | } else { |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | }); |
724 | 724 | $this->registerAlias('Request', \OCP\IRequest::class); |
725 | 725 | |
726 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
726 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
727 | 727 | return new Mailer( |
728 | 728 | $c->getConfig(), |
729 | 729 | $c->getLogger(), |
@@ -735,14 +735,14 @@ discard block |
||
735 | 735 | $this->registerService('LDAPProvider', function(Server $c) { |
736 | 736 | $config = $c->getConfig(); |
737 | 737 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
738 | - if(is_null($factoryClass)) { |
|
738 | + if (is_null($factoryClass)) { |
|
739 | 739 | throw new \Exception('ldapProviderFactory not set'); |
740 | 740 | } |
741 | 741 | /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
742 | 742 | $factory = new $factoryClass($this); |
743 | 743 | return $factory->getLDAPProvider(); |
744 | 744 | }); |
745 | - $this->registerService('LockingProvider', function (Server $c) { |
|
745 | + $this->registerService('LockingProvider', function(Server $c) { |
|
746 | 746 | $ini = $c->getIniWrapper(); |
747 | 747 | $config = $c->getConfig(); |
748 | 748 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -758,37 +758,37 @@ discard block |
||
758 | 758 | return new NoopLockingProvider(); |
759 | 759 | }); |
760 | 760 | |
761 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
761 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
762 | 762 | return new \OC\Files\Mount\Manager(); |
763 | 763 | }); |
764 | 764 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
765 | 765 | |
766 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
766 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
767 | 767 | return new \OC\Files\Type\Detection( |
768 | 768 | $c->getURLGenerator(), |
769 | 769 | \OC::$configDir, |
770 | - \OC::$SERVERROOT . '/resources/config/' |
|
770 | + \OC::$SERVERROOT.'/resources/config/' |
|
771 | 771 | ); |
772 | 772 | }); |
773 | 773 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
774 | 774 | |
775 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
775 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
776 | 776 | return new \OC\Files\Type\Loader( |
777 | 777 | $c->getDatabaseConnection() |
778 | 778 | ); |
779 | 779 | }); |
780 | 780 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
781 | 781 | |
782 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
782 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
783 | 783 | return new Manager( |
784 | 784 | $c->query(IValidator::class) |
785 | 785 | ); |
786 | 786 | }); |
787 | 787 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
788 | 788 | |
789 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
789 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
790 | 790 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
791 | - $manager->registerCapability(function () use ($c) { |
|
791 | + $manager->registerCapability(function() use ($c) { |
|
792 | 792 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
793 | 793 | }); |
794 | 794 | return $manager; |
@@ -830,13 +830,13 @@ discard block |
||
830 | 830 | } |
831 | 831 | return new \OC_Defaults(); |
832 | 832 | }); |
833 | - $this->registerService(EventDispatcher::class, function () { |
|
833 | + $this->registerService(EventDispatcher::class, function() { |
|
834 | 834 | return new EventDispatcher(); |
835 | 835 | }); |
836 | 836 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
837 | 837 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
838 | 838 | |
839 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
839 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
840 | 840 | // FIXME: Instantiiated here due to cyclic dependency |
841 | 841 | $request = new Request( |
842 | 842 | [ |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | $request |
862 | 862 | ); |
863 | 863 | }); |
864 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
864 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
865 | 865 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
866 | 866 | |
867 | 867 | return new CsrfTokenManager( |
@@ -869,10 +869,10 @@ discard block |
||
869 | 869 | $c->query(SessionStorage::class) |
870 | 870 | ); |
871 | 871 | }); |
872 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
872 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
873 | 873 | return new SessionStorage($c->getSession()); |
874 | 874 | }); |
875 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
875 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
876 | 876 | return new ContentSecurityPolicyManager(); |
877 | 877 | }); |
878 | 878 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
@@ -923,25 +923,25 @@ discard block |
||
923 | 923 | ); |
924 | 924 | return $manager; |
925 | 925 | }); |
926 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
926 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
927 | 927 | return new \OC\Files\AppData\Factory( |
928 | 928 | $c->getRootFolder(), |
929 | 929 | $c->getSystemConfig() |
930 | 930 | ); |
931 | 931 | }); |
932 | 932 | |
933 | - $this->registerService('LockdownManager', function (Server $c) { |
|
933 | + $this->registerService('LockdownManager', function(Server $c) { |
|
934 | 934 | return new LockdownManager(function() use ($c) { |
935 | 935 | return $c->getSession(); |
936 | 936 | }); |
937 | 937 | }); |
938 | 938 | |
939 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
939 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
940 | 940 | return new CloudIdManager(); |
941 | 941 | }); |
942 | 942 | |
943 | 943 | /* To trick DI since we don't extend the DIContainer here */ |
944 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
944 | + $this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) { |
|
945 | 945 | return new CleanPreviewsBackgroundJob( |
946 | 946 | $c->getRootFolder(), |
947 | 947 | $c->getLogger(), |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
957 | 957 | $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
958 | 958 | |
959 | - $this->registerService(Defaults::class, function (Server $c) { |
|
959 | + $this->registerService(Defaults::class, function(Server $c) { |
|
960 | 960 | return new Defaults( |
961 | 961 | $c->getThemingDefaults() |
962 | 962 | ); |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | * @deprecated since 9.2.0 use IAppData |
1103 | 1103 | */ |
1104 | 1104 | public function getAppFolder() { |
1105 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1105 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
1106 | 1106 | $root = $this->getRootFolder(); |
1107 | 1107 | if (!$root->nodeExists($dir)) { |
1108 | 1108 | $folder = $root->newFolder($dir); |
@@ -116,1597 +116,1597 @@ |
||
116 | 116 | * TODO: hookup all manager classes |
117 | 117 | */ |
118 | 118 | class Server extends ServerContainer implements IServerContainer { |
119 | - /** @var string */ |
|
120 | - private $webRoot; |
|
121 | - |
|
122 | - /** |
|
123 | - * @param string $webRoot |
|
124 | - * @param \OC\Config $config |
|
125 | - */ |
|
126 | - public function __construct($webRoot, \OC\Config $config) { |
|
127 | - parent::__construct(); |
|
128 | - $this->webRoot = $webRoot; |
|
129 | - |
|
130 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
131 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
132 | - |
|
133 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
134 | - return new PreviewManager( |
|
135 | - $c->getConfig(), |
|
136 | - $c->getRootFolder(), |
|
137 | - $c->getAppDataDir('preview'), |
|
138 | - $c->getEventDispatcher(), |
|
139 | - $c->getSession()->get('user_id') |
|
140 | - ); |
|
141 | - }); |
|
142 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
143 | - |
|
144 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
145 | - return new \OC\Preview\Watcher( |
|
146 | - $c->getAppDataDir('preview') |
|
147 | - ); |
|
148 | - }); |
|
149 | - |
|
150 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
151 | - $view = new View(); |
|
152 | - $util = new Encryption\Util( |
|
153 | - $view, |
|
154 | - $c->getUserManager(), |
|
155 | - $c->getGroupManager(), |
|
156 | - $c->getConfig() |
|
157 | - ); |
|
158 | - return new Encryption\Manager( |
|
159 | - $c->getConfig(), |
|
160 | - $c->getLogger(), |
|
161 | - $c->getL10N('core'), |
|
162 | - new View(), |
|
163 | - $util, |
|
164 | - new ArrayCache() |
|
165 | - ); |
|
166 | - }); |
|
167 | - |
|
168 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
169 | - $util = new Encryption\Util( |
|
170 | - new View(), |
|
171 | - $c->getUserManager(), |
|
172 | - $c->getGroupManager(), |
|
173 | - $c->getConfig() |
|
174 | - ); |
|
175 | - return new Encryption\File($util); |
|
176 | - }); |
|
177 | - |
|
178 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
179 | - $view = new View(); |
|
180 | - $util = new Encryption\Util( |
|
181 | - $view, |
|
182 | - $c->getUserManager(), |
|
183 | - $c->getGroupManager(), |
|
184 | - $c->getConfig() |
|
185 | - ); |
|
186 | - |
|
187 | - return new Encryption\Keys\Storage($view, $util); |
|
188 | - }); |
|
189 | - $this->registerService('TagMapper', function (Server $c) { |
|
190 | - return new TagMapper($c->getDatabaseConnection()); |
|
191 | - }); |
|
192 | - |
|
193 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
194 | - $tagMapper = $c->query('TagMapper'); |
|
195 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
196 | - }); |
|
197 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
198 | - |
|
199 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
200 | - $config = $c->getConfig(); |
|
201 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
202 | - /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
203 | - $factory = new $factoryClass($this); |
|
204 | - return $factory; |
|
205 | - }); |
|
206 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
207 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
208 | - }); |
|
209 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
210 | - |
|
211 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
212 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
213 | - }); |
|
214 | - $this->registerService('RootFolder', function (Server $c) { |
|
215 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
216 | - $view = new View(); |
|
217 | - $root = new Root( |
|
218 | - $manager, |
|
219 | - $view, |
|
220 | - null, |
|
221 | - $c->getUserMountCache(), |
|
222 | - $this->getLogger(), |
|
223 | - $this->getUserManager() |
|
224 | - ); |
|
225 | - $connector = new HookConnector($root, $view); |
|
226 | - $connector->viewToNode(); |
|
227 | - |
|
228 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
229 | - $previewConnector->connectWatcher(); |
|
230 | - |
|
231 | - return $root; |
|
232 | - }); |
|
233 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
234 | - |
|
235 | - $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
236 | - return new LazyRoot(function() use ($c) { |
|
237 | - return $c->query('RootFolder'); |
|
238 | - }); |
|
239 | - }); |
|
240 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
241 | - |
|
242 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
243 | - $config = $c->getConfig(); |
|
244 | - return new \OC\User\Manager($config); |
|
245 | - }); |
|
246 | - $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
247 | - |
|
248 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
249 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
250 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
251 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
252 | - }); |
|
253 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
254 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
255 | - }); |
|
256 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
257 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
258 | - }); |
|
259 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
260 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
261 | - }); |
|
262 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
263 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
264 | - }); |
|
265 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
266 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
267 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
268 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
269 | - }); |
|
270 | - return $groupManager; |
|
271 | - }); |
|
272 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
273 | - |
|
274 | - $this->registerService(Store::class, function(Server $c) { |
|
275 | - $session = $c->getSession(); |
|
276 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
277 | - $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
278 | - } else { |
|
279 | - $tokenProvider = null; |
|
280 | - } |
|
281 | - $logger = $c->getLogger(); |
|
282 | - return new Store($session, $logger, $tokenProvider); |
|
283 | - }); |
|
284 | - $this->registerAlias(IStore::class, Store::class); |
|
285 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
286 | - $dbConnection = $c->getDatabaseConnection(); |
|
287 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
288 | - }); |
|
289 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
290 | - $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
291 | - $crypto = $c->getCrypto(); |
|
292 | - $config = $c->getConfig(); |
|
293 | - $logger = $c->getLogger(); |
|
294 | - $timeFactory = new TimeFactory(); |
|
295 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
296 | - }); |
|
297 | - $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
298 | - |
|
299 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
300 | - $manager = $c->getUserManager(); |
|
301 | - $session = new \OC\Session\Memory(''); |
|
302 | - $timeFactory = new TimeFactory(); |
|
303 | - // Token providers might require a working database. This code |
|
304 | - // might however be called when ownCloud is not yet setup. |
|
305 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
306 | - $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
307 | - } else { |
|
308 | - $defaultTokenProvider = null; |
|
309 | - } |
|
310 | - |
|
311 | - $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
|
312 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
313 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
314 | - }); |
|
315 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
316 | - /** @var $user \OC\User\User */ |
|
317 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
318 | - }); |
|
319 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
320 | - /** @var $user \OC\User\User */ |
|
321 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
322 | - }); |
|
323 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
324 | - /** @var $user \OC\User\User */ |
|
325 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
326 | - }); |
|
327 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
328 | - /** @var $user \OC\User\User */ |
|
329 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
330 | - }); |
|
331 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
332 | - /** @var $user \OC\User\User */ |
|
333 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
334 | - }); |
|
335 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
336 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
337 | - }); |
|
338 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
339 | - /** @var $user \OC\User\User */ |
|
340 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
341 | - }); |
|
342 | - $userSession->listen('\OC\User', 'logout', function () { |
|
343 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
344 | - }); |
|
345 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
346 | - /** @var $user \OC\User\User */ |
|
347 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
|
348 | - }); |
|
349 | - return $userSession; |
|
350 | - }); |
|
351 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
352 | - |
|
353 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
354 | - return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
355 | - }); |
|
356 | - |
|
357 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
358 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
359 | - |
|
360 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
361 | - return new \OC\AllConfig( |
|
362 | - $c->getSystemConfig() |
|
363 | - ); |
|
364 | - }); |
|
365 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
366 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
367 | - |
|
368 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
369 | - return new \OC\SystemConfig($config); |
|
370 | - }); |
|
371 | - |
|
372 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
373 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
374 | - }); |
|
375 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
376 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
377 | - |
|
378 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
379 | - return new \OC\L10N\Factory( |
|
380 | - $c->getConfig(), |
|
381 | - $c->getRequest(), |
|
382 | - $c->getUserSession(), |
|
383 | - \OC::$SERVERROOT |
|
384 | - ); |
|
385 | - }); |
|
386 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
387 | - |
|
388 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
389 | - $config = $c->getConfig(); |
|
390 | - $cacheFactory = $c->getMemCacheFactory(); |
|
391 | - return new \OC\URLGenerator( |
|
392 | - $config, |
|
393 | - $cacheFactory |
|
394 | - ); |
|
395 | - }); |
|
396 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
397 | - |
|
398 | - $this->registerService('AppHelper', function ($c) { |
|
399 | - return new \OC\AppHelper(); |
|
400 | - }); |
|
401 | - $this->registerService('AppFetcher', function ($c) { |
|
402 | - return new AppFetcher( |
|
403 | - $this->getAppDataDir('appstore'), |
|
404 | - $this->getHTTPClientService(), |
|
405 | - $this->query(TimeFactory::class), |
|
406 | - $this->getConfig() |
|
407 | - ); |
|
408 | - }); |
|
409 | - $this->registerService('CategoryFetcher', function ($c) { |
|
410 | - return new CategoryFetcher( |
|
411 | - $this->getAppDataDir('appstore'), |
|
412 | - $this->getHTTPClientService(), |
|
413 | - $this->query(TimeFactory::class), |
|
414 | - $this->getConfig() |
|
415 | - ); |
|
416 | - }); |
|
417 | - |
|
418 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
419 | - return new Cache\File(); |
|
420 | - }); |
|
421 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
422 | - |
|
423 | - $this->registerService(Factory::class, function (Server $c) { |
|
424 | - $config = $c->getConfig(); |
|
425 | - |
|
426 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
427 | - $v = \OC_App::getAppVersions(); |
|
428 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
429 | - $version = implode(',', $v); |
|
430 | - $instanceId = \OC_Util::getInstanceId(); |
|
431 | - $path = \OC::$SERVERROOT; |
|
432 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
433 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
434 | - $config->getSystemValue('memcache.local', null), |
|
435 | - $config->getSystemValue('memcache.distributed', null), |
|
436 | - $config->getSystemValue('memcache.locking', null) |
|
437 | - ); |
|
438 | - } |
|
439 | - |
|
440 | - return new \OC\Memcache\Factory('', $c->getLogger(), |
|
441 | - '\\OC\\Memcache\\ArrayCache', |
|
442 | - '\\OC\\Memcache\\ArrayCache', |
|
443 | - '\\OC\\Memcache\\ArrayCache' |
|
444 | - ); |
|
445 | - }); |
|
446 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
447 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
448 | - |
|
449 | - $this->registerService('RedisFactory', function (Server $c) { |
|
450 | - $systemConfig = $c->getSystemConfig(); |
|
451 | - return new RedisFactory($systemConfig); |
|
452 | - }); |
|
453 | - |
|
454 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
455 | - return new \OC\Activity\Manager( |
|
456 | - $c->getRequest(), |
|
457 | - $c->getUserSession(), |
|
458 | - $c->getConfig(), |
|
459 | - $c->query(IValidator::class) |
|
460 | - ); |
|
461 | - }); |
|
462 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
463 | - |
|
464 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
465 | - return new \OC\Activity\EventMerger( |
|
466 | - $c->getL10N('lib') |
|
467 | - ); |
|
468 | - }); |
|
469 | - $this->registerAlias(IValidator::class, Validator::class); |
|
470 | - |
|
471 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
472 | - return new AvatarManager( |
|
473 | - $c->getUserManager(), |
|
474 | - $c->getAppDataDir('avatar'), |
|
475 | - $c->getL10N('lib'), |
|
476 | - $c->getLogger(), |
|
477 | - $c->getConfig() |
|
478 | - ); |
|
479 | - }); |
|
480 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
481 | - |
|
482 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
483 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
484 | - $logger = Log::getLogClass($logType); |
|
485 | - call_user_func(array($logger, 'init')); |
|
486 | - |
|
487 | - return new Log($logger); |
|
488 | - }); |
|
489 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
490 | - |
|
491 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
492 | - $config = $c->getConfig(); |
|
493 | - return new \OC\BackgroundJob\JobList( |
|
494 | - $c->getDatabaseConnection(), |
|
495 | - $config, |
|
496 | - new TimeFactory() |
|
497 | - ); |
|
498 | - }); |
|
499 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
500 | - |
|
501 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
502 | - $cacheFactory = $c->getMemCacheFactory(); |
|
503 | - $logger = $c->getLogger(); |
|
504 | - if ($cacheFactory->isAvailable()) { |
|
505 | - $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
506 | - } else { |
|
507 | - $router = new \OC\Route\Router($logger); |
|
508 | - } |
|
509 | - return $router; |
|
510 | - }); |
|
511 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
512 | - |
|
513 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
514 | - return new Search(); |
|
515 | - }); |
|
516 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
517 | - |
|
518 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
519 | - return new SecureRandom(); |
|
520 | - }); |
|
521 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
522 | - |
|
523 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
524 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
525 | - }); |
|
526 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
527 | - |
|
528 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
529 | - return new Hasher($c->getConfig()); |
|
530 | - }); |
|
531 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
532 | - |
|
533 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
534 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
535 | - }); |
|
536 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
537 | - |
|
538 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
539 | - $systemConfig = $c->getSystemConfig(); |
|
540 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
541 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
542 | - if (!$factory->isValidType($type)) { |
|
543 | - throw new \OC\DatabaseException('Invalid database type'); |
|
544 | - } |
|
545 | - $connectionParams = $factory->createConnectionParams(); |
|
546 | - $connection = $factory->getConnection($type, $connectionParams); |
|
547 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
548 | - return $connection; |
|
549 | - }); |
|
550 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
551 | - |
|
552 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
553 | - $config = $c->getConfig(); |
|
554 | - return new HTTPHelper( |
|
555 | - $config, |
|
556 | - $c->getHTTPClientService() |
|
557 | - ); |
|
558 | - }); |
|
559 | - |
|
560 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
561 | - $user = \OC_User::getUser(); |
|
562 | - $uid = $user ? $user : null; |
|
563 | - return new ClientService( |
|
564 | - $c->getConfig(), |
|
565 | - new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
566 | - ); |
|
567 | - }); |
|
568 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
569 | - |
|
570 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
571 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
572 | - return new EventLogger(); |
|
573 | - } else { |
|
574 | - return new NullEventLogger(); |
|
575 | - } |
|
576 | - }); |
|
577 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
578 | - |
|
579 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
580 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
581 | - return new QueryLogger(); |
|
582 | - } else { |
|
583 | - return new NullQueryLogger(); |
|
584 | - } |
|
585 | - }); |
|
586 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
587 | - |
|
588 | - $this->registerService(TempManager::class, function (Server $c) { |
|
589 | - return new TempManager( |
|
590 | - $c->getLogger(), |
|
591 | - $c->getConfig() |
|
592 | - ); |
|
593 | - }); |
|
594 | - $this->registerAlias('TempManager', TempManager::class); |
|
595 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
596 | - |
|
597 | - $this->registerService(AppManager::class, function (Server $c) { |
|
598 | - return new \OC\App\AppManager( |
|
599 | - $c->getUserSession(), |
|
600 | - $c->getAppConfig(), |
|
601 | - $c->getGroupManager(), |
|
602 | - $c->getMemCacheFactory(), |
|
603 | - $c->getEventDispatcher() |
|
604 | - ); |
|
605 | - }); |
|
606 | - $this->registerAlias('AppManager', AppManager::class); |
|
607 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
608 | - |
|
609 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
610 | - return new DateTimeZone( |
|
611 | - $c->getConfig(), |
|
612 | - $c->getSession() |
|
613 | - ); |
|
614 | - }); |
|
615 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
616 | - |
|
617 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
618 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
619 | - |
|
620 | - return new DateTimeFormatter( |
|
621 | - $c->getDateTimeZone()->getTimeZone(), |
|
622 | - $c->getL10N('lib', $language) |
|
623 | - ); |
|
624 | - }); |
|
625 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
626 | - |
|
627 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
628 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
629 | - $listener = new UserMountCacheListener($mountCache); |
|
630 | - $listener->listen($c->getUserManager()); |
|
631 | - return $mountCache; |
|
632 | - }); |
|
633 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
634 | - |
|
635 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
636 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
637 | - $mountCache = $c->query('UserMountCache'); |
|
638 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
639 | - |
|
640 | - // builtin providers |
|
641 | - |
|
642 | - $config = $c->getConfig(); |
|
643 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
644 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
645 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
646 | - |
|
647 | - return $manager; |
|
648 | - }); |
|
649 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
650 | - |
|
651 | - $this->registerService('IniWrapper', function ($c) { |
|
652 | - return new IniGetWrapper(); |
|
653 | - }); |
|
654 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
655 | - $jobList = $c->getJobList(); |
|
656 | - return new AsyncBus($jobList); |
|
657 | - }); |
|
658 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
659 | - return new TrustedDomainHelper($this->getConfig()); |
|
660 | - }); |
|
661 | - $this->registerService('Throttler', function(Server $c) { |
|
662 | - return new Throttler( |
|
663 | - $c->getDatabaseConnection(), |
|
664 | - new TimeFactory(), |
|
665 | - $c->getLogger(), |
|
666 | - $c->getConfig() |
|
667 | - ); |
|
668 | - }); |
|
669 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
670 | - // IConfig and IAppManager requires a working database. This code |
|
671 | - // might however be called when ownCloud is not yet setup. |
|
672 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
673 | - $config = $c->getConfig(); |
|
674 | - $appManager = $c->getAppManager(); |
|
675 | - } else { |
|
676 | - $config = null; |
|
677 | - $appManager = null; |
|
678 | - } |
|
679 | - |
|
680 | - return new Checker( |
|
681 | - new EnvironmentHelper(), |
|
682 | - new FileAccessHelper(), |
|
683 | - new AppLocator(), |
|
684 | - $config, |
|
685 | - $c->getMemCacheFactory(), |
|
686 | - $appManager, |
|
687 | - $c->getTempManager() |
|
688 | - ); |
|
689 | - }); |
|
690 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
691 | - if (isset($this['urlParams'])) { |
|
692 | - $urlParams = $this['urlParams']; |
|
693 | - } else { |
|
694 | - $urlParams = []; |
|
695 | - } |
|
696 | - |
|
697 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
698 | - && in_array('fakeinput', stream_get_wrappers()) |
|
699 | - ) { |
|
700 | - $stream = 'fakeinput://data'; |
|
701 | - } else { |
|
702 | - $stream = 'php://input'; |
|
703 | - } |
|
704 | - |
|
705 | - return new Request( |
|
706 | - [ |
|
707 | - 'get' => $_GET, |
|
708 | - 'post' => $_POST, |
|
709 | - 'files' => $_FILES, |
|
710 | - 'server' => $_SERVER, |
|
711 | - 'env' => $_ENV, |
|
712 | - 'cookies' => $_COOKIE, |
|
713 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
714 | - ? $_SERVER['REQUEST_METHOD'] |
|
715 | - : null, |
|
716 | - 'urlParams' => $urlParams, |
|
717 | - ], |
|
718 | - $this->getSecureRandom(), |
|
719 | - $this->getConfig(), |
|
720 | - $this->getCsrfTokenManager(), |
|
721 | - $stream |
|
722 | - ); |
|
723 | - }); |
|
724 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
725 | - |
|
726 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
727 | - return new Mailer( |
|
728 | - $c->getConfig(), |
|
729 | - $c->getLogger(), |
|
730 | - $c->query(Defaults::class) |
|
731 | - ); |
|
732 | - }); |
|
733 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
734 | - |
|
735 | - $this->registerService('LDAPProvider', function(Server $c) { |
|
736 | - $config = $c->getConfig(); |
|
737 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
738 | - if(is_null($factoryClass)) { |
|
739 | - throw new \Exception('ldapProviderFactory not set'); |
|
740 | - } |
|
741 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
742 | - $factory = new $factoryClass($this); |
|
743 | - return $factory->getLDAPProvider(); |
|
744 | - }); |
|
745 | - $this->registerService('LockingProvider', function (Server $c) { |
|
746 | - $ini = $c->getIniWrapper(); |
|
747 | - $config = $c->getConfig(); |
|
748 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
749 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
750 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
751 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
752 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
753 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
754 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
755 | - } |
|
756 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
757 | - } |
|
758 | - return new NoopLockingProvider(); |
|
759 | - }); |
|
760 | - |
|
761 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
762 | - return new \OC\Files\Mount\Manager(); |
|
763 | - }); |
|
764 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
765 | - |
|
766 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
767 | - return new \OC\Files\Type\Detection( |
|
768 | - $c->getURLGenerator(), |
|
769 | - \OC::$configDir, |
|
770 | - \OC::$SERVERROOT . '/resources/config/' |
|
771 | - ); |
|
772 | - }); |
|
773 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
774 | - |
|
775 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
776 | - return new \OC\Files\Type\Loader( |
|
777 | - $c->getDatabaseConnection() |
|
778 | - ); |
|
779 | - }); |
|
780 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
781 | - |
|
782 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
783 | - return new Manager( |
|
784 | - $c->query(IValidator::class) |
|
785 | - ); |
|
786 | - }); |
|
787 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
788 | - |
|
789 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
790 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
791 | - $manager->registerCapability(function () use ($c) { |
|
792 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
793 | - }); |
|
794 | - return $manager; |
|
795 | - }); |
|
796 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
797 | - |
|
798 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
799 | - $config = $c->getConfig(); |
|
800 | - $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
801 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
802 | - $factory = new $factoryClass($this); |
|
803 | - return $factory->getManager(); |
|
804 | - }); |
|
805 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
806 | - |
|
807 | - $this->registerService('ThemingDefaults', function(Server $c) { |
|
808 | - /* |
|
119 | + /** @var string */ |
|
120 | + private $webRoot; |
|
121 | + |
|
122 | + /** |
|
123 | + * @param string $webRoot |
|
124 | + * @param \OC\Config $config |
|
125 | + */ |
|
126 | + public function __construct($webRoot, \OC\Config $config) { |
|
127 | + parent::__construct(); |
|
128 | + $this->webRoot = $webRoot; |
|
129 | + |
|
130 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
131 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
132 | + |
|
133 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
134 | + return new PreviewManager( |
|
135 | + $c->getConfig(), |
|
136 | + $c->getRootFolder(), |
|
137 | + $c->getAppDataDir('preview'), |
|
138 | + $c->getEventDispatcher(), |
|
139 | + $c->getSession()->get('user_id') |
|
140 | + ); |
|
141 | + }); |
|
142 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
143 | + |
|
144 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
145 | + return new \OC\Preview\Watcher( |
|
146 | + $c->getAppDataDir('preview') |
|
147 | + ); |
|
148 | + }); |
|
149 | + |
|
150 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
151 | + $view = new View(); |
|
152 | + $util = new Encryption\Util( |
|
153 | + $view, |
|
154 | + $c->getUserManager(), |
|
155 | + $c->getGroupManager(), |
|
156 | + $c->getConfig() |
|
157 | + ); |
|
158 | + return new Encryption\Manager( |
|
159 | + $c->getConfig(), |
|
160 | + $c->getLogger(), |
|
161 | + $c->getL10N('core'), |
|
162 | + new View(), |
|
163 | + $util, |
|
164 | + new ArrayCache() |
|
165 | + ); |
|
166 | + }); |
|
167 | + |
|
168 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
169 | + $util = new Encryption\Util( |
|
170 | + new View(), |
|
171 | + $c->getUserManager(), |
|
172 | + $c->getGroupManager(), |
|
173 | + $c->getConfig() |
|
174 | + ); |
|
175 | + return new Encryption\File($util); |
|
176 | + }); |
|
177 | + |
|
178 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
179 | + $view = new View(); |
|
180 | + $util = new Encryption\Util( |
|
181 | + $view, |
|
182 | + $c->getUserManager(), |
|
183 | + $c->getGroupManager(), |
|
184 | + $c->getConfig() |
|
185 | + ); |
|
186 | + |
|
187 | + return new Encryption\Keys\Storage($view, $util); |
|
188 | + }); |
|
189 | + $this->registerService('TagMapper', function (Server $c) { |
|
190 | + return new TagMapper($c->getDatabaseConnection()); |
|
191 | + }); |
|
192 | + |
|
193 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
194 | + $tagMapper = $c->query('TagMapper'); |
|
195 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
196 | + }); |
|
197 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
198 | + |
|
199 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
200 | + $config = $c->getConfig(); |
|
201 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
202 | + /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
203 | + $factory = new $factoryClass($this); |
|
204 | + return $factory; |
|
205 | + }); |
|
206 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
207 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
208 | + }); |
|
209 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
210 | + |
|
211 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
212 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
213 | + }); |
|
214 | + $this->registerService('RootFolder', function (Server $c) { |
|
215 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
216 | + $view = new View(); |
|
217 | + $root = new Root( |
|
218 | + $manager, |
|
219 | + $view, |
|
220 | + null, |
|
221 | + $c->getUserMountCache(), |
|
222 | + $this->getLogger(), |
|
223 | + $this->getUserManager() |
|
224 | + ); |
|
225 | + $connector = new HookConnector($root, $view); |
|
226 | + $connector->viewToNode(); |
|
227 | + |
|
228 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
229 | + $previewConnector->connectWatcher(); |
|
230 | + |
|
231 | + return $root; |
|
232 | + }); |
|
233 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
234 | + |
|
235 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
236 | + return new LazyRoot(function() use ($c) { |
|
237 | + return $c->query('RootFolder'); |
|
238 | + }); |
|
239 | + }); |
|
240 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
241 | + |
|
242 | + $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
243 | + $config = $c->getConfig(); |
|
244 | + return new \OC\User\Manager($config); |
|
245 | + }); |
|
246 | + $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
247 | + |
|
248 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
249 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
250 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
251 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
252 | + }); |
|
253 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
254 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
255 | + }); |
|
256 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
257 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
258 | + }); |
|
259 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
260 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
261 | + }); |
|
262 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
263 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
264 | + }); |
|
265 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
266 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
267 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
268 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
269 | + }); |
|
270 | + return $groupManager; |
|
271 | + }); |
|
272 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
273 | + |
|
274 | + $this->registerService(Store::class, function(Server $c) { |
|
275 | + $session = $c->getSession(); |
|
276 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
277 | + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
278 | + } else { |
|
279 | + $tokenProvider = null; |
|
280 | + } |
|
281 | + $logger = $c->getLogger(); |
|
282 | + return new Store($session, $logger, $tokenProvider); |
|
283 | + }); |
|
284 | + $this->registerAlias(IStore::class, Store::class); |
|
285 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
286 | + $dbConnection = $c->getDatabaseConnection(); |
|
287 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
288 | + }); |
|
289 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
290 | + $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
291 | + $crypto = $c->getCrypto(); |
|
292 | + $config = $c->getConfig(); |
|
293 | + $logger = $c->getLogger(); |
|
294 | + $timeFactory = new TimeFactory(); |
|
295 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
296 | + }); |
|
297 | + $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
298 | + |
|
299 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
300 | + $manager = $c->getUserManager(); |
|
301 | + $session = new \OC\Session\Memory(''); |
|
302 | + $timeFactory = new TimeFactory(); |
|
303 | + // Token providers might require a working database. This code |
|
304 | + // might however be called when ownCloud is not yet setup. |
|
305 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
306 | + $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
307 | + } else { |
|
308 | + $defaultTokenProvider = null; |
|
309 | + } |
|
310 | + |
|
311 | + $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
|
312 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
313 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
314 | + }); |
|
315 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
316 | + /** @var $user \OC\User\User */ |
|
317 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
318 | + }); |
|
319 | + $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
320 | + /** @var $user \OC\User\User */ |
|
321 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
322 | + }); |
|
323 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
324 | + /** @var $user \OC\User\User */ |
|
325 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
326 | + }); |
|
327 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
328 | + /** @var $user \OC\User\User */ |
|
329 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
330 | + }); |
|
331 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
332 | + /** @var $user \OC\User\User */ |
|
333 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
334 | + }); |
|
335 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
336 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
337 | + }); |
|
338 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
339 | + /** @var $user \OC\User\User */ |
|
340 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
341 | + }); |
|
342 | + $userSession->listen('\OC\User', 'logout', function () { |
|
343 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
344 | + }); |
|
345 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
346 | + /** @var $user \OC\User\User */ |
|
347 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
|
348 | + }); |
|
349 | + return $userSession; |
|
350 | + }); |
|
351 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
352 | + |
|
353 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
354 | + return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
355 | + }); |
|
356 | + |
|
357 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
358 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
359 | + |
|
360 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
361 | + return new \OC\AllConfig( |
|
362 | + $c->getSystemConfig() |
|
363 | + ); |
|
364 | + }); |
|
365 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
366 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
367 | + |
|
368 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
369 | + return new \OC\SystemConfig($config); |
|
370 | + }); |
|
371 | + |
|
372 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
373 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
374 | + }); |
|
375 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
376 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
377 | + |
|
378 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
379 | + return new \OC\L10N\Factory( |
|
380 | + $c->getConfig(), |
|
381 | + $c->getRequest(), |
|
382 | + $c->getUserSession(), |
|
383 | + \OC::$SERVERROOT |
|
384 | + ); |
|
385 | + }); |
|
386 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
387 | + |
|
388 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
389 | + $config = $c->getConfig(); |
|
390 | + $cacheFactory = $c->getMemCacheFactory(); |
|
391 | + return new \OC\URLGenerator( |
|
392 | + $config, |
|
393 | + $cacheFactory |
|
394 | + ); |
|
395 | + }); |
|
396 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
397 | + |
|
398 | + $this->registerService('AppHelper', function ($c) { |
|
399 | + return new \OC\AppHelper(); |
|
400 | + }); |
|
401 | + $this->registerService('AppFetcher', function ($c) { |
|
402 | + return new AppFetcher( |
|
403 | + $this->getAppDataDir('appstore'), |
|
404 | + $this->getHTTPClientService(), |
|
405 | + $this->query(TimeFactory::class), |
|
406 | + $this->getConfig() |
|
407 | + ); |
|
408 | + }); |
|
409 | + $this->registerService('CategoryFetcher', function ($c) { |
|
410 | + return new CategoryFetcher( |
|
411 | + $this->getAppDataDir('appstore'), |
|
412 | + $this->getHTTPClientService(), |
|
413 | + $this->query(TimeFactory::class), |
|
414 | + $this->getConfig() |
|
415 | + ); |
|
416 | + }); |
|
417 | + |
|
418 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
419 | + return new Cache\File(); |
|
420 | + }); |
|
421 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
422 | + |
|
423 | + $this->registerService(Factory::class, function (Server $c) { |
|
424 | + $config = $c->getConfig(); |
|
425 | + |
|
426 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
427 | + $v = \OC_App::getAppVersions(); |
|
428 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
429 | + $version = implode(',', $v); |
|
430 | + $instanceId = \OC_Util::getInstanceId(); |
|
431 | + $path = \OC::$SERVERROOT; |
|
432 | + $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
433 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
434 | + $config->getSystemValue('memcache.local', null), |
|
435 | + $config->getSystemValue('memcache.distributed', null), |
|
436 | + $config->getSystemValue('memcache.locking', null) |
|
437 | + ); |
|
438 | + } |
|
439 | + |
|
440 | + return new \OC\Memcache\Factory('', $c->getLogger(), |
|
441 | + '\\OC\\Memcache\\ArrayCache', |
|
442 | + '\\OC\\Memcache\\ArrayCache', |
|
443 | + '\\OC\\Memcache\\ArrayCache' |
|
444 | + ); |
|
445 | + }); |
|
446 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
447 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
448 | + |
|
449 | + $this->registerService('RedisFactory', function (Server $c) { |
|
450 | + $systemConfig = $c->getSystemConfig(); |
|
451 | + return new RedisFactory($systemConfig); |
|
452 | + }); |
|
453 | + |
|
454 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
455 | + return new \OC\Activity\Manager( |
|
456 | + $c->getRequest(), |
|
457 | + $c->getUserSession(), |
|
458 | + $c->getConfig(), |
|
459 | + $c->query(IValidator::class) |
|
460 | + ); |
|
461 | + }); |
|
462 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
463 | + |
|
464 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
465 | + return new \OC\Activity\EventMerger( |
|
466 | + $c->getL10N('lib') |
|
467 | + ); |
|
468 | + }); |
|
469 | + $this->registerAlias(IValidator::class, Validator::class); |
|
470 | + |
|
471 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
472 | + return new AvatarManager( |
|
473 | + $c->getUserManager(), |
|
474 | + $c->getAppDataDir('avatar'), |
|
475 | + $c->getL10N('lib'), |
|
476 | + $c->getLogger(), |
|
477 | + $c->getConfig() |
|
478 | + ); |
|
479 | + }); |
|
480 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
481 | + |
|
482 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
483 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
484 | + $logger = Log::getLogClass($logType); |
|
485 | + call_user_func(array($logger, 'init')); |
|
486 | + |
|
487 | + return new Log($logger); |
|
488 | + }); |
|
489 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
490 | + |
|
491 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
492 | + $config = $c->getConfig(); |
|
493 | + return new \OC\BackgroundJob\JobList( |
|
494 | + $c->getDatabaseConnection(), |
|
495 | + $config, |
|
496 | + new TimeFactory() |
|
497 | + ); |
|
498 | + }); |
|
499 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
500 | + |
|
501 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
502 | + $cacheFactory = $c->getMemCacheFactory(); |
|
503 | + $logger = $c->getLogger(); |
|
504 | + if ($cacheFactory->isAvailable()) { |
|
505 | + $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
506 | + } else { |
|
507 | + $router = new \OC\Route\Router($logger); |
|
508 | + } |
|
509 | + return $router; |
|
510 | + }); |
|
511 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
512 | + |
|
513 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
514 | + return new Search(); |
|
515 | + }); |
|
516 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
517 | + |
|
518 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
519 | + return new SecureRandom(); |
|
520 | + }); |
|
521 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
522 | + |
|
523 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
524 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
525 | + }); |
|
526 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
527 | + |
|
528 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
529 | + return new Hasher($c->getConfig()); |
|
530 | + }); |
|
531 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
532 | + |
|
533 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
534 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
535 | + }); |
|
536 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
537 | + |
|
538 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
539 | + $systemConfig = $c->getSystemConfig(); |
|
540 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
541 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
542 | + if (!$factory->isValidType($type)) { |
|
543 | + throw new \OC\DatabaseException('Invalid database type'); |
|
544 | + } |
|
545 | + $connectionParams = $factory->createConnectionParams(); |
|
546 | + $connection = $factory->getConnection($type, $connectionParams); |
|
547 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
548 | + return $connection; |
|
549 | + }); |
|
550 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
551 | + |
|
552 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
553 | + $config = $c->getConfig(); |
|
554 | + return new HTTPHelper( |
|
555 | + $config, |
|
556 | + $c->getHTTPClientService() |
|
557 | + ); |
|
558 | + }); |
|
559 | + |
|
560 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
561 | + $user = \OC_User::getUser(); |
|
562 | + $uid = $user ? $user : null; |
|
563 | + return new ClientService( |
|
564 | + $c->getConfig(), |
|
565 | + new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
566 | + ); |
|
567 | + }); |
|
568 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
569 | + |
|
570 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
571 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
572 | + return new EventLogger(); |
|
573 | + } else { |
|
574 | + return new NullEventLogger(); |
|
575 | + } |
|
576 | + }); |
|
577 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
578 | + |
|
579 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
580 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
581 | + return new QueryLogger(); |
|
582 | + } else { |
|
583 | + return new NullQueryLogger(); |
|
584 | + } |
|
585 | + }); |
|
586 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
587 | + |
|
588 | + $this->registerService(TempManager::class, function (Server $c) { |
|
589 | + return new TempManager( |
|
590 | + $c->getLogger(), |
|
591 | + $c->getConfig() |
|
592 | + ); |
|
593 | + }); |
|
594 | + $this->registerAlias('TempManager', TempManager::class); |
|
595 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
596 | + |
|
597 | + $this->registerService(AppManager::class, function (Server $c) { |
|
598 | + return new \OC\App\AppManager( |
|
599 | + $c->getUserSession(), |
|
600 | + $c->getAppConfig(), |
|
601 | + $c->getGroupManager(), |
|
602 | + $c->getMemCacheFactory(), |
|
603 | + $c->getEventDispatcher() |
|
604 | + ); |
|
605 | + }); |
|
606 | + $this->registerAlias('AppManager', AppManager::class); |
|
607 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
608 | + |
|
609 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
610 | + return new DateTimeZone( |
|
611 | + $c->getConfig(), |
|
612 | + $c->getSession() |
|
613 | + ); |
|
614 | + }); |
|
615 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
616 | + |
|
617 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
618 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
619 | + |
|
620 | + return new DateTimeFormatter( |
|
621 | + $c->getDateTimeZone()->getTimeZone(), |
|
622 | + $c->getL10N('lib', $language) |
|
623 | + ); |
|
624 | + }); |
|
625 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
626 | + |
|
627 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
628 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
629 | + $listener = new UserMountCacheListener($mountCache); |
|
630 | + $listener->listen($c->getUserManager()); |
|
631 | + return $mountCache; |
|
632 | + }); |
|
633 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
634 | + |
|
635 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
636 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
637 | + $mountCache = $c->query('UserMountCache'); |
|
638 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
639 | + |
|
640 | + // builtin providers |
|
641 | + |
|
642 | + $config = $c->getConfig(); |
|
643 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
644 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
645 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
646 | + |
|
647 | + return $manager; |
|
648 | + }); |
|
649 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
650 | + |
|
651 | + $this->registerService('IniWrapper', function ($c) { |
|
652 | + return new IniGetWrapper(); |
|
653 | + }); |
|
654 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
655 | + $jobList = $c->getJobList(); |
|
656 | + return new AsyncBus($jobList); |
|
657 | + }); |
|
658 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
659 | + return new TrustedDomainHelper($this->getConfig()); |
|
660 | + }); |
|
661 | + $this->registerService('Throttler', function(Server $c) { |
|
662 | + return new Throttler( |
|
663 | + $c->getDatabaseConnection(), |
|
664 | + new TimeFactory(), |
|
665 | + $c->getLogger(), |
|
666 | + $c->getConfig() |
|
667 | + ); |
|
668 | + }); |
|
669 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
670 | + // IConfig and IAppManager requires a working database. This code |
|
671 | + // might however be called when ownCloud is not yet setup. |
|
672 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
673 | + $config = $c->getConfig(); |
|
674 | + $appManager = $c->getAppManager(); |
|
675 | + } else { |
|
676 | + $config = null; |
|
677 | + $appManager = null; |
|
678 | + } |
|
679 | + |
|
680 | + return new Checker( |
|
681 | + new EnvironmentHelper(), |
|
682 | + new FileAccessHelper(), |
|
683 | + new AppLocator(), |
|
684 | + $config, |
|
685 | + $c->getMemCacheFactory(), |
|
686 | + $appManager, |
|
687 | + $c->getTempManager() |
|
688 | + ); |
|
689 | + }); |
|
690 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
691 | + if (isset($this['urlParams'])) { |
|
692 | + $urlParams = $this['urlParams']; |
|
693 | + } else { |
|
694 | + $urlParams = []; |
|
695 | + } |
|
696 | + |
|
697 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
698 | + && in_array('fakeinput', stream_get_wrappers()) |
|
699 | + ) { |
|
700 | + $stream = 'fakeinput://data'; |
|
701 | + } else { |
|
702 | + $stream = 'php://input'; |
|
703 | + } |
|
704 | + |
|
705 | + return new Request( |
|
706 | + [ |
|
707 | + 'get' => $_GET, |
|
708 | + 'post' => $_POST, |
|
709 | + 'files' => $_FILES, |
|
710 | + 'server' => $_SERVER, |
|
711 | + 'env' => $_ENV, |
|
712 | + 'cookies' => $_COOKIE, |
|
713 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
714 | + ? $_SERVER['REQUEST_METHOD'] |
|
715 | + : null, |
|
716 | + 'urlParams' => $urlParams, |
|
717 | + ], |
|
718 | + $this->getSecureRandom(), |
|
719 | + $this->getConfig(), |
|
720 | + $this->getCsrfTokenManager(), |
|
721 | + $stream |
|
722 | + ); |
|
723 | + }); |
|
724 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
725 | + |
|
726 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
727 | + return new Mailer( |
|
728 | + $c->getConfig(), |
|
729 | + $c->getLogger(), |
|
730 | + $c->query(Defaults::class) |
|
731 | + ); |
|
732 | + }); |
|
733 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
734 | + |
|
735 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
736 | + $config = $c->getConfig(); |
|
737 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
738 | + if(is_null($factoryClass)) { |
|
739 | + throw new \Exception('ldapProviderFactory not set'); |
|
740 | + } |
|
741 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
742 | + $factory = new $factoryClass($this); |
|
743 | + return $factory->getLDAPProvider(); |
|
744 | + }); |
|
745 | + $this->registerService('LockingProvider', function (Server $c) { |
|
746 | + $ini = $c->getIniWrapper(); |
|
747 | + $config = $c->getConfig(); |
|
748 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
749 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
750 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
751 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
752 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
753 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
754 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
755 | + } |
|
756 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
757 | + } |
|
758 | + return new NoopLockingProvider(); |
|
759 | + }); |
|
760 | + |
|
761 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
762 | + return new \OC\Files\Mount\Manager(); |
|
763 | + }); |
|
764 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
765 | + |
|
766 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
767 | + return new \OC\Files\Type\Detection( |
|
768 | + $c->getURLGenerator(), |
|
769 | + \OC::$configDir, |
|
770 | + \OC::$SERVERROOT . '/resources/config/' |
|
771 | + ); |
|
772 | + }); |
|
773 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
774 | + |
|
775 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
776 | + return new \OC\Files\Type\Loader( |
|
777 | + $c->getDatabaseConnection() |
|
778 | + ); |
|
779 | + }); |
|
780 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
781 | + |
|
782 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
783 | + return new Manager( |
|
784 | + $c->query(IValidator::class) |
|
785 | + ); |
|
786 | + }); |
|
787 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
788 | + |
|
789 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
790 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
791 | + $manager->registerCapability(function () use ($c) { |
|
792 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
793 | + }); |
|
794 | + return $manager; |
|
795 | + }); |
|
796 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
797 | + |
|
798 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
799 | + $config = $c->getConfig(); |
|
800 | + $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
801 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
802 | + $factory = new $factoryClass($this); |
|
803 | + return $factory->getManager(); |
|
804 | + }); |
|
805 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
806 | + |
|
807 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
808 | + /* |
|
809 | 809 | * Dark magic for autoloader. |
810 | 810 | * If we do a class_exists it will try to load the class which will |
811 | 811 | * make composer cache the result. Resulting in errors when enabling |
812 | 812 | * the theming app. |
813 | 813 | */ |
814 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
815 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
816 | - $classExists = true; |
|
817 | - } else { |
|
818 | - $classExists = false; |
|
819 | - } |
|
820 | - |
|
821 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
822 | - return new ThemingDefaults( |
|
823 | - $c->getConfig(), |
|
824 | - $c->getL10N('theming'), |
|
825 | - $c->getURLGenerator(), |
|
826 | - new \OC_Defaults(), |
|
827 | - $c->getAppDataDir('theming'), |
|
828 | - $c->getMemCacheFactory() |
|
829 | - ); |
|
830 | - } |
|
831 | - return new \OC_Defaults(); |
|
832 | - }); |
|
833 | - $this->registerService(EventDispatcher::class, function () { |
|
834 | - return new EventDispatcher(); |
|
835 | - }); |
|
836 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
837 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
838 | - |
|
839 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
840 | - // FIXME: Instantiiated here due to cyclic dependency |
|
841 | - $request = new Request( |
|
842 | - [ |
|
843 | - 'get' => $_GET, |
|
844 | - 'post' => $_POST, |
|
845 | - 'files' => $_FILES, |
|
846 | - 'server' => $_SERVER, |
|
847 | - 'env' => $_ENV, |
|
848 | - 'cookies' => $_COOKIE, |
|
849 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
850 | - ? $_SERVER['REQUEST_METHOD'] |
|
851 | - : null, |
|
852 | - ], |
|
853 | - $c->getSecureRandom(), |
|
854 | - $c->getConfig() |
|
855 | - ); |
|
856 | - |
|
857 | - return new CryptoWrapper( |
|
858 | - $c->getConfig(), |
|
859 | - $c->getCrypto(), |
|
860 | - $c->getSecureRandom(), |
|
861 | - $request |
|
862 | - ); |
|
863 | - }); |
|
864 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
865 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
866 | - |
|
867 | - return new CsrfTokenManager( |
|
868 | - $tokenGenerator, |
|
869 | - $c->query(SessionStorage::class) |
|
870 | - ); |
|
871 | - }); |
|
872 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
873 | - return new SessionStorage($c->getSession()); |
|
874 | - }); |
|
875 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
876 | - return new ContentSecurityPolicyManager(); |
|
877 | - }); |
|
878 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
879 | - |
|
880 | - $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
881 | - return new ContentSecurityPolicyNonceManager( |
|
882 | - $c->getCsrfTokenManager(), |
|
883 | - $c->getRequest() |
|
884 | - ); |
|
885 | - }); |
|
886 | - |
|
887 | - $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
888 | - $config = $c->getConfig(); |
|
889 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
890 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
891 | - $factory = new $factoryClass($this); |
|
892 | - |
|
893 | - $manager = new \OC\Share20\Manager( |
|
894 | - $c->getLogger(), |
|
895 | - $c->getConfig(), |
|
896 | - $c->getSecureRandom(), |
|
897 | - $c->getHasher(), |
|
898 | - $c->getMountManager(), |
|
899 | - $c->getGroupManager(), |
|
900 | - $c->getL10N('core'), |
|
901 | - $factory, |
|
902 | - $c->getUserManager(), |
|
903 | - $c->getLazyRootFolder(), |
|
904 | - $c->getEventDispatcher() |
|
905 | - ); |
|
906 | - |
|
907 | - return $manager; |
|
908 | - }); |
|
909 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
910 | - |
|
911 | - $this->registerService('SettingsManager', function(Server $c) { |
|
912 | - $manager = new \OC\Settings\Manager( |
|
913 | - $c->getLogger(), |
|
914 | - $c->getDatabaseConnection(), |
|
915 | - $c->getL10N('lib'), |
|
916 | - $c->getConfig(), |
|
917 | - $c->getEncryptionManager(), |
|
918 | - $c->getUserManager(), |
|
919 | - $c->getLockingProvider(), |
|
920 | - $c->getRequest(), |
|
921 | - new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
922 | - $c->getURLGenerator() |
|
923 | - ); |
|
924 | - return $manager; |
|
925 | - }); |
|
926 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
927 | - return new \OC\Files\AppData\Factory( |
|
928 | - $c->getRootFolder(), |
|
929 | - $c->getSystemConfig() |
|
930 | - ); |
|
931 | - }); |
|
932 | - |
|
933 | - $this->registerService('LockdownManager', function (Server $c) { |
|
934 | - return new LockdownManager(function() use ($c) { |
|
935 | - return $c->getSession(); |
|
936 | - }); |
|
937 | - }); |
|
938 | - |
|
939 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
940 | - return new CloudIdManager(); |
|
941 | - }); |
|
942 | - |
|
943 | - /* To trick DI since we don't extend the DIContainer here */ |
|
944 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
945 | - return new CleanPreviewsBackgroundJob( |
|
946 | - $c->getRootFolder(), |
|
947 | - $c->getLogger(), |
|
948 | - $c->getJobList(), |
|
949 | - new TimeFactory() |
|
950 | - ); |
|
951 | - }); |
|
952 | - |
|
953 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
954 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
955 | - |
|
956 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
957 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
958 | - |
|
959 | - $this->registerService(Defaults::class, function (Server $c) { |
|
960 | - return new Defaults( |
|
961 | - $c->getThemingDefaults() |
|
962 | - ); |
|
963 | - }); |
|
964 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
965 | - |
|
966 | - $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
967 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
968 | - }); |
|
969 | - } |
|
970 | - |
|
971 | - /** |
|
972 | - * @return \OCP\Contacts\IManager |
|
973 | - */ |
|
974 | - public function getContactsManager() { |
|
975 | - return $this->query('ContactsManager'); |
|
976 | - } |
|
977 | - |
|
978 | - /** |
|
979 | - * @return \OC\Encryption\Manager |
|
980 | - */ |
|
981 | - public function getEncryptionManager() { |
|
982 | - return $this->query('EncryptionManager'); |
|
983 | - } |
|
984 | - |
|
985 | - /** |
|
986 | - * @return \OC\Encryption\File |
|
987 | - */ |
|
988 | - public function getEncryptionFilesHelper() { |
|
989 | - return $this->query('EncryptionFileHelper'); |
|
990 | - } |
|
991 | - |
|
992 | - /** |
|
993 | - * @return \OCP\Encryption\Keys\IStorage |
|
994 | - */ |
|
995 | - public function getEncryptionKeyStorage() { |
|
996 | - return $this->query('EncryptionKeyStorage'); |
|
997 | - } |
|
998 | - |
|
999 | - /** |
|
1000 | - * The current request object holding all information about the request |
|
1001 | - * currently being processed is returned from this method. |
|
1002 | - * In case the current execution was not initiated by a web request null is returned |
|
1003 | - * |
|
1004 | - * @return \OCP\IRequest |
|
1005 | - */ |
|
1006 | - public function getRequest() { |
|
1007 | - return $this->query('Request'); |
|
1008 | - } |
|
1009 | - |
|
1010 | - /** |
|
1011 | - * Returns the preview manager which can create preview images for a given file |
|
1012 | - * |
|
1013 | - * @return \OCP\IPreview |
|
1014 | - */ |
|
1015 | - public function getPreviewManager() { |
|
1016 | - return $this->query('PreviewManager'); |
|
1017 | - } |
|
1018 | - |
|
1019 | - /** |
|
1020 | - * Returns the tag manager which can get and set tags for different object types |
|
1021 | - * |
|
1022 | - * @see \OCP\ITagManager::load() |
|
1023 | - * @return \OCP\ITagManager |
|
1024 | - */ |
|
1025 | - public function getTagManager() { |
|
1026 | - return $this->query('TagManager'); |
|
1027 | - } |
|
1028 | - |
|
1029 | - /** |
|
1030 | - * Returns the system-tag manager |
|
1031 | - * |
|
1032 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1033 | - * |
|
1034 | - * @since 9.0.0 |
|
1035 | - */ |
|
1036 | - public function getSystemTagManager() { |
|
1037 | - return $this->query('SystemTagManager'); |
|
1038 | - } |
|
1039 | - |
|
1040 | - /** |
|
1041 | - * Returns the system-tag object mapper |
|
1042 | - * |
|
1043 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1044 | - * |
|
1045 | - * @since 9.0.0 |
|
1046 | - */ |
|
1047 | - public function getSystemTagObjectMapper() { |
|
1048 | - return $this->query('SystemTagObjectMapper'); |
|
1049 | - } |
|
1050 | - |
|
1051 | - /** |
|
1052 | - * Returns the avatar manager, used for avatar functionality |
|
1053 | - * |
|
1054 | - * @return \OCP\IAvatarManager |
|
1055 | - */ |
|
1056 | - public function getAvatarManager() { |
|
1057 | - return $this->query('AvatarManager'); |
|
1058 | - } |
|
1059 | - |
|
1060 | - /** |
|
1061 | - * Returns the root folder of ownCloud's data directory |
|
1062 | - * |
|
1063 | - * @return \OCP\Files\IRootFolder |
|
1064 | - */ |
|
1065 | - public function getRootFolder() { |
|
1066 | - return $this->query('LazyRootFolder'); |
|
1067 | - } |
|
1068 | - |
|
1069 | - /** |
|
1070 | - * Returns the root folder of ownCloud's data directory |
|
1071 | - * This is the lazy variant so this gets only initialized once it |
|
1072 | - * is actually used. |
|
1073 | - * |
|
1074 | - * @return \OCP\Files\IRootFolder |
|
1075 | - */ |
|
1076 | - public function getLazyRootFolder() { |
|
1077 | - return $this->query('LazyRootFolder'); |
|
1078 | - } |
|
1079 | - |
|
1080 | - /** |
|
1081 | - * Returns a view to ownCloud's files folder |
|
1082 | - * |
|
1083 | - * @param string $userId user ID |
|
1084 | - * @return \OCP\Files\Folder|null |
|
1085 | - */ |
|
1086 | - public function getUserFolder($userId = null) { |
|
1087 | - if ($userId === null) { |
|
1088 | - $user = $this->getUserSession()->getUser(); |
|
1089 | - if (!$user) { |
|
1090 | - return null; |
|
1091 | - } |
|
1092 | - $userId = $user->getUID(); |
|
1093 | - } |
|
1094 | - $root = $this->getRootFolder(); |
|
1095 | - return $root->getUserFolder($userId); |
|
1096 | - } |
|
1097 | - |
|
1098 | - /** |
|
1099 | - * Returns an app-specific view in ownClouds data directory |
|
1100 | - * |
|
1101 | - * @return \OCP\Files\Folder |
|
1102 | - * @deprecated since 9.2.0 use IAppData |
|
1103 | - */ |
|
1104 | - public function getAppFolder() { |
|
1105 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1106 | - $root = $this->getRootFolder(); |
|
1107 | - if (!$root->nodeExists($dir)) { |
|
1108 | - $folder = $root->newFolder($dir); |
|
1109 | - } else { |
|
1110 | - $folder = $root->get($dir); |
|
1111 | - } |
|
1112 | - return $folder; |
|
1113 | - } |
|
1114 | - |
|
1115 | - /** |
|
1116 | - * @return \OC\User\Manager |
|
1117 | - */ |
|
1118 | - public function getUserManager() { |
|
1119 | - return $this->query('UserManager'); |
|
1120 | - } |
|
1121 | - |
|
1122 | - /** |
|
1123 | - * @return \OC\Group\Manager |
|
1124 | - */ |
|
1125 | - public function getGroupManager() { |
|
1126 | - return $this->query('GroupManager'); |
|
1127 | - } |
|
1128 | - |
|
1129 | - /** |
|
1130 | - * @return \OC\User\Session |
|
1131 | - */ |
|
1132 | - public function getUserSession() { |
|
1133 | - return $this->query('UserSession'); |
|
1134 | - } |
|
1135 | - |
|
1136 | - /** |
|
1137 | - * @return \OCP\ISession |
|
1138 | - */ |
|
1139 | - public function getSession() { |
|
1140 | - return $this->query('UserSession')->getSession(); |
|
1141 | - } |
|
1142 | - |
|
1143 | - /** |
|
1144 | - * @param \OCP\ISession $session |
|
1145 | - */ |
|
1146 | - public function setSession(\OCP\ISession $session) { |
|
1147 | - $this->query(SessionStorage::class)->setSession($session); |
|
1148 | - $this->query('UserSession')->setSession($session); |
|
1149 | - $this->query(Store::class)->setSession($session); |
|
1150 | - } |
|
1151 | - |
|
1152 | - /** |
|
1153 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1154 | - */ |
|
1155 | - public function getTwoFactorAuthManager() { |
|
1156 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1157 | - } |
|
1158 | - |
|
1159 | - /** |
|
1160 | - * @return \OC\NavigationManager |
|
1161 | - */ |
|
1162 | - public function getNavigationManager() { |
|
1163 | - return $this->query('NavigationManager'); |
|
1164 | - } |
|
1165 | - |
|
1166 | - /** |
|
1167 | - * @return \OCP\IConfig |
|
1168 | - */ |
|
1169 | - public function getConfig() { |
|
1170 | - return $this->query('AllConfig'); |
|
1171 | - } |
|
1172 | - |
|
1173 | - /** |
|
1174 | - * @internal For internal use only |
|
1175 | - * @return \OC\SystemConfig |
|
1176 | - */ |
|
1177 | - public function getSystemConfig() { |
|
1178 | - return $this->query('SystemConfig'); |
|
1179 | - } |
|
1180 | - |
|
1181 | - /** |
|
1182 | - * Returns the app config manager |
|
1183 | - * |
|
1184 | - * @return \OCP\IAppConfig |
|
1185 | - */ |
|
1186 | - public function getAppConfig() { |
|
1187 | - return $this->query('AppConfig'); |
|
1188 | - } |
|
1189 | - |
|
1190 | - /** |
|
1191 | - * @return \OCP\L10N\IFactory |
|
1192 | - */ |
|
1193 | - public function getL10NFactory() { |
|
1194 | - return $this->query('L10NFactory'); |
|
1195 | - } |
|
1196 | - |
|
1197 | - /** |
|
1198 | - * get an L10N instance |
|
1199 | - * |
|
1200 | - * @param string $app appid |
|
1201 | - * @param string $lang |
|
1202 | - * @return IL10N |
|
1203 | - */ |
|
1204 | - public function getL10N($app, $lang = null) { |
|
1205 | - return $this->getL10NFactory()->get($app, $lang); |
|
1206 | - } |
|
1207 | - |
|
1208 | - /** |
|
1209 | - * @return \OCP\IURLGenerator |
|
1210 | - */ |
|
1211 | - public function getURLGenerator() { |
|
1212 | - return $this->query('URLGenerator'); |
|
1213 | - } |
|
1214 | - |
|
1215 | - /** |
|
1216 | - * @return \OCP\IHelper |
|
1217 | - */ |
|
1218 | - public function getHelper() { |
|
1219 | - return $this->query('AppHelper'); |
|
1220 | - } |
|
1221 | - |
|
1222 | - /** |
|
1223 | - * @return AppFetcher |
|
1224 | - */ |
|
1225 | - public function getAppFetcher() { |
|
1226 | - return $this->query('AppFetcher'); |
|
1227 | - } |
|
1228 | - |
|
1229 | - /** |
|
1230 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1231 | - * getMemCacheFactory() instead. |
|
1232 | - * |
|
1233 | - * @return \OCP\ICache |
|
1234 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1235 | - */ |
|
1236 | - public function getCache() { |
|
1237 | - return $this->query('UserCache'); |
|
1238 | - } |
|
1239 | - |
|
1240 | - /** |
|
1241 | - * Returns an \OCP\CacheFactory instance |
|
1242 | - * |
|
1243 | - * @return \OCP\ICacheFactory |
|
1244 | - */ |
|
1245 | - public function getMemCacheFactory() { |
|
1246 | - return $this->query('MemCacheFactory'); |
|
1247 | - } |
|
1248 | - |
|
1249 | - /** |
|
1250 | - * Returns an \OC\RedisFactory instance |
|
1251 | - * |
|
1252 | - * @return \OC\RedisFactory |
|
1253 | - */ |
|
1254 | - public function getGetRedisFactory() { |
|
1255 | - return $this->query('RedisFactory'); |
|
1256 | - } |
|
1257 | - |
|
1258 | - |
|
1259 | - /** |
|
1260 | - * Returns the current session |
|
1261 | - * |
|
1262 | - * @return \OCP\IDBConnection |
|
1263 | - */ |
|
1264 | - public function getDatabaseConnection() { |
|
1265 | - return $this->query('DatabaseConnection'); |
|
1266 | - } |
|
1267 | - |
|
1268 | - /** |
|
1269 | - * Returns the activity manager |
|
1270 | - * |
|
1271 | - * @return \OCP\Activity\IManager |
|
1272 | - */ |
|
1273 | - public function getActivityManager() { |
|
1274 | - return $this->query('ActivityManager'); |
|
1275 | - } |
|
1276 | - |
|
1277 | - /** |
|
1278 | - * Returns an job list for controlling background jobs |
|
1279 | - * |
|
1280 | - * @return \OCP\BackgroundJob\IJobList |
|
1281 | - */ |
|
1282 | - public function getJobList() { |
|
1283 | - return $this->query('JobList'); |
|
1284 | - } |
|
1285 | - |
|
1286 | - /** |
|
1287 | - * Returns a logger instance |
|
1288 | - * |
|
1289 | - * @return \OCP\ILogger |
|
1290 | - */ |
|
1291 | - public function getLogger() { |
|
1292 | - return $this->query('Logger'); |
|
1293 | - } |
|
1294 | - |
|
1295 | - /** |
|
1296 | - * Returns a router for generating and matching urls |
|
1297 | - * |
|
1298 | - * @return \OCP\Route\IRouter |
|
1299 | - */ |
|
1300 | - public function getRouter() { |
|
1301 | - return $this->query('Router'); |
|
1302 | - } |
|
1303 | - |
|
1304 | - /** |
|
1305 | - * Returns a search instance |
|
1306 | - * |
|
1307 | - * @return \OCP\ISearch |
|
1308 | - */ |
|
1309 | - public function getSearch() { |
|
1310 | - return $this->query('Search'); |
|
1311 | - } |
|
1312 | - |
|
1313 | - /** |
|
1314 | - * Returns a SecureRandom instance |
|
1315 | - * |
|
1316 | - * @return \OCP\Security\ISecureRandom |
|
1317 | - */ |
|
1318 | - public function getSecureRandom() { |
|
1319 | - return $this->query('SecureRandom'); |
|
1320 | - } |
|
1321 | - |
|
1322 | - /** |
|
1323 | - * Returns a Crypto instance |
|
1324 | - * |
|
1325 | - * @return \OCP\Security\ICrypto |
|
1326 | - */ |
|
1327 | - public function getCrypto() { |
|
1328 | - return $this->query('Crypto'); |
|
1329 | - } |
|
1330 | - |
|
1331 | - /** |
|
1332 | - * Returns a Hasher instance |
|
1333 | - * |
|
1334 | - * @return \OCP\Security\IHasher |
|
1335 | - */ |
|
1336 | - public function getHasher() { |
|
1337 | - return $this->query('Hasher'); |
|
1338 | - } |
|
1339 | - |
|
1340 | - /** |
|
1341 | - * Returns a CredentialsManager instance |
|
1342 | - * |
|
1343 | - * @return \OCP\Security\ICredentialsManager |
|
1344 | - */ |
|
1345 | - public function getCredentialsManager() { |
|
1346 | - return $this->query('CredentialsManager'); |
|
1347 | - } |
|
1348 | - |
|
1349 | - /** |
|
1350 | - * Returns an instance of the HTTP helper class |
|
1351 | - * |
|
1352 | - * @deprecated Use getHTTPClientService() |
|
1353 | - * @return \OC\HTTPHelper |
|
1354 | - */ |
|
1355 | - public function getHTTPHelper() { |
|
1356 | - return $this->query('HTTPHelper'); |
|
1357 | - } |
|
1358 | - |
|
1359 | - /** |
|
1360 | - * Get the certificate manager for the user |
|
1361 | - * |
|
1362 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1363 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1364 | - */ |
|
1365 | - public function getCertificateManager($userId = '') { |
|
1366 | - if ($userId === '') { |
|
1367 | - $userSession = $this->getUserSession(); |
|
1368 | - $user = $userSession->getUser(); |
|
1369 | - if (is_null($user)) { |
|
1370 | - return null; |
|
1371 | - } |
|
1372 | - $userId = $user->getUID(); |
|
1373 | - } |
|
1374 | - return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1375 | - } |
|
1376 | - |
|
1377 | - /** |
|
1378 | - * Returns an instance of the HTTP client service |
|
1379 | - * |
|
1380 | - * @return \OCP\Http\Client\IClientService |
|
1381 | - */ |
|
1382 | - public function getHTTPClientService() { |
|
1383 | - return $this->query('HttpClientService'); |
|
1384 | - } |
|
1385 | - |
|
1386 | - /** |
|
1387 | - * Create a new event source |
|
1388 | - * |
|
1389 | - * @return \OCP\IEventSource |
|
1390 | - */ |
|
1391 | - public function createEventSource() { |
|
1392 | - return new \OC_EventSource(); |
|
1393 | - } |
|
1394 | - |
|
1395 | - /** |
|
1396 | - * Get the active event logger |
|
1397 | - * |
|
1398 | - * The returned logger only logs data when debug mode is enabled |
|
1399 | - * |
|
1400 | - * @return \OCP\Diagnostics\IEventLogger |
|
1401 | - */ |
|
1402 | - public function getEventLogger() { |
|
1403 | - return $this->query('EventLogger'); |
|
1404 | - } |
|
1405 | - |
|
1406 | - /** |
|
1407 | - * Get the active query logger |
|
1408 | - * |
|
1409 | - * The returned logger only logs data when debug mode is enabled |
|
1410 | - * |
|
1411 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1412 | - */ |
|
1413 | - public function getQueryLogger() { |
|
1414 | - return $this->query('QueryLogger'); |
|
1415 | - } |
|
1416 | - |
|
1417 | - /** |
|
1418 | - * Get the manager for temporary files and folders |
|
1419 | - * |
|
1420 | - * @return \OCP\ITempManager |
|
1421 | - */ |
|
1422 | - public function getTempManager() { |
|
1423 | - return $this->query('TempManager'); |
|
1424 | - } |
|
1425 | - |
|
1426 | - /** |
|
1427 | - * Get the app manager |
|
1428 | - * |
|
1429 | - * @return \OCP\App\IAppManager |
|
1430 | - */ |
|
1431 | - public function getAppManager() { |
|
1432 | - return $this->query('AppManager'); |
|
1433 | - } |
|
1434 | - |
|
1435 | - /** |
|
1436 | - * Creates a new mailer |
|
1437 | - * |
|
1438 | - * @return \OCP\Mail\IMailer |
|
1439 | - */ |
|
1440 | - public function getMailer() { |
|
1441 | - return $this->query('Mailer'); |
|
1442 | - } |
|
1443 | - |
|
1444 | - /** |
|
1445 | - * Get the webroot |
|
1446 | - * |
|
1447 | - * @return string |
|
1448 | - */ |
|
1449 | - public function getWebRoot() { |
|
1450 | - return $this->webRoot; |
|
1451 | - } |
|
1452 | - |
|
1453 | - /** |
|
1454 | - * @return \OC\OCSClient |
|
1455 | - */ |
|
1456 | - public function getOcsClient() { |
|
1457 | - return $this->query('OcsClient'); |
|
1458 | - } |
|
1459 | - |
|
1460 | - /** |
|
1461 | - * @return \OCP\IDateTimeZone |
|
1462 | - */ |
|
1463 | - public function getDateTimeZone() { |
|
1464 | - return $this->query('DateTimeZone'); |
|
1465 | - } |
|
1466 | - |
|
1467 | - /** |
|
1468 | - * @return \OCP\IDateTimeFormatter |
|
1469 | - */ |
|
1470 | - public function getDateTimeFormatter() { |
|
1471 | - return $this->query('DateTimeFormatter'); |
|
1472 | - } |
|
1473 | - |
|
1474 | - /** |
|
1475 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1476 | - */ |
|
1477 | - public function getMountProviderCollection() { |
|
1478 | - return $this->query('MountConfigManager'); |
|
1479 | - } |
|
1480 | - |
|
1481 | - /** |
|
1482 | - * Get the IniWrapper |
|
1483 | - * |
|
1484 | - * @return IniGetWrapper |
|
1485 | - */ |
|
1486 | - public function getIniWrapper() { |
|
1487 | - return $this->query('IniWrapper'); |
|
1488 | - } |
|
1489 | - |
|
1490 | - /** |
|
1491 | - * @return \OCP\Command\IBus |
|
1492 | - */ |
|
1493 | - public function getCommandBus() { |
|
1494 | - return $this->query('AsyncCommandBus'); |
|
1495 | - } |
|
1496 | - |
|
1497 | - /** |
|
1498 | - * Get the trusted domain helper |
|
1499 | - * |
|
1500 | - * @return TrustedDomainHelper |
|
1501 | - */ |
|
1502 | - public function getTrustedDomainHelper() { |
|
1503 | - return $this->query('TrustedDomainHelper'); |
|
1504 | - } |
|
1505 | - |
|
1506 | - /** |
|
1507 | - * Get the locking provider |
|
1508 | - * |
|
1509 | - * @return \OCP\Lock\ILockingProvider |
|
1510 | - * @since 8.1.0 |
|
1511 | - */ |
|
1512 | - public function getLockingProvider() { |
|
1513 | - return $this->query('LockingProvider'); |
|
1514 | - } |
|
1515 | - |
|
1516 | - /** |
|
1517 | - * @return \OCP\Files\Mount\IMountManager |
|
1518 | - **/ |
|
1519 | - function getMountManager() { |
|
1520 | - return $this->query('MountManager'); |
|
1521 | - } |
|
1522 | - |
|
1523 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1524 | - function getUserMountCache() { |
|
1525 | - return $this->query('UserMountCache'); |
|
1526 | - } |
|
1527 | - |
|
1528 | - /** |
|
1529 | - * Get the MimeTypeDetector |
|
1530 | - * |
|
1531 | - * @return \OCP\Files\IMimeTypeDetector |
|
1532 | - */ |
|
1533 | - public function getMimeTypeDetector() { |
|
1534 | - return $this->query('MimeTypeDetector'); |
|
1535 | - } |
|
1536 | - |
|
1537 | - /** |
|
1538 | - * Get the MimeTypeLoader |
|
1539 | - * |
|
1540 | - * @return \OCP\Files\IMimeTypeLoader |
|
1541 | - */ |
|
1542 | - public function getMimeTypeLoader() { |
|
1543 | - return $this->query('MimeTypeLoader'); |
|
1544 | - } |
|
1545 | - |
|
1546 | - /** |
|
1547 | - * Get the manager of all the capabilities |
|
1548 | - * |
|
1549 | - * @return \OC\CapabilitiesManager |
|
1550 | - */ |
|
1551 | - public function getCapabilitiesManager() { |
|
1552 | - return $this->query('CapabilitiesManager'); |
|
1553 | - } |
|
1554 | - |
|
1555 | - /** |
|
1556 | - * Get the EventDispatcher |
|
1557 | - * |
|
1558 | - * @return EventDispatcherInterface |
|
1559 | - * @since 8.2.0 |
|
1560 | - */ |
|
1561 | - public function getEventDispatcher() { |
|
1562 | - return $this->query('EventDispatcher'); |
|
1563 | - } |
|
1564 | - |
|
1565 | - /** |
|
1566 | - * Get the Notification Manager |
|
1567 | - * |
|
1568 | - * @return \OCP\Notification\IManager |
|
1569 | - * @since 8.2.0 |
|
1570 | - */ |
|
1571 | - public function getNotificationManager() { |
|
1572 | - return $this->query('NotificationManager'); |
|
1573 | - } |
|
1574 | - |
|
1575 | - /** |
|
1576 | - * @return \OCP\Comments\ICommentsManager |
|
1577 | - */ |
|
1578 | - public function getCommentsManager() { |
|
1579 | - return $this->query('CommentsManager'); |
|
1580 | - } |
|
1581 | - |
|
1582 | - /** |
|
1583 | - * @return \OCA\Theming\ThemingDefaults |
|
1584 | - */ |
|
1585 | - public function getThemingDefaults() { |
|
1586 | - return $this->query('ThemingDefaults'); |
|
1587 | - } |
|
1588 | - |
|
1589 | - /** |
|
1590 | - * @return \OC\IntegrityCheck\Checker |
|
1591 | - */ |
|
1592 | - public function getIntegrityCodeChecker() { |
|
1593 | - return $this->query('IntegrityCodeChecker'); |
|
1594 | - } |
|
1595 | - |
|
1596 | - /** |
|
1597 | - * @return \OC\Session\CryptoWrapper |
|
1598 | - */ |
|
1599 | - public function getSessionCryptoWrapper() { |
|
1600 | - return $this->query('CryptoWrapper'); |
|
1601 | - } |
|
1602 | - |
|
1603 | - /** |
|
1604 | - * @return CsrfTokenManager |
|
1605 | - */ |
|
1606 | - public function getCsrfTokenManager() { |
|
1607 | - return $this->query('CsrfTokenManager'); |
|
1608 | - } |
|
1609 | - |
|
1610 | - /** |
|
1611 | - * @return Throttler |
|
1612 | - */ |
|
1613 | - public function getBruteForceThrottler() { |
|
1614 | - return $this->query('Throttler'); |
|
1615 | - } |
|
1616 | - |
|
1617 | - /** |
|
1618 | - * @return IContentSecurityPolicyManager |
|
1619 | - */ |
|
1620 | - public function getContentSecurityPolicyManager() { |
|
1621 | - return $this->query('ContentSecurityPolicyManager'); |
|
1622 | - } |
|
1623 | - |
|
1624 | - /** |
|
1625 | - * @return ContentSecurityPolicyNonceManager |
|
1626 | - */ |
|
1627 | - public function getContentSecurityPolicyNonceManager() { |
|
1628 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1629 | - } |
|
1630 | - |
|
1631 | - /** |
|
1632 | - * Not a public API as of 8.2, wait for 9.0 |
|
1633 | - * |
|
1634 | - * @return \OCA\Files_External\Service\BackendService |
|
1635 | - */ |
|
1636 | - public function getStoragesBackendService() { |
|
1637 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1638 | - } |
|
1639 | - |
|
1640 | - /** |
|
1641 | - * Not a public API as of 8.2, wait for 9.0 |
|
1642 | - * |
|
1643 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1644 | - */ |
|
1645 | - public function getGlobalStoragesService() { |
|
1646 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1647 | - } |
|
1648 | - |
|
1649 | - /** |
|
1650 | - * Not a public API as of 8.2, wait for 9.0 |
|
1651 | - * |
|
1652 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1653 | - */ |
|
1654 | - public function getUserGlobalStoragesService() { |
|
1655 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1656 | - } |
|
1657 | - |
|
1658 | - /** |
|
1659 | - * Not a public API as of 8.2, wait for 9.0 |
|
1660 | - * |
|
1661 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1662 | - */ |
|
1663 | - public function getUserStoragesService() { |
|
1664 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1665 | - } |
|
1666 | - |
|
1667 | - /** |
|
1668 | - * @return \OCP\Share\IManager |
|
1669 | - */ |
|
1670 | - public function getShareManager() { |
|
1671 | - return $this->query('ShareManager'); |
|
1672 | - } |
|
1673 | - |
|
1674 | - /** |
|
1675 | - * Returns the LDAP Provider |
|
1676 | - * |
|
1677 | - * @return \OCP\LDAP\ILDAPProvider |
|
1678 | - */ |
|
1679 | - public function getLDAPProvider() { |
|
1680 | - return $this->query('LDAPProvider'); |
|
1681 | - } |
|
1682 | - |
|
1683 | - /** |
|
1684 | - * @return \OCP\Settings\IManager |
|
1685 | - */ |
|
1686 | - public function getSettingsManager() { |
|
1687 | - return $this->query('SettingsManager'); |
|
1688 | - } |
|
1689 | - |
|
1690 | - /** |
|
1691 | - * @return \OCP\Files\IAppData |
|
1692 | - */ |
|
1693 | - public function getAppDataDir($app) { |
|
1694 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1695 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1696 | - return $factory->get($app); |
|
1697 | - } |
|
1698 | - |
|
1699 | - /** |
|
1700 | - * @return \OCP\Lockdown\ILockdownManager |
|
1701 | - */ |
|
1702 | - public function getLockdownManager() { |
|
1703 | - return $this->query('LockdownManager'); |
|
1704 | - } |
|
1705 | - |
|
1706 | - /** |
|
1707 | - * @return \OCP\Federation\ICloudIdManager |
|
1708 | - */ |
|
1709 | - public function getCloudIdManager() { |
|
1710 | - return $this->query(ICloudIdManager::class); |
|
1711 | - } |
|
814 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
815 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
816 | + $classExists = true; |
|
817 | + } else { |
|
818 | + $classExists = false; |
|
819 | + } |
|
820 | + |
|
821 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
822 | + return new ThemingDefaults( |
|
823 | + $c->getConfig(), |
|
824 | + $c->getL10N('theming'), |
|
825 | + $c->getURLGenerator(), |
|
826 | + new \OC_Defaults(), |
|
827 | + $c->getAppDataDir('theming'), |
|
828 | + $c->getMemCacheFactory() |
|
829 | + ); |
|
830 | + } |
|
831 | + return new \OC_Defaults(); |
|
832 | + }); |
|
833 | + $this->registerService(EventDispatcher::class, function () { |
|
834 | + return new EventDispatcher(); |
|
835 | + }); |
|
836 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
837 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
838 | + |
|
839 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
840 | + // FIXME: Instantiiated here due to cyclic dependency |
|
841 | + $request = new Request( |
|
842 | + [ |
|
843 | + 'get' => $_GET, |
|
844 | + 'post' => $_POST, |
|
845 | + 'files' => $_FILES, |
|
846 | + 'server' => $_SERVER, |
|
847 | + 'env' => $_ENV, |
|
848 | + 'cookies' => $_COOKIE, |
|
849 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
850 | + ? $_SERVER['REQUEST_METHOD'] |
|
851 | + : null, |
|
852 | + ], |
|
853 | + $c->getSecureRandom(), |
|
854 | + $c->getConfig() |
|
855 | + ); |
|
856 | + |
|
857 | + return new CryptoWrapper( |
|
858 | + $c->getConfig(), |
|
859 | + $c->getCrypto(), |
|
860 | + $c->getSecureRandom(), |
|
861 | + $request |
|
862 | + ); |
|
863 | + }); |
|
864 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
865 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
866 | + |
|
867 | + return new CsrfTokenManager( |
|
868 | + $tokenGenerator, |
|
869 | + $c->query(SessionStorage::class) |
|
870 | + ); |
|
871 | + }); |
|
872 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
873 | + return new SessionStorage($c->getSession()); |
|
874 | + }); |
|
875 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
876 | + return new ContentSecurityPolicyManager(); |
|
877 | + }); |
|
878 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
879 | + |
|
880 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
881 | + return new ContentSecurityPolicyNonceManager( |
|
882 | + $c->getCsrfTokenManager(), |
|
883 | + $c->getRequest() |
|
884 | + ); |
|
885 | + }); |
|
886 | + |
|
887 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
888 | + $config = $c->getConfig(); |
|
889 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
890 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
891 | + $factory = new $factoryClass($this); |
|
892 | + |
|
893 | + $manager = new \OC\Share20\Manager( |
|
894 | + $c->getLogger(), |
|
895 | + $c->getConfig(), |
|
896 | + $c->getSecureRandom(), |
|
897 | + $c->getHasher(), |
|
898 | + $c->getMountManager(), |
|
899 | + $c->getGroupManager(), |
|
900 | + $c->getL10N('core'), |
|
901 | + $factory, |
|
902 | + $c->getUserManager(), |
|
903 | + $c->getLazyRootFolder(), |
|
904 | + $c->getEventDispatcher() |
|
905 | + ); |
|
906 | + |
|
907 | + return $manager; |
|
908 | + }); |
|
909 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
910 | + |
|
911 | + $this->registerService('SettingsManager', function(Server $c) { |
|
912 | + $manager = new \OC\Settings\Manager( |
|
913 | + $c->getLogger(), |
|
914 | + $c->getDatabaseConnection(), |
|
915 | + $c->getL10N('lib'), |
|
916 | + $c->getConfig(), |
|
917 | + $c->getEncryptionManager(), |
|
918 | + $c->getUserManager(), |
|
919 | + $c->getLockingProvider(), |
|
920 | + $c->getRequest(), |
|
921 | + new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
922 | + $c->getURLGenerator() |
|
923 | + ); |
|
924 | + return $manager; |
|
925 | + }); |
|
926 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
927 | + return new \OC\Files\AppData\Factory( |
|
928 | + $c->getRootFolder(), |
|
929 | + $c->getSystemConfig() |
|
930 | + ); |
|
931 | + }); |
|
932 | + |
|
933 | + $this->registerService('LockdownManager', function (Server $c) { |
|
934 | + return new LockdownManager(function() use ($c) { |
|
935 | + return $c->getSession(); |
|
936 | + }); |
|
937 | + }); |
|
938 | + |
|
939 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
940 | + return new CloudIdManager(); |
|
941 | + }); |
|
942 | + |
|
943 | + /* To trick DI since we don't extend the DIContainer here */ |
|
944 | + $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
945 | + return new CleanPreviewsBackgroundJob( |
|
946 | + $c->getRootFolder(), |
|
947 | + $c->getLogger(), |
|
948 | + $c->getJobList(), |
|
949 | + new TimeFactory() |
|
950 | + ); |
|
951 | + }); |
|
952 | + |
|
953 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
954 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
955 | + |
|
956 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
957 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
958 | + |
|
959 | + $this->registerService(Defaults::class, function (Server $c) { |
|
960 | + return new Defaults( |
|
961 | + $c->getThemingDefaults() |
|
962 | + ); |
|
963 | + }); |
|
964 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
965 | + |
|
966 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
967 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
968 | + }); |
|
969 | + } |
|
970 | + |
|
971 | + /** |
|
972 | + * @return \OCP\Contacts\IManager |
|
973 | + */ |
|
974 | + public function getContactsManager() { |
|
975 | + return $this->query('ContactsManager'); |
|
976 | + } |
|
977 | + |
|
978 | + /** |
|
979 | + * @return \OC\Encryption\Manager |
|
980 | + */ |
|
981 | + public function getEncryptionManager() { |
|
982 | + return $this->query('EncryptionManager'); |
|
983 | + } |
|
984 | + |
|
985 | + /** |
|
986 | + * @return \OC\Encryption\File |
|
987 | + */ |
|
988 | + public function getEncryptionFilesHelper() { |
|
989 | + return $this->query('EncryptionFileHelper'); |
|
990 | + } |
|
991 | + |
|
992 | + /** |
|
993 | + * @return \OCP\Encryption\Keys\IStorage |
|
994 | + */ |
|
995 | + public function getEncryptionKeyStorage() { |
|
996 | + return $this->query('EncryptionKeyStorage'); |
|
997 | + } |
|
998 | + |
|
999 | + /** |
|
1000 | + * The current request object holding all information about the request |
|
1001 | + * currently being processed is returned from this method. |
|
1002 | + * In case the current execution was not initiated by a web request null is returned |
|
1003 | + * |
|
1004 | + * @return \OCP\IRequest |
|
1005 | + */ |
|
1006 | + public function getRequest() { |
|
1007 | + return $this->query('Request'); |
|
1008 | + } |
|
1009 | + |
|
1010 | + /** |
|
1011 | + * Returns the preview manager which can create preview images for a given file |
|
1012 | + * |
|
1013 | + * @return \OCP\IPreview |
|
1014 | + */ |
|
1015 | + public function getPreviewManager() { |
|
1016 | + return $this->query('PreviewManager'); |
|
1017 | + } |
|
1018 | + |
|
1019 | + /** |
|
1020 | + * Returns the tag manager which can get and set tags for different object types |
|
1021 | + * |
|
1022 | + * @see \OCP\ITagManager::load() |
|
1023 | + * @return \OCP\ITagManager |
|
1024 | + */ |
|
1025 | + public function getTagManager() { |
|
1026 | + return $this->query('TagManager'); |
|
1027 | + } |
|
1028 | + |
|
1029 | + /** |
|
1030 | + * Returns the system-tag manager |
|
1031 | + * |
|
1032 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1033 | + * |
|
1034 | + * @since 9.0.0 |
|
1035 | + */ |
|
1036 | + public function getSystemTagManager() { |
|
1037 | + return $this->query('SystemTagManager'); |
|
1038 | + } |
|
1039 | + |
|
1040 | + /** |
|
1041 | + * Returns the system-tag object mapper |
|
1042 | + * |
|
1043 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1044 | + * |
|
1045 | + * @since 9.0.0 |
|
1046 | + */ |
|
1047 | + public function getSystemTagObjectMapper() { |
|
1048 | + return $this->query('SystemTagObjectMapper'); |
|
1049 | + } |
|
1050 | + |
|
1051 | + /** |
|
1052 | + * Returns the avatar manager, used for avatar functionality |
|
1053 | + * |
|
1054 | + * @return \OCP\IAvatarManager |
|
1055 | + */ |
|
1056 | + public function getAvatarManager() { |
|
1057 | + return $this->query('AvatarManager'); |
|
1058 | + } |
|
1059 | + |
|
1060 | + /** |
|
1061 | + * Returns the root folder of ownCloud's data directory |
|
1062 | + * |
|
1063 | + * @return \OCP\Files\IRootFolder |
|
1064 | + */ |
|
1065 | + public function getRootFolder() { |
|
1066 | + return $this->query('LazyRootFolder'); |
|
1067 | + } |
|
1068 | + |
|
1069 | + /** |
|
1070 | + * Returns the root folder of ownCloud's data directory |
|
1071 | + * This is the lazy variant so this gets only initialized once it |
|
1072 | + * is actually used. |
|
1073 | + * |
|
1074 | + * @return \OCP\Files\IRootFolder |
|
1075 | + */ |
|
1076 | + public function getLazyRootFolder() { |
|
1077 | + return $this->query('LazyRootFolder'); |
|
1078 | + } |
|
1079 | + |
|
1080 | + /** |
|
1081 | + * Returns a view to ownCloud's files folder |
|
1082 | + * |
|
1083 | + * @param string $userId user ID |
|
1084 | + * @return \OCP\Files\Folder|null |
|
1085 | + */ |
|
1086 | + public function getUserFolder($userId = null) { |
|
1087 | + if ($userId === null) { |
|
1088 | + $user = $this->getUserSession()->getUser(); |
|
1089 | + if (!$user) { |
|
1090 | + return null; |
|
1091 | + } |
|
1092 | + $userId = $user->getUID(); |
|
1093 | + } |
|
1094 | + $root = $this->getRootFolder(); |
|
1095 | + return $root->getUserFolder($userId); |
|
1096 | + } |
|
1097 | + |
|
1098 | + /** |
|
1099 | + * Returns an app-specific view in ownClouds data directory |
|
1100 | + * |
|
1101 | + * @return \OCP\Files\Folder |
|
1102 | + * @deprecated since 9.2.0 use IAppData |
|
1103 | + */ |
|
1104 | + public function getAppFolder() { |
|
1105 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1106 | + $root = $this->getRootFolder(); |
|
1107 | + if (!$root->nodeExists($dir)) { |
|
1108 | + $folder = $root->newFolder($dir); |
|
1109 | + } else { |
|
1110 | + $folder = $root->get($dir); |
|
1111 | + } |
|
1112 | + return $folder; |
|
1113 | + } |
|
1114 | + |
|
1115 | + /** |
|
1116 | + * @return \OC\User\Manager |
|
1117 | + */ |
|
1118 | + public function getUserManager() { |
|
1119 | + return $this->query('UserManager'); |
|
1120 | + } |
|
1121 | + |
|
1122 | + /** |
|
1123 | + * @return \OC\Group\Manager |
|
1124 | + */ |
|
1125 | + public function getGroupManager() { |
|
1126 | + return $this->query('GroupManager'); |
|
1127 | + } |
|
1128 | + |
|
1129 | + /** |
|
1130 | + * @return \OC\User\Session |
|
1131 | + */ |
|
1132 | + public function getUserSession() { |
|
1133 | + return $this->query('UserSession'); |
|
1134 | + } |
|
1135 | + |
|
1136 | + /** |
|
1137 | + * @return \OCP\ISession |
|
1138 | + */ |
|
1139 | + public function getSession() { |
|
1140 | + return $this->query('UserSession')->getSession(); |
|
1141 | + } |
|
1142 | + |
|
1143 | + /** |
|
1144 | + * @param \OCP\ISession $session |
|
1145 | + */ |
|
1146 | + public function setSession(\OCP\ISession $session) { |
|
1147 | + $this->query(SessionStorage::class)->setSession($session); |
|
1148 | + $this->query('UserSession')->setSession($session); |
|
1149 | + $this->query(Store::class)->setSession($session); |
|
1150 | + } |
|
1151 | + |
|
1152 | + /** |
|
1153 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1154 | + */ |
|
1155 | + public function getTwoFactorAuthManager() { |
|
1156 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1157 | + } |
|
1158 | + |
|
1159 | + /** |
|
1160 | + * @return \OC\NavigationManager |
|
1161 | + */ |
|
1162 | + public function getNavigationManager() { |
|
1163 | + return $this->query('NavigationManager'); |
|
1164 | + } |
|
1165 | + |
|
1166 | + /** |
|
1167 | + * @return \OCP\IConfig |
|
1168 | + */ |
|
1169 | + public function getConfig() { |
|
1170 | + return $this->query('AllConfig'); |
|
1171 | + } |
|
1172 | + |
|
1173 | + /** |
|
1174 | + * @internal For internal use only |
|
1175 | + * @return \OC\SystemConfig |
|
1176 | + */ |
|
1177 | + public function getSystemConfig() { |
|
1178 | + return $this->query('SystemConfig'); |
|
1179 | + } |
|
1180 | + |
|
1181 | + /** |
|
1182 | + * Returns the app config manager |
|
1183 | + * |
|
1184 | + * @return \OCP\IAppConfig |
|
1185 | + */ |
|
1186 | + public function getAppConfig() { |
|
1187 | + return $this->query('AppConfig'); |
|
1188 | + } |
|
1189 | + |
|
1190 | + /** |
|
1191 | + * @return \OCP\L10N\IFactory |
|
1192 | + */ |
|
1193 | + public function getL10NFactory() { |
|
1194 | + return $this->query('L10NFactory'); |
|
1195 | + } |
|
1196 | + |
|
1197 | + /** |
|
1198 | + * get an L10N instance |
|
1199 | + * |
|
1200 | + * @param string $app appid |
|
1201 | + * @param string $lang |
|
1202 | + * @return IL10N |
|
1203 | + */ |
|
1204 | + public function getL10N($app, $lang = null) { |
|
1205 | + return $this->getL10NFactory()->get($app, $lang); |
|
1206 | + } |
|
1207 | + |
|
1208 | + /** |
|
1209 | + * @return \OCP\IURLGenerator |
|
1210 | + */ |
|
1211 | + public function getURLGenerator() { |
|
1212 | + return $this->query('URLGenerator'); |
|
1213 | + } |
|
1214 | + |
|
1215 | + /** |
|
1216 | + * @return \OCP\IHelper |
|
1217 | + */ |
|
1218 | + public function getHelper() { |
|
1219 | + return $this->query('AppHelper'); |
|
1220 | + } |
|
1221 | + |
|
1222 | + /** |
|
1223 | + * @return AppFetcher |
|
1224 | + */ |
|
1225 | + public function getAppFetcher() { |
|
1226 | + return $this->query('AppFetcher'); |
|
1227 | + } |
|
1228 | + |
|
1229 | + /** |
|
1230 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1231 | + * getMemCacheFactory() instead. |
|
1232 | + * |
|
1233 | + * @return \OCP\ICache |
|
1234 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1235 | + */ |
|
1236 | + public function getCache() { |
|
1237 | + return $this->query('UserCache'); |
|
1238 | + } |
|
1239 | + |
|
1240 | + /** |
|
1241 | + * Returns an \OCP\CacheFactory instance |
|
1242 | + * |
|
1243 | + * @return \OCP\ICacheFactory |
|
1244 | + */ |
|
1245 | + public function getMemCacheFactory() { |
|
1246 | + return $this->query('MemCacheFactory'); |
|
1247 | + } |
|
1248 | + |
|
1249 | + /** |
|
1250 | + * Returns an \OC\RedisFactory instance |
|
1251 | + * |
|
1252 | + * @return \OC\RedisFactory |
|
1253 | + */ |
|
1254 | + public function getGetRedisFactory() { |
|
1255 | + return $this->query('RedisFactory'); |
|
1256 | + } |
|
1257 | + |
|
1258 | + |
|
1259 | + /** |
|
1260 | + * Returns the current session |
|
1261 | + * |
|
1262 | + * @return \OCP\IDBConnection |
|
1263 | + */ |
|
1264 | + public function getDatabaseConnection() { |
|
1265 | + return $this->query('DatabaseConnection'); |
|
1266 | + } |
|
1267 | + |
|
1268 | + /** |
|
1269 | + * Returns the activity manager |
|
1270 | + * |
|
1271 | + * @return \OCP\Activity\IManager |
|
1272 | + */ |
|
1273 | + public function getActivityManager() { |
|
1274 | + return $this->query('ActivityManager'); |
|
1275 | + } |
|
1276 | + |
|
1277 | + /** |
|
1278 | + * Returns an job list for controlling background jobs |
|
1279 | + * |
|
1280 | + * @return \OCP\BackgroundJob\IJobList |
|
1281 | + */ |
|
1282 | + public function getJobList() { |
|
1283 | + return $this->query('JobList'); |
|
1284 | + } |
|
1285 | + |
|
1286 | + /** |
|
1287 | + * Returns a logger instance |
|
1288 | + * |
|
1289 | + * @return \OCP\ILogger |
|
1290 | + */ |
|
1291 | + public function getLogger() { |
|
1292 | + return $this->query('Logger'); |
|
1293 | + } |
|
1294 | + |
|
1295 | + /** |
|
1296 | + * Returns a router for generating and matching urls |
|
1297 | + * |
|
1298 | + * @return \OCP\Route\IRouter |
|
1299 | + */ |
|
1300 | + public function getRouter() { |
|
1301 | + return $this->query('Router'); |
|
1302 | + } |
|
1303 | + |
|
1304 | + /** |
|
1305 | + * Returns a search instance |
|
1306 | + * |
|
1307 | + * @return \OCP\ISearch |
|
1308 | + */ |
|
1309 | + public function getSearch() { |
|
1310 | + return $this->query('Search'); |
|
1311 | + } |
|
1312 | + |
|
1313 | + /** |
|
1314 | + * Returns a SecureRandom instance |
|
1315 | + * |
|
1316 | + * @return \OCP\Security\ISecureRandom |
|
1317 | + */ |
|
1318 | + public function getSecureRandom() { |
|
1319 | + return $this->query('SecureRandom'); |
|
1320 | + } |
|
1321 | + |
|
1322 | + /** |
|
1323 | + * Returns a Crypto instance |
|
1324 | + * |
|
1325 | + * @return \OCP\Security\ICrypto |
|
1326 | + */ |
|
1327 | + public function getCrypto() { |
|
1328 | + return $this->query('Crypto'); |
|
1329 | + } |
|
1330 | + |
|
1331 | + /** |
|
1332 | + * Returns a Hasher instance |
|
1333 | + * |
|
1334 | + * @return \OCP\Security\IHasher |
|
1335 | + */ |
|
1336 | + public function getHasher() { |
|
1337 | + return $this->query('Hasher'); |
|
1338 | + } |
|
1339 | + |
|
1340 | + /** |
|
1341 | + * Returns a CredentialsManager instance |
|
1342 | + * |
|
1343 | + * @return \OCP\Security\ICredentialsManager |
|
1344 | + */ |
|
1345 | + public function getCredentialsManager() { |
|
1346 | + return $this->query('CredentialsManager'); |
|
1347 | + } |
|
1348 | + |
|
1349 | + /** |
|
1350 | + * Returns an instance of the HTTP helper class |
|
1351 | + * |
|
1352 | + * @deprecated Use getHTTPClientService() |
|
1353 | + * @return \OC\HTTPHelper |
|
1354 | + */ |
|
1355 | + public function getHTTPHelper() { |
|
1356 | + return $this->query('HTTPHelper'); |
|
1357 | + } |
|
1358 | + |
|
1359 | + /** |
|
1360 | + * Get the certificate manager for the user |
|
1361 | + * |
|
1362 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1363 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1364 | + */ |
|
1365 | + public function getCertificateManager($userId = '') { |
|
1366 | + if ($userId === '') { |
|
1367 | + $userSession = $this->getUserSession(); |
|
1368 | + $user = $userSession->getUser(); |
|
1369 | + if (is_null($user)) { |
|
1370 | + return null; |
|
1371 | + } |
|
1372 | + $userId = $user->getUID(); |
|
1373 | + } |
|
1374 | + return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1375 | + } |
|
1376 | + |
|
1377 | + /** |
|
1378 | + * Returns an instance of the HTTP client service |
|
1379 | + * |
|
1380 | + * @return \OCP\Http\Client\IClientService |
|
1381 | + */ |
|
1382 | + public function getHTTPClientService() { |
|
1383 | + return $this->query('HttpClientService'); |
|
1384 | + } |
|
1385 | + |
|
1386 | + /** |
|
1387 | + * Create a new event source |
|
1388 | + * |
|
1389 | + * @return \OCP\IEventSource |
|
1390 | + */ |
|
1391 | + public function createEventSource() { |
|
1392 | + return new \OC_EventSource(); |
|
1393 | + } |
|
1394 | + |
|
1395 | + /** |
|
1396 | + * Get the active event logger |
|
1397 | + * |
|
1398 | + * The returned logger only logs data when debug mode is enabled |
|
1399 | + * |
|
1400 | + * @return \OCP\Diagnostics\IEventLogger |
|
1401 | + */ |
|
1402 | + public function getEventLogger() { |
|
1403 | + return $this->query('EventLogger'); |
|
1404 | + } |
|
1405 | + |
|
1406 | + /** |
|
1407 | + * Get the active query logger |
|
1408 | + * |
|
1409 | + * The returned logger only logs data when debug mode is enabled |
|
1410 | + * |
|
1411 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1412 | + */ |
|
1413 | + public function getQueryLogger() { |
|
1414 | + return $this->query('QueryLogger'); |
|
1415 | + } |
|
1416 | + |
|
1417 | + /** |
|
1418 | + * Get the manager for temporary files and folders |
|
1419 | + * |
|
1420 | + * @return \OCP\ITempManager |
|
1421 | + */ |
|
1422 | + public function getTempManager() { |
|
1423 | + return $this->query('TempManager'); |
|
1424 | + } |
|
1425 | + |
|
1426 | + /** |
|
1427 | + * Get the app manager |
|
1428 | + * |
|
1429 | + * @return \OCP\App\IAppManager |
|
1430 | + */ |
|
1431 | + public function getAppManager() { |
|
1432 | + return $this->query('AppManager'); |
|
1433 | + } |
|
1434 | + |
|
1435 | + /** |
|
1436 | + * Creates a new mailer |
|
1437 | + * |
|
1438 | + * @return \OCP\Mail\IMailer |
|
1439 | + */ |
|
1440 | + public function getMailer() { |
|
1441 | + return $this->query('Mailer'); |
|
1442 | + } |
|
1443 | + |
|
1444 | + /** |
|
1445 | + * Get the webroot |
|
1446 | + * |
|
1447 | + * @return string |
|
1448 | + */ |
|
1449 | + public function getWebRoot() { |
|
1450 | + return $this->webRoot; |
|
1451 | + } |
|
1452 | + |
|
1453 | + /** |
|
1454 | + * @return \OC\OCSClient |
|
1455 | + */ |
|
1456 | + public function getOcsClient() { |
|
1457 | + return $this->query('OcsClient'); |
|
1458 | + } |
|
1459 | + |
|
1460 | + /** |
|
1461 | + * @return \OCP\IDateTimeZone |
|
1462 | + */ |
|
1463 | + public function getDateTimeZone() { |
|
1464 | + return $this->query('DateTimeZone'); |
|
1465 | + } |
|
1466 | + |
|
1467 | + /** |
|
1468 | + * @return \OCP\IDateTimeFormatter |
|
1469 | + */ |
|
1470 | + public function getDateTimeFormatter() { |
|
1471 | + return $this->query('DateTimeFormatter'); |
|
1472 | + } |
|
1473 | + |
|
1474 | + /** |
|
1475 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1476 | + */ |
|
1477 | + public function getMountProviderCollection() { |
|
1478 | + return $this->query('MountConfigManager'); |
|
1479 | + } |
|
1480 | + |
|
1481 | + /** |
|
1482 | + * Get the IniWrapper |
|
1483 | + * |
|
1484 | + * @return IniGetWrapper |
|
1485 | + */ |
|
1486 | + public function getIniWrapper() { |
|
1487 | + return $this->query('IniWrapper'); |
|
1488 | + } |
|
1489 | + |
|
1490 | + /** |
|
1491 | + * @return \OCP\Command\IBus |
|
1492 | + */ |
|
1493 | + public function getCommandBus() { |
|
1494 | + return $this->query('AsyncCommandBus'); |
|
1495 | + } |
|
1496 | + |
|
1497 | + /** |
|
1498 | + * Get the trusted domain helper |
|
1499 | + * |
|
1500 | + * @return TrustedDomainHelper |
|
1501 | + */ |
|
1502 | + public function getTrustedDomainHelper() { |
|
1503 | + return $this->query('TrustedDomainHelper'); |
|
1504 | + } |
|
1505 | + |
|
1506 | + /** |
|
1507 | + * Get the locking provider |
|
1508 | + * |
|
1509 | + * @return \OCP\Lock\ILockingProvider |
|
1510 | + * @since 8.1.0 |
|
1511 | + */ |
|
1512 | + public function getLockingProvider() { |
|
1513 | + return $this->query('LockingProvider'); |
|
1514 | + } |
|
1515 | + |
|
1516 | + /** |
|
1517 | + * @return \OCP\Files\Mount\IMountManager |
|
1518 | + **/ |
|
1519 | + function getMountManager() { |
|
1520 | + return $this->query('MountManager'); |
|
1521 | + } |
|
1522 | + |
|
1523 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1524 | + function getUserMountCache() { |
|
1525 | + return $this->query('UserMountCache'); |
|
1526 | + } |
|
1527 | + |
|
1528 | + /** |
|
1529 | + * Get the MimeTypeDetector |
|
1530 | + * |
|
1531 | + * @return \OCP\Files\IMimeTypeDetector |
|
1532 | + */ |
|
1533 | + public function getMimeTypeDetector() { |
|
1534 | + return $this->query('MimeTypeDetector'); |
|
1535 | + } |
|
1536 | + |
|
1537 | + /** |
|
1538 | + * Get the MimeTypeLoader |
|
1539 | + * |
|
1540 | + * @return \OCP\Files\IMimeTypeLoader |
|
1541 | + */ |
|
1542 | + public function getMimeTypeLoader() { |
|
1543 | + return $this->query('MimeTypeLoader'); |
|
1544 | + } |
|
1545 | + |
|
1546 | + /** |
|
1547 | + * Get the manager of all the capabilities |
|
1548 | + * |
|
1549 | + * @return \OC\CapabilitiesManager |
|
1550 | + */ |
|
1551 | + public function getCapabilitiesManager() { |
|
1552 | + return $this->query('CapabilitiesManager'); |
|
1553 | + } |
|
1554 | + |
|
1555 | + /** |
|
1556 | + * Get the EventDispatcher |
|
1557 | + * |
|
1558 | + * @return EventDispatcherInterface |
|
1559 | + * @since 8.2.0 |
|
1560 | + */ |
|
1561 | + public function getEventDispatcher() { |
|
1562 | + return $this->query('EventDispatcher'); |
|
1563 | + } |
|
1564 | + |
|
1565 | + /** |
|
1566 | + * Get the Notification Manager |
|
1567 | + * |
|
1568 | + * @return \OCP\Notification\IManager |
|
1569 | + * @since 8.2.0 |
|
1570 | + */ |
|
1571 | + public function getNotificationManager() { |
|
1572 | + return $this->query('NotificationManager'); |
|
1573 | + } |
|
1574 | + |
|
1575 | + /** |
|
1576 | + * @return \OCP\Comments\ICommentsManager |
|
1577 | + */ |
|
1578 | + public function getCommentsManager() { |
|
1579 | + return $this->query('CommentsManager'); |
|
1580 | + } |
|
1581 | + |
|
1582 | + /** |
|
1583 | + * @return \OCA\Theming\ThemingDefaults |
|
1584 | + */ |
|
1585 | + public function getThemingDefaults() { |
|
1586 | + return $this->query('ThemingDefaults'); |
|
1587 | + } |
|
1588 | + |
|
1589 | + /** |
|
1590 | + * @return \OC\IntegrityCheck\Checker |
|
1591 | + */ |
|
1592 | + public function getIntegrityCodeChecker() { |
|
1593 | + return $this->query('IntegrityCodeChecker'); |
|
1594 | + } |
|
1595 | + |
|
1596 | + /** |
|
1597 | + * @return \OC\Session\CryptoWrapper |
|
1598 | + */ |
|
1599 | + public function getSessionCryptoWrapper() { |
|
1600 | + return $this->query('CryptoWrapper'); |
|
1601 | + } |
|
1602 | + |
|
1603 | + /** |
|
1604 | + * @return CsrfTokenManager |
|
1605 | + */ |
|
1606 | + public function getCsrfTokenManager() { |
|
1607 | + return $this->query('CsrfTokenManager'); |
|
1608 | + } |
|
1609 | + |
|
1610 | + /** |
|
1611 | + * @return Throttler |
|
1612 | + */ |
|
1613 | + public function getBruteForceThrottler() { |
|
1614 | + return $this->query('Throttler'); |
|
1615 | + } |
|
1616 | + |
|
1617 | + /** |
|
1618 | + * @return IContentSecurityPolicyManager |
|
1619 | + */ |
|
1620 | + public function getContentSecurityPolicyManager() { |
|
1621 | + return $this->query('ContentSecurityPolicyManager'); |
|
1622 | + } |
|
1623 | + |
|
1624 | + /** |
|
1625 | + * @return ContentSecurityPolicyNonceManager |
|
1626 | + */ |
|
1627 | + public function getContentSecurityPolicyNonceManager() { |
|
1628 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1629 | + } |
|
1630 | + |
|
1631 | + /** |
|
1632 | + * Not a public API as of 8.2, wait for 9.0 |
|
1633 | + * |
|
1634 | + * @return \OCA\Files_External\Service\BackendService |
|
1635 | + */ |
|
1636 | + public function getStoragesBackendService() { |
|
1637 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1638 | + } |
|
1639 | + |
|
1640 | + /** |
|
1641 | + * Not a public API as of 8.2, wait for 9.0 |
|
1642 | + * |
|
1643 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1644 | + */ |
|
1645 | + public function getGlobalStoragesService() { |
|
1646 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1647 | + } |
|
1648 | + |
|
1649 | + /** |
|
1650 | + * Not a public API as of 8.2, wait for 9.0 |
|
1651 | + * |
|
1652 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1653 | + */ |
|
1654 | + public function getUserGlobalStoragesService() { |
|
1655 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1656 | + } |
|
1657 | + |
|
1658 | + /** |
|
1659 | + * Not a public API as of 8.2, wait for 9.0 |
|
1660 | + * |
|
1661 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1662 | + */ |
|
1663 | + public function getUserStoragesService() { |
|
1664 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1665 | + } |
|
1666 | + |
|
1667 | + /** |
|
1668 | + * @return \OCP\Share\IManager |
|
1669 | + */ |
|
1670 | + public function getShareManager() { |
|
1671 | + return $this->query('ShareManager'); |
|
1672 | + } |
|
1673 | + |
|
1674 | + /** |
|
1675 | + * Returns the LDAP Provider |
|
1676 | + * |
|
1677 | + * @return \OCP\LDAP\ILDAPProvider |
|
1678 | + */ |
|
1679 | + public function getLDAPProvider() { |
|
1680 | + return $this->query('LDAPProvider'); |
|
1681 | + } |
|
1682 | + |
|
1683 | + /** |
|
1684 | + * @return \OCP\Settings\IManager |
|
1685 | + */ |
|
1686 | + public function getSettingsManager() { |
|
1687 | + return $this->query('SettingsManager'); |
|
1688 | + } |
|
1689 | + |
|
1690 | + /** |
|
1691 | + * @return \OCP\Files\IAppData |
|
1692 | + */ |
|
1693 | + public function getAppDataDir($app) { |
|
1694 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1695 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1696 | + return $factory->get($app); |
|
1697 | + } |
|
1698 | + |
|
1699 | + /** |
|
1700 | + * @return \OCP\Lockdown\ILockdownManager |
|
1701 | + */ |
|
1702 | + public function getLockdownManager() { |
|
1703 | + return $this->query('LockdownManager'); |
|
1704 | + } |
|
1705 | + |
|
1706 | + /** |
|
1707 | + * @return \OCP\Federation\ICloudIdManager |
|
1708 | + */ |
|
1709 | + public function getCloudIdManager() { |
|
1710 | + return $this->query(ICloudIdManager::class); |
|
1711 | + } |
|
1712 | 1712 | } |
@@ -51,62 +51,62 @@ |
||
51 | 51 | * $plainContent = $emailTemplate->renderText(); |
52 | 52 | */ |
53 | 53 | interface IEMailTemplate { |
54 | - /** |
|
55 | - * @param Defaults $themingDefaults |
|
56 | - * @param \OCP\IURLGenerator $urlGenerator |
|
57 | - * @param \OCP\IL10N $l10n |
|
58 | - */ |
|
59 | - public function __construct(Defaults $themingDefaults, |
|
60 | - \OCP\IURLGenerator $urlGenerator, |
|
61 | - \OCP\IL10N $l10n); |
|
54 | + /** |
|
55 | + * @param Defaults $themingDefaults |
|
56 | + * @param \OCP\IURLGenerator $urlGenerator |
|
57 | + * @param \OCP\IL10N $l10n |
|
58 | + */ |
|
59 | + public function __construct(Defaults $themingDefaults, |
|
60 | + \OCP\IURLGenerator $urlGenerator, |
|
61 | + \OCP\IL10N $l10n); |
|
62 | 62 | |
63 | - /** |
|
64 | - * Adds a header to the email |
|
65 | - */ |
|
66 | - public function addHeader(); |
|
63 | + /** |
|
64 | + * Adds a header to the email |
|
65 | + */ |
|
66 | + public function addHeader(); |
|
67 | 67 | |
68 | - /** |
|
69 | - * Adds a heading to the email |
|
70 | - * |
|
71 | - * @param string $title |
|
72 | - */ |
|
73 | - public function addHeading($title); |
|
68 | + /** |
|
69 | + * Adds a heading to the email |
|
70 | + * |
|
71 | + * @param string $title |
|
72 | + */ |
|
73 | + public function addHeading($title); |
|
74 | 74 | |
75 | - /** |
|
76 | - * Adds a paragraph to the body of the email |
|
77 | - * |
|
78 | - * @param string $text |
|
79 | - */ |
|
80 | - public function addBodyText($text); |
|
75 | + /** |
|
76 | + * Adds a paragraph to the body of the email |
|
77 | + * |
|
78 | + * @param string $text |
|
79 | + */ |
|
80 | + public function addBodyText($text); |
|
81 | 81 | |
82 | - /** |
|
83 | - * Adds a button group of two buttons to the body of the email |
|
84 | - * |
|
85 | - * @param string $textLeft Text of left button |
|
86 | - * @param string $urlLeft URL of left button |
|
87 | - * @param string $textRight Text of right button |
|
88 | - * @param string $urlRight URL of right button |
|
89 | - */ |
|
90 | - public function addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight); |
|
82 | + /** |
|
83 | + * Adds a button group of two buttons to the body of the email |
|
84 | + * |
|
85 | + * @param string $textLeft Text of left button |
|
86 | + * @param string $urlLeft URL of left button |
|
87 | + * @param string $textRight Text of right button |
|
88 | + * @param string $urlRight URL of right button |
|
89 | + */ |
|
90 | + public function addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight); |
|
91 | 91 | |
92 | - /** |
|
93 | - * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email |
|
94 | - * |
|
95 | - * @param string $text |
|
96 | - */ |
|
97 | - public function addFooter($text = ''); |
|
92 | + /** |
|
93 | + * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email |
|
94 | + * |
|
95 | + * @param string $text |
|
96 | + */ |
|
97 | + public function addFooter($text = ''); |
|
98 | 98 | |
99 | - /** |
|
100 | - * Returns the rendered HTML email as string |
|
101 | - * |
|
102 | - * @return string |
|
103 | - */ |
|
104 | - public function renderHTML(); |
|
99 | + /** |
|
100 | + * Returns the rendered HTML email as string |
|
101 | + * |
|
102 | + * @return string |
|
103 | + */ |
|
104 | + public function renderHTML(); |
|
105 | 105 | |
106 | - /** |
|
107 | - * Returns the rendered plain text email as string |
|
108 | - * |
|
109 | - * @return string |
|
110 | - */ |
|
111 | - public function renderText(); |
|
106 | + /** |
|
107 | + * Returns the rendered plain text email as string |
|
108 | + * |
|
109 | + * @return string |
|
110 | + */ |
|
111 | + public function renderText(); |
|
112 | 112 | } |
@@ -46,180 +46,180 @@ |
||
46 | 46 | * @package OC\Mail |
47 | 47 | */ |
48 | 48 | class Mailer implements IMailer { |
49 | - /** @var \Swift_SmtpTransport|\Swift_SendmailTransport|\Swift_MailTransport Cached transport */ |
|
50 | - private $instance = null; |
|
51 | - /** @var IConfig */ |
|
52 | - private $config; |
|
53 | - /** @var ILogger */ |
|
54 | - private $logger; |
|
55 | - /** @var Defaults */ |
|
56 | - private $defaults; |
|
57 | - |
|
58 | - /** |
|
59 | - * @param IConfig $config |
|
60 | - * @param ILogger $logger |
|
61 | - * @param Defaults $defaults |
|
62 | - */ |
|
63 | - function __construct(IConfig $config, |
|
64 | - ILogger $logger, |
|
65 | - Defaults $defaults) { |
|
66 | - $this->config = $config; |
|
67 | - $this->logger = $logger; |
|
68 | - $this->defaults = $defaults; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Creates a new message object that can be passed to send() |
|
73 | - * |
|
74 | - * @return Message |
|
75 | - */ |
|
76 | - public function createMessage() { |
|
77 | - return new Message(new \Swift_Message()); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Send the specified message. Also sets the from address to the value defined in config.php |
|
82 | - * if no-one has been passed. |
|
83 | - * |
|
84 | - * @param Message $message Message to send |
|
85 | - * @return string[] Array with failed recipients. Be aware that this depends on the used mail backend and |
|
86 | - * therefore should be considered |
|
87 | - * @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address |
|
88 | - * has been supplied.) |
|
89 | - */ |
|
90 | - public function send(Message $message) { |
|
91 | - $debugMode = $this->config->getSystemValue('mail_smtpdebug', false); |
|
92 | - |
|
93 | - if (sizeof($message->getFrom()) === 0) { |
|
94 | - $message->setFrom([\OCP\Util::getDefaultEmailAddress($this->defaults->getName())]); |
|
95 | - } |
|
96 | - |
|
97 | - $failedRecipients = []; |
|
98 | - |
|
99 | - $mailer = $this->getInstance(); |
|
100 | - |
|
101 | - // Enable logger if debug mode is enabled |
|
102 | - if($debugMode) { |
|
103 | - $mailLogger = new \Swift_Plugins_Loggers_ArrayLogger(); |
|
104 | - $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger)); |
|
105 | - } |
|
106 | - |
|
107 | - $mailer->send($message->getSwiftMessage(), $failedRecipients); |
|
108 | - |
|
109 | - // Debugging logging |
|
110 | - $logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject()); |
|
111 | - $this->logger->debug($logMessage, ['app' => 'core']); |
|
112 | - if($debugMode && isset($mailLogger)) { |
|
113 | - $this->logger->debug($mailLogger->dump(), ['app' => 'core']); |
|
114 | - } |
|
115 | - |
|
116 | - return $failedRecipients; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Checks if an e-mail address is valid |
|
121 | - * |
|
122 | - * @param string $email Email address to be validated |
|
123 | - * @return bool True if the mail address is valid, false otherwise |
|
124 | - */ |
|
125 | - public function validateMailAddress($email) { |
|
126 | - return \Swift_Validate::email($this->convertEmail($email)); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains |
|
131 | - * |
|
132 | - * FIXME: Remove this once SwiftMailer supports IDN |
|
133 | - * |
|
134 | - * @param string $email |
|
135 | - * @return string Converted mail address if `idn_to_ascii` exists |
|
136 | - */ |
|
137 | - protected function convertEmail($email) { |
|
138 | - if (!function_exists('idn_to_ascii') || strpos($email, '@') === false) { |
|
139 | - return $email; |
|
140 | - } |
|
141 | - |
|
142 | - list($name, $domain) = explode('@', $email, 2); |
|
143 | - $domain = idn_to_ascii($domain); |
|
144 | - return $name.'@'.$domain; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * Returns whatever transport is configured within the config |
|
149 | - * |
|
150 | - * @return \Swift_SmtpTransport|\Swift_SendmailTransport|\Swift_MailTransport |
|
151 | - */ |
|
152 | - protected function getInstance() { |
|
153 | - if (!is_null($this->instance)) { |
|
154 | - return $this->instance; |
|
155 | - } |
|
156 | - |
|
157 | - switch ($this->config->getSystemValue('mail_smtpmode', 'php')) { |
|
158 | - case 'smtp': |
|
159 | - $this->instance = $this->getSMTPInstance(); |
|
160 | - break; |
|
161 | - case 'sendmail': |
|
162 | - // FIXME: Move into the return statement but requires proper testing |
|
163 | - // for SMTP and mail as well. Thus not really doable for a |
|
164 | - // minor release. |
|
165 | - $this->instance = \Swift_Mailer::newInstance($this->getSendMailInstance()); |
|
166 | - break; |
|
167 | - default: |
|
168 | - $this->instance = $this->getMailInstance(); |
|
169 | - break; |
|
170 | - } |
|
171 | - |
|
172 | - return $this->instance; |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Returns the SMTP transport |
|
177 | - * |
|
178 | - * @return \Swift_SmtpTransport |
|
179 | - */ |
|
180 | - protected function getSmtpInstance() { |
|
181 | - $transport = \Swift_SmtpTransport::newInstance(); |
|
182 | - $transport->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10)); |
|
183 | - $transport->setHost($this->config->getSystemValue('mail_smtphost', '127.0.0.1')); |
|
184 | - $transport->setPort($this->config->getSystemValue('mail_smtpport', 25)); |
|
185 | - if ($this->config->getSystemValue('mail_smtpauth', false)) { |
|
186 | - $transport->setUsername($this->config->getSystemValue('mail_smtpname', '')); |
|
187 | - $transport->setPassword($this->config->getSystemValue('mail_smtppassword', '')); |
|
188 | - $transport->setAuthMode($this->config->getSystemValue('mail_smtpauthtype', 'LOGIN')); |
|
189 | - } |
|
190 | - $smtpSecurity = $this->config->getSystemValue('mail_smtpsecure', ''); |
|
191 | - if (!empty($smtpSecurity)) { |
|
192 | - $transport->setEncryption($smtpSecurity); |
|
193 | - } |
|
194 | - $transport->start(); |
|
195 | - return $transport; |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * Returns the sendmail transport |
|
200 | - * |
|
201 | - * @return \Swift_SendmailTransport |
|
202 | - */ |
|
203 | - protected function getSendMailInstance() { |
|
204 | - switch ($this->config->getSystemValue('mail_smtpmode', 'php')) { |
|
205 | - case 'qmail': |
|
206 | - $binaryPath = '/var/qmail/bin/sendmail'; |
|
207 | - break; |
|
208 | - default: |
|
209 | - $binaryPath = '/usr/sbin/sendmail'; |
|
210 | - break; |
|
211 | - } |
|
212 | - |
|
213 | - return \Swift_SendmailTransport::newInstance($binaryPath . ' -bs'); |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * Returns the mail transport |
|
218 | - * |
|
219 | - * @return \Swift_MailTransport |
|
220 | - */ |
|
221 | - protected function getMailInstance() { |
|
222 | - return \Swift_MailTransport::newInstance(); |
|
223 | - } |
|
49 | + /** @var \Swift_SmtpTransport|\Swift_SendmailTransport|\Swift_MailTransport Cached transport */ |
|
50 | + private $instance = null; |
|
51 | + /** @var IConfig */ |
|
52 | + private $config; |
|
53 | + /** @var ILogger */ |
|
54 | + private $logger; |
|
55 | + /** @var Defaults */ |
|
56 | + private $defaults; |
|
57 | + |
|
58 | + /** |
|
59 | + * @param IConfig $config |
|
60 | + * @param ILogger $logger |
|
61 | + * @param Defaults $defaults |
|
62 | + */ |
|
63 | + function __construct(IConfig $config, |
|
64 | + ILogger $logger, |
|
65 | + Defaults $defaults) { |
|
66 | + $this->config = $config; |
|
67 | + $this->logger = $logger; |
|
68 | + $this->defaults = $defaults; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Creates a new message object that can be passed to send() |
|
73 | + * |
|
74 | + * @return Message |
|
75 | + */ |
|
76 | + public function createMessage() { |
|
77 | + return new Message(new \Swift_Message()); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Send the specified message. Also sets the from address to the value defined in config.php |
|
82 | + * if no-one has been passed. |
|
83 | + * |
|
84 | + * @param Message $message Message to send |
|
85 | + * @return string[] Array with failed recipients. Be aware that this depends on the used mail backend and |
|
86 | + * therefore should be considered |
|
87 | + * @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address |
|
88 | + * has been supplied.) |
|
89 | + */ |
|
90 | + public function send(Message $message) { |
|
91 | + $debugMode = $this->config->getSystemValue('mail_smtpdebug', false); |
|
92 | + |
|
93 | + if (sizeof($message->getFrom()) === 0) { |
|
94 | + $message->setFrom([\OCP\Util::getDefaultEmailAddress($this->defaults->getName())]); |
|
95 | + } |
|
96 | + |
|
97 | + $failedRecipients = []; |
|
98 | + |
|
99 | + $mailer = $this->getInstance(); |
|
100 | + |
|
101 | + // Enable logger if debug mode is enabled |
|
102 | + if($debugMode) { |
|
103 | + $mailLogger = new \Swift_Plugins_Loggers_ArrayLogger(); |
|
104 | + $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger)); |
|
105 | + } |
|
106 | + |
|
107 | + $mailer->send($message->getSwiftMessage(), $failedRecipients); |
|
108 | + |
|
109 | + // Debugging logging |
|
110 | + $logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject()); |
|
111 | + $this->logger->debug($logMessage, ['app' => 'core']); |
|
112 | + if($debugMode && isset($mailLogger)) { |
|
113 | + $this->logger->debug($mailLogger->dump(), ['app' => 'core']); |
|
114 | + } |
|
115 | + |
|
116 | + return $failedRecipients; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Checks if an e-mail address is valid |
|
121 | + * |
|
122 | + * @param string $email Email address to be validated |
|
123 | + * @return bool True if the mail address is valid, false otherwise |
|
124 | + */ |
|
125 | + public function validateMailAddress($email) { |
|
126 | + return \Swift_Validate::email($this->convertEmail($email)); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains |
|
131 | + * |
|
132 | + * FIXME: Remove this once SwiftMailer supports IDN |
|
133 | + * |
|
134 | + * @param string $email |
|
135 | + * @return string Converted mail address if `idn_to_ascii` exists |
|
136 | + */ |
|
137 | + protected function convertEmail($email) { |
|
138 | + if (!function_exists('idn_to_ascii') || strpos($email, '@') === false) { |
|
139 | + return $email; |
|
140 | + } |
|
141 | + |
|
142 | + list($name, $domain) = explode('@', $email, 2); |
|
143 | + $domain = idn_to_ascii($domain); |
|
144 | + return $name.'@'.$domain; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Returns whatever transport is configured within the config |
|
149 | + * |
|
150 | + * @return \Swift_SmtpTransport|\Swift_SendmailTransport|\Swift_MailTransport |
|
151 | + */ |
|
152 | + protected function getInstance() { |
|
153 | + if (!is_null($this->instance)) { |
|
154 | + return $this->instance; |
|
155 | + } |
|
156 | + |
|
157 | + switch ($this->config->getSystemValue('mail_smtpmode', 'php')) { |
|
158 | + case 'smtp': |
|
159 | + $this->instance = $this->getSMTPInstance(); |
|
160 | + break; |
|
161 | + case 'sendmail': |
|
162 | + // FIXME: Move into the return statement but requires proper testing |
|
163 | + // for SMTP and mail as well. Thus not really doable for a |
|
164 | + // minor release. |
|
165 | + $this->instance = \Swift_Mailer::newInstance($this->getSendMailInstance()); |
|
166 | + break; |
|
167 | + default: |
|
168 | + $this->instance = $this->getMailInstance(); |
|
169 | + break; |
|
170 | + } |
|
171 | + |
|
172 | + return $this->instance; |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Returns the SMTP transport |
|
177 | + * |
|
178 | + * @return \Swift_SmtpTransport |
|
179 | + */ |
|
180 | + protected function getSmtpInstance() { |
|
181 | + $transport = \Swift_SmtpTransport::newInstance(); |
|
182 | + $transport->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10)); |
|
183 | + $transport->setHost($this->config->getSystemValue('mail_smtphost', '127.0.0.1')); |
|
184 | + $transport->setPort($this->config->getSystemValue('mail_smtpport', 25)); |
|
185 | + if ($this->config->getSystemValue('mail_smtpauth', false)) { |
|
186 | + $transport->setUsername($this->config->getSystemValue('mail_smtpname', '')); |
|
187 | + $transport->setPassword($this->config->getSystemValue('mail_smtppassword', '')); |
|
188 | + $transport->setAuthMode($this->config->getSystemValue('mail_smtpauthtype', 'LOGIN')); |
|
189 | + } |
|
190 | + $smtpSecurity = $this->config->getSystemValue('mail_smtpsecure', ''); |
|
191 | + if (!empty($smtpSecurity)) { |
|
192 | + $transport->setEncryption($smtpSecurity); |
|
193 | + } |
|
194 | + $transport->start(); |
|
195 | + return $transport; |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * Returns the sendmail transport |
|
200 | + * |
|
201 | + * @return \Swift_SendmailTransport |
|
202 | + */ |
|
203 | + protected function getSendMailInstance() { |
|
204 | + switch ($this->config->getSystemValue('mail_smtpmode', 'php')) { |
|
205 | + case 'qmail': |
|
206 | + $binaryPath = '/var/qmail/bin/sendmail'; |
|
207 | + break; |
|
208 | + default: |
|
209 | + $binaryPath = '/usr/sbin/sendmail'; |
|
210 | + break; |
|
211 | + } |
|
212 | + |
|
213 | + return \Swift_SendmailTransport::newInstance($binaryPath . ' -bs'); |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Returns the mail transport |
|
218 | + * |
|
219 | + * @return \Swift_MailTransport |
|
220 | + */ |
|
221 | + protected function getMailInstance() { |
|
222 | + return \Swift_MailTransport::newInstance(); |
|
223 | + } |
|
224 | 224 | |
225 | 225 | } |
@@ -34,235 +34,235 @@ |
||
34 | 34 | |
35 | 35 | class JSConfigHelper { |
36 | 36 | |
37 | - /** @var IL10N */ |
|
38 | - private $l; |
|
37 | + /** @var IL10N */ |
|
38 | + private $l; |
|
39 | 39 | |
40 | - /** @var Defaults */ |
|
41 | - private $defaults; |
|
40 | + /** @var Defaults */ |
|
41 | + private $defaults; |
|
42 | 42 | |
43 | - /** @var IAppManager */ |
|
44 | - private $appManager; |
|
43 | + /** @var IAppManager */ |
|
44 | + private $appManager; |
|
45 | 45 | |
46 | - /** @var ISession */ |
|
47 | - private $session; |
|
46 | + /** @var ISession */ |
|
47 | + private $session; |
|
48 | 48 | |
49 | - /** @var IUser|null */ |
|
50 | - private $currentUser; |
|
49 | + /** @var IUser|null */ |
|
50 | + private $currentUser; |
|
51 | 51 | |
52 | - /** @var IConfig */ |
|
53 | - private $config; |
|
52 | + /** @var IConfig */ |
|
53 | + private $config; |
|
54 | 54 | |
55 | - /** @var IGroupManager */ |
|
56 | - private $groupManager; |
|
55 | + /** @var IGroupManager */ |
|
56 | + private $groupManager; |
|
57 | 57 | |
58 | - /** @var IniGetWrapper */ |
|
59 | - private $iniWrapper; |
|
58 | + /** @var IniGetWrapper */ |
|
59 | + private $iniWrapper; |
|
60 | 60 | |
61 | - /** @var IURLGenerator */ |
|
62 | - private $urlGenerator; |
|
61 | + /** @var IURLGenerator */ |
|
62 | + private $urlGenerator; |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param IL10N $l |
|
66 | - * @param Defaults $defaults |
|
67 | - * @param IAppManager $appManager |
|
68 | - * @param ISession $session |
|
69 | - * @param IUser|null $currentUser |
|
70 | - * @param IConfig $config |
|
71 | - * @param IGroupManager $groupManager |
|
72 | - * @param IniGetWrapper $iniWrapper |
|
73 | - * @param IURLGenerator $urlGenerator |
|
74 | - */ |
|
75 | - public function __construct(IL10N $l, |
|
76 | - Defaults $defaults, |
|
77 | - IAppManager $appManager, |
|
78 | - ISession $session, |
|
79 | - $currentUser, |
|
80 | - IConfig $config, |
|
81 | - IGroupManager $groupManager, |
|
82 | - IniGetWrapper $iniWrapper, |
|
83 | - IURLGenerator $urlGenerator) { |
|
84 | - $this->l = $l; |
|
85 | - $this->defaults = $defaults; |
|
86 | - $this->appManager = $appManager; |
|
87 | - $this->session = $session; |
|
88 | - $this->currentUser = $currentUser; |
|
89 | - $this->config = $config; |
|
90 | - $this->groupManager = $groupManager; |
|
91 | - $this->iniWrapper = $iniWrapper; |
|
92 | - $this->urlGenerator = $urlGenerator; |
|
93 | - } |
|
64 | + /** |
|
65 | + * @param IL10N $l |
|
66 | + * @param Defaults $defaults |
|
67 | + * @param IAppManager $appManager |
|
68 | + * @param ISession $session |
|
69 | + * @param IUser|null $currentUser |
|
70 | + * @param IConfig $config |
|
71 | + * @param IGroupManager $groupManager |
|
72 | + * @param IniGetWrapper $iniWrapper |
|
73 | + * @param IURLGenerator $urlGenerator |
|
74 | + */ |
|
75 | + public function __construct(IL10N $l, |
|
76 | + Defaults $defaults, |
|
77 | + IAppManager $appManager, |
|
78 | + ISession $session, |
|
79 | + $currentUser, |
|
80 | + IConfig $config, |
|
81 | + IGroupManager $groupManager, |
|
82 | + IniGetWrapper $iniWrapper, |
|
83 | + IURLGenerator $urlGenerator) { |
|
84 | + $this->l = $l; |
|
85 | + $this->defaults = $defaults; |
|
86 | + $this->appManager = $appManager; |
|
87 | + $this->session = $session; |
|
88 | + $this->currentUser = $currentUser; |
|
89 | + $this->config = $config; |
|
90 | + $this->groupManager = $groupManager; |
|
91 | + $this->iniWrapper = $iniWrapper; |
|
92 | + $this->urlGenerator = $urlGenerator; |
|
93 | + } |
|
94 | 94 | |
95 | - public function getConfig() { |
|
95 | + public function getConfig() { |
|
96 | 96 | |
97 | - if ($this->currentUser !== null) { |
|
98 | - $uid = $this->currentUser->getUID(); |
|
99 | - } else { |
|
100 | - $uid = null; |
|
101 | - } |
|
97 | + if ($this->currentUser !== null) { |
|
98 | + $uid = $this->currentUser->getUID(); |
|
99 | + } else { |
|
100 | + $uid = null; |
|
101 | + } |
|
102 | 102 | |
103 | - // Get the config |
|
104 | - $apps_paths = []; |
|
103 | + // Get the config |
|
104 | + $apps_paths = []; |
|
105 | 105 | |
106 | - if ($this->currentUser === null) { |
|
107 | - $apps = $this->appManager->getInstalledApps(); |
|
108 | - } else { |
|
109 | - $apps = $this->appManager->getEnabledAppsForUser($this->currentUser); |
|
110 | - } |
|
106 | + if ($this->currentUser === null) { |
|
107 | + $apps = $this->appManager->getInstalledApps(); |
|
108 | + } else { |
|
109 | + $apps = $this->appManager->getEnabledAppsForUser($this->currentUser); |
|
110 | + } |
|
111 | 111 | |
112 | - foreach($apps as $app) { |
|
113 | - $apps_paths[$app] = \OC_App::getAppWebPath($app); |
|
114 | - } |
|
112 | + foreach($apps as $app) { |
|
113 | + $apps_paths[$app] = \OC_App::getAppWebPath($app); |
|
114 | + } |
|
115 | 115 | |
116 | 116 | |
117 | - $enableLinkPasswordByDefault = $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'); |
|
118 | - $enableLinkPasswordByDefault = ($enableLinkPasswordByDefault === 'yes') ? true : false; |
|
119 | - $defaultExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; |
|
120 | - $defaultExpireDate = $enforceDefaultExpireDate = null; |
|
121 | - if ($defaultExpireDateEnabled) { |
|
122 | - $defaultExpireDate = (int) $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
|
123 | - $enforceDefaultExpireDate = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; |
|
124 | - } |
|
125 | - $outgoingServer2serverShareEnabled = $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes'; |
|
117 | + $enableLinkPasswordByDefault = $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'); |
|
118 | + $enableLinkPasswordByDefault = ($enableLinkPasswordByDefault === 'yes') ? true : false; |
|
119 | + $defaultExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; |
|
120 | + $defaultExpireDate = $enforceDefaultExpireDate = null; |
|
121 | + if ($defaultExpireDateEnabled) { |
|
122 | + $defaultExpireDate = (int) $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
|
123 | + $enforceDefaultExpireDate = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; |
|
124 | + } |
|
125 | + $outgoingServer2serverShareEnabled = $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes'; |
|
126 | 126 | |
127 | - $countOfDataLocation = 0; |
|
128 | - $dataLocation = str_replace(\OC::$SERVERROOT .'/', '', $this->config->getSystemValue('datadirectory', ''), $countOfDataLocation); |
|
129 | - if($countOfDataLocation !== 1 || !$this->groupManager->isAdmin($uid)) { |
|
130 | - $dataLocation = false; |
|
131 | - } |
|
127 | + $countOfDataLocation = 0; |
|
128 | + $dataLocation = str_replace(\OC::$SERVERROOT .'/', '', $this->config->getSystemValue('datadirectory', ''), $countOfDataLocation); |
|
129 | + if($countOfDataLocation !== 1 || !$this->groupManager->isAdmin($uid)) { |
|
130 | + $dataLocation = false; |
|
131 | + } |
|
132 | 132 | |
133 | - if ($this->currentUser instanceof IUser) { |
|
134 | - $lastConfirmTimestamp = $this->session->get('last-password-confirm'); |
|
135 | - if (!is_int($lastConfirmTimestamp)) { |
|
136 | - $lastConfirmTimestamp = 0; |
|
137 | - } |
|
138 | - } else { |
|
139 | - $lastConfirmTimestamp = 0; |
|
140 | - } |
|
133 | + if ($this->currentUser instanceof IUser) { |
|
134 | + $lastConfirmTimestamp = $this->session->get('last-password-confirm'); |
|
135 | + if (!is_int($lastConfirmTimestamp)) { |
|
136 | + $lastConfirmTimestamp = 0; |
|
137 | + } |
|
138 | + } else { |
|
139 | + $lastConfirmTimestamp = 0; |
|
140 | + } |
|
141 | 141 | |
142 | - $array = [ |
|
143 | - "oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false', |
|
144 | - "oc_isadmin" => $this->groupManager->isAdmin($uid) ? 'true' : 'false', |
|
145 | - "oc_dataURL" => is_string($dataLocation) ? "\"".$dataLocation."\"" : 'false', |
|
146 | - "oc_webroot" => "\"".\OC::$WEBROOT."\"", |
|
147 | - "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution |
|
148 | - "datepickerFormatDate" => json_encode($this->l->l('jsdate', null)), |
|
149 | - 'nc_lastLogin' => $lastConfirmTimestamp, |
|
150 | - "dayNames" => json_encode([ |
|
151 | - (string)$this->l->t('Sunday'), |
|
152 | - (string)$this->l->t('Monday'), |
|
153 | - (string)$this->l->t('Tuesday'), |
|
154 | - (string)$this->l->t('Wednesday'), |
|
155 | - (string)$this->l->t('Thursday'), |
|
156 | - (string)$this->l->t('Friday'), |
|
157 | - (string)$this->l->t('Saturday') |
|
158 | - ]), |
|
159 | - "dayNamesShort" => json_encode([ |
|
160 | - (string)$this->l->t('Sun.'), |
|
161 | - (string)$this->l->t('Mon.'), |
|
162 | - (string)$this->l->t('Tue.'), |
|
163 | - (string)$this->l->t('Wed.'), |
|
164 | - (string)$this->l->t('Thu.'), |
|
165 | - (string)$this->l->t('Fri.'), |
|
166 | - (string)$this->l->t('Sat.') |
|
167 | - ]), |
|
168 | - "dayNamesMin" => json_encode([ |
|
169 | - (string)$this->l->t('Su'), |
|
170 | - (string)$this->l->t('Mo'), |
|
171 | - (string)$this->l->t('Tu'), |
|
172 | - (string)$this->l->t('We'), |
|
173 | - (string)$this->l->t('Th'), |
|
174 | - (string)$this->l->t('Fr'), |
|
175 | - (string)$this->l->t('Sa') |
|
176 | - ]), |
|
177 | - "monthNames" => json_encode([ |
|
178 | - (string)$this->l->t('January'), |
|
179 | - (string)$this->l->t('February'), |
|
180 | - (string)$this->l->t('March'), |
|
181 | - (string)$this->l->t('April'), |
|
182 | - (string)$this->l->t('May'), |
|
183 | - (string)$this->l->t('June'), |
|
184 | - (string)$this->l->t('July'), |
|
185 | - (string)$this->l->t('August'), |
|
186 | - (string)$this->l->t('September'), |
|
187 | - (string)$this->l->t('October'), |
|
188 | - (string)$this->l->t('November'), |
|
189 | - (string)$this->l->t('December') |
|
190 | - ]), |
|
191 | - "monthNamesShort" => json_encode([ |
|
192 | - (string)$this->l->t('Jan.'), |
|
193 | - (string)$this->l->t('Feb.'), |
|
194 | - (string)$this->l->t('Mar.'), |
|
195 | - (string)$this->l->t('Apr.'), |
|
196 | - (string)$this->l->t('May.'), |
|
197 | - (string)$this->l->t('Jun.'), |
|
198 | - (string)$this->l->t('Jul.'), |
|
199 | - (string)$this->l->t('Aug.'), |
|
200 | - (string)$this->l->t('Sep.'), |
|
201 | - (string)$this->l->t('Oct.'), |
|
202 | - (string)$this->l->t('Nov.'), |
|
203 | - (string)$this->l->t('Dec.') |
|
204 | - ]), |
|
205 | - "firstDay" => json_encode($this->l->l('firstday', null)) , |
|
206 | - "oc_config" => json_encode([ |
|
207 | - 'session_lifetime' => min($this->config->getSystemValue('session_lifetime', $this->iniWrapper->getNumeric('session.gc_maxlifetime')), $this->iniWrapper->getNumeric('session.gc_maxlifetime')), |
|
208 | - 'session_keepalive' => $this->config->getSystemValue('session_keepalive', true), |
|
209 | - 'version' => implode('.', \OCP\Util::getVersion()), |
|
210 | - 'versionstring' => \OC_Util::getVersionString(), |
|
211 | - 'enable_avatars' => true, // here for legacy reasons - to not crash existing code that relies on this value |
|
212 | - 'lost_password_link'=> $this->config->getSystemValue('lost_password_link', null), |
|
213 | - 'modRewriteWorking' => ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'), |
|
214 | - 'sharing.maxAutocompleteResults' => intval($this->config->getSystemValue('sharing.maxAutocompleteResults', 0)), |
|
215 | - 'sharing.minSearchStringLength' => intval($this->config->getSystemValue('sharing.minSearchStringLength', 0)), |
|
216 | - 'blacklist_files_regex' => \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX, |
|
217 | - ]), |
|
218 | - "oc_appconfig" => json_encode([ |
|
219 | - 'core' => [ |
|
220 | - 'defaultExpireDateEnabled' => $defaultExpireDateEnabled, |
|
221 | - 'defaultExpireDate' => $defaultExpireDate, |
|
222 | - 'defaultExpireDateEnforced' => $enforceDefaultExpireDate, |
|
223 | - 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(), |
|
224 | - 'enableLinkPasswordByDefault' => $enableLinkPasswordByDefault, |
|
225 | - 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(), |
|
226 | - 'resharingAllowed' => \OCP\Share::isResharingAllowed(), |
|
227 | - 'remoteShareAllowed' => $outgoingServer2serverShareEnabled, |
|
228 | - 'federatedCloudShareDoc' => $this->urlGenerator->linkToDocs('user-sharing-federated'), |
|
229 | - 'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing() |
|
230 | - ] |
|
231 | - ]), |
|
232 | - "oc_defaults" => json_encode([ |
|
233 | - 'entity' => $this->defaults->getEntity(), |
|
234 | - 'name' => $this->defaults->getName(), |
|
235 | - 'title' => $this->defaults->getTitle(), |
|
236 | - 'baseUrl' => $this->defaults->getBaseUrl(), |
|
237 | - 'syncClientUrl' => $this->defaults->getSyncClientUrl(), |
|
238 | - 'docBaseUrl' => $this->defaults->getDocBaseUrl(), |
|
239 | - 'docPlaceholderUrl' => $this->defaults->buildDocLinkToKey('PLACEHOLDER'), |
|
240 | - 'slogan' => $this->defaults->getSlogan(), |
|
241 | - 'logoClaim' => $this->defaults->getLogoClaim(), |
|
242 | - 'shortFooter' => $this->defaults->getShortFooter(), |
|
243 | - 'longFooter' => $this->defaults->getLongFooter(), |
|
244 | - 'folder' => \OC_Util::getTheme(), |
|
245 | - ]), |
|
246 | - ]; |
|
142 | + $array = [ |
|
143 | + "oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false', |
|
144 | + "oc_isadmin" => $this->groupManager->isAdmin($uid) ? 'true' : 'false', |
|
145 | + "oc_dataURL" => is_string($dataLocation) ? "\"".$dataLocation."\"" : 'false', |
|
146 | + "oc_webroot" => "\"".\OC::$WEBROOT."\"", |
|
147 | + "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution |
|
148 | + "datepickerFormatDate" => json_encode($this->l->l('jsdate', null)), |
|
149 | + 'nc_lastLogin' => $lastConfirmTimestamp, |
|
150 | + "dayNames" => json_encode([ |
|
151 | + (string)$this->l->t('Sunday'), |
|
152 | + (string)$this->l->t('Monday'), |
|
153 | + (string)$this->l->t('Tuesday'), |
|
154 | + (string)$this->l->t('Wednesday'), |
|
155 | + (string)$this->l->t('Thursday'), |
|
156 | + (string)$this->l->t('Friday'), |
|
157 | + (string)$this->l->t('Saturday') |
|
158 | + ]), |
|
159 | + "dayNamesShort" => json_encode([ |
|
160 | + (string)$this->l->t('Sun.'), |
|
161 | + (string)$this->l->t('Mon.'), |
|
162 | + (string)$this->l->t('Tue.'), |
|
163 | + (string)$this->l->t('Wed.'), |
|
164 | + (string)$this->l->t('Thu.'), |
|
165 | + (string)$this->l->t('Fri.'), |
|
166 | + (string)$this->l->t('Sat.') |
|
167 | + ]), |
|
168 | + "dayNamesMin" => json_encode([ |
|
169 | + (string)$this->l->t('Su'), |
|
170 | + (string)$this->l->t('Mo'), |
|
171 | + (string)$this->l->t('Tu'), |
|
172 | + (string)$this->l->t('We'), |
|
173 | + (string)$this->l->t('Th'), |
|
174 | + (string)$this->l->t('Fr'), |
|
175 | + (string)$this->l->t('Sa') |
|
176 | + ]), |
|
177 | + "monthNames" => json_encode([ |
|
178 | + (string)$this->l->t('January'), |
|
179 | + (string)$this->l->t('February'), |
|
180 | + (string)$this->l->t('March'), |
|
181 | + (string)$this->l->t('April'), |
|
182 | + (string)$this->l->t('May'), |
|
183 | + (string)$this->l->t('June'), |
|
184 | + (string)$this->l->t('July'), |
|
185 | + (string)$this->l->t('August'), |
|
186 | + (string)$this->l->t('September'), |
|
187 | + (string)$this->l->t('October'), |
|
188 | + (string)$this->l->t('November'), |
|
189 | + (string)$this->l->t('December') |
|
190 | + ]), |
|
191 | + "monthNamesShort" => json_encode([ |
|
192 | + (string)$this->l->t('Jan.'), |
|
193 | + (string)$this->l->t('Feb.'), |
|
194 | + (string)$this->l->t('Mar.'), |
|
195 | + (string)$this->l->t('Apr.'), |
|
196 | + (string)$this->l->t('May.'), |
|
197 | + (string)$this->l->t('Jun.'), |
|
198 | + (string)$this->l->t('Jul.'), |
|
199 | + (string)$this->l->t('Aug.'), |
|
200 | + (string)$this->l->t('Sep.'), |
|
201 | + (string)$this->l->t('Oct.'), |
|
202 | + (string)$this->l->t('Nov.'), |
|
203 | + (string)$this->l->t('Dec.') |
|
204 | + ]), |
|
205 | + "firstDay" => json_encode($this->l->l('firstday', null)) , |
|
206 | + "oc_config" => json_encode([ |
|
207 | + 'session_lifetime' => min($this->config->getSystemValue('session_lifetime', $this->iniWrapper->getNumeric('session.gc_maxlifetime')), $this->iniWrapper->getNumeric('session.gc_maxlifetime')), |
|
208 | + 'session_keepalive' => $this->config->getSystemValue('session_keepalive', true), |
|
209 | + 'version' => implode('.', \OCP\Util::getVersion()), |
|
210 | + 'versionstring' => \OC_Util::getVersionString(), |
|
211 | + 'enable_avatars' => true, // here for legacy reasons - to not crash existing code that relies on this value |
|
212 | + 'lost_password_link'=> $this->config->getSystemValue('lost_password_link', null), |
|
213 | + 'modRewriteWorking' => ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'), |
|
214 | + 'sharing.maxAutocompleteResults' => intval($this->config->getSystemValue('sharing.maxAutocompleteResults', 0)), |
|
215 | + 'sharing.minSearchStringLength' => intval($this->config->getSystemValue('sharing.minSearchStringLength', 0)), |
|
216 | + 'blacklist_files_regex' => \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX, |
|
217 | + ]), |
|
218 | + "oc_appconfig" => json_encode([ |
|
219 | + 'core' => [ |
|
220 | + 'defaultExpireDateEnabled' => $defaultExpireDateEnabled, |
|
221 | + 'defaultExpireDate' => $defaultExpireDate, |
|
222 | + 'defaultExpireDateEnforced' => $enforceDefaultExpireDate, |
|
223 | + 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(), |
|
224 | + 'enableLinkPasswordByDefault' => $enableLinkPasswordByDefault, |
|
225 | + 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(), |
|
226 | + 'resharingAllowed' => \OCP\Share::isResharingAllowed(), |
|
227 | + 'remoteShareAllowed' => $outgoingServer2serverShareEnabled, |
|
228 | + 'federatedCloudShareDoc' => $this->urlGenerator->linkToDocs('user-sharing-federated'), |
|
229 | + 'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing() |
|
230 | + ] |
|
231 | + ]), |
|
232 | + "oc_defaults" => json_encode([ |
|
233 | + 'entity' => $this->defaults->getEntity(), |
|
234 | + 'name' => $this->defaults->getName(), |
|
235 | + 'title' => $this->defaults->getTitle(), |
|
236 | + 'baseUrl' => $this->defaults->getBaseUrl(), |
|
237 | + 'syncClientUrl' => $this->defaults->getSyncClientUrl(), |
|
238 | + 'docBaseUrl' => $this->defaults->getDocBaseUrl(), |
|
239 | + 'docPlaceholderUrl' => $this->defaults->buildDocLinkToKey('PLACEHOLDER'), |
|
240 | + 'slogan' => $this->defaults->getSlogan(), |
|
241 | + 'logoClaim' => $this->defaults->getLogoClaim(), |
|
242 | + 'shortFooter' => $this->defaults->getShortFooter(), |
|
243 | + 'longFooter' => $this->defaults->getLongFooter(), |
|
244 | + 'folder' => \OC_Util::getTheme(), |
|
245 | + ]), |
|
246 | + ]; |
|
247 | 247 | |
248 | - if ($this->currentUser !== null) { |
|
249 | - $array['oc_userconfig'] = json_encode([ |
|
250 | - 'avatar' => [ |
|
251 | - 'version' => (int)$this->config->getUserValue($uid, 'avatar', 'version', 0), |
|
252 | - ] |
|
253 | - ]); |
|
254 | - } |
|
248 | + if ($this->currentUser !== null) { |
|
249 | + $array['oc_userconfig'] = json_encode([ |
|
250 | + 'avatar' => [ |
|
251 | + 'version' => (int)$this->config->getUserValue($uid, 'avatar', 'version', 0), |
|
252 | + ] |
|
253 | + ]); |
|
254 | + } |
|
255 | 255 | |
256 | - // Allow hooks to modify the output values |
|
257 | - \OC_Hook::emit('\OCP\Config', 'js', array('array' => &$array)); |
|
256 | + // Allow hooks to modify the output values |
|
257 | + \OC_Hook::emit('\OCP\Config', 'js', array('array' => &$array)); |
|
258 | 258 | |
259 | - $result = ''; |
|
259 | + $result = ''; |
|
260 | 260 | |
261 | - // Echo it |
|
262 | - foreach ($array as $setting => $value) { |
|
263 | - $result .= 'var '. $setting . '='. $value . ';' . PHP_EOL; |
|
264 | - } |
|
261 | + // Echo it |
|
262 | + foreach ($array as $setting => $value) { |
|
263 | + $result .= 'var '. $setting . '='. $value . ';' . PHP_EOL; |
|
264 | + } |
|
265 | 265 | |
266 | - return $result; |
|
267 | - } |
|
266 | + return $result; |
|
267 | + } |
|
268 | 268 | } |
@@ -31,158 +31,158 @@ |
||
31 | 31 | use OCP\Defaults; |
32 | 32 | |
33 | 33 | class Base { |
34 | - private $template; // The template |
|
35 | - private $vars; // Vars |
|
36 | - |
|
37 | - /** @var \OCP\IL10N */ |
|
38 | - private $l10n; |
|
39 | - |
|
40 | - /** @var Defaults */ |
|
41 | - private $theme; |
|
42 | - |
|
43 | - /** |
|
44 | - * @param string $template |
|
45 | - * @param string $requestToken |
|
46 | - * @param \OCP\IL10N $l10n |
|
47 | - * @param Defaults $theme |
|
48 | - */ |
|
49 | - public function __construct($template, $requestToken, $l10n, $theme ) { |
|
50 | - $this->vars = array(); |
|
51 | - $this->vars['requesttoken'] = $requestToken; |
|
52 | - $this->l10n = $l10n; |
|
53 | - $this->template = $template; |
|
54 | - $this->theme = $theme; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param string $serverRoot |
|
59 | - * @param string|false $app_dir |
|
60 | - * @param string $theme |
|
61 | - * @param string $app |
|
62 | - * @return string[] |
|
63 | - */ |
|
64 | - protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) { |
|
65 | - // Check if the app is in the app folder or in the root |
|
66 | - if( file_exists($app_dir.'/templates/' )) { |
|
67 | - return [ |
|
68 | - $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/', |
|
69 | - $app_dir.'/templates/', |
|
70 | - ]; |
|
71 | - } |
|
72 | - return [ |
|
73 | - $serverRoot.'/themes/'.$theme.'/'.$app.'/templates/', |
|
74 | - $serverRoot.'/'.$app.'/templates/', |
|
75 | - ]; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @param string $serverRoot |
|
80 | - * @param string $theme |
|
81 | - * @return string[] |
|
82 | - */ |
|
83 | - protected function getCoreTemplateDirs($theme, $serverRoot) { |
|
84 | - return [ |
|
85 | - $serverRoot.'/themes/'.$theme.'/core/templates/', |
|
86 | - $serverRoot.'/core/templates/', |
|
87 | - ]; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Assign variables |
|
92 | - * @param string $key key |
|
93 | - * @param array|bool|integer|string $value value |
|
94 | - * @return bool |
|
95 | - * |
|
96 | - * This function assigns a variable. It can be accessed via $_[$key] in |
|
97 | - * the template. |
|
98 | - * |
|
99 | - * If the key existed before, it will be overwritten |
|
100 | - */ |
|
101 | - public function assign( $key, $value) { |
|
102 | - $this->vars[$key] = $value; |
|
103 | - return true; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Appends a variable |
|
108 | - * @param string $key key |
|
109 | - * @param mixed $value value |
|
110 | - * @return boolean|null |
|
111 | - * |
|
112 | - * This function assigns a variable in an array context. If the key already |
|
113 | - * exists, the value will be appended. It can be accessed via |
|
114 | - * $_[$key][$position] in the template. |
|
115 | - */ |
|
116 | - public function append( $key, $value ) { |
|
117 | - if( array_key_exists( $key, $this->vars )) { |
|
118 | - $this->vars[$key][] = $value; |
|
119 | - } |
|
120 | - else{ |
|
121 | - $this->vars[$key] = array( $value ); |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Prints the proceeded template |
|
127 | - * @return bool |
|
128 | - * |
|
129 | - * This function proceeds the template and prints its output. |
|
130 | - */ |
|
131 | - public function printPage() { |
|
132 | - $data = $this->fetchPage(); |
|
133 | - if( $data === false ) { |
|
134 | - return false; |
|
135 | - } |
|
136 | - else{ |
|
137 | - print $data; |
|
138 | - return true; |
|
139 | - } |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Process the template |
|
144 | - * |
|
145 | - * @param array|null $additionalParams |
|
146 | - * @return string This function processes the template. |
|
147 | - * |
|
148 | - * This function processes the template. |
|
149 | - */ |
|
150 | - public function fetchPage($additionalParams = null) { |
|
151 | - return $this->load($this->template, $additionalParams); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * doing the actual work |
|
156 | - * |
|
157 | - * @param string $file |
|
158 | - * @param array|null $additionalParams |
|
159 | - * @return string content |
|
160 | - * |
|
161 | - * Includes the template file, fetches its output |
|
162 | - */ |
|
163 | - protected function load($file, $additionalParams = null) { |
|
164 | - // Register the variables |
|
165 | - $_ = $this->vars; |
|
166 | - $l = $this->l10n; |
|
167 | - $theme = $this->theme; |
|
168 | - |
|
169 | - if( !is_null($additionalParams)) { |
|
170 | - $_ = array_merge( $additionalParams, $this->vars ); |
|
171 | - } |
|
172 | - |
|
173 | - // Include |
|
174 | - ob_start(); |
|
175 | - try { |
|
176 | - include $file; |
|
177 | - $data = ob_get_contents(); |
|
178 | - } catch (\Exception $e) { |
|
179 | - @ob_end_clean(); |
|
180 | - throw $e; |
|
181 | - } |
|
182 | - @ob_end_clean(); |
|
183 | - |
|
184 | - // Return data |
|
185 | - return $data; |
|
186 | - } |
|
34 | + private $template; // The template |
|
35 | + private $vars; // Vars |
|
36 | + |
|
37 | + /** @var \OCP\IL10N */ |
|
38 | + private $l10n; |
|
39 | + |
|
40 | + /** @var Defaults */ |
|
41 | + private $theme; |
|
42 | + |
|
43 | + /** |
|
44 | + * @param string $template |
|
45 | + * @param string $requestToken |
|
46 | + * @param \OCP\IL10N $l10n |
|
47 | + * @param Defaults $theme |
|
48 | + */ |
|
49 | + public function __construct($template, $requestToken, $l10n, $theme ) { |
|
50 | + $this->vars = array(); |
|
51 | + $this->vars['requesttoken'] = $requestToken; |
|
52 | + $this->l10n = $l10n; |
|
53 | + $this->template = $template; |
|
54 | + $this->theme = $theme; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param string $serverRoot |
|
59 | + * @param string|false $app_dir |
|
60 | + * @param string $theme |
|
61 | + * @param string $app |
|
62 | + * @return string[] |
|
63 | + */ |
|
64 | + protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) { |
|
65 | + // Check if the app is in the app folder or in the root |
|
66 | + if( file_exists($app_dir.'/templates/' )) { |
|
67 | + return [ |
|
68 | + $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/', |
|
69 | + $app_dir.'/templates/', |
|
70 | + ]; |
|
71 | + } |
|
72 | + return [ |
|
73 | + $serverRoot.'/themes/'.$theme.'/'.$app.'/templates/', |
|
74 | + $serverRoot.'/'.$app.'/templates/', |
|
75 | + ]; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @param string $serverRoot |
|
80 | + * @param string $theme |
|
81 | + * @return string[] |
|
82 | + */ |
|
83 | + protected function getCoreTemplateDirs($theme, $serverRoot) { |
|
84 | + return [ |
|
85 | + $serverRoot.'/themes/'.$theme.'/core/templates/', |
|
86 | + $serverRoot.'/core/templates/', |
|
87 | + ]; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Assign variables |
|
92 | + * @param string $key key |
|
93 | + * @param array|bool|integer|string $value value |
|
94 | + * @return bool |
|
95 | + * |
|
96 | + * This function assigns a variable. It can be accessed via $_[$key] in |
|
97 | + * the template. |
|
98 | + * |
|
99 | + * If the key existed before, it will be overwritten |
|
100 | + */ |
|
101 | + public function assign( $key, $value) { |
|
102 | + $this->vars[$key] = $value; |
|
103 | + return true; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Appends a variable |
|
108 | + * @param string $key key |
|
109 | + * @param mixed $value value |
|
110 | + * @return boolean|null |
|
111 | + * |
|
112 | + * This function assigns a variable in an array context. If the key already |
|
113 | + * exists, the value will be appended. It can be accessed via |
|
114 | + * $_[$key][$position] in the template. |
|
115 | + */ |
|
116 | + public function append( $key, $value ) { |
|
117 | + if( array_key_exists( $key, $this->vars )) { |
|
118 | + $this->vars[$key][] = $value; |
|
119 | + } |
|
120 | + else{ |
|
121 | + $this->vars[$key] = array( $value ); |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Prints the proceeded template |
|
127 | + * @return bool |
|
128 | + * |
|
129 | + * This function proceeds the template and prints its output. |
|
130 | + */ |
|
131 | + public function printPage() { |
|
132 | + $data = $this->fetchPage(); |
|
133 | + if( $data === false ) { |
|
134 | + return false; |
|
135 | + } |
|
136 | + else{ |
|
137 | + print $data; |
|
138 | + return true; |
|
139 | + } |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * Process the template |
|
144 | + * |
|
145 | + * @param array|null $additionalParams |
|
146 | + * @return string This function processes the template. |
|
147 | + * |
|
148 | + * This function processes the template. |
|
149 | + */ |
|
150 | + public function fetchPage($additionalParams = null) { |
|
151 | + return $this->load($this->template, $additionalParams); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * doing the actual work |
|
156 | + * |
|
157 | + * @param string $file |
|
158 | + * @param array|null $additionalParams |
|
159 | + * @return string content |
|
160 | + * |
|
161 | + * Includes the template file, fetches its output |
|
162 | + */ |
|
163 | + protected function load($file, $additionalParams = null) { |
|
164 | + // Register the variables |
|
165 | + $_ = $this->vars; |
|
166 | + $l = $this->l10n; |
|
167 | + $theme = $this->theme; |
|
168 | + |
|
169 | + if( !is_null($additionalParams)) { |
|
170 | + $_ = array_merge( $additionalParams, $this->vars ); |
|
171 | + } |
|
172 | + |
|
173 | + // Include |
|
174 | + ob_start(); |
|
175 | + try { |
|
176 | + include $file; |
|
177 | + $data = ob_get_contents(); |
|
178 | + } catch (\Exception $e) { |
|
179 | + @ob_end_clean(); |
|
180 | + throw $e; |
|
181 | + } |
|
182 | + @ob_end_clean(); |
|
183 | + |
|
184 | + // Return data |
|
185 | + return $data; |
|
186 | + } |
|
187 | 187 | |
188 | 188 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param \OCP\IL10N $l10n |
47 | 47 | * @param Defaults $theme |
48 | 48 | */ |
49 | - public function __construct($template, $requestToken, $l10n, $theme ) { |
|
49 | + public function __construct($template, $requestToken, $l10n, $theme) { |
|
50 | 50 | $this->vars = array(); |
51 | 51 | $this->vars['requesttoken'] = $requestToken; |
52 | 52 | $this->l10n = $l10n; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) { |
65 | 65 | // Check if the app is in the app folder or in the root |
66 | - if( file_exists($app_dir.'/templates/' )) { |
|
66 | + if (file_exists($app_dir.'/templates/')) { |
|
67 | 67 | return [ |
68 | 68 | $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/', |
69 | 69 | $app_dir.'/templates/', |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * If the key existed before, it will be overwritten |
100 | 100 | */ |
101 | - public function assign( $key, $value) { |
|
101 | + public function assign($key, $value) { |
|
102 | 102 | $this->vars[$key] = $value; |
103 | 103 | return true; |
104 | 104 | } |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | * exists, the value will be appended. It can be accessed via |
114 | 114 | * $_[$key][$position] in the template. |
115 | 115 | */ |
116 | - public function append( $key, $value ) { |
|
117 | - if( array_key_exists( $key, $this->vars )) { |
|
116 | + public function append($key, $value) { |
|
117 | + if (array_key_exists($key, $this->vars)) { |
|
118 | 118 | $this->vars[$key][] = $value; |
119 | 119 | } |
120 | - else{ |
|
121 | - $this->vars[$key] = array( $value ); |
|
120 | + else { |
|
121 | + $this->vars[$key] = array($value); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function printPage() { |
132 | 132 | $data = $this->fetchPage(); |
133 | - if( $data === false ) { |
|
133 | + if ($data === false) { |
|
134 | 134 | return false; |
135 | 135 | } |
136 | - else{ |
|
136 | + else { |
|
137 | 137 | print $data; |
138 | 138 | return true; |
139 | 139 | } |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | $l = $this->l10n; |
167 | 167 | $theme = $this->theme; |
168 | 168 | |
169 | - if( !is_null($additionalParams)) { |
|
170 | - $_ = array_merge( $additionalParams, $this->vars ); |
|
169 | + if (!is_null($additionalParams)) { |
|
170 | + $_ = array_merge($additionalParams, $this->vars); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // Include |
@@ -39,59 +39,59 @@ |
||
39 | 39 | |
40 | 40 | class OCJSController extends Controller { |
41 | 41 | |
42 | - /** @var JSConfigHelper */ |
|
43 | - private $helper; |
|
42 | + /** @var JSConfigHelper */ |
|
43 | + private $helper; |
|
44 | 44 | |
45 | - /** |
|
46 | - * OCJSController constructor. |
|
47 | - * |
|
48 | - * @param string $appName |
|
49 | - * @param IRequest $request |
|
50 | - * @param IL10N $l |
|
51 | - * @param Defaults $defaults |
|
52 | - * @param IAppManager $appManager |
|
53 | - * @param ISession $session |
|
54 | - * @param IUserSession $userSession |
|
55 | - * @param IConfig $config |
|
56 | - * @param IGroupManager $groupManager |
|
57 | - * @param IniGetWrapper $iniWrapper |
|
58 | - * @param IURLGenerator $urlGenerator |
|
59 | - */ |
|
60 | - public function __construct($appName, |
|
61 | - IRequest $request, |
|
62 | - IL10N $l, |
|
63 | - Defaults $defaults, |
|
64 | - IAppManager $appManager, |
|
65 | - ISession $session, |
|
66 | - IUserSession $userSession, |
|
67 | - IConfig $config, |
|
68 | - IGroupManager $groupManager, |
|
69 | - IniGetWrapper $iniWrapper, |
|
70 | - IURLGenerator $urlGenerator) { |
|
71 | - parent::__construct($appName, $request); |
|
45 | + /** |
|
46 | + * OCJSController constructor. |
|
47 | + * |
|
48 | + * @param string $appName |
|
49 | + * @param IRequest $request |
|
50 | + * @param IL10N $l |
|
51 | + * @param Defaults $defaults |
|
52 | + * @param IAppManager $appManager |
|
53 | + * @param ISession $session |
|
54 | + * @param IUserSession $userSession |
|
55 | + * @param IConfig $config |
|
56 | + * @param IGroupManager $groupManager |
|
57 | + * @param IniGetWrapper $iniWrapper |
|
58 | + * @param IURLGenerator $urlGenerator |
|
59 | + */ |
|
60 | + public function __construct($appName, |
|
61 | + IRequest $request, |
|
62 | + IL10N $l, |
|
63 | + Defaults $defaults, |
|
64 | + IAppManager $appManager, |
|
65 | + ISession $session, |
|
66 | + IUserSession $userSession, |
|
67 | + IConfig $config, |
|
68 | + IGroupManager $groupManager, |
|
69 | + IniGetWrapper $iniWrapper, |
|
70 | + IURLGenerator $urlGenerator) { |
|
71 | + parent::__construct($appName, $request); |
|
72 | 72 | |
73 | - $this->helper = new JSConfigHelper( |
|
74 | - $l, |
|
75 | - $defaults, |
|
76 | - $appManager, |
|
77 | - $session, |
|
78 | - $userSession->getUser(), |
|
79 | - $config, |
|
80 | - $groupManager, |
|
81 | - $iniWrapper, |
|
82 | - $urlGenerator |
|
83 | - ); |
|
84 | - } |
|
73 | + $this->helper = new JSConfigHelper( |
|
74 | + $l, |
|
75 | + $defaults, |
|
76 | + $appManager, |
|
77 | + $session, |
|
78 | + $userSession->getUser(), |
|
79 | + $config, |
|
80 | + $groupManager, |
|
81 | + $iniWrapper, |
|
82 | + $urlGenerator |
|
83 | + ); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @NoCSRFRequired |
|
88 | - * @PublicPage |
|
89 | - * |
|
90 | - * @return DataDisplayResponse |
|
91 | - */ |
|
92 | - public function getConfig() { |
|
93 | - $data = $this->helper->getConfig(); |
|
86 | + /** |
|
87 | + * @NoCSRFRequired |
|
88 | + * @PublicPage |
|
89 | + * |
|
90 | + * @return DataDisplayResponse |
|
91 | + */ |
|
92 | + public function getConfig() { |
|
93 | + $data = $this->helper->getConfig(); |
|
94 | 94 | |
95 | - return new DataDisplayResponse($data, Http::STATUS_OK, ['Content-type' => 'text/javascript']); |
|
96 | - } |
|
95 | + return new DataDisplayResponse($data, Http::STATUS_OK, ['Content-type' => 'text/javascript']); |
|
96 | + } |
|
97 | 97 | } |
@@ -55,268 +55,268 @@ |
||
55 | 55 | */ |
56 | 56 | class LostController extends Controller { |
57 | 57 | |
58 | - /** @var IURLGenerator */ |
|
59 | - protected $urlGenerator; |
|
60 | - /** @var IUserManager */ |
|
61 | - protected $userManager; |
|
62 | - /** @var Defaults */ |
|
63 | - protected $defaults; |
|
64 | - /** @var IL10N */ |
|
65 | - protected $l10n; |
|
66 | - /** @var string */ |
|
67 | - protected $from; |
|
68 | - /** @var IManager */ |
|
69 | - protected $encryptionManager; |
|
70 | - /** @var IConfig */ |
|
71 | - protected $config; |
|
72 | - /** @var ISecureRandom */ |
|
73 | - protected $secureRandom; |
|
74 | - /** @var IMailer */ |
|
75 | - protected $mailer; |
|
76 | - /** @var ITimeFactory */ |
|
77 | - protected $timeFactory; |
|
78 | - /** @var ICrypto */ |
|
79 | - protected $crypto; |
|
58 | + /** @var IURLGenerator */ |
|
59 | + protected $urlGenerator; |
|
60 | + /** @var IUserManager */ |
|
61 | + protected $userManager; |
|
62 | + /** @var Defaults */ |
|
63 | + protected $defaults; |
|
64 | + /** @var IL10N */ |
|
65 | + protected $l10n; |
|
66 | + /** @var string */ |
|
67 | + protected $from; |
|
68 | + /** @var IManager */ |
|
69 | + protected $encryptionManager; |
|
70 | + /** @var IConfig */ |
|
71 | + protected $config; |
|
72 | + /** @var ISecureRandom */ |
|
73 | + protected $secureRandom; |
|
74 | + /** @var IMailer */ |
|
75 | + protected $mailer; |
|
76 | + /** @var ITimeFactory */ |
|
77 | + protected $timeFactory; |
|
78 | + /** @var ICrypto */ |
|
79 | + protected $crypto; |
|
80 | 80 | |
81 | - /** |
|
82 | - * @param string $appName |
|
83 | - * @param IRequest $request |
|
84 | - * @param IURLGenerator $urlGenerator |
|
85 | - * @param IUserManager $userManager |
|
86 | - * @param Defaults $defaults |
|
87 | - * @param IL10N $l10n |
|
88 | - * @param IConfig $config |
|
89 | - * @param ISecureRandom $secureRandom |
|
90 | - * @param string $defaultMailAddress |
|
91 | - * @param IManager $encryptionManager |
|
92 | - * @param IMailer $mailer |
|
93 | - * @param ITimeFactory $timeFactory |
|
94 | - * @param ICrypto $crypto |
|
95 | - */ |
|
96 | - public function __construct($appName, |
|
97 | - IRequest $request, |
|
98 | - IURLGenerator $urlGenerator, |
|
99 | - IUserManager $userManager, |
|
100 | - Defaults $defaults, |
|
101 | - IL10N $l10n, |
|
102 | - IConfig $config, |
|
103 | - ISecureRandom $secureRandom, |
|
104 | - $defaultMailAddress, |
|
105 | - IManager $encryptionManager, |
|
106 | - IMailer $mailer, |
|
107 | - ITimeFactory $timeFactory, |
|
108 | - ICrypto $crypto) { |
|
109 | - parent::__construct($appName, $request); |
|
110 | - $this->urlGenerator = $urlGenerator; |
|
111 | - $this->userManager = $userManager; |
|
112 | - $this->defaults = $defaults; |
|
113 | - $this->l10n = $l10n; |
|
114 | - $this->secureRandom = $secureRandom; |
|
115 | - $this->from = $defaultMailAddress; |
|
116 | - $this->encryptionManager = $encryptionManager; |
|
117 | - $this->config = $config; |
|
118 | - $this->mailer = $mailer; |
|
119 | - $this->timeFactory = $timeFactory; |
|
120 | - $this->crypto = $crypto; |
|
121 | - } |
|
81 | + /** |
|
82 | + * @param string $appName |
|
83 | + * @param IRequest $request |
|
84 | + * @param IURLGenerator $urlGenerator |
|
85 | + * @param IUserManager $userManager |
|
86 | + * @param Defaults $defaults |
|
87 | + * @param IL10N $l10n |
|
88 | + * @param IConfig $config |
|
89 | + * @param ISecureRandom $secureRandom |
|
90 | + * @param string $defaultMailAddress |
|
91 | + * @param IManager $encryptionManager |
|
92 | + * @param IMailer $mailer |
|
93 | + * @param ITimeFactory $timeFactory |
|
94 | + * @param ICrypto $crypto |
|
95 | + */ |
|
96 | + public function __construct($appName, |
|
97 | + IRequest $request, |
|
98 | + IURLGenerator $urlGenerator, |
|
99 | + IUserManager $userManager, |
|
100 | + Defaults $defaults, |
|
101 | + IL10N $l10n, |
|
102 | + IConfig $config, |
|
103 | + ISecureRandom $secureRandom, |
|
104 | + $defaultMailAddress, |
|
105 | + IManager $encryptionManager, |
|
106 | + IMailer $mailer, |
|
107 | + ITimeFactory $timeFactory, |
|
108 | + ICrypto $crypto) { |
|
109 | + parent::__construct($appName, $request); |
|
110 | + $this->urlGenerator = $urlGenerator; |
|
111 | + $this->userManager = $userManager; |
|
112 | + $this->defaults = $defaults; |
|
113 | + $this->l10n = $l10n; |
|
114 | + $this->secureRandom = $secureRandom; |
|
115 | + $this->from = $defaultMailAddress; |
|
116 | + $this->encryptionManager = $encryptionManager; |
|
117 | + $this->config = $config; |
|
118 | + $this->mailer = $mailer; |
|
119 | + $this->timeFactory = $timeFactory; |
|
120 | + $this->crypto = $crypto; |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Someone wants to reset their password: |
|
125 | - * |
|
126 | - * @PublicPage |
|
127 | - * @NoCSRFRequired |
|
128 | - * |
|
129 | - * @param string $token |
|
130 | - * @param string $userId |
|
131 | - * @return TemplateResponse |
|
132 | - */ |
|
133 | - public function resetform($token, $userId) { |
|
134 | - try { |
|
135 | - $this->checkPasswordResetToken($token, $userId); |
|
136 | - } catch (\Exception $e) { |
|
137 | - return new TemplateResponse( |
|
138 | - 'core', 'error', [ |
|
139 | - "errors" => array(array("error" => $e->getMessage())) |
|
140 | - ], |
|
141 | - 'guest' |
|
142 | - ); |
|
143 | - } |
|
123 | + /** |
|
124 | + * Someone wants to reset their password: |
|
125 | + * |
|
126 | + * @PublicPage |
|
127 | + * @NoCSRFRequired |
|
128 | + * |
|
129 | + * @param string $token |
|
130 | + * @param string $userId |
|
131 | + * @return TemplateResponse |
|
132 | + */ |
|
133 | + public function resetform($token, $userId) { |
|
134 | + try { |
|
135 | + $this->checkPasswordResetToken($token, $userId); |
|
136 | + } catch (\Exception $e) { |
|
137 | + return new TemplateResponse( |
|
138 | + 'core', 'error', [ |
|
139 | + "errors" => array(array("error" => $e->getMessage())) |
|
140 | + ], |
|
141 | + 'guest' |
|
142 | + ); |
|
143 | + } |
|
144 | 144 | |
145 | - return new TemplateResponse( |
|
146 | - 'core', |
|
147 | - 'lostpassword/resetpassword', |
|
148 | - array( |
|
149 | - 'link' => $this->urlGenerator->linkToRouteAbsolute('core.lost.setPassword', array('userId' => $userId, 'token' => $token)), |
|
150 | - ), |
|
151 | - 'guest' |
|
152 | - ); |
|
153 | - } |
|
145 | + return new TemplateResponse( |
|
146 | + 'core', |
|
147 | + 'lostpassword/resetpassword', |
|
148 | + array( |
|
149 | + 'link' => $this->urlGenerator->linkToRouteAbsolute('core.lost.setPassword', array('userId' => $userId, 'token' => $token)), |
|
150 | + ), |
|
151 | + 'guest' |
|
152 | + ); |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * @param string $token |
|
157 | - * @param string $userId |
|
158 | - * @throws \Exception |
|
159 | - */ |
|
160 | - protected function checkPasswordResetToken($token, $userId) { |
|
161 | - $user = $this->userManager->get($userId); |
|
162 | - if($user === null) { |
|
163 | - throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid')); |
|
164 | - } |
|
155 | + /** |
|
156 | + * @param string $token |
|
157 | + * @param string $userId |
|
158 | + * @throws \Exception |
|
159 | + */ |
|
160 | + protected function checkPasswordResetToken($token, $userId) { |
|
161 | + $user = $this->userManager->get($userId); |
|
162 | + if($user === null) { |
|
163 | + throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid')); |
|
164 | + } |
|
165 | 165 | |
166 | - try { |
|
167 | - $encryptedToken = $this->config->getUserValue($userId, 'core', 'lostpassword', null); |
|
168 | - $mailAddress = !is_null($user->getEMailAddress()) ? $user->getEMailAddress() : ''; |
|
169 | - $decryptedToken = $this->crypto->decrypt($encryptedToken, $mailAddress.$this->config->getSystemValue('secret')); |
|
170 | - } catch (\Exception $e) { |
|
171 | - throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid')); |
|
172 | - } |
|
166 | + try { |
|
167 | + $encryptedToken = $this->config->getUserValue($userId, 'core', 'lostpassword', null); |
|
168 | + $mailAddress = !is_null($user->getEMailAddress()) ? $user->getEMailAddress() : ''; |
|
169 | + $decryptedToken = $this->crypto->decrypt($encryptedToken, $mailAddress.$this->config->getSystemValue('secret')); |
|
170 | + } catch (\Exception $e) { |
|
171 | + throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid')); |
|
172 | + } |
|
173 | 173 | |
174 | - $splittedToken = explode(':', $decryptedToken); |
|
175 | - if(count($splittedToken) !== 2) { |
|
176 | - throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid')); |
|
177 | - } |
|
174 | + $splittedToken = explode(':', $decryptedToken); |
|
175 | + if(count($splittedToken) !== 2) { |
|
176 | + throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid')); |
|
177 | + } |
|
178 | 178 | |
179 | - if ($splittedToken[0] < ($this->timeFactory->getTime() - 60*60*12) || |
|
180 | - $user->getLastLogin() > $splittedToken[0]) { |
|
181 | - throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is expired')); |
|
182 | - } |
|
179 | + if ($splittedToken[0] < ($this->timeFactory->getTime() - 60*60*12) || |
|
180 | + $user->getLastLogin() > $splittedToken[0]) { |
|
181 | + throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is expired')); |
|
182 | + } |
|
183 | 183 | |
184 | - if (!hash_equals($splittedToken[1], $token)) { |
|
185 | - throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid')); |
|
186 | - } |
|
187 | - } |
|
184 | + if (!hash_equals($splittedToken[1], $token)) { |
|
185 | + throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid')); |
|
186 | + } |
|
187 | + } |
|
188 | 188 | |
189 | - /** |
|
190 | - * @param $message |
|
191 | - * @param array $additional |
|
192 | - * @return array |
|
193 | - */ |
|
194 | - private function error($message, array $additional=array()) { |
|
195 | - return array_merge(array('status' => 'error', 'msg' => $message), $additional); |
|
196 | - } |
|
189 | + /** |
|
190 | + * @param $message |
|
191 | + * @param array $additional |
|
192 | + * @return array |
|
193 | + */ |
|
194 | + private function error($message, array $additional=array()) { |
|
195 | + return array_merge(array('status' => 'error', 'msg' => $message), $additional); |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * @return array |
|
200 | - */ |
|
201 | - private function success() { |
|
202 | - return array('status'=>'success'); |
|
203 | - } |
|
198 | + /** |
|
199 | + * @return array |
|
200 | + */ |
|
201 | + private function success() { |
|
202 | + return array('status'=>'success'); |
|
203 | + } |
|
204 | 204 | |
205 | - /** |
|
206 | - * @PublicPage |
|
207 | - * @BruteForceProtection passwordResetEmail |
|
208 | - * |
|
209 | - * @param string $user |
|
210 | - * @return array |
|
211 | - */ |
|
212 | - public function email($user){ |
|
213 | - // FIXME: use HTTP error codes |
|
214 | - try { |
|
215 | - $this->sendEmail($user); |
|
216 | - } catch (\Exception $e){ |
|
217 | - return $this->error($e->getMessage()); |
|
218 | - } |
|
205 | + /** |
|
206 | + * @PublicPage |
|
207 | + * @BruteForceProtection passwordResetEmail |
|
208 | + * |
|
209 | + * @param string $user |
|
210 | + * @return array |
|
211 | + */ |
|
212 | + public function email($user){ |
|
213 | + // FIXME: use HTTP error codes |
|
214 | + try { |
|
215 | + $this->sendEmail($user); |
|
216 | + } catch (\Exception $e){ |
|
217 | + return $this->error($e->getMessage()); |
|
218 | + } |
|
219 | 219 | |
220 | - return $this->success(); |
|
221 | - } |
|
220 | + return $this->success(); |
|
221 | + } |
|
222 | 222 | |
223 | - /** |
|
224 | - * @PublicPage |
|
225 | - * @param string $token |
|
226 | - * @param string $userId |
|
227 | - * @param string $password |
|
228 | - * @param boolean $proceed |
|
229 | - * @return array |
|
230 | - */ |
|
231 | - public function setPassword($token, $userId, $password, $proceed) { |
|
232 | - if ($this->encryptionManager->isEnabled() && !$proceed) { |
|
233 | - return $this->error('', array('encryption' => true)); |
|
234 | - } |
|
223 | + /** |
|
224 | + * @PublicPage |
|
225 | + * @param string $token |
|
226 | + * @param string $userId |
|
227 | + * @param string $password |
|
228 | + * @param boolean $proceed |
|
229 | + * @return array |
|
230 | + */ |
|
231 | + public function setPassword($token, $userId, $password, $proceed) { |
|
232 | + if ($this->encryptionManager->isEnabled() && !$proceed) { |
|
233 | + return $this->error('', array('encryption' => true)); |
|
234 | + } |
|
235 | 235 | |
236 | - try { |
|
237 | - $this->checkPasswordResetToken($token, $userId); |
|
238 | - $user = $this->userManager->get($userId); |
|
236 | + try { |
|
237 | + $this->checkPasswordResetToken($token, $userId); |
|
238 | + $user = $this->userManager->get($userId); |
|
239 | 239 | |
240 | - \OC_Hook::emit('\OC\Core\LostPassword\Controller\LostController', 'pre_passwordReset', array('uid' => $userId, 'password' => $password)); |
|
240 | + \OC_Hook::emit('\OC\Core\LostPassword\Controller\LostController', 'pre_passwordReset', array('uid' => $userId, 'password' => $password)); |
|
241 | 241 | |
242 | - if (!$user->setPassword($password)) { |
|
243 | - throw new \Exception(); |
|
244 | - } |
|
242 | + if (!$user->setPassword($password)) { |
|
243 | + throw new \Exception(); |
|
244 | + } |
|
245 | 245 | |
246 | - \OC_Hook::emit('\OC\Core\LostPassword\Controller\LostController', 'post_passwordReset', array('uid' => $userId, 'password' => $password)); |
|
246 | + \OC_Hook::emit('\OC\Core\LostPassword\Controller\LostController', 'post_passwordReset', array('uid' => $userId, 'password' => $password)); |
|
247 | 247 | |
248 | - $this->config->deleteUserValue($userId, 'core', 'lostpassword'); |
|
249 | - @\OC_User::unsetMagicInCookie(); |
|
250 | - } catch (\Exception $e){ |
|
251 | - return $this->error($e->getMessage()); |
|
252 | - } |
|
248 | + $this->config->deleteUserValue($userId, 'core', 'lostpassword'); |
|
249 | + @\OC_User::unsetMagicInCookie(); |
|
250 | + } catch (\Exception $e){ |
|
251 | + return $this->error($e->getMessage()); |
|
252 | + } |
|
253 | 253 | |
254 | - return $this->success(); |
|
255 | - } |
|
254 | + return $this->success(); |
|
255 | + } |
|
256 | 256 | |
257 | - /** |
|
258 | - * @param string $input |
|
259 | - * @throws \Exception |
|
260 | - */ |
|
261 | - protected function sendEmail($input) { |
|
262 | - $user = $this->findUserByIdOrMail($input); |
|
263 | - $email = $user->getEMailAddress(); |
|
257 | + /** |
|
258 | + * @param string $input |
|
259 | + * @throws \Exception |
|
260 | + */ |
|
261 | + protected function sendEmail($input) { |
|
262 | + $user = $this->findUserByIdOrMail($input); |
|
263 | + $email = $user->getEMailAddress(); |
|
264 | 264 | |
265 | - if (empty($email)) { |
|
266 | - throw new \Exception( |
|
267 | - $this->l10n->t('Could not send reset email because there is no email address for this username. Please contact your administrator.') |
|
268 | - ); |
|
269 | - } |
|
265 | + if (empty($email)) { |
|
266 | + throw new \Exception( |
|
267 | + $this->l10n->t('Could not send reset email because there is no email address for this username. Please contact your administrator.') |
|
268 | + ); |
|
269 | + } |
|
270 | 270 | |
271 | - // Generate the token. It is stored encrypted in the database with the |
|
272 | - // secret being the users' email address appended with the system secret. |
|
273 | - // This makes the token automatically invalidate once the user changes |
|
274 | - // their email address. |
|
275 | - $token = $this->secureRandom->generate( |
|
276 | - 21, |
|
277 | - ISecureRandom::CHAR_DIGITS. |
|
278 | - ISecureRandom::CHAR_LOWER. |
|
279 | - ISecureRandom::CHAR_UPPER |
|
280 | - ); |
|
281 | - $tokenValue = $this->timeFactory->getTime() .':'. $token; |
|
282 | - $encryptedValue = $this->crypto->encrypt($tokenValue, $email . $this->config->getSystemValue('secret')); |
|
283 | - $this->config->setUserValue($user->getUID(), 'core', 'lostpassword', $encryptedValue); |
|
271 | + // Generate the token. It is stored encrypted in the database with the |
|
272 | + // secret being the users' email address appended with the system secret. |
|
273 | + // This makes the token automatically invalidate once the user changes |
|
274 | + // their email address. |
|
275 | + $token = $this->secureRandom->generate( |
|
276 | + 21, |
|
277 | + ISecureRandom::CHAR_DIGITS. |
|
278 | + ISecureRandom::CHAR_LOWER. |
|
279 | + ISecureRandom::CHAR_UPPER |
|
280 | + ); |
|
281 | + $tokenValue = $this->timeFactory->getTime() .':'. $token; |
|
282 | + $encryptedValue = $this->crypto->encrypt($tokenValue, $email . $this->config->getSystemValue('secret')); |
|
283 | + $this->config->setUserValue($user->getUID(), 'core', 'lostpassword', $encryptedValue); |
|
284 | 284 | |
285 | - $link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', array('userId' => $user->getUID(), 'token' => $token)); |
|
285 | + $link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', array('userId' => $user->getUID(), 'token' => $token)); |
|
286 | 286 | |
287 | - $tmpl = new \OC_Template('core', 'lostpassword/email'); |
|
288 | - $tmpl->assign('link', $link); |
|
289 | - $msg = $tmpl->fetchPage(); |
|
287 | + $tmpl = new \OC_Template('core', 'lostpassword/email'); |
|
288 | + $tmpl->assign('link', $link); |
|
289 | + $msg = $tmpl->fetchPage(); |
|
290 | 290 | |
291 | - try { |
|
292 | - $message = $this->mailer->createMessage(); |
|
293 | - $message->setTo([$email => $user->getUID()]); |
|
294 | - $message->setSubject($this->l10n->t('%s password reset', [$this->defaults->getName()])); |
|
295 | - $message->setPlainBody($msg); |
|
296 | - $message->setFrom([$this->from => $this->defaults->getName()]); |
|
297 | - $this->mailer->send($message); |
|
298 | - } catch (\Exception $e) { |
|
299 | - throw new \Exception($this->l10n->t( |
|
300 | - 'Couldn\'t send reset email. Please contact your administrator.' |
|
301 | - )); |
|
302 | - } |
|
303 | - } |
|
291 | + try { |
|
292 | + $message = $this->mailer->createMessage(); |
|
293 | + $message->setTo([$email => $user->getUID()]); |
|
294 | + $message->setSubject($this->l10n->t('%s password reset', [$this->defaults->getName()])); |
|
295 | + $message->setPlainBody($msg); |
|
296 | + $message->setFrom([$this->from => $this->defaults->getName()]); |
|
297 | + $this->mailer->send($message); |
|
298 | + } catch (\Exception $e) { |
|
299 | + throw new \Exception($this->l10n->t( |
|
300 | + 'Couldn\'t send reset email. Please contact your administrator.' |
|
301 | + )); |
|
302 | + } |
|
303 | + } |
|
304 | 304 | |
305 | - /** |
|
306 | - * @param string $input |
|
307 | - * @return IUser |
|
308 | - * @throws \Exception |
|
309 | - */ |
|
310 | - protected function findUserByIdOrMail($input) { |
|
311 | - $user = $this->userManager->get($input); |
|
312 | - if ($user instanceof IUser) { |
|
313 | - return $user; |
|
314 | - } |
|
315 | - $users = $this->userManager->getByEmail($input); |
|
316 | - if (count($users) === 1) { |
|
317 | - return $users[0]; |
|
318 | - } |
|
305 | + /** |
|
306 | + * @param string $input |
|
307 | + * @return IUser |
|
308 | + * @throws \Exception |
|
309 | + */ |
|
310 | + protected function findUserByIdOrMail($input) { |
|
311 | + $user = $this->userManager->get($input); |
|
312 | + if ($user instanceof IUser) { |
|
313 | + return $user; |
|
314 | + } |
|
315 | + $users = $this->userManager->getByEmail($input); |
|
316 | + if (count($users) === 1) { |
|
317 | + return $users[0]; |
|
318 | + } |
|
319 | 319 | |
320 | - throw new \InvalidArgumentException($this->l10n->t('Couldn\'t send reset email. Please make sure your username is correct.')); |
|
321 | - } |
|
320 | + throw new \InvalidArgumentException($this->l10n->t('Couldn\'t send reset email. Please make sure your username is correct.')); |
|
321 | + } |
|
322 | 322 | } |
@@ -45,35 +45,35 @@ |
||
45 | 45 | */ |
46 | 46 | class Application extends App { |
47 | 47 | |
48 | - public function __construct() { |
|
49 | - parent::__construct('core'); |
|
48 | + public function __construct() { |
|
49 | + parent::__construct('core'); |
|
50 | 50 | |
51 | - $container = $this->getContainer(); |
|
51 | + $container = $this->getContainer(); |
|
52 | 52 | |
53 | - $container->registerService('defaultMailAddress', function () { |
|
54 | - return Util::getDefaultEmailAddress('lostpassword-noreply'); |
|
55 | - }); |
|
56 | - $container->registerService(Manager::class, function () { |
|
57 | - return new Manager( |
|
58 | - \OC::$server->getAppDataDir('identityproof'), |
|
59 | - \OC::$server->getCrypto() |
|
60 | - ); |
|
61 | - }); |
|
62 | - $container->registerService(CssController::class, function () use ($container) { |
|
63 | - return new CssController( |
|
64 | - $container->query('appName'), |
|
65 | - $container->query(IRequest::class), |
|
66 | - \OC::$server->getAppDataDir('css'), |
|
67 | - $container->query(ITimeFactory::class) |
|
68 | - ); |
|
69 | - }); |
|
70 | - $container->registerService(JsController::class, function () use ($container) { |
|
71 | - return new JsController( |
|
72 | - $container->query('AppName'), |
|
73 | - $container->query(IRequest::class), |
|
74 | - $container->getServer()->getAppDataDir('js'), |
|
75 | - $container->query(ITimeFactory::class) |
|
76 | - ); |
|
77 | - }); |
|
78 | - } |
|
53 | + $container->registerService('defaultMailAddress', function () { |
|
54 | + return Util::getDefaultEmailAddress('lostpassword-noreply'); |
|
55 | + }); |
|
56 | + $container->registerService(Manager::class, function () { |
|
57 | + return new Manager( |
|
58 | + \OC::$server->getAppDataDir('identityproof'), |
|
59 | + \OC::$server->getCrypto() |
|
60 | + ); |
|
61 | + }); |
|
62 | + $container->registerService(CssController::class, function () use ($container) { |
|
63 | + return new CssController( |
|
64 | + $container->query('appName'), |
|
65 | + $container->query(IRequest::class), |
|
66 | + \OC::$server->getAppDataDir('css'), |
|
67 | + $container->query(ITimeFactory::class) |
|
68 | + ); |
|
69 | + }); |
|
70 | + $container->registerService(JsController::class, function () use ($container) { |
|
71 | + return new JsController( |
|
72 | + $container->query('AppName'), |
|
73 | + $container->query(IRequest::class), |
|
74 | + $container->getServer()->getAppDataDir('js'), |
|
75 | + $container->query(ITimeFactory::class) |
|
76 | + ); |
|
77 | + }); |
|
78 | + } |
|
79 | 79 | } |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | |
51 | 51 | $container = $this->getContainer(); |
52 | 52 | |
53 | - $container->registerService('defaultMailAddress', function () { |
|
53 | + $container->registerService('defaultMailAddress', function() { |
|
54 | 54 | return Util::getDefaultEmailAddress('lostpassword-noreply'); |
55 | 55 | }); |
56 | - $container->registerService(Manager::class, function () { |
|
56 | + $container->registerService(Manager::class, function() { |
|
57 | 57 | return new Manager( |
58 | 58 | \OC::$server->getAppDataDir('identityproof'), |
59 | 59 | \OC::$server->getCrypto() |
60 | 60 | ); |
61 | 61 | }); |
62 | - $container->registerService(CssController::class, function () use ($container) { |
|
62 | + $container->registerService(CssController::class, function() use ($container) { |
|
63 | 63 | return new CssController( |
64 | 64 | $container->query('appName'), |
65 | 65 | $container->query(IRequest::class), |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $container->query(ITimeFactory::class) |
68 | 68 | ); |
69 | 69 | }); |
70 | - $container->registerService(JsController::class, function () use ($container) { |
|
70 | + $container->registerService(JsController::class, function() use ($container) { |
|
71 | 71 | return new JsController( |
72 | 72 | $container->query('AppName'), |
73 | 73 | $container->query(IRequest::class), |
@@ -36,142 +36,142 @@ |
||
36 | 36 | use OCP\IConfig; |
37 | 37 | |
38 | 38 | class IconController extends Controller { |
39 | - /** @var Defaults */ |
|
40 | - private $themingDefaults; |
|
41 | - /** @var Util */ |
|
42 | - private $util; |
|
43 | - /** @var ITimeFactory */ |
|
44 | - private $timeFactory; |
|
45 | - /** @var IConfig */ |
|
46 | - private $config; |
|
47 | - /** @var IconBuilder */ |
|
48 | - private $iconBuilder; |
|
49 | - /** @var ImageManager */ |
|
50 | - private $imageManager; |
|
39 | + /** @var Defaults */ |
|
40 | + private $themingDefaults; |
|
41 | + /** @var Util */ |
|
42 | + private $util; |
|
43 | + /** @var ITimeFactory */ |
|
44 | + private $timeFactory; |
|
45 | + /** @var IConfig */ |
|
46 | + private $config; |
|
47 | + /** @var IconBuilder */ |
|
48 | + private $iconBuilder; |
|
49 | + /** @var ImageManager */ |
|
50 | + private $imageManager; |
|
51 | 51 | |
52 | - /** |
|
53 | - * IconController constructor. |
|
54 | - * |
|
55 | - * @param string $appName |
|
56 | - * @param IRequest $request |
|
57 | - * @param Defaults $themingDefaults |
|
58 | - * @param Util $util |
|
59 | - * @param ITimeFactory $timeFactory |
|
60 | - * @param IConfig $config |
|
61 | - * @param IconBuilder $iconBuilder |
|
62 | - * @param ImageManager $imageManager |
|
63 | - */ |
|
64 | - public function __construct( |
|
65 | - $appName, |
|
66 | - IRequest $request, |
|
67 | - Defaults $themingDefaults, |
|
68 | - Util $util, |
|
69 | - ITimeFactory $timeFactory, |
|
70 | - IConfig $config, |
|
71 | - IconBuilder $iconBuilder, |
|
72 | - ImageManager $imageManager |
|
73 | - ) { |
|
74 | - parent::__construct($appName, $request); |
|
52 | + /** |
|
53 | + * IconController constructor. |
|
54 | + * |
|
55 | + * @param string $appName |
|
56 | + * @param IRequest $request |
|
57 | + * @param Defaults $themingDefaults |
|
58 | + * @param Util $util |
|
59 | + * @param ITimeFactory $timeFactory |
|
60 | + * @param IConfig $config |
|
61 | + * @param IconBuilder $iconBuilder |
|
62 | + * @param ImageManager $imageManager |
|
63 | + */ |
|
64 | + public function __construct( |
|
65 | + $appName, |
|
66 | + IRequest $request, |
|
67 | + Defaults $themingDefaults, |
|
68 | + Util $util, |
|
69 | + ITimeFactory $timeFactory, |
|
70 | + IConfig $config, |
|
71 | + IconBuilder $iconBuilder, |
|
72 | + ImageManager $imageManager |
|
73 | + ) { |
|
74 | + parent::__construct($appName, $request); |
|
75 | 75 | |
76 | - $this->themingDefaults = $themingDefaults; |
|
77 | - $this->util = $util; |
|
78 | - $this->timeFactory = $timeFactory; |
|
79 | - $this->config = $config; |
|
80 | - $this->iconBuilder = $iconBuilder; |
|
81 | - $this->imageManager = $imageManager; |
|
82 | - } |
|
76 | + $this->themingDefaults = $themingDefaults; |
|
77 | + $this->util = $util; |
|
78 | + $this->timeFactory = $timeFactory; |
|
79 | + $this->config = $config; |
|
80 | + $this->iconBuilder = $iconBuilder; |
|
81 | + $this->imageManager = $imageManager; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @PublicPage |
|
86 | - * @NoCSRFRequired |
|
87 | - * |
|
88 | - * @param $app string app name |
|
89 | - * @param $image string image file name (svg required) |
|
90 | - * @return FileDisplayResponse|NotFoundResponse |
|
91 | - */ |
|
92 | - public function getThemedIcon($app, $image) { |
|
93 | - try { |
|
94 | - $iconFile = $this->imageManager->getCachedImage("icon-" . $app . '-' . str_replace("/","_",$image)); |
|
95 | - } catch (NotFoundException $exception) { |
|
96 | - $icon = $this->iconBuilder->colorSvg($app, $image); |
|
97 | - if ($icon === false || $icon === "") { |
|
98 | - return new NotFoundResponse(); |
|
99 | - } |
|
100 | - $iconFile = $this->imageManager->setCachedImage("icon-" . $app . '-' . str_replace("/","_",$image), $icon); |
|
101 | - } |
|
102 | - if ($iconFile !== false) { |
|
103 | - $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']); |
|
104 | - $response->cacheFor(86400); |
|
105 | - $expires = new \DateTime(); |
|
106 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
107 | - $expires->add(new \DateInterval('PT24H')); |
|
108 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
109 | - $response->addHeader('Pragma', 'cache'); |
|
110 | - return $response; |
|
111 | - } else { |
|
112 | - return new NotFoundResponse(); |
|
113 | - } |
|
114 | - } |
|
84 | + /** |
|
85 | + * @PublicPage |
|
86 | + * @NoCSRFRequired |
|
87 | + * |
|
88 | + * @param $app string app name |
|
89 | + * @param $image string image file name (svg required) |
|
90 | + * @return FileDisplayResponse|NotFoundResponse |
|
91 | + */ |
|
92 | + public function getThemedIcon($app, $image) { |
|
93 | + try { |
|
94 | + $iconFile = $this->imageManager->getCachedImage("icon-" . $app . '-' . str_replace("/","_",$image)); |
|
95 | + } catch (NotFoundException $exception) { |
|
96 | + $icon = $this->iconBuilder->colorSvg($app, $image); |
|
97 | + if ($icon === false || $icon === "") { |
|
98 | + return new NotFoundResponse(); |
|
99 | + } |
|
100 | + $iconFile = $this->imageManager->setCachedImage("icon-" . $app . '-' . str_replace("/","_",$image), $icon); |
|
101 | + } |
|
102 | + if ($iconFile !== false) { |
|
103 | + $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']); |
|
104 | + $response->cacheFor(86400); |
|
105 | + $expires = new \DateTime(); |
|
106 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
107 | + $expires->add(new \DateInterval('PT24H')); |
|
108 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
109 | + $response->addHeader('Pragma', 'cache'); |
|
110 | + return $response; |
|
111 | + } else { |
|
112 | + return new NotFoundResponse(); |
|
113 | + } |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Return a 32x32 favicon as png |
|
118 | - * |
|
119 | - * @PublicPage |
|
120 | - * @NoCSRFRequired |
|
121 | - * |
|
122 | - * @param $app string app name |
|
123 | - * @return FileDisplayResponse|NotFoundResponse |
|
124 | - */ |
|
125 | - public function getFavicon($app = "core") { |
|
126 | - if ($this->themingDefaults->shouldReplaceIcons()) { |
|
127 | - try { |
|
128 | - $iconFile = $this->imageManager->getCachedImage('favIcon-' . $app); |
|
129 | - } catch (NotFoundException $exception) { |
|
130 | - $icon = $this->iconBuilder->getFavicon($app); |
|
131 | - $iconFile = $this->imageManager->setCachedImage('favIcon-' . $app, $icon); |
|
132 | - } |
|
133 | - if ($iconFile !== false) { |
|
134 | - $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); |
|
135 | - $response->cacheFor(86400); |
|
136 | - $expires = new \DateTime(); |
|
137 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
138 | - $expires->add(new \DateInterval('PT24H')); |
|
139 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
140 | - $response->addHeader('Pragma', 'cache'); |
|
141 | - return $response; |
|
142 | - } |
|
143 | - } |
|
144 | - return new NotFoundResponse(); |
|
145 | - } |
|
116 | + /** |
|
117 | + * Return a 32x32 favicon as png |
|
118 | + * |
|
119 | + * @PublicPage |
|
120 | + * @NoCSRFRequired |
|
121 | + * |
|
122 | + * @param $app string app name |
|
123 | + * @return FileDisplayResponse|NotFoundResponse |
|
124 | + */ |
|
125 | + public function getFavicon($app = "core") { |
|
126 | + if ($this->themingDefaults->shouldReplaceIcons()) { |
|
127 | + try { |
|
128 | + $iconFile = $this->imageManager->getCachedImage('favIcon-' . $app); |
|
129 | + } catch (NotFoundException $exception) { |
|
130 | + $icon = $this->iconBuilder->getFavicon($app); |
|
131 | + $iconFile = $this->imageManager->setCachedImage('favIcon-' . $app, $icon); |
|
132 | + } |
|
133 | + if ($iconFile !== false) { |
|
134 | + $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); |
|
135 | + $response->cacheFor(86400); |
|
136 | + $expires = new \DateTime(); |
|
137 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
138 | + $expires->add(new \DateInterval('PT24H')); |
|
139 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
140 | + $response->addHeader('Pragma', 'cache'); |
|
141 | + return $response; |
|
142 | + } |
|
143 | + } |
|
144 | + return new NotFoundResponse(); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Return a 512x512 icon for touch devices |
|
149 | - * |
|
150 | - * @PublicPage |
|
151 | - * @NoCSRFRequired |
|
152 | - * |
|
153 | - * @param $app string app name |
|
154 | - * @return FileDisplayResponse|NotFoundResponse |
|
155 | - */ |
|
156 | - public function getTouchIcon($app = "core") { |
|
157 | - if ($this->themingDefaults->shouldReplaceIcons()) { |
|
158 | - try { |
|
159 | - $iconFile = $this->imageManager->getCachedImage('touchIcon-' . $app); |
|
160 | - } catch (NotFoundException $exception) { |
|
161 | - $icon = $this->iconBuilder->getTouchIcon($app); |
|
162 | - $iconFile = $this->imageManager->setCachedImage('touchIcon-' . $app, $icon); |
|
163 | - } |
|
164 | - if ($iconFile !== false) { |
|
165 | - $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']); |
|
166 | - $response->cacheFor(86400); |
|
167 | - $expires = new \DateTime(); |
|
168 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
169 | - $expires->add(new \DateInterval('PT24H')); |
|
170 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
171 | - $response->addHeader('Pragma', 'cache'); |
|
172 | - return $response; |
|
173 | - } |
|
174 | - } |
|
175 | - return new NotFoundResponse(); |
|
176 | - } |
|
147 | + /** |
|
148 | + * Return a 512x512 icon for touch devices |
|
149 | + * |
|
150 | + * @PublicPage |
|
151 | + * @NoCSRFRequired |
|
152 | + * |
|
153 | + * @param $app string app name |
|
154 | + * @return FileDisplayResponse|NotFoundResponse |
|
155 | + */ |
|
156 | + public function getTouchIcon($app = "core") { |
|
157 | + if ($this->themingDefaults->shouldReplaceIcons()) { |
|
158 | + try { |
|
159 | + $iconFile = $this->imageManager->getCachedImage('touchIcon-' . $app); |
|
160 | + } catch (NotFoundException $exception) { |
|
161 | + $icon = $this->iconBuilder->getTouchIcon($app); |
|
162 | + $iconFile = $this->imageManager->setCachedImage('touchIcon-' . $app, $icon); |
|
163 | + } |
|
164 | + if ($iconFile !== false) { |
|
165 | + $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']); |
|
166 | + $response->cacheFor(86400); |
|
167 | + $expires = new \DateTime(); |
|
168 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
169 | + $expires->add(new \DateInterval('PT24H')); |
|
170 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
171 | + $response->addHeader('Pragma', 'cache'); |
|
172 | + return $response; |
|
173 | + } |
|
174 | + } |
|
175 | + return new NotFoundResponse(); |
|
176 | + } |
|
177 | 177 | } |