@@ -59,998 +59,998 @@ |
||
59 | 59 | * OC_autoload! |
60 | 60 | */ |
61 | 61 | class OC { |
62 | - /** |
|
63 | - * Associative array for autoloading. classname => filename |
|
64 | - */ |
|
65 | - public static $CLASSPATH = array(); |
|
66 | - /** |
|
67 | - * The installation path for Nextcloud on the server (e.g. /srv/http/nextcloud) |
|
68 | - */ |
|
69 | - public static $SERVERROOT = ''; |
|
70 | - /** |
|
71 | - * the current request path relative to the Nextcloud root (e.g. files/index.php) |
|
72 | - */ |
|
73 | - private static $SUBURI = ''; |
|
74 | - /** |
|
75 | - * the Nextcloud root path for http requests (e.g. nextcloud/) |
|
76 | - */ |
|
77 | - public static $WEBROOT = ''; |
|
78 | - /** |
|
79 | - * The installation path array of the apps folder on the server (e.g. /srv/http/nextcloud) 'path' and |
|
80 | - * web path in 'url' |
|
81 | - */ |
|
82 | - public static $APPSROOTS = array(); |
|
83 | - |
|
84 | - /** |
|
85 | - * @var string |
|
86 | - */ |
|
87 | - public static $configDir; |
|
88 | - |
|
89 | - /** |
|
90 | - * requested app |
|
91 | - */ |
|
92 | - public static $REQUESTEDAPP = ''; |
|
93 | - |
|
94 | - /** |
|
95 | - * check if Nextcloud runs in cli mode |
|
96 | - */ |
|
97 | - public static $CLI = false; |
|
98 | - |
|
99 | - /** |
|
100 | - * @var \OC\Autoloader $loader |
|
101 | - */ |
|
102 | - public static $loader = null; |
|
103 | - |
|
104 | - /** @var \Composer\Autoload\ClassLoader $composerAutoloader */ |
|
105 | - public static $composerAutoloader = null; |
|
106 | - |
|
107 | - /** |
|
108 | - * @var \OC\Server |
|
109 | - */ |
|
110 | - public static $server = null; |
|
111 | - |
|
112 | - /** |
|
113 | - * @var \OC\Config |
|
114 | - */ |
|
115 | - private static $config = null; |
|
116 | - |
|
117 | - /** |
|
118 | - * @throws \RuntimeException when the 3rdparty directory is missing or |
|
119 | - * the app path list is empty or contains an invalid path |
|
120 | - */ |
|
121 | - public static function initPaths() { |
|
122 | - if(defined('PHPUNIT_CONFIG_DIR')) { |
|
123 | - self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; |
|
124 | - } elseif(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { |
|
125 | - self::$configDir = OC::$SERVERROOT . '/tests/config/'; |
|
126 | - } elseif($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
127 | - self::$configDir = rtrim($dir, '/') . '/'; |
|
128 | - } else { |
|
129 | - self::$configDir = OC::$SERVERROOT . '/config/'; |
|
130 | - } |
|
131 | - self::$config = new \OC\Config(self::$configDir); |
|
132 | - |
|
133 | - OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT))); |
|
134 | - /** |
|
135 | - * FIXME: The following lines are required because we can't yet instantiiate |
|
136 | - * \OC::$server->getRequest() since \OC::$server does not yet exist. |
|
137 | - */ |
|
138 | - $params = [ |
|
139 | - 'server' => [ |
|
140 | - 'SCRIPT_NAME' => $_SERVER['SCRIPT_NAME'], |
|
141 | - 'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME'], |
|
142 | - ], |
|
143 | - ]; |
|
144 | - $fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig(self::$config))); |
|
145 | - $scriptName = $fakeRequest->getScriptName(); |
|
146 | - if (substr($scriptName, -1) == '/') { |
|
147 | - $scriptName .= 'index.php'; |
|
148 | - //make sure suburi follows the same rules as scriptName |
|
149 | - if (substr(OC::$SUBURI, -9) != 'index.php') { |
|
150 | - if (substr(OC::$SUBURI, -1) != '/') { |
|
151 | - OC::$SUBURI = OC::$SUBURI . '/'; |
|
152 | - } |
|
153 | - OC::$SUBURI = OC::$SUBURI . 'index.php'; |
|
154 | - } |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - if (OC::$CLI) { |
|
159 | - OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); |
|
160 | - } else { |
|
161 | - if (substr($scriptName, 0 - strlen(OC::$SUBURI)) === OC::$SUBURI) { |
|
162 | - OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
|
163 | - |
|
164 | - if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
|
165 | - OC::$WEBROOT = '/' . OC::$WEBROOT; |
|
166 | - } |
|
167 | - } else { |
|
168 | - // The scriptName is not ending with OC::$SUBURI |
|
169 | - // This most likely means that we are calling from CLI. |
|
170 | - // However some cron jobs still need to generate |
|
171 | - // a web URL, so we use overwritewebroot as a fallback. |
|
172 | - OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); |
|
173 | - } |
|
174 | - |
|
175 | - // Resolve /nextcloud to /nextcloud/ to ensure to always have a trailing |
|
176 | - // slash which is required by URL generation. |
|
177 | - if($_SERVER['REQUEST_URI'] === \OC::$WEBROOT && |
|
178 | - substr($_SERVER['REQUEST_URI'], -1) !== '/') { |
|
179 | - header('Location: '.\OC::$WEBROOT.'/'); |
|
180 | - exit(); |
|
181 | - } |
|
182 | - } |
|
183 | - |
|
184 | - // search the apps folder |
|
185 | - $config_paths = self::$config->getValue('apps_paths', array()); |
|
186 | - if (!empty($config_paths)) { |
|
187 | - foreach ($config_paths as $paths) { |
|
188 | - if (isset($paths['url']) && isset($paths['path'])) { |
|
189 | - $paths['url'] = rtrim($paths['url'], '/'); |
|
190 | - $paths['path'] = rtrim($paths['path'], '/'); |
|
191 | - OC::$APPSROOTS[] = $paths; |
|
192 | - } |
|
193 | - } |
|
194 | - } elseif (file_exists(OC::$SERVERROOT . '/apps')) { |
|
195 | - OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true); |
|
196 | - } elseif (file_exists(OC::$SERVERROOT . '/../apps')) { |
|
197 | - OC::$APPSROOTS[] = array( |
|
198 | - 'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', |
|
199 | - 'url' => '/apps', |
|
200 | - 'writable' => true |
|
201 | - ); |
|
202 | - } |
|
203 | - |
|
204 | - if (empty(OC::$APPSROOTS)) { |
|
205 | - throw new \RuntimeException('apps directory not found! Please put the Nextcloud apps folder in the Nextcloud folder' |
|
206 | - . ' or the folder above. You can also configure the location in the config.php file.'); |
|
207 | - } |
|
208 | - $paths = array(); |
|
209 | - foreach (OC::$APPSROOTS as $path) { |
|
210 | - $paths[] = $path['path']; |
|
211 | - if (!is_dir($path['path'])) { |
|
212 | - throw new \RuntimeException(sprintf('App directory "%s" not found! Please put the Nextcloud apps folder in the' |
|
213 | - . ' Nextcloud folder or the folder above. You can also configure the location in the' |
|
214 | - . ' config.php file.', $path['path'])); |
|
215 | - } |
|
216 | - } |
|
217 | - |
|
218 | - // set the right include path |
|
219 | - set_include_path( |
|
220 | - implode(PATH_SEPARATOR, $paths) |
|
221 | - ); |
|
222 | - } |
|
223 | - |
|
224 | - public static function checkConfig() { |
|
225 | - $l = \OC::$server->getL10N('lib'); |
|
226 | - |
|
227 | - // Create config if it does not already exist |
|
228 | - $configFilePath = self::$configDir .'/config.php'; |
|
229 | - if(!file_exists($configFilePath)) { |
|
230 | - @touch($configFilePath); |
|
231 | - } |
|
232 | - |
|
233 | - // Check if config is writable |
|
234 | - $configFileWritable = is_writable($configFilePath); |
|
235 | - if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled() |
|
236 | - || !$configFileWritable && self::checkUpgrade(false)) { |
|
237 | - |
|
238 | - $urlGenerator = \OC::$server->getURLGenerator(); |
|
239 | - |
|
240 | - if (self::$CLI) { |
|
241 | - echo $l->t('Cannot write into "config" directory!')."\n"; |
|
242 | - echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; |
|
243 | - echo "\n"; |
|
244 | - echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-dir_permissions') ])."\n"; |
|
245 | - exit; |
|
246 | - } else { |
|
247 | - OC_Template::printErrorPage( |
|
248 | - $l->t('Cannot write into "config" directory!'), |
|
249 | - $l->t('This can usually be fixed by ' |
|
250 | - . '%sgiving the webserver write access to the config directory%s.', |
|
251 | - array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank" rel="noreferrer">', '</a>')) |
|
252 | - ); |
|
253 | - } |
|
254 | - } |
|
255 | - } |
|
256 | - |
|
257 | - public static function checkInstalled() { |
|
258 | - if (defined('OC_CONSOLE')) { |
|
259 | - return; |
|
260 | - } |
|
261 | - // Redirect to installer if not installed |
|
262 | - if (!\OC::$server->getSystemConfig()->getValue('installed', false) && OC::$SUBURI !== '/index.php' && OC::$SUBURI !== '/status.php') { |
|
263 | - if (OC::$CLI) { |
|
264 | - throw new Exception('Not installed'); |
|
265 | - } else { |
|
266 | - $url = OC::$WEBROOT . '/index.php'; |
|
267 | - header('Location: ' . $url); |
|
268 | - } |
|
269 | - exit(); |
|
270 | - } |
|
271 | - } |
|
272 | - |
|
273 | - public static function checkMaintenanceMode() { |
|
274 | - // Allow ajax update script to execute without being stopped |
|
275 | - if (\OC::$server->getSystemConfig()->getValue('maintenance', false) && OC::$SUBURI != '/core/ajax/update.php') { |
|
276 | - // send http status 503 |
|
277 | - header('HTTP/1.1 503 Service Temporarily Unavailable'); |
|
278 | - header('Status: 503 Service Temporarily Unavailable'); |
|
279 | - header('Retry-After: 120'); |
|
280 | - |
|
281 | - // render error page |
|
282 | - $template = new OC_Template('', 'update.user', 'guest'); |
|
283 | - OC_Util::addScript('maintenance-check'); |
|
284 | - $template->printPage(); |
|
285 | - die(); |
|
286 | - } |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * Checks if the version requires an update and shows |
|
291 | - * @param bool $showTemplate Whether an update screen should get shown |
|
292 | - * @return bool|void |
|
293 | - */ |
|
294 | - public static function checkUpgrade($showTemplate = true) { |
|
295 | - if (\OCP\Util::needUpgrade()) { |
|
296 | - $systemConfig = \OC::$server->getSystemConfig(); |
|
297 | - if ($showTemplate && !$systemConfig->getValue('maintenance', false)) { |
|
298 | - self::printUpgradePage(); |
|
299 | - exit(); |
|
300 | - } else { |
|
301 | - return true; |
|
302 | - } |
|
303 | - } |
|
304 | - return false; |
|
305 | - } |
|
306 | - |
|
307 | - /** |
|
308 | - * Prints the upgrade page |
|
309 | - */ |
|
310 | - private static function printUpgradePage() { |
|
311 | - $systemConfig = \OC::$server->getSystemConfig(); |
|
312 | - |
|
313 | - $disableWebUpdater = $systemConfig->getValue('upgrade.disable-web', false); |
|
314 | - $tooBig = false; |
|
315 | - if (!$disableWebUpdater) { |
|
316 | - $apps = \OC::$server->getAppManager(); |
|
317 | - $tooBig = $apps->isInstalled('user_ldap') || $apps->isInstalled('user_shibboleth'); |
|
318 | - if (!$tooBig) { |
|
319 | - // count users |
|
320 | - $stats = \OC::$server->getUserManager()->countUsers(); |
|
321 | - $totalUsers = array_sum($stats); |
|
322 | - $tooBig = ($totalUsers > 50); |
|
323 | - } |
|
324 | - } |
|
325 | - if ($disableWebUpdater || $tooBig) { |
|
326 | - // send http status 503 |
|
327 | - header('HTTP/1.1 503 Service Temporarily Unavailable'); |
|
328 | - header('Status: 503 Service Temporarily Unavailable'); |
|
329 | - header('Retry-After: 120'); |
|
330 | - |
|
331 | - // render error page |
|
332 | - $template = new OC_Template('', 'update.use-cli', 'guest'); |
|
333 | - $template->assign('productName', 'nextcloud'); // for now |
|
334 | - $template->assign('version', OC_Util::getVersionString()); |
|
335 | - $template->assign('tooBig', $tooBig); |
|
336 | - |
|
337 | - $template->printPage(); |
|
338 | - die(); |
|
339 | - } |
|
340 | - |
|
341 | - // check whether this is a core update or apps update |
|
342 | - $installedVersion = $systemConfig->getValue('version', '0.0.0'); |
|
343 | - $currentVersion = implode('.', \OCP\Util::getVersion()); |
|
344 | - |
|
345 | - // if not a core upgrade, then it's apps upgrade |
|
346 | - $isAppsOnlyUpgrade = (version_compare($currentVersion, $installedVersion, '=')); |
|
347 | - |
|
348 | - $oldTheme = $systemConfig->getValue('theme'); |
|
349 | - $systemConfig->setValue('theme', ''); |
|
350 | - OC_Util::addScript('config'); // needed for web root |
|
351 | - OC_Util::addScript('update'); |
|
352 | - |
|
353 | - /** @var \OC\App\AppManager $appManager */ |
|
354 | - $appManager = \OC::$server->getAppManager(); |
|
355 | - |
|
356 | - $tmpl = new OC_Template('', 'update.admin', 'guest'); |
|
357 | - $tmpl->assign('version', OC_Util::getVersionString()); |
|
358 | - $tmpl->assign('isAppsOnlyUpgrade', $isAppsOnlyUpgrade); |
|
359 | - |
|
360 | - // get third party apps |
|
361 | - $ocVersion = \OCP\Util::getVersion(); |
|
362 | - $incompatibleApps = $appManager->getIncompatibleApps($ocVersion); |
|
363 | - $incompatibleShippedApps = []; |
|
364 | - foreach ($incompatibleApps as $appInfo) { |
|
365 | - if ($appManager->isShipped($appInfo['id'])) { |
|
366 | - $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
367 | - } |
|
368 | - } |
|
369 | - |
|
370 | - if (!empty($incompatibleShippedApps)) { |
|
371 | - $l = \OC::$server->getL10N('core'); |
|
372 | - $hint = $l->t('The files of the app %$1s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]); |
|
373 | - throw new \OC\HintException('The files of the app ' . implode(', ', $incompatibleShippedApps) . ' were not replaced correctly. Make sure it is a version compatible with the server.', $hint); |
|
374 | - } |
|
375 | - |
|
376 | - $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
|
377 | - $tmpl->assign('incompatibleAppsList', $incompatibleApps); |
|
378 | - $tmpl->assign('productName', 'Nextcloud'); // for now |
|
379 | - $tmpl->assign('oldTheme', $oldTheme); |
|
380 | - $tmpl->printPage(); |
|
381 | - } |
|
382 | - |
|
383 | - public static function initSession() { |
|
384 | - // prevents javascript from accessing php session cookies |
|
385 | - ini_set('session.cookie_httponly', true); |
|
386 | - |
|
387 | - // set the cookie path to the Nextcloud directory |
|
388 | - $cookie_path = OC::$WEBROOT ? : '/'; |
|
389 | - ini_set('session.cookie_path', $cookie_path); |
|
390 | - |
|
391 | - // Let the session name be changed in the initSession Hook |
|
392 | - $sessionName = OC_Util::getInstanceId(); |
|
393 | - |
|
394 | - try { |
|
395 | - // Allow session apps to create a custom session object |
|
396 | - $useCustomSession = false; |
|
397 | - $session = self::$server->getSession(); |
|
398 | - OC_Hook::emit('OC', 'initSession', array('session' => &$session, 'sessionName' => &$sessionName, 'useCustomSession' => &$useCustomSession)); |
|
399 | - if (!$useCustomSession) { |
|
400 | - // set the session name to the instance id - which is unique |
|
401 | - $session = new \OC\Session\Internal($sessionName); |
|
402 | - } |
|
403 | - |
|
404 | - $cryptoWrapper = \OC::$server->getSessionCryptoWrapper(); |
|
405 | - $session = $cryptoWrapper->wrapSession($session); |
|
406 | - self::$server->setSession($session); |
|
407 | - |
|
408 | - // if session can't be started break with http 500 error |
|
409 | - } catch (Exception $e) { |
|
410 | - \OCP\Util::logException('base', $e); |
|
411 | - //show the user a detailed error page |
|
412 | - OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR); |
|
413 | - OC_Template::printExceptionErrorPage($e); |
|
414 | - die(); |
|
415 | - } |
|
416 | - |
|
417 | - $sessionLifeTime = self::getSessionLifeTime(); |
|
418 | - |
|
419 | - // session timeout |
|
420 | - if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
|
421 | - if (isset($_COOKIE[session_name()])) { |
|
422 | - setcookie(session_name(), null, -1, self::$WEBROOT ? : '/'); |
|
423 | - } |
|
424 | - \OC::$server->getUserSession()->logout(); |
|
425 | - } |
|
426 | - |
|
427 | - $session->set('LAST_ACTIVITY', time()); |
|
428 | - } |
|
429 | - |
|
430 | - /** |
|
431 | - * @return string |
|
432 | - */ |
|
433 | - private static function getSessionLifeTime() { |
|
434 | - return \OC::$server->getConfig()->getSystemValue('session_lifetime', 60 * 60 * 24); |
|
435 | - } |
|
436 | - |
|
437 | - public static function loadAppClassPaths() { |
|
438 | - foreach (OC_App::getEnabledApps() as $app) { |
|
439 | - $appPath = OC_App::getAppPath($app); |
|
440 | - if ($appPath === false) { |
|
441 | - continue; |
|
442 | - } |
|
443 | - |
|
444 | - $file = $appPath . '/appinfo/classpath.php'; |
|
445 | - if (file_exists($file)) { |
|
446 | - require_once $file; |
|
447 | - } |
|
448 | - } |
|
449 | - } |
|
450 | - |
|
451 | - /** |
|
452 | - * Try to set some values to the required Nextcloud default |
|
453 | - */ |
|
454 | - public static function setRequiredIniValues() { |
|
455 | - @ini_set('default_charset', 'UTF-8'); |
|
456 | - @ini_set('gd.jpeg_ignore_warning', 1); |
|
457 | - } |
|
458 | - |
|
459 | - /** |
|
460 | - * Send the same site cookies |
|
461 | - */ |
|
462 | - private static function sendSameSiteCookies() { |
|
463 | - $cookieParams = session_get_cookie_params(); |
|
464 | - $secureCookie = ($cookieParams['secure'] === true) ? 'secure; ' : ''; |
|
465 | - $policies = [ |
|
466 | - 'lax', |
|
467 | - 'strict', |
|
468 | - ]; |
|
469 | - |
|
470 | - // Append __Host to the cookie if it meets the requirements |
|
471 | - $cookiePrefix = ''; |
|
472 | - if($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
473 | - $cookiePrefix = '__Host-'; |
|
474 | - } |
|
475 | - |
|
476 | - foreach($policies as $policy) { |
|
477 | - header( |
|
478 | - sprintf( |
|
479 | - 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
480 | - $cookiePrefix, |
|
481 | - $policy, |
|
482 | - $cookieParams['path'], |
|
483 | - $policy |
|
484 | - ), |
|
485 | - false |
|
486 | - ); |
|
487 | - } |
|
488 | - } |
|
489 | - |
|
490 | - /** |
|
491 | - * Same Site cookie to further mitigate CSRF attacks. This cookie has to |
|
492 | - * be set in every request if cookies are sent to add a second level of |
|
493 | - * defense against CSRF. |
|
494 | - * |
|
495 | - * If the cookie is not sent this will set the cookie and reload the page. |
|
496 | - * We use an additional cookie since we want to protect logout CSRF and |
|
497 | - * also we can't directly interfere with PHP's session mechanism. |
|
498 | - */ |
|
499 | - private static function performSameSiteCookieProtection() { |
|
500 | - $request = \OC::$server->getRequest(); |
|
501 | - |
|
502 | - // Some user agents are notorious and don't really properly follow HTTP |
|
503 | - // specifications. For those, have an automated opt-out. Since the protection |
|
504 | - // for remote.php is applied in base.php as starting point we need to opt out |
|
505 | - // here. |
|
506 | - $incompatibleUserAgents = [ |
|
507 | - // OS X Finder |
|
508 | - '/^WebDAVFS/', |
|
509 | - ]; |
|
510 | - if($request->isUserAgent($incompatibleUserAgents)) { |
|
511 | - return; |
|
512 | - } |
|
513 | - |
|
514 | - if(count($_COOKIE) > 0) { |
|
515 | - $requestUri = $request->getScriptName(); |
|
516 | - $processingScript = explode('/', $requestUri); |
|
517 | - $processingScript = $processingScript[count($processingScript)-1]; |
|
518 | - // FIXME: In a SAML scenario we don't get any strict or lax cookie |
|
519 | - // send for the ACS endpoint. Since we have some legacy code in Nextcloud |
|
520 | - // (direct PHP files) the enforcement of lax cookies is performed here |
|
521 | - // instead of the middleware. |
|
522 | - // |
|
523 | - // This means we cannot exclude some routes from the cookie validation, |
|
524 | - // which normally is not a problem but is a little bit cumbersome for |
|
525 | - // this use-case. |
|
526 | - // Once the old legacy PHP endpoints have been removed we can move |
|
527 | - // the verification into a middleware and also adds some exemptions. |
|
528 | - // |
|
529 | - // Questions about this code? Ask Lukas ;-) |
|
530 | - $currentUrl = substr(explode('?',$request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT)); |
|
531 | - if($currentUrl === '/index.php/apps/user_saml/saml/acs' || $currentUrl === '/apps/user_saml/saml/acs') { |
|
532 | - return; |
|
533 | - } |
|
534 | - // For the "index.php" endpoint only a lax cookie is required. |
|
535 | - if($processingScript === 'index.php') { |
|
536 | - if(!$request->passesLaxCookieCheck()) { |
|
537 | - self::sendSameSiteCookies(); |
|
538 | - header('Location: '.$_SERVER['REQUEST_URI']); |
|
539 | - exit(); |
|
540 | - } |
|
541 | - } else { |
|
542 | - // All other endpoints require the lax and the strict cookie |
|
543 | - if(!$request->passesStrictCookieCheck()) { |
|
544 | - self::sendSameSiteCookies(); |
|
545 | - // Debug mode gets access to the resources without strict cookie |
|
546 | - // due to the fact that the SabreDAV browser also lives there. |
|
547 | - if(!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
548 | - http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); |
|
549 | - exit(); |
|
550 | - } |
|
551 | - } |
|
552 | - } |
|
553 | - } elseif(!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
554 | - self::sendSameSiteCookies(); |
|
555 | - } |
|
556 | - } |
|
557 | - |
|
558 | - public static function init() { |
|
559 | - // calculate the root directories |
|
560 | - OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4)); |
|
561 | - |
|
562 | - // register autoloader |
|
563 | - $loaderStart = microtime(true); |
|
564 | - require_once __DIR__ . '/autoloader.php'; |
|
565 | - self::$loader = new \OC\Autoloader([ |
|
566 | - OC::$SERVERROOT . '/lib/private/legacy', |
|
567 | - ]); |
|
568 | - if (defined('PHPUNIT_RUN')) { |
|
569 | - self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
|
570 | - } |
|
571 | - spl_autoload_register(array(self::$loader, 'load')); |
|
572 | - $loaderEnd = microtime(true); |
|
573 | - |
|
574 | - self::$CLI = (php_sapi_name() == 'cli'); |
|
575 | - |
|
576 | - // Add default composer PSR-4 autoloader |
|
577 | - self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
|
578 | - |
|
579 | - try { |
|
580 | - self::initPaths(); |
|
581 | - // setup 3rdparty autoloader |
|
582 | - $vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php'; |
|
583 | - if (!file_exists($vendorAutoLoad)) { |
|
584 | - throw new \RuntimeException('Composer autoloader not found, unable to continue. Check the folder "3rdparty". Running "git submodule update --init" will initialize the git submodule that handles the subfolder "3rdparty".'); |
|
585 | - } |
|
586 | - require_once $vendorAutoLoad; |
|
587 | - |
|
588 | - } catch (\RuntimeException $e) { |
|
589 | - if (!self::$CLI) { |
|
590 | - $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
|
591 | - $protocol = in_array($claimedProtocol, ['HTTP/1.0', 'HTTP/1.1', 'HTTP/2']) ? $claimedProtocol : 'HTTP/1.1'; |
|
592 | - header($protocol . ' ' . OC_Response::STATUS_SERVICE_UNAVAILABLE); |
|
593 | - } |
|
594 | - // we can't use the template error page here, because this needs the |
|
595 | - // DI container which isn't available yet |
|
596 | - print($e->getMessage()); |
|
597 | - exit(); |
|
598 | - } |
|
599 | - |
|
600 | - // setup the basic server |
|
601 | - self::$server = new \OC\Server(\OC::$WEBROOT, self::$config); |
|
602 | - \OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd); |
|
603 | - \OC::$server->getEventLogger()->start('boot', 'Initialize'); |
|
604 | - |
|
605 | - // Don't display errors and log them |
|
606 | - error_reporting(E_ALL | E_STRICT); |
|
607 | - @ini_set('display_errors', 0); |
|
608 | - @ini_set('log_errors', 1); |
|
609 | - |
|
610 | - if(!date_default_timezone_set('UTC')) { |
|
611 | - throw new \RuntimeException('Could not set timezone to UTC'); |
|
612 | - }; |
|
613 | - |
|
614 | - //try to configure php to enable big file uploads. |
|
615 | - //this doesn´t work always depending on the webserver and php configuration. |
|
616 | - //Let´s try to overwrite some defaults anyway |
|
617 | - |
|
618 | - //try to set the maximum execution time to 60min |
|
619 | - if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
620 | - @set_time_limit(3600); |
|
621 | - } |
|
622 | - @ini_set('max_execution_time', 3600); |
|
623 | - @ini_set('max_input_time', 3600); |
|
624 | - |
|
625 | - //try to set the maximum filesize to 10G |
|
626 | - @ini_set('upload_max_filesize', '10G'); |
|
627 | - @ini_set('post_max_size', '10G'); |
|
628 | - @ini_set('file_uploads', '50'); |
|
629 | - |
|
630 | - self::setRequiredIniValues(); |
|
631 | - self::handleAuthHeaders(); |
|
632 | - self::registerAutoloaderCache(); |
|
633 | - |
|
634 | - // initialize intl fallback is necessary |
|
635 | - \Patchwork\Utf8\Bootup::initIntl(); |
|
636 | - OC_Util::isSetLocaleWorking(); |
|
637 | - |
|
638 | - if (!defined('PHPUNIT_RUN')) { |
|
639 | - OC\Log\ErrorHandler::setLogger(\OC::$server->getLogger()); |
|
640 | - $debug = \OC::$server->getConfig()->getSystemValue('debug', false); |
|
641 | - OC\Log\ErrorHandler::register($debug); |
|
642 | - } |
|
643 | - |
|
644 | - \OC::$server->getEventLogger()->start('init_session', 'Initialize session'); |
|
645 | - OC_App::loadApps(array('session')); |
|
646 | - if (!self::$CLI) { |
|
647 | - self::initSession(); |
|
648 | - } |
|
649 | - \OC::$server->getEventLogger()->end('init_session'); |
|
650 | - self::checkConfig(); |
|
651 | - self::checkInstalled(); |
|
652 | - |
|
653 | - OC_Response::addSecurityHeaders(); |
|
654 | - if(self::$server->getRequest()->getServerProtocol() === 'https') { |
|
655 | - ini_set('session.cookie_secure', true); |
|
656 | - } |
|
657 | - |
|
658 | - self::performSameSiteCookieProtection(); |
|
659 | - |
|
660 | - if (!defined('OC_CONSOLE')) { |
|
661 | - $errors = OC_Util::checkServer(\OC::$server->getSystemConfig()); |
|
662 | - if (count($errors) > 0) { |
|
663 | - if (self::$CLI) { |
|
664 | - // Convert l10n string into regular string for usage in database |
|
665 | - $staticErrors = []; |
|
666 | - foreach ($errors as $error) { |
|
667 | - echo $error['error'] . "\n"; |
|
668 | - echo $error['hint'] . "\n\n"; |
|
669 | - $staticErrors[] = [ |
|
670 | - 'error' => (string)$error['error'], |
|
671 | - 'hint' => (string)$error['hint'], |
|
672 | - ]; |
|
673 | - } |
|
674 | - |
|
675 | - try { |
|
676 | - \OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors)); |
|
677 | - } catch (\Exception $e) { |
|
678 | - echo('Writing to database failed'); |
|
679 | - } |
|
680 | - exit(1); |
|
681 | - } else { |
|
682 | - OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); |
|
683 | - OC_Util::addStyle('guest'); |
|
684 | - OC_Template::printGuestPage('', 'error', array('errors' => $errors)); |
|
685 | - exit; |
|
686 | - } |
|
687 | - } elseif (self::$CLI && \OC::$server->getConfig()->getSystemValue('installed', false)) { |
|
688 | - \OC::$server->getConfig()->deleteAppValue('core', 'cronErrors'); |
|
689 | - } |
|
690 | - } |
|
691 | - //try to set the session lifetime |
|
692 | - $sessionLifeTime = self::getSessionLifeTime(); |
|
693 | - @ini_set('gc_maxlifetime', (string)$sessionLifeTime); |
|
694 | - |
|
695 | - $systemConfig = \OC::$server->getSystemConfig(); |
|
696 | - |
|
697 | - // User and Groups |
|
698 | - if (!$systemConfig->getValue("installed", false)) { |
|
699 | - self::$server->getSession()->set('user_id', ''); |
|
700 | - } |
|
701 | - |
|
702 | - OC_User::useBackend(new \OC\User\Database()); |
|
703 | - \OC::$server->getGroupManager()->addBackend(new \OC\Group\Database()); |
|
704 | - |
|
705 | - // Subscribe to the hook |
|
706 | - \OCP\Util::connectHook( |
|
707 | - '\OCA\Files_Sharing\API\Server2Server', |
|
708 | - 'preLoginNameUsedAsUserName', |
|
709 | - '\OC\User\Database', |
|
710 | - 'preLoginNameUsedAsUserName' |
|
711 | - ); |
|
712 | - |
|
713 | - //setup extra user backends |
|
714 | - if (!self::checkUpgrade(false)) { |
|
715 | - OC_User::setupBackends(); |
|
716 | - } else { |
|
717 | - // Run upgrades in incognito mode |
|
718 | - OC_User::setIncognitoMode(true); |
|
719 | - } |
|
720 | - |
|
721 | - self::registerCacheHooks(); |
|
722 | - self::registerFilesystemHooks(); |
|
723 | - self::registerShareHooks(); |
|
724 | - self::registerLogRotate(); |
|
725 | - self::registerEncryptionWrapper(); |
|
726 | - self::registerEncryptionHooks(); |
|
727 | - self::registerAccountHooks(); |
|
728 | - self::registerSettingsHooks(); |
|
729 | - |
|
730 | - $settings = new \OC\Settings\Application(); |
|
731 | - $settings->register(); |
|
732 | - |
|
733 | - //make sure temporary files are cleaned up |
|
734 | - $tmpManager = \OC::$server->getTempManager(); |
|
735 | - register_shutdown_function(array($tmpManager, 'clean')); |
|
736 | - $lockProvider = \OC::$server->getLockingProvider(); |
|
737 | - register_shutdown_function(array($lockProvider, 'releaseAll')); |
|
738 | - |
|
739 | - // Check whether the sample configuration has been copied |
|
740 | - if($systemConfig->getValue('copied_sample_config', false)) { |
|
741 | - $l = \OC::$server->getL10N('lib'); |
|
742 | - header('HTTP/1.1 503 Service Temporarily Unavailable'); |
|
743 | - header('Status: 503 Service Temporarily Unavailable'); |
|
744 | - OC_Template::printErrorPage( |
|
745 | - $l->t('Sample configuration detected'), |
|
746 | - $l->t('It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php') |
|
747 | - ); |
|
748 | - return; |
|
749 | - } |
|
750 | - |
|
751 | - $request = \OC::$server->getRequest(); |
|
752 | - $host = $request->getInsecureServerHost(); |
|
753 | - /** |
|
754 | - * if the host passed in headers isn't trusted |
|
755 | - * FIXME: Should not be in here at all :see_no_evil: |
|
756 | - */ |
|
757 | - if (!OC::$CLI |
|
758 | - // overwritehost is always trusted, workaround to not have to make |
|
759 | - // \OC\AppFramework\Http\Request::getOverwriteHost public |
|
760 | - && self::$server->getConfig()->getSystemValue('overwritehost') === '' |
|
761 | - && !\OC::$server->getTrustedDomainHelper()->isTrustedDomain($host) |
|
762 | - && self::$server->getConfig()->getSystemValue('installed', false) |
|
763 | - ) { |
|
764 | - // Allow access to CSS resources |
|
765 | - $isScssRequest = false; |
|
766 | - if(strpos($request->getPathInfo(), '/css/') === 0) { |
|
767 | - $isScssRequest = true; |
|
768 | - } |
|
769 | - |
|
770 | - if (!$isScssRequest) { |
|
771 | - header('HTTP/1.1 400 Bad Request'); |
|
772 | - header('Status: 400 Bad Request'); |
|
773 | - |
|
774 | - \OC::$server->getLogger()->warning( |
|
775 | - 'Trusted domain error. "{remoteAddress}" tried to access using "{host}" as host.', |
|
776 | - [ |
|
777 | - 'app' => 'core', |
|
778 | - 'remoteAddress' => $request->getRemoteAddress(), |
|
779 | - 'host' => $host, |
|
780 | - ] |
|
781 | - ); |
|
782 | - |
|
783 | - $tmpl = new OCP\Template('core', 'untrustedDomain', 'guest'); |
|
784 | - $tmpl->assign('domain', $host); |
|
785 | - $tmpl->printPage(); |
|
786 | - |
|
787 | - exit(); |
|
788 | - } |
|
789 | - } |
|
790 | - \OC::$server->getEventLogger()->end('boot'); |
|
791 | - } |
|
792 | - |
|
793 | - /** |
|
794 | - * register hooks for the cache |
|
795 | - */ |
|
796 | - public static function registerCacheHooks() { |
|
797 | - //don't try to do this before we are properly setup |
|
798 | - if (\OC::$server->getSystemConfig()->getValue('installed', false) && !self::checkUpgrade(false)) { |
|
799 | - |
|
800 | - // NOTE: This will be replaced to use OCP |
|
801 | - $userSession = self::$server->getUserSession(); |
|
802 | - $userSession->listen('\OC\User', 'postLogin', function () { |
|
803 | - try { |
|
804 | - $cache = new \OC\Cache\File(); |
|
805 | - $cache->gc(); |
|
806 | - } catch (\OC\ServerNotAvailableException $e) { |
|
807 | - // not a GC exception, pass it on |
|
808 | - throw $e; |
|
809 | - } catch (\Exception $e) { |
|
810 | - // a GC exception should not prevent users from using OC, |
|
811 | - // so log the exception |
|
812 | - \OC::$server->getLogger()->warning('Exception when running cache gc: ' . $e->getMessage(), array('app' => 'core')); |
|
813 | - } |
|
814 | - }); |
|
815 | - } |
|
816 | - } |
|
817 | - |
|
818 | - public static function registerSettingsHooks() { |
|
819 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
820 | - $dispatcher->addListener(OCP\App\ManagerEvent::EVENT_APP_DISABLE, function($event) { |
|
821 | - /** @var \OCP\App\ManagerEvent $event */ |
|
822 | - \OC::$server->getSettingsManager()->onAppDisabled($event->getAppID()); |
|
823 | - }); |
|
824 | - $dispatcher->addListener(OCP\App\ManagerEvent::EVENT_APP_UPDATE, function($event) { |
|
825 | - /** @var \OCP\App\ManagerEvent $event */ |
|
826 | - $jobList = \OC::$server->getJobList(); |
|
827 | - $job = 'OC\\Settings\\RemoveOrphaned'; |
|
828 | - if(!($jobList->has($job, null))) { |
|
829 | - $jobList->add($job); |
|
830 | - } |
|
831 | - }); |
|
832 | - } |
|
833 | - |
|
834 | - private static function registerEncryptionWrapper() { |
|
835 | - $manager = self::$server->getEncryptionManager(); |
|
836 | - \OCP\Util::connectHook('OC_Filesystem', 'preSetup', $manager, 'setupStorage'); |
|
837 | - } |
|
838 | - |
|
839 | - private static function registerEncryptionHooks() { |
|
840 | - $enabled = self::$server->getEncryptionManager()->isEnabled(); |
|
841 | - if ($enabled) { |
|
842 | - \OCP\Util::connectHook('OCP\Share', 'post_shared', 'OC\Encryption\HookManager', 'postShared'); |
|
843 | - \OCP\Util::connectHook('OCP\Share', 'post_unshare', 'OC\Encryption\HookManager', 'postUnshared'); |
|
844 | - \OCP\Util::connectHook('OC_Filesystem', 'post_rename', 'OC\Encryption\HookManager', 'postRename'); |
|
845 | - \OCP\Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', 'OC\Encryption\HookManager', 'postRestore'); |
|
846 | - } |
|
847 | - } |
|
848 | - |
|
849 | - private static function registerAccountHooks() { |
|
850 | - $hookHandler = new \OC\Accounts\Hooks(\OC::$server->getLogger()); |
|
851 | - \OCP\Util::connectHook('OC_User', 'changeUser', $hookHandler, 'changeUserHook'); |
|
852 | - } |
|
853 | - |
|
854 | - /** |
|
855 | - * register hooks for the cache |
|
856 | - */ |
|
857 | - public static function registerLogRotate() { |
|
858 | - $systemConfig = \OC::$server->getSystemConfig(); |
|
859 | - if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !self::checkUpgrade(false)) { |
|
860 | - //don't try to do this before we are properly setup |
|
861 | - //use custom logfile path if defined, otherwise use default of nextcloud.log in data directory |
|
862 | - \OC::$server->getJobList()->add('OC\Log\Rotate'); |
|
863 | - } |
|
864 | - } |
|
865 | - |
|
866 | - /** |
|
867 | - * register hooks for the filesystem |
|
868 | - */ |
|
869 | - public static function registerFilesystemHooks() { |
|
870 | - // Check for blacklisted files |
|
871 | - OC_Hook::connect('OC_Filesystem', 'write', 'OC\Files\Filesystem', 'isBlacklisted'); |
|
872 | - OC_Hook::connect('OC_Filesystem', 'rename', 'OC\Files\Filesystem', 'isBlacklisted'); |
|
873 | - } |
|
874 | - |
|
875 | - /** |
|
876 | - * register hooks for sharing |
|
877 | - */ |
|
878 | - public static function registerShareHooks() { |
|
879 | - if (\OC::$server->getSystemConfig()->getValue('installed')) { |
|
880 | - OC_Hook::connect('OC_User', 'post_deleteUser', 'OC\Share20\Hooks', 'post_deleteUser'); |
|
881 | - OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OC\Share20\Hooks', 'post_removeFromGroup'); |
|
882 | - OC_Hook::connect('OC_User', 'post_deleteGroup', 'OC\Share20\Hooks', 'post_deleteGroup'); |
|
883 | - } |
|
884 | - } |
|
885 | - |
|
886 | - protected static function registerAutoloaderCache() { |
|
887 | - // The class loader takes an optional low-latency cache, which MUST be |
|
888 | - // namespaced. The instanceid is used for namespacing, but might be |
|
889 | - // unavailable at this point. Furthermore, it might not be possible to |
|
890 | - // generate an instanceid via \OC_Util::getInstanceId() because the |
|
891 | - // config file may not be writable. As such, we only register a class |
|
892 | - // loader cache if instanceid is available without trying to create one. |
|
893 | - $instanceId = \OC::$server->getSystemConfig()->getValue('instanceid', null); |
|
894 | - if ($instanceId) { |
|
895 | - try { |
|
896 | - $memcacheFactory = \OC::$server->getMemCacheFactory(); |
|
897 | - self::$loader->setMemoryCache($memcacheFactory->createLocal('Autoloader')); |
|
898 | - } catch (\Exception $ex) { |
|
899 | - } |
|
900 | - } |
|
901 | - } |
|
902 | - |
|
903 | - /** |
|
904 | - * Handle the request |
|
905 | - */ |
|
906 | - public static function handleRequest() { |
|
907 | - |
|
908 | - \OC::$server->getEventLogger()->start('handle_request', 'Handle request'); |
|
909 | - $systemConfig = \OC::$server->getSystemConfig(); |
|
910 | - // load all the classpaths from the enabled apps so they are available |
|
911 | - // in the routing files of each app |
|
912 | - OC::loadAppClassPaths(); |
|
913 | - |
|
914 | - // Check if Nextcloud is installed or in maintenance (update) mode |
|
915 | - if (!$systemConfig->getValue('installed', false)) { |
|
916 | - \OC::$server->getSession()->clear(); |
|
917 | - $setupHelper = new OC\Setup(\OC::$server->getSystemConfig(), \OC::$server->getIniWrapper(), |
|
918 | - \OC::$server->getL10N('lib'), \OC::$server->query(\OCP\Defaults::class), \OC::$server->getLogger(), |
|
919 | - \OC::$server->getSecureRandom()); |
|
920 | - $controller = new OC\Core\Controller\SetupController($setupHelper); |
|
921 | - $controller->run($_POST); |
|
922 | - exit(); |
|
923 | - } |
|
924 | - |
|
925 | - $request = \OC::$server->getRequest(); |
|
926 | - $requestPath = $request->getRawPathInfo(); |
|
927 | - if ($requestPath === '/heartbeat') { |
|
928 | - return; |
|
929 | - } |
|
930 | - if (substr($requestPath, -3) !== '.js') { // we need these files during the upgrade |
|
931 | - self::checkMaintenanceMode(); |
|
932 | - self::checkUpgrade(); |
|
933 | - } |
|
934 | - |
|
935 | - // emergency app disabling |
|
936 | - if ($requestPath === '/disableapp' |
|
937 | - && $request->getMethod() === 'POST' |
|
938 | - && ((array)$request->getParam('appid')) !== '' |
|
939 | - ) { |
|
940 | - \OCP\JSON::callCheck(); |
|
941 | - \OCP\JSON::checkAdminUser(); |
|
942 | - $appIds = (array)$request->getParam('appid'); |
|
943 | - foreach($appIds as $appId) { |
|
944 | - $appId = \OC_App::cleanAppId($appId); |
|
945 | - \OC_App::disable($appId); |
|
946 | - } |
|
947 | - \OC_JSON::success(); |
|
948 | - exit(); |
|
949 | - } |
|
950 | - |
|
951 | - // Always load authentication apps |
|
952 | - OC_App::loadApps(['authentication']); |
|
953 | - |
|
954 | - // Load minimum set of apps |
|
955 | - if (!self::checkUpgrade(false) |
|
956 | - && !$systemConfig->getValue('maintenance', false)) { |
|
957 | - // For logged-in users: Load everything |
|
958 | - if(\OC::$server->getUserSession()->isLoggedIn()) { |
|
959 | - OC_App::loadApps(); |
|
960 | - } else { |
|
961 | - // For guests: Load only filesystem and logging |
|
962 | - OC_App::loadApps(array('filesystem', 'logging')); |
|
963 | - self::handleLogin($request); |
|
964 | - } |
|
965 | - } |
|
966 | - |
|
967 | - if (!self::$CLI) { |
|
968 | - try { |
|
969 | - if (!$systemConfig->getValue('maintenance', false) && !self::checkUpgrade(false)) { |
|
970 | - OC_App::loadApps(array('filesystem', 'logging')); |
|
971 | - OC_App::loadApps(); |
|
972 | - } |
|
973 | - OC_Util::setupFS(); |
|
974 | - OC::$server->getRouter()->match(\OC::$server->getRequest()->getRawPathInfo()); |
|
975 | - return; |
|
976 | - } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) { |
|
977 | - //header('HTTP/1.0 404 Not Found'); |
|
978 | - } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) { |
|
979 | - OC_Response::setStatus(405); |
|
980 | - return; |
|
981 | - } |
|
982 | - } |
|
983 | - |
|
984 | - // Handle WebDAV |
|
985 | - if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') { |
|
986 | - // not allowed any more to prevent people |
|
987 | - // mounting this root directly. |
|
988 | - // Users need to mount remote.php/webdav instead. |
|
989 | - header('HTTP/1.1 405 Method Not Allowed'); |
|
990 | - header('Status: 405 Method Not Allowed'); |
|
991 | - return; |
|
992 | - } |
|
993 | - |
|
994 | - // Someone is logged in |
|
995 | - if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
996 | - OC_App::loadApps(); |
|
997 | - OC_User::setupBackends(); |
|
998 | - OC_Util::setupFS(); |
|
999 | - // FIXME |
|
1000 | - // Redirect to default application |
|
1001 | - OC_Util::redirectToDefaultPage(); |
|
1002 | - } else { |
|
1003 | - // Not handled and not logged in |
|
1004 | - header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute('core.login.showLoginForm')); |
|
1005 | - } |
|
1006 | - } |
|
1007 | - |
|
1008 | - /** |
|
1009 | - * Check login: apache auth, auth token, basic auth |
|
1010 | - * |
|
1011 | - * @param OCP\IRequest $request |
|
1012 | - * @return boolean |
|
1013 | - */ |
|
1014 | - static function handleLogin(OCP\IRequest $request) { |
|
1015 | - $userSession = self::$server->getUserSession(); |
|
1016 | - if (OC_User::handleApacheAuth()) { |
|
1017 | - return true; |
|
1018 | - } |
|
1019 | - if ($userSession->tryTokenLogin($request)) { |
|
1020 | - return true; |
|
1021 | - } |
|
1022 | - if (isset($_COOKIE['nc_username']) |
|
1023 | - && isset($_COOKIE['nc_token']) |
|
1024 | - && isset($_COOKIE['nc_session_id']) |
|
1025 | - && $userSession->loginWithCookie($_COOKIE['nc_username'], $_COOKIE['nc_token'], $_COOKIE['nc_session_id'])) { |
|
1026 | - return true; |
|
1027 | - } |
|
1028 | - if ($userSession->tryBasicAuthLogin($request, \OC::$server->getBruteForceThrottler())) { |
|
1029 | - return true; |
|
1030 | - } |
|
1031 | - return false; |
|
1032 | - } |
|
1033 | - |
|
1034 | - protected static function handleAuthHeaders() { |
|
1035 | - //copy http auth headers for apache+php-fcgid work around |
|
1036 | - if (isset($_SERVER['HTTP_XAUTHORIZATION']) && !isset($_SERVER['HTTP_AUTHORIZATION'])) { |
|
1037 | - $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_XAUTHORIZATION']; |
|
1038 | - } |
|
1039 | - |
|
1040 | - // Extract PHP_AUTH_USER/PHP_AUTH_PW from other headers if necessary. |
|
1041 | - $vars = array( |
|
1042 | - 'HTTP_AUTHORIZATION', // apache+php-cgi work around |
|
1043 | - 'REDIRECT_HTTP_AUTHORIZATION', // apache+php-cgi alternative |
|
1044 | - ); |
|
1045 | - foreach ($vars as $var) { |
|
1046 | - if (isset($_SERVER[$var]) && preg_match('/Basic\s+(.*)$/i', $_SERVER[$var], $matches)) { |
|
1047 | - list($name, $password) = explode(':', base64_decode($matches[1]), 2); |
|
1048 | - $_SERVER['PHP_AUTH_USER'] = $name; |
|
1049 | - $_SERVER['PHP_AUTH_PW'] = $password; |
|
1050 | - break; |
|
1051 | - } |
|
1052 | - } |
|
1053 | - } |
|
62 | + /** |
|
63 | + * Associative array for autoloading. classname => filename |
|
64 | + */ |
|
65 | + public static $CLASSPATH = array(); |
|
66 | + /** |
|
67 | + * The installation path for Nextcloud on the server (e.g. /srv/http/nextcloud) |
|
68 | + */ |
|
69 | + public static $SERVERROOT = ''; |
|
70 | + /** |
|
71 | + * the current request path relative to the Nextcloud root (e.g. files/index.php) |
|
72 | + */ |
|
73 | + private static $SUBURI = ''; |
|
74 | + /** |
|
75 | + * the Nextcloud root path for http requests (e.g. nextcloud/) |
|
76 | + */ |
|
77 | + public static $WEBROOT = ''; |
|
78 | + /** |
|
79 | + * The installation path array of the apps folder on the server (e.g. /srv/http/nextcloud) 'path' and |
|
80 | + * web path in 'url' |
|
81 | + */ |
|
82 | + public static $APPSROOTS = array(); |
|
83 | + |
|
84 | + /** |
|
85 | + * @var string |
|
86 | + */ |
|
87 | + public static $configDir; |
|
88 | + |
|
89 | + /** |
|
90 | + * requested app |
|
91 | + */ |
|
92 | + public static $REQUESTEDAPP = ''; |
|
93 | + |
|
94 | + /** |
|
95 | + * check if Nextcloud runs in cli mode |
|
96 | + */ |
|
97 | + public static $CLI = false; |
|
98 | + |
|
99 | + /** |
|
100 | + * @var \OC\Autoloader $loader |
|
101 | + */ |
|
102 | + public static $loader = null; |
|
103 | + |
|
104 | + /** @var \Composer\Autoload\ClassLoader $composerAutoloader */ |
|
105 | + public static $composerAutoloader = null; |
|
106 | + |
|
107 | + /** |
|
108 | + * @var \OC\Server |
|
109 | + */ |
|
110 | + public static $server = null; |
|
111 | + |
|
112 | + /** |
|
113 | + * @var \OC\Config |
|
114 | + */ |
|
115 | + private static $config = null; |
|
116 | + |
|
117 | + /** |
|
118 | + * @throws \RuntimeException when the 3rdparty directory is missing or |
|
119 | + * the app path list is empty or contains an invalid path |
|
120 | + */ |
|
121 | + public static function initPaths() { |
|
122 | + if(defined('PHPUNIT_CONFIG_DIR')) { |
|
123 | + self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; |
|
124 | + } elseif(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { |
|
125 | + self::$configDir = OC::$SERVERROOT . '/tests/config/'; |
|
126 | + } elseif($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
127 | + self::$configDir = rtrim($dir, '/') . '/'; |
|
128 | + } else { |
|
129 | + self::$configDir = OC::$SERVERROOT . '/config/'; |
|
130 | + } |
|
131 | + self::$config = new \OC\Config(self::$configDir); |
|
132 | + |
|
133 | + OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT))); |
|
134 | + /** |
|
135 | + * FIXME: The following lines are required because we can't yet instantiiate |
|
136 | + * \OC::$server->getRequest() since \OC::$server does not yet exist. |
|
137 | + */ |
|
138 | + $params = [ |
|
139 | + 'server' => [ |
|
140 | + 'SCRIPT_NAME' => $_SERVER['SCRIPT_NAME'], |
|
141 | + 'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME'], |
|
142 | + ], |
|
143 | + ]; |
|
144 | + $fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig(self::$config))); |
|
145 | + $scriptName = $fakeRequest->getScriptName(); |
|
146 | + if (substr($scriptName, -1) == '/') { |
|
147 | + $scriptName .= 'index.php'; |
|
148 | + //make sure suburi follows the same rules as scriptName |
|
149 | + if (substr(OC::$SUBURI, -9) != 'index.php') { |
|
150 | + if (substr(OC::$SUBURI, -1) != '/') { |
|
151 | + OC::$SUBURI = OC::$SUBURI . '/'; |
|
152 | + } |
|
153 | + OC::$SUBURI = OC::$SUBURI . 'index.php'; |
|
154 | + } |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + if (OC::$CLI) { |
|
159 | + OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); |
|
160 | + } else { |
|
161 | + if (substr($scriptName, 0 - strlen(OC::$SUBURI)) === OC::$SUBURI) { |
|
162 | + OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
|
163 | + |
|
164 | + if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
|
165 | + OC::$WEBROOT = '/' . OC::$WEBROOT; |
|
166 | + } |
|
167 | + } else { |
|
168 | + // The scriptName is not ending with OC::$SUBURI |
|
169 | + // This most likely means that we are calling from CLI. |
|
170 | + // However some cron jobs still need to generate |
|
171 | + // a web URL, so we use overwritewebroot as a fallback. |
|
172 | + OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); |
|
173 | + } |
|
174 | + |
|
175 | + // Resolve /nextcloud to /nextcloud/ to ensure to always have a trailing |
|
176 | + // slash which is required by URL generation. |
|
177 | + if($_SERVER['REQUEST_URI'] === \OC::$WEBROOT && |
|
178 | + substr($_SERVER['REQUEST_URI'], -1) !== '/') { |
|
179 | + header('Location: '.\OC::$WEBROOT.'/'); |
|
180 | + exit(); |
|
181 | + } |
|
182 | + } |
|
183 | + |
|
184 | + // search the apps folder |
|
185 | + $config_paths = self::$config->getValue('apps_paths', array()); |
|
186 | + if (!empty($config_paths)) { |
|
187 | + foreach ($config_paths as $paths) { |
|
188 | + if (isset($paths['url']) && isset($paths['path'])) { |
|
189 | + $paths['url'] = rtrim($paths['url'], '/'); |
|
190 | + $paths['path'] = rtrim($paths['path'], '/'); |
|
191 | + OC::$APPSROOTS[] = $paths; |
|
192 | + } |
|
193 | + } |
|
194 | + } elseif (file_exists(OC::$SERVERROOT . '/apps')) { |
|
195 | + OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true); |
|
196 | + } elseif (file_exists(OC::$SERVERROOT . '/../apps')) { |
|
197 | + OC::$APPSROOTS[] = array( |
|
198 | + 'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', |
|
199 | + 'url' => '/apps', |
|
200 | + 'writable' => true |
|
201 | + ); |
|
202 | + } |
|
203 | + |
|
204 | + if (empty(OC::$APPSROOTS)) { |
|
205 | + throw new \RuntimeException('apps directory not found! Please put the Nextcloud apps folder in the Nextcloud folder' |
|
206 | + . ' or the folder above. You can also configure the location in the config.php file.'); |
|
207 | + } |
|
208 | + $paths = array(); |
|
209 | + foreach (OC::$APPSROOTS as $path) { |
|
210 | + $paths[] = $path['path']; |
|
211 | + if (!is_dir($path['path'])) { |
|
212 | + throw new \RuntimeException(sprintf('App directory "%s" not found! Please put the Nextcloud apps folder in the' |
|
213 | + . ' Nextcloud folder or the folder above. You can also configure the location in the' |
|
214 | + . ' config.php file.', $path['path'])); |
|
215 | + } |
|
216 | + } |
|
217 | + |
|
218 | + // set the right include path |
|
219 | + set_include_path( |
|
220 | + implode(PATH_SEPARATOR, $paths) |
|
221 | + ); |
|
222 | + } |
|
223 | + |
|
224 | + public static function checkConfig() { |
|
225 | + $l = \OC::$server->getL10N('lib'); |
|
226 | + |
|
227 | + // Create config if it does not already exist |
|
228 | + $configFilePath = self::$configDir .'/config.php'; |
|
229 | + if(!file_exists($configFilePath)) { |
|
230 | + @touch($configFilePath); |
|
231 | + } |
|
232 | + |
|
233 | + // Check if config is writable |
|
234 | + $configFileWritable = is_writable($configFilePath); |
|
235 | + if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled() |
|
236 | + || !$configFileWritable && self::checkUpgrade(false)) { |
|
237 | + |
|
238 | + $urlGenerator = \OC::$server->getURLGenerator(); |
|
239 | + |
|
240 | + if (self::$CLI) { |
|
241 | + echo $l->t('Cannot write into "config" directory!')."\n"; |
|
242 | + echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; |
|
243 | + echo "\n"; |
|
244 | + echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-dir_permissions') ])."\n"; |
|
245 | + exit; |
|
246 | + } else { |
|
247 | + OC_Template::printErrorPage( |
|
248 | + $l->t('Cannot write into "config" directory!'), |
|
249 | + $l->t('This can usually be fixed by ' |
|
250 | + . '%sgiving the webserver write access to the config directory%s.', |
|
251 | + array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank" rel="noreferrer">', '</a>')) |
|
252 | + ); |
|
253 | + } |
|
254 | + } |
|
255 | + } |
|
256 | + |
|
257 | + public static function checkInstalled() { |
|
258 | + if (defined('OC_CONSOLE')) { |
|
259 | + return; |
|
260 | + } |
|
261 | + // Redirect to installer if not installed |
|
262 | + if (!\OC::$server->getSystemConfig()->getValue('installed', false) && OC::$SUBURI !== '/index.php' && OC::$SUBURI !== '/status.php') { |
|
263 | + if (OC::$CLI) { |
|
264 | + throw new Exception('Not installed'); |
|
265 | + } else { |
|
266 | + $url = OC::$WEBROOT . '/index.php'; |
|
267 | + header('Location: ' . $url); |
|
268 | + } |
|
269 | + exit(); |
|
270 | + } |
|
271 | + } |
|
272 | + |
|
273 | + public static function checkMaintenanceMode() { |
|
274 | + // Allow ajax update script to execute without being stopped |
|
275 | + if (\OC::$server->getSystemConfig()->getValue('maintenance', false) && OC::$SUBURI != '/core/ajax/update.php') { |
|
276 | + // send http status 503 |
|
277 | + header('HTTP/1.1 503 Service Temporarily Unavailable'); |
|
278 | + header('Status: 503 Service Temporarily Unavailable'); |
|
279 | + header('Retry-After: 120'); |
|
280 | + |
|
281 | + // render error page |
|
282 | + $template = new OC_Template('', 'update.user', 'guest'); |
|
283 | + OC_Util::addScript('maintenance-check'); |
|
284 | + $template->printPage(); |
|
285 | + die(); |
|
286 | + } |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * Checks if the version requires an update and shows |
|
291 | + * @param bool $showTemplate Whether an update screen should get shown |
|
292 | + * @return bool|void |
|
293 | + */ |
|
294 | + public static function checkUpgrade($showTemplate = true) { |
|
295 | + if (\OCP\Util::needUpgrade()) { |
|
296 | + $systemConfig = \OC::$server->getSystemConfig(); |
|
297 | + if ($showTemplate && !$systemConfig->getValue('maintenance', false)) { |
|
298 | + self::printUpgradePage(); |
|
299 | + exit(); |
|
300 | + } else { |
|
301 | + return true; |
|
302 | + } |
|
303 | + } |
|
304 | + return false; |
|
305 | + } |
|
306 | + |
|
307 | + /** |
|
308 | + * Prints the upgrade page |
|
309 | + */ |
|
310 | + private static function printUpgradePage() { |
|
311 | + $systemConfig = \OC::$server->getSystemConfig(); |
|
312 | + |
|
313 | + $disableWebUpdater = $systemConfig->getValue('upgrade.disable-web', false); |
|
314 | + $tooBig = false; |
|
315 | + if (!$disableWebUpdater) { |
|
316 | + $apps = \OC::$server->getAppManager(); |
|
317 | + $tooBig = $apps->isInstalled('user_ldap') || $apps->isInstalled('user_shibboleth'); |
|
318 | + if (!$tooBig) { |
|
319 | + // count users |
|
320 | + $stats = \OC::$server->getUserManager()->countUsers(); |
|
321 | + $totalUsers = array_sum($stats); |
|
322 | + $tooBig = ($totalUsers > 50); |
|
323 | + } |
|
324 | + } |
|
325 | + if ($disableWebUpdater || $tooBig) { |
|
326 | + // send http status 503 |
|
327 | + header('HTTP/1.1 503 Service Temporarily Unavailable'); |
|
328 | + header('Status: 503 Service Temporarily Unavailable'); |
|
329 | + header('Retry-After: 120'); |
|
330 | + |
|
331 | + // render error page |
|
332 | + $template = new OC_Template('', 'update.use-cli', 'guest'); |
|
333 | + $template->assign('productName', 'nextcloud'); // for now |
|
334 | + $template->assign('version', OC_Util::getVersionString()); |
|
335 | + $template->assign('tooBig', $tooBig); |
|
336 | + |
|
337 | + $template->printPage(); |
|
338 | + die(); |
|
339 | + } |
|
340 | + |
|
341 | + // check whether this is a core update or apps update |
|
342 | + $installedVersion = $systemConfig->getValue('version', '0.0.0'); |
|
343 | + $currentVersion = implode('.', \OCP\Util::getVersion()); |
|
344 | + |
|
345 | + // if not a core upgrade, then it's apps upgrade |
|
346 | + $isAppsOnlyUpgrade = (version_compare($currentVersion, $installedVersion, '=')); |
|
347 | + |
|
348 | + $oldTheme = $systemConfig->getValue('theme'); |
|
349 | + $systemConfig->setValue('theme', ''); |
|
350 | + OC_Util::addScript('config'); // needed for web root |
|
351 | + OC_Util::addScript('update'); |
|
352 | + |
|
353 | + /** @var \OC\App\AppManager $appManager */ |
|
354 | + $appManager = \OC::$server->getAppManager(); |
|
355 | + |
|
356 | + $tmpl = new OC_Template('', 'update.admin', 'guest'); |
|
357 | + $tmpl->assign('version', OC_Util::getVersionString()); |
|
358 | + $tmpl->assign('isAppsOnlyUpgrade', $isAppsOnlyUpgrade); |
|
359 | + |
|
360 | + // get third party apps |
|
361 | + $ocVersion = \OCP\Util::getVersion(); |
|
362 | + $incompatibleApps = $appManager->getIncompatibleApps($ocVersion); |
|
363 | + $incompatibleShippedApps = []; |
|
364 | + foreach ($incompatibleApps as $appInfo) { |
|
365 | + if ($appManager->isShipped($appInfo['id'])) { |
|
366 | + $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
367 | + } |
|
368 | + } |
|
369 | + |
|
370 | + if (!empty($incompatibleShippedApps)) { |
|
371 | + $l = \OC::$server->getL10N('core'); |
|
372 | + $hint = $l->t('The files of the app %$1s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]); |
|
373 | + throw new \OC\HintException('The files of the app ' . implode(', ', $incompatibleShippedApps) . ' were not replaced correctly. Make sure it is a version compatible with the server.', $hint); |
|
374 | + } |
|
375 | + |
|
376 | + $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
|
377 | + $tmpl->assign('incompatibleAppsList', $incompatibleApps); |
|
378 | + $tmpl->assign('productName', 'Nextcloud'); // for now |
|
379 | + $tmpl->assign('oldTheme', $oldTheme); |
|
380 | + $tmpl->printPage(); |
|
381 | + } |
|
382 | + |
|
383 | + public static function initSession() { |
|
384 | + // prevents javascript from accessing php session cookies |
|
385 | + ini_set('session.cookie_httponly', true); |
|
386 | + |
|
387 | + // set the cookie path to the Nextcloud directory |
|
388 | + $cookie_path = OC::$WEBROOT ? : '/'; |
|
389 | + ini_set('session.cookie_path', $cookie_path); |
|
390 | + |
|
391 | + // Let the session name be changed in the initSession Hook |
|
392 | + $sessionName = OC_Util::getInstanceId(); |
|
393 | + |
|
394 | + try { |
|
395 | + // Allow session apps to create a custom session object |
|
396 | + $useCustomSession = false; |
|
397 | + $session = self::$server->getSession(); |
|
398 | + OC_Hook::emit('OC', 'initSession', array('session' => &$session, 'sessionName' => &$sessionName, 'useCustomSession' => &$useCustomSession)); |
|
399 | + if (!$useCustomSession) { |
|
400 | + // set the session name to the instance id - which is unique |
|
401 | + $session = new \OC\Session\Internal($sessionName); |
|
402 | + } |
|
403 | + |
|
404 | + $cryptoWrapper = \OC::$server->getSessionCryptoWrapper(); |
|
405 | + $session = $cryptoWrapper->wrapSession($session); |
|
406 | + self::$server->setSession($session); |
|
407 | + |
|
408 | + // if session can't be started break with http 500 error |
|
409 | + } catch (Exception $e) { |
|
410 | + \OCP\Util::logException('base', $e); |
|
411 | + //show the user a detailed error page |
|
412 | + OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR); |
|
413 | + OC_Template::printExceptionErrorPage($e); |
|
414 | + die(); |
|
415 | + } |
|
416 | + |
|
417 | + $sessionLifeTime = self::getSessionLifeTime(); |
|
418 | + |
|
419 | + // session timeout |
|
420 | + if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
|
421 | + if (isset($_COOKIE[session_name()])) { |
|
422 | + setcookie(session_name(), null, -1, self::$WEBROOT ? : '/'); |
|
423 | + } |
|
424 | + \OC::$server->getUserSession()->logout(); |
|
425 | + } |
|
426 | + |
|
427 | + $session->set('LAST_ACTIVITY', time()); |
|
428 | + } |
|
429 | + |
|
430 | + /** |
|
431 | + * @return string |
|
432 | + */ |
|
433 | + private static function getSessionLifeTime() { |
|
434 | + return \OC::$server->getConfig()->getSystemValue('session_lifetime', 60 * 60 * 24); |
|
435 | + } |
|
436 | + |
|
437 | + public static function loadAppClassPaths() { |
|
438 | + foreach (OC_App::getEnabledApps() as $app) { |
|
439 | + $appPath = OC_App::getAppPath($app); |
|
440 | + if ($appPath === false) { |
|
441 | + continue; |
|
442 | + } |
|
443 | + |
|
444 | + $file = $appPath . '/appinfo/classpath.php'; |
|
445 | + if (file_exists($file)) { |
|
446 | + require_once $file; |
|
447 | + } |
|
448 | + } |
|
449 | + } |
|
450 | + |
|
451 | + /** |
|
452 | + * Try to set some values to the required Nextcloud default |
|
453 | + */ |
|
454 | + public static function setRequiredIniValues() { |
|
455 | + @ini_set('default_charset', 'UTF-8'); |
|
456 | + @ini_set('gd.jpeg_ignore_warning', 1); |
|
457 | + } |
|
458 | + |
|
459 | + /** |
|
460 | + * Send the same site cookies |
|
461 | + */ |
|
462 | + private static function sendSameSiteCookies() { |
|
463 | + $cookieParams = session_get_cookie_params(); |
|
464 | + $secureCookie = ($cookieParams['secure'] === true) ? 'secure; ' : ''; |
|
465 | + $policies = [ |
|
466 | + 'lax', |
|
467 | + 'strict', |
|
468 | + ]; |
|
469 | + |
|
470 | + // Append __Host to the cookie if it meets the requirements |
|
471 | + $cookiePrefix = ''; |
|
472 | + if($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
473 | + $cookiePrefix = '__Host-'; |
|
474 | + } |
|
475 | + |
|
476 | + foreach($policies as $policy) { |
|
477 | + header( |
|
478 | + sprintf( |
|
479 | + 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
480 | + $cookiePrefix, |
|
481 | + $policy, |
|
482 | + $cookieParams['path'], |
|
483 | + $policy |
|
484 | + ), |
|
485 | + false |
|
486 | + ); |
|
487 | + } |
|
488 | + } |
|
489 | + |
|
490 | + /** |
|
491 | + * Same Site cookie to further mitigate CSRF attacks. This cookie has to |
|
492 | + * be set in every request if cookies are sent to add a second level of |
|
493 | + * defense against CSRF. |
|
494 | + * |
|
495 | + * If the cookie is not sent this will set the cookie and reload the page. |
|
496 | + * We use an additional cookie since we want to protect logout CSRF and |
|
497 | + * also we can't directly interfere with PHP's session mechanism. |
|
498 | + */ |
|
499 | + private static function performSameSiteCookieProtection() { |
|
500 | + $request = \OC::$server->getRequest(); |
|
501 | + |
|
502 | + // Some user agents are notorious and don't really properly follow HTTP |
|
503 | + // specifications. For those, have an automated opt-out. Since the protection |
|
504 | + // for remote.php is applied in base.php as starting point we need to opt out |
|
505 | + // here. |
|
506 | + $incompatibleUserAgents = [ |
|
507 | + // OS X Finder |
|
508 | + '/^WebDAVFS/', |
|
509 | + ]; |
|
510 | + if($request->isUserAgent($incompatibleUserAgents)) { |
|
511 | + return; |
|
512 | + } |
|
513 | + |
|
514 | + if(count($_COOKIE) > 0) { |
|
515 | + $requestUri = $request->getScriptName(); |
|
516 | + $processingScript = explode('/', $requestUri); |
|
517 | + $processingScript = $processingScript[count($processingScript)-1]; |
|
518 | + // FIXME: In a SAML scenario we don't get any strict or lax cookie |
|
519 | + // send for the ACS endpoint. Since we have some legacy code in Nextcloud |
|
520 | + // (direct PHP files) the enforcement of lax cookies is performed here |
|
521 | + // instead of the middleware. |
|
522 | + // |
|
523 | + // This means we cannot exclude some routes from the cookie validation, |
|
524 | + // which normally is not a problem but is a little bit cumbersome for |
|
525 | + // this use-case. |
|
526 | + // Once the old legacy PHP endpoints have been removed we can move |
|
527 | + // the verification into a middleware and also adds some exemptions. |
|
528 | + // |
|
529 | + // Questions about this code? Ask Lukas ;-) |
|
530 | + $currentUrl = substr(explode('?',$request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT)); |
|
531 | + if($currentUrl === '/index.php/apps/user_saml/saml/acs' || $currentUrl === '/apps/user_saml/saml/acs') { |
|
532 | + return; |
|
533 | + } |
|
534 | + // For the "index.php" endpoint only a lax cookie is required. |
|
535 | + if($processingScript === 'index.php') { |
|
536 | + if(!$request->passesLaxCookieCheck()) { |
|
537 | + self::sendSameSiteCookies(); |
|
538 | + header('Location: '.$_SERVER['REQUEST_URI']); |
|
539 | + exit(); |
|
540 | + } |
|
541 | + } else { |
|
542 | + // All other endpoints require the lax and the strict cookie |
|
543 | + if(!$request->passesStrictCookieCheck()) { |
|
544 | + self::sendSameSiteCookies(); |
|
545 | + // Debug mode gets access to the resources without strict cookie |
|
546 | + // due to the fact that the SabreDAV browser also lives there. |
|
547 | + if(!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
548 | + http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); |
|
549 | + exit(); |
|
550 | + } |
|
551 | + } |
|
552 | + } |
|
553 | + } elseif(!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
554 | + self::sendSameSiteCookies(); |
|
555 | + } |
|
556 | + } |
|
557 | + |
|
558 | + public static function init() { |
|
559 | + // calculate the root directories |
|
560 | + OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4)); |
|
561 | + |
|
562 | + // register autoloader |
|
563 | + $loaderStart = microtime(true); |
|
564 | + require_once __DIR__ . '/autoloader.php'; |
|
565 | + self::$loader = new \OC\Autoloader([ |
|
566 | + OC::$SERVERROOT . '/lib/private/legacy', |
|
567 | + ]); |
|
568 | + if (defined('PHPUNIT_RUN')) { |
|
569 | + self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
|
570 | + } |
|
571 | + spl_autoload_register(array(self::$loader, 'load')); |
|
572 | + $loaderEnd = microtime(true); |
|
573 | + |
|
574 | + self::$CLI = (php_sapi_name() == 'cli'); |
|
575 | + |
|
576 | + // Add default composer PSR-4 autoloader |
|
577 | + self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
|
578 | + |
|
579 | + try { |
|
580 | + self::initPaths(); |
|
581 | + // setup 3rdparty autoloader |
|
582 | + $vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php'; |
|
583 | + if (!file_exists($vendorAutoLoad)) { |
|
584 | + throw new \RuntimeException('Composer autoloader not found, unable to continue. Check the folder "3rdparty". Running "git submodule update --init" will initialize the git submodule that handles the subfolder "3rdparty".'); |
|
585 | + } |
|
586 | + require_once $vendorAutoLoad; |
|
587 | + |
|
588 | + } catch (\RuntimeException $e) { |
|
589 | + if (!self::$CLI) { |
|
590 | + $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
|
591 | + $protocol = in_array($claimedProtocol, ['HTTP/1.0', 'HTTP/1.1', 'HTTP/2']) ? $claimedProtocol : 'HTTP/1.1'; |
|
592 | + header($protocol . ' ' . OC_Response::STATUS_SERVICE_UNAVAILABLE); |
|
593 | + } |
|
594 | + // we can't use the template error page here, because this needs the |
|
595 | + // DI container which isn't available yet |
|
596 | + print($e->getMessage()); |
|
597 | + exit(); |
|
598 | + } |
|
599 | + |
|
600 | + // setup the basic server |
|
601 | + self::$server = new \OC\Server(\OC::$WEBROOT, self::$config); |
|
602 | + \OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd); |
|
603 | + \OC::$server->getEventLogger()->start('boot', 'Initialize'); |
|
604 | + |
|
605 | + // Don't display errors and log them |
|
606 | + error_reporting(E_ALL | E_STRICT); |
|
607 | + @ini_set('display_errors', 0); |
|
608 | + @ini_set('log_errors', 1); |
|
609 | + |
|
610 | + if(!date_default_timezone_set('UTC')) { |
|
611 | + throw new \RuntimeException('Could not set timezone to UTC'); |
|
612 | + }; |
|
613 | + |
|
614 | + //try to configure php to enable big file uploads. |
|
615 | + //this doesn´t work always depending on the webserver and php configuration. |
|
616 | + //Let´s try to overwrite some defaults anyway |
|
617 | + |
|
618 | + //try to set the maximum execution time to 60min |
|
619 | + if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
620 | + @set_time_limit(3600); |
|
621 | + } |
|
622 | + @ini_set('max_execution_time', 3600); |
|
623 | + @ini_set('max_input_time', 3600); |
|
624 | + |
|
625 | + //try to set the maximum filesize to 10G |
|
626 | + @ini_set('upload_max_filesize', '10G'); |
|
627 | + @ini_set('post_max_size', '10G'); |
|
628 | + @ini_set('file_uploads', '50'); |
|
629 | + |
|
630 | + self::setRequiredIniValues(); |
|
631 | + self::handleAuthHeaders(); |
|
632 | + self::registerAutoloaderCache(); |
|
633 | + |
|
634 | + // initialize intl fallback is necessary |
|
635 | + \Patchwork\Utf8\Bootup::initIntl(); |
|
636 | + OC_Util::isSetLocaleWorking(); |
|
637 | + |
|
638 | + if (!defined('PHPUNIT_RUN')) { |
|
639 | + OC\Log\ErrorHandler::setLogger(\OC::$server->getLogger()); |
|
640 | + $debug = \OC::$server->getConfig()->getSystemValue('debug', false); |
|
641 | + OC\Log\ErrorHandler::register($debug); |
|
642 | + } |
|
643 | + |
|
644 | + \OC::$server->getEventLogger()->start('init_session', 'Initialize session'); |
|
645 | + OC_App::loadApps(array('session')); |
|
646 | + if (!self::$CLI) { |
|
647 | + self::initSession(); |
|
648 | + } |
|
649 | + \OC::$server->getEventLogger()->end('init_session'); |
|
650 | + self::checkConfig(); |
|
651 | + self::checkInstalled(); |
|
652 | + |
|
653 | + OC_Response::addSecurityHeaders(); |
|
654 | + if(self::$server->getRequest()->getServerProtocol() === 'https') { |
|
655 | + ini_set('session.cookie_secure', true); |
|
656 | + } |
|
657 | + |
|
658 | + self::performSameSiteCookieProtection(); |
|
659 | + |
|
660 | + if (!defined('OC_CONSOLE')) { |
|
661 | + $errors = OC_Util::checkServer(\OC::$server->getSystemConfig()); |
|
662 | + if (count($errors) > 0) { |
|
663 | + if (self::$CLI) { |
|
664 | + // Convert l10n string into regular string for usage in database |
|
665 | + $staticErrors = []; |
|
666 | + foreach ($errors as $error) { |
|
667 | + echo $error['error'] . "\n"; |
|
668 | + echo $error['hint'] . "\n\n"; |
|
669 | + $staticErrors[] = [ |
|
670 | + 'error' => (string)$error['error'], |
|
671 | + 'hint' => (string)$error['hint'], |
|
672 | + ]; |
|
673 | + } |
|
674 | + |
|
675 | + try { |
|
676 | + \OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors)); |
|
677 | + } catch (\Exception $e) { |
|
678 | + echo('Writing to database failed'); |
|
679 | + } |
|
680 | + exit(1); |
|
681 | + } else { |
|
682 | + OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); |
|
683 | + OC_Util::addStyle('guest'); |
|
684 | + OC_Template::printGuestPage('', 'error', array('errors' => $errors)); |
|
685 | + exit; |
|
686 | + } |
|
687 | + } elseif (self::$CLI && \OC::$server->getConfig()->getSystemValue('installed', false)) { |
|
688 | + \OC::$server->getConfig()->deleteAppValue('core', 'cronErrors'); |
|
689 | + } |
|
690 | + } |
|
691 | + //try to set the session lifetime |
|
692 | + $sessionLifeTime = self::getSessionLifeTime(); |
|
693 | + @ini_set('gc_maxlifetime', (string)$sessionLifeTime); |
|
694 | + |
|
695 | + $systemConfig = \OC::$server->getSystemConfig(); |
|
696 | + |
|
697 | + // User and Groups |
|
698 | + if (!$systemConfig->getValue("installed", false)) { |
|
699 | + self::$server->getSession()->set('user_id', ''); |
|
700 | + } |
|
701 | + |
|
702 | + OC_User::useBackend(new \OC\User\Database()); |
|
703 | + \OC::$server->getGroupManager()->addBackend(new \OC\Group\Database()); |
|
704 | + |
|
705 | + // Subscribe to the hook |
|
706 | + \OCP\Util::connectHook( |
|
707 | + '\OCA\Files_Sharing\API\Server2Server', |
|
708 | + 'preLoginNameUsedAsUserName', |
|
709 | + '\OC\User\Database', |
|
710 | + 'preLoginNameUsedAsUserName' |
|
711 | + ); |
|
712 | + |
|
713 | + //setup extra user backends |
|
714 | + if (!self::checkUpgrade(false)) { |
|
715 | + OC_User::setupBackends(); |
|
716 | + } else { |
|
717 | + // Run upgrades in incognito mode |
|
718 | + OC_User::setIncognitoMode(true); |
|
719 | + } |
|
720 | + |
|
721 | + self::registerCacheHooks(); |
|
722 | + self::registerFilesystemHooks(); |
|
723 | + self::registerShareHooks(); |
|
724 | + self::registerLogRotate(); |
|
725 | + self::registerEncryptionWrapper(); |
|
726 | + self::registerEncryptionHooks(); |
|
727 | + self::registerAccountHooks(); |
|
728 | + self::registerSettingsHooks(); |
|
729 | + |
|
730 | + $settings = new \OC\Settings\Application(); |
|
731 | + $settings->register(); |
|
732 | + |
|
733 | + //make sure temporary files are cleaned up |
|
734 | + $tmpManager = \OC::$server->getTempManager(); |
|
735 | + register_shutdown_function(array($tmpManager, 'clean')); |
|
736 | + $lockProvider = \OC::$server->getLockingProvider(); |
|
737 | + register_shutdown_function(array($lockProvider, 'releaseAll')); |
|
738 | + |
|
739 | + // Check whether the sample configuration has been copied |
|
740 | + if($systemConfig->getValue('copied_sample_config', false)) { |
|
741 | + $l = \OC::$server->getL10N('lib'); |
|
742 | + header('HTTP/1.1 503 Service Temporarily Unavailable'); |
|
743 | + header('Status: 503 Service Temporarily Unavailable'); |
|
744 | + OC_Template::printErrorPage( |
|
745 | + $l->t('Sample configuration detected'), |
|
746 | + $l->t('It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php') |
|
747 | + ); |
|
748 | + return; |
|
749 | + } |
|
750 | + |
|
751 | + $request = \OC::$server->getRequest(); |
|
752 | + $host = $request->getInsecureServerHost(); |
|
753 | + /** |
|
754 | + * if the host passed in headers isn't trusted |
|
755 | + * FIXME: Should not be in here at all :see_no_evil: |
|
756 | + */ |
|
757 | + if (!OC::$CLI |
|
758 | + // overwritehost is always trusted, workaround to not have to make |
|
759 | + // \OC\AppFramework\Http\Request::getOverwriteHost public |
|
760 | + && self::$server->getConfig()->getSystemValue('overwritehost') === '' |
|
761 | + && !\OC::$server->getTrustedDomainHelper()->isTrustedDomain($host) |
|
762 | + && self::$server->getConfig()->getSystemValue('installed', false) |
|
763 | + ) { |
|
764 | + // Allow access to CSS resources |
|
765 | + $isScssRequest = false; |
|
766 | + if(strpos($request->getPathInfo(), '/css/') === 0) { |
|
767 | + $isScssRequest = true; |
|
768 | + } |
|
769 | + |
|
770 | + if (!$isScssRequest) { |
|
771 | + header('HTTP/1.1 400 Bad Request'); |
|
772 | + header('Status: 400 Bad Request'); |
|
773 | + |
|
774 | + \OC::$server->getLogger()->warning( |
|
775 | + 'Trusted domain error. "{remoteAddress}" tried to access using "{host}" as host.', |
|
776 | + [ |
|
777 | + 'app' => 'core', |
|
778 | + 'remoteAddress' => $request->getRemoteAddress(), |
|
779 | + 'host' => $host, |
|
780 | + ] |
|
781 | + ); |
|
782 | + |
|
783 | + $tmpl = new OCP\Template('core', 'untrustedDomain', 'guest'); |
|
784 | + $tmpl->assign('domain', $host); |
|
785 | + $tmpl->printPage(); |
|
786 | + |
|
787 | + exit(); |
|
788 | + } |
|
789 | + } |
|
790 | + \OC::$server->getEventLogger()->end('boot'); |
|
791 | + } |
|
792 | + |
|
793 | + /** |
|
794 | + * register hooks for the cache |
|
795 | + */ |
|
796 | + public static function registerCacheHooks() { |
|
797 | + //don't try to do this before we are properly setup |
|
798 | + if (\OC::$server->getSystemConfig()->getValue('installed', false) && !self::checkUpgrade(false)) { |
|
799 | + |
|
800 | + // NOTE: This will be replaced to use OCP |
|
801 | + $userSession = self::$server->getUserSession(); |
|
802 | + $userSession->listen('\OC\User', 'postLogin', function () { |
|
803 | + try { |
|
804 | + $cache = new \OC\Cache\File(); |
|
805 | + $cache->gc(); |
|
806 | + } catch (\OC\ServerNotAvailableException $e) { |
|
807 | + // not a GC exception, pass it on |
|
808 | + throw $e; |
|
809 | + } catch (\Exception $e) { |
|
810 | + // a GC exception should not prevent users from using OC, |
|
811 | + // so log the exception |
|
812 | + \OC::$server->getLogger()->warning('Exception when running cache gc: ' . $e->getMessage(), array('app' => 'core')); |
|
813 | + } |
|
814 | + }); |
|
815 | + } |
|
816 | + } |
|
817 | + |
|
818 | + public static function registerSettingsHooks() { |
|
819 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
820 | + $dispatcher->addListener(OCP\App\ManagerEvent::EVENT_APP_DISABLE, function($event) { |
|
821 | + /** @var \OCP\App\ManagerEvent $event */ |
|
822 | + \OC::$server->getSettingsManager()->onAppDisabled($event->getAppID()); |
|
823 | + }); |
|
824 | + $dispatcher->addListener(OCP\App\ManagerEvent::EVENT_APP_UPDATE, function($event) { |
|
825 | + /** @var \OCP\App\ManagerEvent $event */ |
|
826 | + $jobList = \OC::$server->getJobList(); |
|
827 | + $job = 'OC\\Settings\\RemoveOrphaned'; |
|
828 | + if(!($jobList->has($job, null))) { |
|
829 | + $jobList->add($job); |
|
830 | + } |
|
831 | + }); |
|
832 | + } |
|
833 | + |
|
834 | + private static function registerEncryptionWrapper() { |
|
835 | + $manager = self::$server->getEncryptionManager(); |
|
836 | + \OCP\Util::connectHook('OC_Filesystem', 'preSetup', $manager, 'setupStorage'); |
|
837 | + } |
|
838 | + |
|
839 | + private static function registerEncryptionHooks() { |
|
840 | + $enabled = self::$server->getEncryptionManager()->isEnabled(); |
|
841 | + if ($enabled) { |
|
842 | + \OCP\Util::connectHook('OCP\Share', 'post_shared', 'OC\Encryption\HookManager', 'postShared'); |
|
843 | + \OCP\Util::connectHook('OCP\Share', 'post_unshare', 'OC\Encryption\HookManager', 'postUnshared'); |
|
844 | + \OCP\Util::connectHook('OC_Filesystem', 'post_rename', 'OC\Encryption\HookManager', 'postRename'); |
|
845 | + \OCP\Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', 'OC\Encryption\HookManager', 'postRestore'); |
|
846 | + } |
|
847 | + } |
|
848 | + |
|
849 | + private static function registerAccountHooks() { |
|
850 | + $hookHandler = new \OC\Accounts\Hooks(\OC::$server->getLogger()); |
|
851 | + \OCP\Util::connectHook('OC_User', 'changeUser', $hookHandler, 'changeUserHook'); |
|
852 | + } |
|
853 | + |
|
854 | + /** |
|
855 | + * register hooks for the cache |
|
856 | + */ |
|
857 | + public static function registerLogRotate() { |
|
858 | + $systemConfig = \OC::$server->getSystemConfig(); |
|
859 | + if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !self::checkUpgrade(false)) { |
|
860 | + //don't try to do this before we are properly setup |
|
861 | + //use custom logfile path if defined, otherwise use default of nextcloud.log in data directory |
|
862 | + \OC::$server->getJobList()->add('OC\Log\Rotate'); |
|
863 | + } |
|
864 | + } |
|
865 | + |
|
866 | + /** |
|
867 | + * register hooks for the filesystem |
|
868 | + */ |
|
869 | + public static function registerFilesystemHooks() { |
|
870 | + // Check for blacklisted files |
|
871 | + OC_Hook::connect('OC_Filesystem', 'write', 'OC\Files\Filesystem', 'isBlacklisted'); |
|
872 | + OC_Hook::connect('OC_Filesystem', 'rename', 'OC\Files\Filesystem', 'isBlacklisted'); |
|
873 | + } |
|
874 | + |
|
875 | + /** |
|
876 | + * register hooks for sharing |
|
877 | + */ |
|
878 | + public static function registerShareHooks() { |
|
879 | + if (\OC::$server->getSystemConfig()->getValue('installed')) { |
|
880 | + OC_Hook::connect('OC_User', 'post_deleteUser', 'OC\Share20\Hooks', 'post_deleteUser'); |
|
881 | + OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OC\Share20\Hooks', 'post_removeFromGroup'); |
|
882 | + OC_Hook::connect('OC_User', 'post_deleteGroup', 'OC\Share20\Hooks', 'post_deleteGroup'); |
|
883 | + } |
|
884 | + } |
|
885 | + |
|
886 | + protected static function registerAutoloaderCache() { |
|
887 | + // The class loader takes an optional low-latency cache, which MUST be |
|
888 | + // namespaced. The instanceid is used for namespacing, but might be |
|
889 | + // unavailable at this point. Furthermore, it might not be possible to |
|
890 | + // generate an instanceid via \OC_Util::getInstanceId() because the |
|
891 | + // config file may not be writable. As such, we only register a class |
|
892 | + // loader cache if instanceid is available without trying to create one. |
|
893 | + $instanceId = \OC::$server->getSystemConfig()->getValue('instanceid', null); |
|
894 | + if ($instanceId) { |
|
895 | + try { |
|
896 | + $memcacheFactory = \OC::$server->getMemCacheFactory(); |
|
897 | + self::$loader->setMemoryCache($memcacheFactory->createLocal('Autoloader')); |
|
898 | + } catch (\Exception $ex) { |
|
899 | + } |
|
900 | + } |
|
901 | + } |
|
902 | + |
|
903 | + /** |
|
904 | + * Handle the request |
|
905 | + */ |
|
906 | + public static function handleRequest() { |
|
907 | + |
|
908 | + \OC::$server->getEventLogger()->start('handle_request', 'Handle request'); |
|
909 | + $systemConfig = \OC::$server->getSystemConfig(); |
|
910 | + // load all the classpaths from the enabled apps so they are available |
|
911 | + // in the routing files of each app |
|
912 | + OC::loadAppClassPaths(); |
|
913 | + |
|
914 | + // Check if Nextcloud is installed or in maintenance (update) mode |
|
915 | + if (!$systemConfig->getValue('installed', false)) { |
|
916 | + \OC::$server->getSession()->clear(); |
|
917 | + $setupHelper = new OC\Setup(\OC::$server->getSystemConfig(), \OC::$server->getIniWrapper(), |
|
918 | + \OC::$server->getL10N('lib'), \OC::$server->query(\OCP\Defaults::class), \OC::$server->getLogger(), |
|
919 | + \OC::$server->getSecureRandom()); |
|
920 | + $controller = new OC\Core\Controller\SetupController($setupHelper); |
|
921 | + $controller->run($_POST); |
|
922 | + exit(); |
|
923 | + } |
|
924 | + |
|
925 | + $request = \OC::$server->getRequest(); |
|
926 | + $requestPath = $request->getRawPathInfo(); |
|
927 | + if ($requestPath === '/heartbeat') { |
|
928 | + return; |
|
929 | + } |
|
930 | + if (substr($requestPath, -3) !== '.js') { // we need these files during the upgrade |
|
931 | + self::checkMaintenanceMode(); |
|
932 | + self::checkUpgrade(); |
|
933 | + } |
|
934 | + |
|
935 | + // emergency app disabling |
|
936 | + if ($requestPath === '/disableapp' |
|
937 | + && $request->getMethod() === 'POST' |
|
938 | + && ((array)$request->getParam('appid')) !== '' |
|
939 | + ) { |
|
940 | + \OCP\JSON::callCheck(); |
|
941 | + \OCP\JSON::checkAdminUser(); |
|
942 | + $appIds = (array)$request->getParam('appid'); |
|
943 | + foreach($appIds as $appId) { |
|
944 | + $appId = \OC_App::cleanAppId($appId); |
|
945 | + \OC_App::disable($appId); |
|
946 | + } |
|
947 | + \OC_JSON::success(); |
|
948 | + exit(); |
|
949 | + } |
|
950 | + |
|
951 | + // Always load authentication apps |
|
952 | + OC_App::loadApps(['authentication']); |
|
953 | + |
|
954 | + // Load minimum set of apps |
|
955 | + if (!self::checkUpgrade(false) |
|
956 | + && !$systemConfig->getValue('maintenance', false)) { |
|
957 | + // For logged-in users: Load everything |
|
958 | + if(\OC::$server->getUserSession()->isLoggedIn()) { |
|
959 | + OC_App::loadApps(); |
|
960 | + } else { |
|
961 | + // For guests: Load only filesystem and logging |
|
962 | + OC_App::loadApps(array('filesystem', 'logging')); |
|
963 | + self::handleLogin($request); |
|
964 | + } |
|
965 | + } |
|
966 | + |
|
967 | + if (!self::$CLI) { |
|
968 | + try { |
|
969 | + if (!$systemConfig->getValue('maintenance', false) && !self::checkUpgrade(false)) { |
|
970 | + OC_App::loadApps(array('filesystem', 'logging')); |
|
971 | + OC_App::loadApps(); |
|
972 | + } |
|
973 | + OC_Util::setupFS(); |
|
974 | + OC::$server->getRouter()->match(\OC::$server->getRequest()->getRawPathInfo()); |
|
975 | + return; |
|
976 | + } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) { |
|
977 | + //header('HTTP/1.0 404 Not Found'); |
|
978 | + } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) { |
|
979 | + OC_Response::setStatus(405); |
|
980 | + return; |
|
981 | + } |
|
982 | + } |
|
983 | + |
|
984 | + // Handle WebDAV |
|
985 | + if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') { |
|
986 | + // not allowed any more to prevent people |
|
987 | + // mounting this root directly. |
|
988 | + // Users need to mount remote.php/webdav instead. |
|
989 | + header('HTTP/1.1 405 Method Not Allowed'); |
|
990 | + header('Status: 405 Method Not Allowed'); |
|
991 | + return; |
|
992 | + } |
|
993 | + |
|
994 | + // Someone is logged in |
|
995 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
996 | + OC_App::loadApps(); |
|
997 | + OC_User::setupBackends(); |
|
998 | + OC_Util::setupFS(); |
|
999 | + // FIXME |
|
1000 | + // Redirect to default application |
|
1001 | + OC_Util::redirectToDefaultPage(); |
|
1002 | + } else { |
|
1003 | + // Not handled and not logged in |
|
1004 | + header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute('core.login.showLoginForm')); |
|
1005 | + } |
|
1006 | + } |
|
1007 | + |
|
1008 | + /** |
|
1009 | + * Check login: apache auth, auth token, basic auth |
|
1010 | + * |
|
1011 | + * @param OCP\IRequest $request |
|
1012 | + * @return boolean |
|
1013 | + */ |
|
1014 | + static function handleLogin(OCP\IRequest $request) { |
|
1015 | + $userSession = self::$server->getUserSession(); |
|
1016 | + if (OC_User::handleApacheAuth()) { |
|
1017 | + return true; |
|
1018 | + } |
|
1019 | + if ($userSession->tryTokenLogin($request)) { |
|
1020 | + return true; |
|
1021 | + } |
|
1022 | + if (isset($_COOKIE['nc_username']) |
|
1023 | + && isset($_COOKIE['nc_token']) |
|
1024 | + && isset($_COOKIE['nc_session_id']) |
|
1025 | + && $userSession->loginWithCookie($_COOKIE['nc_username'], $_COOKIE['nc_token'], $_COOKIE['nc_session_id'])) { |
|
1026 | + return true; |
|
1027 | + } |
|
1028 | + if ($userSession->tryBasicAuthLogin($request, \OC::$server->getBruteForceThrottler())) { |
|
1029 | + return true; |
|
1030 | + } |
|
1031 | + return false; |
|
1032 | + } |
|
1033 | + |
|
1034 | + protected static function handleAuthHeaders() { |
|
1035 | + //copy http auth headers for apache+php-fcgid work around |
|
1036 | + if (isset($_SERVER['HTTP_XAUTHORIZATION']) && !isset($_SERVER['HTTP_AUTHORIZATION'])) { |
|
1037 | + $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_XAUTHORIZATION']; |
|
1038 | + } |
|
1039 | + |
|
1040 | + // Extract PHP_AUTH_USER/PHP_AUTH_PW from other headers if necessary. |
|
1041 | + $vars = array( |
|
1042 | + 'HTTP_AUTHORIZATION', // apache+php-cgi work around |
|
1043 | + 'REDIRECT_HTTP_AUTHORIZATION', // apache+php-cgi alternative |
|
1044 | + ); |
|
1045 | + foreach ($vars as $var) { |
|
1046 | + if (isset($_SERVER[$var]) && preg_match('/Basic\s+(.*)$/i', $_SERVER[$var], $matches)) { |
|
1047 | + list($name, $password) = explode(':', base64_decode($matches[1]), 2); |
|
1048 | + $_SERVER['PHP_AUTH_USER'] = $name; |
|
1049 | + $_SERVER['PHP_AUTH_PW'] = $password; |
|
1050 | + break; |
|
1051 | + } |
|
1052 | + } |
|
1053 | + } |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | OC::init(); |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | * the app path list is empty or contains an invalid path |
120 | 120 | */ |
121 | 121 | public static function initPaths() { |
122 | - if(defined('PHPUNIT_CONFIG_DIR')) { |
|
123 | - self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; |
|
124 | - } elseif(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { |
|
125 | - self::$configDir = OC::$SERVERROOT . '/tests/config/'; |
|
126 | - } elseif($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
127 | - self::$configDir = rtrim($dir, '/') . '/'; |
|
122 | + if (defined('PHPUNIT_CONFIG_DIR')) { |
|
123 | + self::$configDir = OC::$SERVERROOT.'/'.PHPUNIT_CONFIG_DIR.'/'; |
|
124 | + } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT.'/tests/config/')) { |
|
125 | + self::$configDir = OC::$SERVERROOT.'/tests/config/'; |
|
126 | + } elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
127 | + self::$configDir = rtrim($dir, '/').'/'; |
|
128 | 128 | } else { |
129 | - self::$configDir = OC::$SERVERROOT . '/config/'; |
|
129 | + self::$configDir = OC::$SERVERROOT.'/config/'; |
|
130 | 130 | } |
131 | 131 | self::$config = new \OC\Config(self::$configDir); |
132 | 132 | |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | //make sure suburi follows the same rules as scriptName |
149 | 149 | if (substr(OC::$SUBURI, -9) != 'index.php') { |
150 | 150 | if (substr(OC::$SUBURI, -1) != '/') { |
151 | - OC::$SUBURI = OC::$SUBURI . '/'; |
|
151 | + OC::$SUBURI = OC::$SUBURI.'/'; |
|
152 | 152 | } |
153 | - OC::$SUBURI = OC::$SUBURI . 'index.php'; |
|
153 | + OC::$SUBURI = OC::$SUBURI.'index.php'; |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
163 | 163 | |
164 | 164 | if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
165 | - OC::$WEBROOT = '/' . OC::$WEBROOT; |
|
165 | + OC::$WEBROOT = '/'.OC::$WEBROOT; |
|
166 | 166 | } |
167 | 167 | } else { |
168 | 168 | // The scriptName is not ending with OC::$SUBURI |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | // Resolve /nextcloud to /nextcloud/ to ensure to always have a trailing |
176 | 176 | // slash which is required by URL generation. |
177 | - if($_SERVER['REQUEST_URI'] === \OC::$WEBROOT && |
|
177 | + if ($_SERVER['REQUEST_URI'] === \OC::$WEBROOT && |
|
178 | 178 | substr($_SERVER['REQUEST_URI'], -1) !== '/') { |
179 | 179 | header('Location: '.\OC::$WEBROOT.'/'); |
180 | 180 | exit(); |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | OC::$APPSROOTS[] = $paths; |
192 | 192 | } |
193 | 193 | } |
194 | - } elseif (file_exists(OC::$SERVERROOT . '/apps')) { |
|
195 | - OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true); |
|
196 | - } elseif (file_exists(OC::$SERVERROOT . '/../apps')) { |
|
194 | + } elseif (file_exists(OC::$SERVERROOT.'/apps')) { |
|
195 | + OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => true); |
|
196 | + } elseif (file_exists(OC::$SERVERROOT.'/../apps')) { |
|
197 | 197 | OC::$APPSROOTS[] = array( |
198 | - 'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', |
|
198 | + 'path' => rtrim(dirname(OC::$SERVERROOT), '/').'/apps', |
|
199 | 199 | 'url' => '/apps', |
200 | 200 | 'writable' => true |
201 | 201 | ); |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | $l = \OC::$server->getL10N('lib'); |
226 | 226 | |
227 | 227 | // Create config if it does not already exist |
228 | - $configFilePath = self::$configDir .'/config.php'; |
|
229 | - if(!file_exists($configFilePath)) { |
|
228 | + $configFilePath = self::$configDir.'/config.php'; |
|
229 | + if (!file_exists($configFilePath)) { |
|
230 | 230 | @touch($configFilePath); |
231 | 231 | } |
232 | 232 | |
@@ -241,14 +241,14 @@ discard block |
||
241 | 241 | echo $l->t('Cannot write into "config" directory!')."\n"; |
242 | 242 | echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; |
243 | 243 | echo "\n"; |
244 | - echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-dir_permissions') ])."\n"; |
|
244 | + echo $l->t('See %s', [$urlGenerator->linkToDocs('admin-dir_permissions')])."\n"; |
|
245 | 245 | exit; |
246 | 246 | } else { |
247 | 247 | OC_Template::printErrorPage( |
248 | 248 | $l->t('Cannot write into "config" directory!'), |
249 | 249 | $l->t('This can usually be fixed by ' |
250 | 250 | . '%sgiving the webserver write access to the config directory%s.', |
251 | - array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank" rel="noreferrer">', '</a>')) |
|
251 | + array('<a href="'.$urlGenerator->linkToDocs('admin-dir_permissions').'" target="_blank" rel="noreferrer">', '</a>')) |
|
252 | 252 | ); |
253 | 253 | } |
254 | 254 | } |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | if (OC::$CLI) { |
264 | 264 | throw new Exception('Not installed'); |
265 | 265 | } else { |
266 | - $url = OC::$WEBROOT . '/index.php'; |
|
267 | - header('Location: ' . $url); |
|
266 | + $url = OC::$WEBROOT.'/index.php'; |
|
267 | + header('Location: '.$url); |
|
268 | 268 | } |
269 | 269 | exit(); |
270 | 270 | } |
@@ -363,14 +363,14 @@ discard block |
||
363 | 363 | $incompatibleShippedApps = []; |
364 | 364 | foreach ($incompatibleApps as $appInfo) { |
365 | 365 | if ($appManager->isShipped($appInfo['id'])) { |
366 | - $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
366 | + $incompatibleShippedApps[] = $appInfo['name'].' ('.$appInfo['id'].')'; |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
370 | 370 | if (!empty($incompatibleShippedApps)) { |
371 | 371 | $l = \OC::$server->getL10N('core'); |
372 | 372 | $hint = $l->t('The files of the app %$1s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]); |
373 | - throw new \OC\HintException('The files of the app ' . implode(', ', $incompatibleShippedApps) . ' were not replaced correctly. Make sure it is a version compatible with the server.', $hint); |
|
373 | + throw new \OC\HintException('The files of the app '.implode(', ', $incompatibleShippedApps).' were not replaced correctly. Make sure it is a version compatible with the server.', $hint); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | ini_set('session.cookie_httponly', true); |
386 | 386 | |
387 | 387 | // set the cookie path to the Nextcloud directory |
388 | - $cookie_path = OC::$WEBROOT ? : '/'; |
|
388 | + $cookie_path = OC::$WEBROOT ?: '/'; |
|
389 | 389 | ini_set('session.cookie_path', $cookie_path); |
390 | 390 | |
391 | 391 | // Let the session name be changed in the initSession Hook |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | // session timeout |
420 | 420 | if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
421 | 421 | if (isset($_COOKIE[session_name()])) { |
422 | - setcookie(session_name(), null, -1, self::$WEBROOT ? : '/'); |
|
422 | + setcookie(session_name(), null, -1, self::$WEBROOT ?: '/'); |
|
423 | 423 | } |
424 | 424 | \OC::$server->getUserSession()->logout(); |
425 | 425 | } |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | continue; |
442 | 442 | } |
443 | 443 | |
444 | - $file = $appPath . '/appinfo/classpath.php'; |
|
444 | + $file = $appPath.'/appinfo/classpath.php'; |
|
445 | 445 | if (file_exists($file)) { |
446 | 446 | require_once $file; |
447 | 447 | } |
@@ -469,14 +469,14 @@ discard block |
||
469 | 469 | |
470 | 470 | // Append __Host to the cookie if it meets the requirements |
471 | 471 | $cookiePrefix = ''; |
472 | - if($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
472 | + if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
473 | 473 | $cookiePrefix = '__Host-'; |
474 | 474 | } |
475 | 475 | |
476 | - foreach($policies as $policy) { |
|
476 | + foreach ($policies as $policy) { |
|
477 | 477 | header( |
478 | 478 | sprintf( |
479 | - 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
479 | + 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
480 | 480 | $cookiePrefix, |
481 | 481 | $policy, |
482 | 482 | $cookieParams['path'], |
@@ -507,14 +507,14 @@ discard block |
||
507 | 507 | // OS X Finder |
508 | 508 | '/^WebDAVFS/', |
509 | 509 | ]; |
510 | - if($request->isUserAgent($incompatibleUserAgents)) { |
|
510 | + if ($request->isUserAgent($incompatibleUserAgents)) { |
|
511 | 511 | return; |
512 | 512 | } |
513 | 513 | |
514 | - if(count($_COOKIE) > 0) { |
|
514 | + if (count($_COOKIE) > 0) { |
|
515 | 515 | $requestUri = $request->getScriptName(); |
516 | 516 | $processingScript = explode('/', $requestUri); |
517 | - $processingScript = $processingScript[count($processingScript)-1]; |
|
517 | + $processingScript = $processingScript[count($processingScript) - 1]; |
|
518 | 518 | // FIXME: In a SAML scenario we don't get any strict or lax cookie |
519 | 519 | // send for the ACS endpoint. Since we have some legacy code in Nextcloud |
520 | 520 | // (direct PHP files) the enforcement of lax cookies is performed here |
@@ -527,30 +527,30 @@ discard block |
||
527 | 527 | // the verification into a middleware and also adds some exemptions. |
528 | 528 | // |
529 | 529 | // Questions about this code? Ask Lukas ;-) |
530 | - $currentUrl = substr(explode('?',$request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT)); |
|
531 | - if($currentUrl === '/index.php/apps/user_saml/saml/acs' || $currentUrl === '/apps/user_saml/saml/acs') { |
|
530 | + $currentUrl = substr(explode('?', $request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT)); |
|
531 | + if ($currentUrl === '/index.php/apps/user_saml/saml/acs' || $currentUrl === '/apps/user_saml/saml/acs') { |
|
532 | 532 | return; |
533 | 533 | } |
534 | 534 | // For the "index.php" endpoint only a lax cookie is required. |
535 | - if($processingScript === 'index.php') { |
|
536 | - if(!$request->passesLaxCookieCheck()) { |
|
535 | + if ($processingScript === 'index.php') { |
|
536 | + if (!$request->passesLaxCookieCheck()) { |
|
537 | 537 | self::sendSameSiteCookies(); |
538 | 538 | header('Location: '.$_SERVER['REQUEST_URI']); |
539 | 539 | exit(); |
540 | 540 | } |
541 | 541 | } else { |
542 | 542 | // All other endpoints require the lax and the strict cookie |
543 | - if(!$request->passesStrictCookieCheck()) { |
|
543 | + if (!$request->passesStrictCookieCheck()) { |
|
544 | 544 | self::sendSameSiteCookies(); |
545 | 545 | // Debug mode gets access to the resources without strict cookie |
546 | 546 | // due to the fact that the SabreDAV browser also lives there. |
547 | - if(!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
547 | + if (!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
548 | 548 | http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); |
549 | 549 | exit(); |
550 | 550 | } |
551 | 551 | } |
552 | 552 | } |
553 | - } elseif(!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
553 | + } elseif (!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
554 | 554 | self::sendSameSiteCookies(); |
555 | 555 | } |
556 | 556 | } |
@@ -561,12 +561,12 @@ discard block |
||
561 | 561 | |
562 | 562 | // register autoloader |
563 | 563 | $loaderStart = microtime(true); |
564 | - require_once __DIR__ . '/autoloader.php'; |
|
564 | + require_once __DIR__.'/autoloader.php'; |
|
565 | 565 | self::$loader = new \OC\Autoloader([ |
566 | - OC::$SERVERROOT . '/lib/private/legacy', |
|
566 | + OC::$SERVERROOT.'/lib/private/legacy', |
|
567 | 567 | ]); |
568 | 568 | if (defined('PHPUNIT_RUN')) { |
569 | - self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
|
569 | + self::$loader->addValidRoot(OC::$SERVERROOT.'/tests'); |
|
570 | 570 | } |
571 | 571 | spl_autoload_register(array(self::$loader, 'load')); |
572 | 572 | $loaderEnd = microtime(true); |
@@ -574,12 +574,12 @@ discard block |
||
574 | 574 | self::$CLI = (php_sapi_name() == 'cli'); |
575 | 575 | |
576 | 576 | // Add default composer PSR-4 autoloader |
577 | - self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
|
577 | + self::$composerAutoloader = require_once OC::$SERVERROOT.'/lib/composer/autoload.php'; |
|
578 | 578 | |
579 | 579 | try { |
580 | 580 | self::initPaths(); |
581 | 581 | // setup 3rdparty autoloader |
582 | - $vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php'; |
|
582 | + $vendorAutoLoad = OC::$SERVERROOT.'/3rdparty/autoload.php'; |
|
583 | 583 | if (!file_exists($vendorAutoLoad)) { |
584 | 584 | throw new \RuntimeException('Composer autoloader not found, unable to continue. Check the folder "3rdparty". Running "git submodule update --init" will initialize the git submodule that handles the subfolder "3rdparty".'); |
585 | 585 | } |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | if (!self::$CLI) { |
590 | 590 | $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
591 | 591 | $protocol = in_array($claimedProtocol, ['HTTP/1.0', 'HTTP/1.1', 'HTTP/2']) ? $claimedProtocol : 'HTTP/1.1'; |
592 | - header($protocol . ' ' . OC_Response::STATUS_SERVICE_UNAVAILABLE); |
|
592 | + header($protocol.' '.OC_Response::STATUS_SERVICE_UNAVAILABLE); |
|
593 | 593 | } |
594 | 594 | // we can't use the template error page here, because this needs the |
595 | 595 | // DI container which isn't available yet |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | @ini_set('display_errors', 0); |
608 | 608 | @ini_set('log_errors', 1); |
609 | 609 | |
610 | - if(!date_default_timezone_set('UTC')) { |
|
610 | + if (!date_default_timezone_set('UTC')) { |
|
611 | 611 | throw new \RuntimeException('Could not set timezone to UTC'); |
612 | 612 | }; |
613 | 613 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | self::checkInstalled(); |
652 | 652 | |
653 | 653 | OC_Response::addSecurityHeaders(); |
654 | - if(self::$server->getRequest()->getServerProtocol() === 'https') { |
|
654 | + if (self::$server->getRequest()->getServerProtocol() === 'https') { |
|
655 | 655 | ini_set('session.cookie_secure', true); |
656 | 656 | } |
657 | 657 | |
@@ -664,11 +664,11 @@ discard block |
||
664 | 664 | // Convert l10n string into regular string for usage in database |
665 | 665 | $staticErrors = []; |
666 | 666 | foreach ($errors as $error) { |
667 | - echo $error['error'] . "\n"; |
|
668 | - echo $error['hint'] . "\n\n"; |
|
667 | + echo $error['error']."\n"; |
|
668 | + echo $error['hint']."\n\n"; |
|
669 | 669 | $staticErrors[] = [ |
670 | - 'error' => (string)$error['error'], |
|
671 | - 'hint' => (string)$error['hint'], |
|
670 | + 'error' => (string) $error['error'], |
|
671 | + 'hint' => (string) $error['hint'], |
|
672 | 672 | ]; |
673 | 673 | } |
674 | 674 | |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | } |
691 | 691 | //try to set the session lifetime |
692 | 692 | $sessionLifeTime = self::getSessionLifeTime(); |
693 | - @ini_set('gc_maxlifetime', (string)$sessionLifeTime); |
|
693 | + @ini_set('gc_maxlifetime', (string) $sessionLifeTime); |
|
694 | 694 | |
695 | 695 | $systemConfig = \OC::$server->getSystemConfig(); |
696 | 696 | |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | register_shutdown_function(array($lockProvider, 'releaseAll')); |
738 | 738 | |
739 | 739 | // Check whether the sample configuration has been copied |
740 | - if($systemConfig->getValue('copied_sample_config', false)) { |
|
740 | + if ($systemConfig->getValue('copied_sample_config', false)) { |
|
741 | 741 | $l = \OC::$server->getL10N('lib'); |
742 | 742 | header('HTTP/1.1 503 Service Temporarily Unavailable'); |
743 | 743 | header('Status: 503 Service Temporarily Unavailable'); |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | ) { |
764 | 764 | // Allow access to CSS resources |
765 | 765 | $isScssRequest = false; |
766 | - if(strpos($request->getPathInfo(), '/css/') === 0) { |
|
766 | + if (strpos($request->getPathInfo(), '/css/') === 0) { |
|
767 | 767 | $isScssRequest = true; |
768 | 768 | } |
769 | 769 | |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | |
800 | 800 | // NOTE: This will be replaced to use OCP |
801 | 801 | $userSession = self::$server->getUserSession(); |
802 | - $userSession->listen('\OC\User', 'postLogin', function () { |
|
802 | + $userSession->listen('\OC\User', 'postLogin', function() { |
|
803 | 803 | try { |
804 | 804 | $cache = new \OC\Cache\File(); |
805 | 805 | $cache->gc(); |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | } catch (\Exception $e) { |
810 | 810 | // a GC exception should not prevent users from using OC, |
811 | 811 | // so log the exception |
812 | - \OC::$server->getLogger()->warning('Exception when running cache gc: ' . $e->getMessage(), array('app' => 'core')); |
|
812 | + \OC::$server->getLogger()->warning('Exception when running cache gc: '.$e->getMessage(), array('app' => 'core')); |
|
813 | 813 | } |
814 | 814 | }); |
815 | 815 | } |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | /** @var \OCP\App\ManagerEvent $event */ |
826 | 826 | $jobList = \OC::$server->getJobList(); |
827 | 827 | $job = 'OC\\Settings\\RemoveOrphaned'; |
828 | - if(!($jobList->has($job, null))) { |
|
828 | + if (!($jobList->has($job, null))) { |
|
829 | 829 | $jobList->add($job); |
830 | 830 | } |
831 | 831 | }); |
@@ -935,12 +935,12 @@ discard block |
||
935 | 935 | // emergency app disabling |
936 | 936 | if ($requestPath === '/disableapp' |
937 | 937 | && $request->getMethod() === 'POST' |
938 | - && ((array)$request->getParam('appid')) !== '' |
|
938 | + && ((array) $request->getParam('appid')) !== '' |
|
939 | 939 | ) { |
940 | 940 | \OCP\JSON::callCheck(); |
941 | 941 | \OCP\JSON::checkAdminUser(); |
942 | - $appIds = (array)$request->getParam('appid'); |
|
943 | - foreach($appIds as $appId) { |
|
942 | + $appIds = (array) $request->getParam('appid'); |
|
943 | + foreach ($appIds as $appId) { |
|
944 | 944 | $appId = \OC_App::cleanAppId($appId); |
945 | 945 | \OC_App::disable($appId); |
946 | 946 | } |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | if (!self::checkUpgrade(false) |
956 | 956 | && !$systemConfig->getValue('maintenance', false)) { |
957 | 957 | // For logged-in users: Load everything |
958 | - if(\OC::$server->getUserSession()->isLoggedIn()) { |
|
958 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
959 | 959 | OC_App::loadApps(); |
960 | 960 | } else { |
961 | 961 | // For guests: Load only filesystem and logging |
@@ -23,20 +23,20 @@ |
||
23 | 23 | |
24 | 24 | class CoreBundle extends Bundle { |
25 | 25 | |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getName() { |
|
30 | - return 'Core bundle'; |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getName() { |
|
30 | + return 'Core bundle'; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * {@inheritDoc} |
|
35 | - */ |
|
36 | - public function getAppIdentifiers() { |
|
37 | - return [ |
|
38 | - 'bruteforcesettings', |
|
39 | - ]; |
|
40 | - } |
|
33 | + /** |
|
34 | + * {@inheritDoc} |
|
35 | + */ |
|
36 | + public function getAppIdentifiers() { |
|
37 | + return [ |
|
38 | + 'bruteforcesettings', |
|
39 | + ]; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * {@inheritDoc} |
28 | 28 | */ |
29 | 29 | public function getName() { |
30 | - return (string)$this->l10n->t('Groupware bundle'); |
|
30 | + return (string) $this->l10n->t('Groupware bundle'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -23,22 +23,22 @@ |
||
23 | 23 | |
24 | 24 | class GroupwareBundle extends Bundle { |
25 | 25 | |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getName() { |
|
30 | - return (string)$this->l10n->t('Groupware bundle'); |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getName() { |
|
30 | + return (string)$this->l10n->t('Groupware bundle'); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * {@inheritDoc} |
|
35 | - */ |
|
36 | - public function getAppIdentifiers() { |
|
37 | - return [ |
|
38 | - 'calendar', |
|
39 | - 'contacts', |
|
40 | - 'spreed', |
|
41 | - ]; |
|
42 | - } |
|
33 | + /** |
|
34 | + * {@inheritDoc} |
|
35 | + */ |
|
36 | + public function getAppIdentifiers() { |
|
37 | + return [ |
|
38 | + 'calendar', |
|
39 | + 'contacts', |
|
40 | + 'spreed', |
|
41 | + ]; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | } |
@@ -23,25 +23,25 @@ |
||
23 | 23 | |
24 | 24 | class EnterpriseBundle extends Bundle { |
25 | 25 | |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getName() { |
|
30 | - return (string)$this->l10n->t('Enterprise bundle'); |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getName() { |
|
30 | + return (string)$this->l10n->t('Enterprise bundle'); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * {@inheritDoc} |
|
35 | - */ |
|
36 | - public function getAppIdentifiers() { |
|
37 | - return [ |
|
38 | - 'admin_audit', |
|
39 | - 'user_ldap', |
|
40 | - 'files_retention', |
|
41 | - 'files_automatedtagging', |
|
42 | - 'user_saml', |
|
43 | - 'files_accesscontrol', |
|
44 | - ]; |
|
45 | - } |
|
33 | + /** |
|
34 | + * {@inheritDoc} |
|
35 | + */ |
|
36 | + public function getAppIdentifiers() { |
|
37 | + return [ |
|
38 | + 'admin_audit', |
|
39 | + 'user_ldap', |
|
40 | + 'files_retention', |
|
41 | + 'files_automatedtagging', |
|
42 | + 'user_saml', |
|
43 | + 'files_accesscontrol', |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * {@inheritDoc} |
28 | 28 | */ |
29 | 29 | public function getName() { |
30 | - return (string)$this->l10n->t('Enterprise bundle'); |
|
30 | + return (string) $this->l10n->t('Enterprise bundle'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -24,36 +24,36 @@ |
||
24 | 24 | use OCP\IL10N; |
25 | 25 | |
26 | 26 | abstract class Bundle { |
27 | - /** @var IL10N */ |
|
28 | - protected $l10n; |
|
27 | + /** @var IL10N */ |
|
28 | + protected $l10n; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param IL10N $l10n |
|
32 | - */ |
|
33 | - public function __construct(IL10N $l10n) { |
|
34 | - $this->l10n = $l10n; |
|
35 | - } |
|
30 | + /** |
|
31 | + * @param IL10N $l10n |
|
32 | + */ |
|
33 | + public function __construct(IL10N $l10n) { |
|
34 | + $this->l10n = $l10n; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Get the identifier of the bundle |
|
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public final function getIdentifier() { |
|
43 | - return substr(strrchr(get_class($this), '\\'), 1); |
|
44 | - } |
|
37 | + /** |
|
38 | + * Get the identifier of the bundle |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public final function getIdentifier() { |
|
43 | + return substr(strrchr(get_class($this), '\\'), 1); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Get the name of the bundle |
|
48 | - * |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public abstract function getName(); |
|
46 | + /** |
|
47 | + * Get the name of the bundle |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public abstract function getName(); |
|
52 | 52 | |
53 | - /** |
|
54 | - * Get the list of app identifiers in the bundle |
|
55 | - * |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public abstract function getAppIdentifiers(); |
|
53 | + /** |
|
54 | + * Get the list of app identifiers in the bundle |
|
55 | + * |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public abstract function getAppIdentifiers(); |
|
59 | 59 | } |
@@ -28,51 +28,51 @@ |
||
28 | 28 | use OCP\Migration\IRepairStep; |
29 | 29 | |
30 | 30 | class InstallCoreBundle implements IRepairStep { |
31 | - /** @var BundleFetcher */ |
|
32 | - private $bundleFetcher; |
|
33 | - /** @var IConfig */ |
|
34 | - private $config; |
|
35 | - /** @var Installer */ |
|
36 | - private $installer; |
|
31 | + /** @var BundleFetcher */ |
|
32 | + private $bundleFetcher; |
|
33 | + /** @var IConfig */ |
|
34 | + private $config; |
|
35 | + /** @var Installer */ |
|
36 | + private $installer; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param BundleFetcher $bundleFetcher |
|
40 | - * @param IConfig $config |
|
41 | - * @param Installer $installer |
|
42 | - */ |
|
43 | - public function __construct(BundleFetcher $bundleFetcher, |
|
44 | - IConfig $config, |
|
45 | - Installer $installer) { |
|
46 | - $this->bundleFetcher = $bundleFetcher; |
|
47 | - $this->config = $config; |
|
48 | - $this->installer = $installer; |
|
49 | - } |
|
38 | + /** |
|
39 | + * @param BundleFetcher $bundleFetcher |
|
40 | + * @param IConfig $config |
|
41 | + * @param Installer $installer |
|
42 | + */ |
|
43 | + public function __construct(BundleFetcher $bundleFetcher, |
|
44 | + IConfig $config, |
|
45 | + Installer $installer) { |
|
46 | + $this->bundleFetcher = $bundleFetcher; |
|
47 | + $this->config = $config; |
|
48 | + $this->installer = $installer; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inheritdoc} |
|
53 | - */ |
|
54 | - public function getName() { |
|
55 | - return 'Install new core bundle components'; |
|
56 | - } |
|
51 | + /** |
|
52 | + * {@inheritdoc} |
|
53 | + */ |
|
54 | + public function getName() { |
|
55 | + return 'Install new core bundle components'; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * {@inheritdoc} |
|
60 | - */ |
|
61 | - public function run(IOutput $output) { |
|
62 | - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
58 | + /** |
|
59 | + * {@inheritdoc} |
|
60 | + */ |
|
61 | + public function run(IOutput $output) { |
|
62 | + $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
63 | 63 | |
64 | - if (version_compare($versionFromBeforeUpdate, '12.0.0.14', '>')) { |
|
65 | - return; |
|
66 | - } |
|
64 | + if (version_compare($versionFromBeforeUpdate, '12.0.0.14', '>')) { |
|
65 | + return; |
|
66 | + } |
|
67 | 67 | |
68 | - $defaultBundle = $this->bundleFetcher->getDefaultInstallationBundle(); |
|
69 | - foreach($defaultBundle as $bundle) { |
|
70 | - try { |
|
71 | - $this->installer->installAppBundle($bundle); |
|
72 | - $output->info('Successfully installed core app bundle.'); |
|
73 | - } catch (\Exception $e) { |
|
74 | - $output->warning('Could not install core app bundle: ' . $e->getMessage()); |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
68 | + $defaultBundle = $this->bundleFetcher->getDefaultInstallationBundle(); |
|
69 | + foreach($defaultBundle as $bundle) { |
|
70 | + try { |
|
71 | + $this->installer->installAppBundle($bundle); |
|
72 | + $output->info('Successfully installed core app bundle.'); |
|
73 | + } catch (\Exception $e) { |
|
74 | + $output->warning('Could not install core app bundle: ' . $e->getMessage()); |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | 78 | } |
@@ -66,12 +66,12 @@ |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | $defaultBundle = $this->bundleFetcher->getDefaultInstallationBundle(); |
69 | - foreach($defaultBundle as $bundle) { |
|
69 | + foreach ($defaultBundle as $bundle) { |
|
70 | 70 | try { |
71 | 71 | $this->installer->installAppBundle($bundle); |
72 | 72 | $output->info('Successfully installed core app bundle.'); |
73 | 73 | } catch (\Exception $e) { |
74 | - $output->warning('Could not install core app bundle: ' . $e->getMessage()); |
|
74 | + $output->warning('Could not install core app bundle: '.$e->getMessage()); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | } |
@@ -126,1655 +126,1655 @@ |
||
126 | 126 | * TODO: hookup all manager classes |
127 | 127 | */ |
128 | 128 | class Server extends ServerContainer implements IServerContainer { |
129 | - /** @var string */ |
|
130 | - private $webRoot; |
|
131 | - |
|
132 | - /** |
|
133 | - * @param string $webRoot |
|
134 | - * @param \OC\Config $config |
|
135 | - */ |
|
136 | - public function __construct($webRoot, \OC\Config $config) { |
|
137 | - parent::__construct(); |
|
138 | - $this->webRoot = $webRoot; |
|
139 | - |
|
140 | - $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
141 | - return $c; |
|
142 | - }); |
|
143 | - |
|
144 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
145 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
146 | - |
|
147 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
148 | - |
|
149 | - |
|
150 | - |
|
151 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
152 | - return new PreviewManager( |
|
153 | - $c->getConfig(), |
|
154 | - $c->getRootFolder(), |
|
155 | - $c->getAppDataDir('preview'), |
|
156 | - $c->getEventDispatcher(), |
|
157 | - $c->getSession()->get('user_id') |
|
158 | - ); |
|
159 | - }); |
|
160 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
161 | - |
|
162 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
163 | - return new \OC\Preview\Watcher( |
|
164 | - $c->getAppDataDir('preview') |
|
165 | - ); |
|
166 | - }); |
|
167 | - |
|
168 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
169 | - $view = new View(); |
|
170 | - $util = new Encryption\Util( |
|
171 | - $view, |
|
172 | - $c->getUserManager(), |
|
173 | - $c->getGroupManager(), |
|
174 | - $c->getConfig() |
|
175 | - ); |
|
176 | - return new Encryption\Manager( |
|
177 | - $c->getConfig(), |
|
178 | - $c->getLogger(), |
|
179 | - $c->getL10N('core'), |
|
180 | - new View(), |
|
181 | - $util, |
|
182 | - new ArrayCache() |
|
183 | - ); |
|
184 | - }); |
|
185 | - |
|
186 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
187 | - $util = new Encryption\Util( |
|
188 | - new View(), |
|
189 | - $c->getUserManager(), |
|
190 | - $c->getGroupManager(), |
|
191 | - $c->getConfig() |
|
192 | - ); |
|
193 | - return new Encryption\File( |
|
194 | - $util, |
|
195 | - $c->getRootFolder(), |
|
196 | - $c->getShareManager() |
|
197 | - ); |
|
198 | - }); |
|
199 | - |
|
200 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
201 | - $view = new View(); |
|
202 | - $util = new Encryption\Util( |
|
203 | - $view, |
|
204 | - $c->getUserManager(), |
|
205 | - $c->getGroupManager(), |
|
206 | - $c->getConfig() |
|
207 | - ); |
|
208 | - |
|
209 | - return new Encryption\Keys\Storage($view, $util); |
|
210 | - }); |
|
211 | - $this->registerService('TagMapper', function (Server $c) { |
|
212 | - return new TagMapper($c->getDatabaseConnection()); |
|
213 | - }); |
|
214 | - |
|
215 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
216 | - $tagMapper = $c->query('TagMapper'); |
|
217 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
218 | - }); |
|
219 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
220 | - |
|
221 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
222 | - $config = $c->getConfig(); |
|
223 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
224 | - /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
225 | - $factory = new $factoryClass($this); |
|
226 | - return $factory; |
|
227 | - }); |
|
228 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
229 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
230 | - }); |
|
231 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
232 | - |
|
233 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
234 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
235 | - }); |
|
236 | - $this->registerService('RootFolder', function (Server $c) { |
|
237 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
238 | - $view = new View(); |
|
239 | - $root = new Root( |
|
240 | - $manager, |
|
241 | - $view, |
|
242 | - null, |
|
243 | - $c->getUserMountCache(), |
|
244 | - $this->getLogger(), |
|
245 | - $this->getUserManager() |
|
246 | - ); |
|
247 | - $connector = new HookConnector($root, $view); |
|
248 | - $connector->viewToNode(); |
|
249 | - |
|
250 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
251 | - $previewConnector->connectWatcher(); |
|
252 | - |
|
253 | - return $root; |
|
254 | - }); |
|
255 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
256 | - |
|
257 | - $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
258 | - return new LazyRoot(function() use ($c) { |
|
259 | - return $c->query('RootFolder'); |
|
260 | - }); |
|
261 | - }); |
|
262 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
263 | - |
|
264 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
265 | - $config = $c->getConfig(); |
|
266 | - return new \OC\User\Manager($config); |
|
267 | - }); |
|
268 | - $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
269 | - |
|
270 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
271 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
272 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
273 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
274 | - }); |
|
275 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
276 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
277 | - }); |
|
278 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
279 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
280 | - }); |
|
281 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
282 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
283 | - }); |
|
284 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
285 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
286 | - }); |
|
287 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
288 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
289 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
290 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
291 | - }); |
|
292 | - return $groupManager; |
|
293 | - }); |
|
294 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
295 | - |
|
296 | - $this->registerService(Store::class, function(Server $c) { |
|
297 | - $session = $c->getSession(); |
|
298 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
299 | - $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
300 | - } else { |
|
301 | - $tokenProvider = null; |
|
302 | - } |
|
303 | - $logger = $c->getLogger(); |
|
304 | - return new Store($session, $logger, $tokenProvider); |
|
305 | - }); |
|
306 | - $this->registerAlias(IStore::class, Store::class); |
|
307 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
308 | - $dbConnection = $c->getDatabaseConnection(); |
|
309 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
310 | - }); |
|
311 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
312 | - $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
313 | - $crypto = $c->getCrypto(); |
|
314 | - $config = $c->getConfig(); |
|
315 | - $logger = $c->getLogger(); |
|
316 | - $timeFactory = new TimeFactory(); |
|
317 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
318 | - }); |
|
319 | - $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
320 | - |
|
321 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
322 | - $manager = $c->getUserManager(); |
|
323 | - $session = new \OC\Session\Memory(''); |
|
324 | - $timeFactory = new TimeFactory(); |
|
325 | - // Token providers might require a working database. This code |
|
326 | - // might however be called when ownCloud is not yet setup. |
|
327 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
328 | - $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
329 | - } else { |
|
330 | - $defaultTokenProvider = null; |
|
331 | - } |
|
332 | - |
|
333 | - $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
|
334 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
335 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
336 | - }); |
|
337 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
338 | - /** @var $user \OC\User\User */ |
|
339 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
340 | - }); |
|
341 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
342 | - /** @var $user \OC\User\User */ |
|
343 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
344 | - }); |
|
345 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
346 | - /** @var $user \OC\User\User */ |
|
347 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
348 | - }); |
|
349 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
350 | - /** @var $user \OC\User\User */ |
|
351 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
352 | - }); |
|
353 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
354 | - /** @var $user \OC\User\User */ |
|
355 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
356 | - }); |
|
357 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
358 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
359 | - }); |
|
360 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
361 | - /** @var $user \OC\User\User */ |
|
362 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
363 | - }); |
|
364 | - $userSession->listen('\OC\User', 'logout', function () { |
|
365 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
366 | - }); |
|
367 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
368 | - /** @var $user \OC\User\User */ |
|
369 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
370 | - }); |
|
371 | - return $userSession; |
|
372 | - }); |
|
373 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
374 | - |
|
375 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
376 | - return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
377 | - }); |
|
378 | - |
|
379 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
380 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
381 | - |
|
382 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
383 | - return new \OC\AllConfig( |
|
384 | - $c->getSystemConfig() |
|
385 | - ); |
|
386 | - }); |
|
387 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
388 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
389 | - |
|
390 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
391 | - return new \OC\SystemConfig($config); |
|
392 | - }); |
|
393 | - |
|
394 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
395 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
396 | - }); |
|
397 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
398 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
399 | - |
|
400 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
401 | - return new \OC\L10N\Factory( |
|
402 | - $c->getConfig(), |
|
403 | - $c->getRequest(), |
|
404 | - $c->getUserSession(), |
|
405 | - \OC::$SERVERROOT |
|
406 | - ); |
|
407 | - }); |
|
408 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
409 | - |
|
410 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
411 | - $config = $c->getConfig(); |
|
412 | - $cacheFactory = $c->getMemCacheFactory(); |
|
413 | - return new \OC\URLGenerator( |
|
414 | - $config, |
|
415 | - $cacheFactory |
|
416 | - ); |
|
417 | - }); |
|
418 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
419 | - |
|
420 | - $this->registerService('AppHelper', function ($c) { |
|
421 | - return new \OC\AppHelper(); |
|
422 | - }); |
|
423 | - $this->registerService('AppFetcher', function ($c) { |
|
424 | - return new AppFetcher( |
|
425 | - $this->getAppDataDir('appstore'), |
|
426 | - $this->getHTTPClientService(), |
|
427 | - $this->query(TimeFactory::class), |
|
428 | - $this->getConfig() |
|
429 | - ); |
|
430 | - }); |
|
431 | - $this->registerService('CategoryFetcher', function ($c) { |
|
432 | - return new CategoryFetcher( |
|
433 | - $this->getAppDataDir('appstore'), |
|
434 | - $this->getHTTPClientService(), |
|
435 | - $this->query(TimeFactory::class), |
|
436 | - $this->getConfig() |
|
437 | - ); |
|
438 | - }); |
|
439 | - |
|
440 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
441 | - return new Cache\File(); |
|
442 | - }); |
|
443 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
444 | - |
|
445 | - $this->registerService(Factory::class, function (Server $c) { |
|
446 | - $config = $c->getConfig(); |
|
447 | - |
|
448 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
449 | - $v = \OC_App::getAppVersions(); |
|
450 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
451 | - $version = implode(',', $v); |
|
452 | - $instanceId = \OC_Util::getInstanceId(); |
|
453 | - $path = \OC::$SERVERROOT; |
|
454 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
455 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
456 | - $config->getSystemValue('memcache.local', null), |
|
457 | - $config->getSystemValue('memcache.distributed', null), |
|
458 | - $config->getSystemValue('memcache.locking', null) |
|
459 | - ); |
|
460 | - } |
|
461 | - |
|
462 | - return new \OC\Memcache\Factory('', $c->getLogger(), |
|
463 | - '\\OC\\Memcache\\ArrayCache', |
|
464 | - '\\OC\\Memcache\\ArrayCache', |
|
465 | - '\\OC\\Memcache\\ArrayCache' |
|
466 | - ); |
|
467 | - }); |
|
468 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
469 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
470 | - |
|
471 | - $this->registerService('RedisFactory', function (Server $c) { |
|
472 | - $systemConfig = $c->getSystemConfig(); |
|
473 | - return new RedisFactory($systemConfig); |
|
474 | - }); |
|
475 | - |
|
476 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
477 | - return new \OC\Activity\Manager( |
|
478 | - $c->getRequest(), |
|
479 | - $c->getUserSession(), |
|
480 | - $c->getConfig(), |
|
481 | - $c->query(IValidator::class) |
|
482 | - ); |
|
483 | - }); |
|
484 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
485 | - |
|
486 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
487 | - return new \OC\Activity\EventMerger( |
|
488 | - $c->getL10N('lib') |
|
489 | - ); |
|
490 | - }); |
|
491 | - $this->registerAlias(IValidator::class, Validator::class); |
|
492 | - |
|
493 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
494 | - return new AvatarManager( |
|
495 | - $c->getUserManager(), |
|
496 | - $c->getAppDataDir('avatar'), |
|
497 | - $c->getL10N('lib'), |
|
498 | - $c->getLogger(), |
|
499 | - $c->getConfig() |
|
500 | - ); |
|
501 | - }); |
|
502 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
503 | - |
|
504 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
505 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
506 | - $logger = Log::getLogClass($logType); |
|
507 | - call_user_func(array($logger, 'init')); |
|
508 | - |
|
509 | - return new Log($logger); |
|
510 | - }); |
|
511 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
512 | - |
|
513 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
514 | - $config = $c->getConfig(); |
|
515 | - return new \OC\BackgroundJob\JobList( |
|
516 | - $c->getDatabaseConnection(), |
|
517 | - $config, |
|
518 | - new TimeFactory() |
|
519 | - ); |
|
520 | - }); |
|
521 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
522 | - |
|
523 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
524 | - $cacheFactory = $c->getMemCacheFactory(); |
|
525 | - $logger = $c->getLogger(); |
|
526 | - if ($cacheFactory->isAvailable()) { |
|
527 | - $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
528 | - } else { |
|
529 | - $router = new \OC\Route\Router($logger); |
|
530 | - } |
|
531 | - return $router; |
|
532 | - }); |
|
533 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
534 | - |
|
535 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
536 | - return new Search(); |
|
537 | - }); |
|
538 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
539 | - |
|
540 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) { |
|
541 | - return new \OC\Security\RateLimiting\Limiter( |
|
542 | - $this->getUserSession(), |
|
543 | - $this->getRequest(), |
|
544 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
545 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
546 | - ); |
|
547 | - }); |
|
548 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
549 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
550 | - $this->getMemCacheFactory(), |
|
551 | - new \OC\AppFramework\Utility\TimeFactory() |
|
552 | - ); |
|
553 | - }); |
|
554 | - |
|
555 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
556 | - return new SecureRandom(); |
|
557 | - }); |
|
558 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
559 | - |
|
560 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
561 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
562 | - }); |
|
563 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
564 | - |
|
565 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
566 | - return new Hasher($c->getConfig()); |
|
567 | - }); |
|
568 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
569 | - |
|
570 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
571 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
572 | - }); |
|
573 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
574 | - |
|
575 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
576 | - $systemConfig = $c->getSystemConfig(); |
|
577 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
578 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
579 | - if (!$factory->isValidType($type)) { |
|
580 | - throw new \OC\DatabaseException('Invalid database type'); |
|
581 | - } |
|
582 | - $connectionParams = $factory->createConnectionParams(); |
|
583 | - $connection = $factory->getConnection($type, $connectionParams); |
|
584 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
585 | - return $connection; |
|
586 | - }); |
|
587 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
588 | - |
|
589 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
590 | - $config = $c->getConfig(); |
|
591 | - return new HTTPHelper( |
|
592 | - $config, |
|
593 | - $c->getHTTPClientService() |
|
594 | - ); |
|
595 | - }); |
|
596 | - |
|
597 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
598 | - $user = \OC_User::getUser(); |
|
599 | - $uid = $user ? $user : null; |
|
600 | - return new ClientService( |
|
601 | - $c->getConfig(), |
|
602 | - new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
603 | - ); |
|
604 | - }); |
|
605 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
606 | - |
|
607 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
608 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
609 | - return new EventLogger(); |
|
610 | - } else { |
|
611 | - return new NullEventLogger(); |
|
612 | - } |
|
613 | - }); |
|
614 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
615 | - |
|
616 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
617 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
618 | - return new QueryLogger(); |
|
619 | - } else { |
|
620 | - return new NullQueryLogger(); |
|
621 | - } |
|
622 | - }); |
|
623 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
624 | - |
|
625 | - $this->registerService(TempManager::class, function (Server $c) { |
|
626 | - return new TempManager( |
|
627 | - $c->getLogger(), |
|
628 | - $c->getConfig() |
|
629 | - ); |
|
630 | - }); |
|
631 | - $this->registerAlias('TempManager', TempManager::class); |
|
632 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
633 | - |
|
634 | - $this->registerService(AppManager::class, function (Server $c) { |
|
635 | - return new \OC\App\AppManager( |
|
636 | - $c->getUserSession(), |
|
637 | - $c->getAppConfig(), |
|
638 | - $c->getGroupManager(), |
|
639 | - $c->getMemCacheFactory(), |
|
640 | - $c->getEventDispatcher() |
|
641 | - ); |
|
642 | - }); |
|
643 | - $this->registerAlias('AppManager', AppManager::class); |
|
644 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
645 | - |
|
646 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
647 | - return new DateTimeZone( |
|
648 | - $c->getConfig(), |
|
649 | - $c->getSession() |
|
650 | - ); |
|
651 | - }); |
|
652 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
653 | - |
|
654 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
655 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
656 | - |
|
657 | - return new DateTimeFormatter( |
|
658 | - $c->getDateTimeZone()->getTimeZone(), |
|
659 | - $c->getL10N('lib', $language) |
|
660 | - ); |
|
661 | - }); |
|
662 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
663 | - |
|
664 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
665 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
666 | - $listener = new UserMountCacheListener($mountCache); |
|
667 | - $listener->listen($c->getUserManager()); |
|
668 | - return $mountCache; |
|
669 | - }); |
|
670 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
671 | - |
|
672 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
673 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
674 | - $mountCache = $c->query('UserMountCache'); |
|
675 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
676 | - |
|
677 | - // builtin providers |
|
678 | - |
|
679 | - $config = $c->getConfig(); |
|
680 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
681 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
682 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
683 | - |
|
684 | - return $manager; |
|
685 | - }); |
|
686 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
687 | - |
|
688 | - $this->registerService('IniWrapper', function ($c) { |
|
689 | - return new IniGetWrapper(); |
|
690 | - }); |
|
691 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
692 | - $jobList = $c->getJobList(); |
|
693 | - return new AsyncBus($jobList); |
|
694 | - }); |
|
695 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
696 | - return new TrustedDomainHelper($this->getConfig()); |
|
697 | - }); |
|
698 | - $this->registerService('Throttler', function(Server $c) { |
|
699 | - return new Throttler( |
|
700 | - $c->getDatabaseConnection(), |
|
701 | - new TimeFactory(), |
|
702 | - $c->getLogger(), |
|
703 | - $c->getConfig() |
|
704 | - ); |
|
705 | - }); |
|
706 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
707 | - // IConfig and IAppManager requires a working database. This code |
|
708 | - // might however be called when ownCloud is not yet setup. |
|
709 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
710 | - $config = $c->getConfig(); |
|
711 | - $appManager = $c->getAppManager(); |
|
712 | - } else { |
|
713 | - $config = null; |
|
714 | - $appManager = null; |
|
715 | - } |
|
716 | - |
|
717 | - return new Checker( |
|
718 | - new EnvironmentHelper(), |
|
719 | - new FileAccessHelper(), |
|
720 | - new AppLocator(), |
|
721 | - $config, |
|
722 | - $c->getMemCacheFactory(), |
|
723 | - $appManager, |
|
724 | - $c->getTempManager() |
|
725 | - ); |
|
726 | - }); |
|
727 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
728 | - if (isset($this['urlParams'])) { |
|
729 | - $urlParams = $this['urlParams']; |
|
730 | - } else { |
|
731 | - $urlParams = []; |
|
732 | - } |
|
733 | - |
|
734 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
735 | - && in_array('fakeinput', stream_get_wrappers()) |
|
736 | - ) { |
|
737 | - $stream = 'fakeinput://data'; |
|
738 | - } else { |
|
739 | - $stream = 'php://input'; |
|
740 | - } |
|
741 | - |
|
742 | - return new Request( |
|
743 | - [ |
|
744 | - 'get' => $_GET, |
|
745 | - 'post' => $_POST, |
|
746 | - 'files' => $_FILES, |
|
747 | - 'server' => $_SERVER, |
|
748 | - 'env' => $_ENV, |
|
749 | - 'cookies' => $_COOKIE, |
|
750 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
751 | - ? $_SERVER['REQUEST_METHOD'] |
|
752 | - : null, |
|
753 | - 'urlParams' => $urlParams, |
|
754 | - ], |
|
755 | - $this->getSecureRandom(), |
|
756 | - $this->getConfig(), |
|
757 | - $this->getCsrfTokenManager(), |
|
758 | - $stream |
|
759 | - ); |
|
760 | - }); |
|
761 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
762 | - |
|
763 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
764 | - return new Mailer( |
|
765 | - $c->getConfig(), |
|
766 | - $c->getLogger(), |
|
767 | - $c->query(Defaults::class), |
|
768 | - $c->getURLGenerator(), |
|
769 | - $c->getL10N('lib') |
|
770 | - ); |
|
771 | - }); |
|
772 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
773 | - |
|
774 | - $this->registerService('LDAPProvider', function(Server $c) { |
|
775 | - $config = $c->getConfig(); |
|
776 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
777 | - if(is_null($factoryClass)) { |
|
778 | - throw new \Exception('ldapProviderFactory not set'); |
|
779 | - } |
|
780 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
781 | - $factory = new $factoryClass($this); |
|
782 | - return $factory->getLDAPProvider(); |
|
783 | - }); |
|
784 | - $this->registerService('LockingProvider', function (Server $c) { |
|
785 | - $ini = $c->getIniWrapper(); |
|
786 | - $config = $c->getConfig(); |
|
787 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
788 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
789 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
790 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
791 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
792 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
793 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
794 | - } |
|
795 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
796 | - } |
|
797 | - return new NoopLockingProvider(); |
|
798 | - }); |
|
799 | - |
|
800 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
801 | - return new \OC\Files\Mount\Manager(); |
|
802 | - }); |
|
803 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
804 | - |
|
805 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
806 | - return new \OC\Files\Type\Detection( |
|
807 | - $c->getURLGenerator(), |
|
808 | - \OC::$configDir, |
|
809 | - \OC::$SERVERROOT . '/resources/config/' |
|
810 | - ); |
|
811 | - }); |
|
812 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
813 | - |
|
814 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
815 | - return new \OC\Files\Type\Loader( |
|
816 | - $c->getDatabaseConnection() |
|
817 | - ); |
|
818 | - }); |
|
819 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
820 | - $this->registerService(BundleFetcher::class, function () { |
|
821 | - return new BundleFetcher($this->getL10N('lib')); |
|
822 | - }); |
|
823 | - $this->registerService(AppFetcher::class, function() { |
|
824 | - return $this->getAppFetcher(); |
|
825 | - }); |
|
826 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
827 | - return new Manager( |
|
828 | - $c->query(IValidator::class) |
|
829 | - ); |
|
830 | - }); |
|
831 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
832 | - |
|
833 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
834 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
835 | - $manager->registerCapability(function () use ($c) { |
|
836 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
837 | - }); |
|
838 | - return $manager; |
|
839 | - }); |
|
840 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
841 | - |
|
842 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
843 | - $config = $c->getConfig(); |
|
844 | - $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
845 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
846 | - $factory = new $factoryClass($this); |
|
847 | - return $factory->getManager(); |
|
848 | - }); |
|
849 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
850 | - |
|
851 | - $this->registerService('ThemingDefaults', function(Server $c) { |
|
852 | - /* |
|
129 | + /** @var string */ |
|
130 | + private $webRoot; |
|
131 | + |
|
132 | + /** |
|
133 | + * @param string $webRoot |
|
134 | + * @param \OC\Config $config |
|
135 | + */ |
|
136 | + public function __construct($webRoot, \OC\Config $config) { |
|
137 | + parent::__construct(); |
|
138 | + $this->webRoot = $webRoot; |
|
139 | + |
|
140 | + $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
141 | + return $c; |
|
142 | + }); |
|
143 | + |
|
144 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
145 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
146 | + |
|
147 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
148 | + |
|
149 | + |
|
150 | + |
|
151 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
152 | + return new PreviewManager( |
|
153 | + $c->getConfig(), |
|
154 | + $c->getRootFolder(), |
|
155 | + $c->getAppDataDir('preview'), |
|
156 | + $c->getEventDispatcher(), |
|
157 | + $c->getSession()->get('user_id') |
|
158 | + ); |
|
159 | + }); |
|
160 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
161 | + |
|
162 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
163 | + return new \OC\Preview\Watcher( |
|
164 | + $c->getAppDataDir('preview') |
|
165 | + ); |
|
166 | + }); |
|
167 | + |
|
168 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
169 | + $view = new View(); |
|
170 | + $util = new Encryption\Util( |
|
171 | + $view, |
|
172 | + $c->getUserManager(), |
|
173 | + $c->getGroupManager(), |
|
174 | + $c->getConfig() |
|
175 | + ); |
|
176 | + return new Encryption\Manager( |
|
177 | + $c->getConfig(), |
|
178 | + $c->getLogger(), |
|
179 | + $c->getL10N('core'), |
|
180 | + new View(), |
|
181 | + $util, |
|
182 | + new ArrayCache() |
|
183 | + ); |
|
184 | + }); |
|
185 | + |
|
186 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
187 | + $util = new Encryption\Util( |
|
188 | + new View(), |
|
189 | + $c->getUserManager(), |
|
190 | + $c->getGroupManager(), |
|
191 | + $c->getConfig() |
|
192 | + ); |
|
193 | + return new Encryption\File( |
|
194 | + $util, |
|
195 | + $c->getRootFolder(), |
|
196 | + $c->getShareManager() |
|
197 | + ); |
|
198 | + }); |
|
199 | + |
|
200 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
201 | + $view = new View(); |
|
202 | + $util = new Encryption\Util( |
|
203 | + $view, |
|
204 | + $c->getUserManager(), |
|
205 | + $c->getGroupManager(), |
|
206 | + $c->getConfig() |
|
207 | + ); |
|
208 | + |
|
209 | + return new Encryption\Keys\Storage($view, $util); |
|
210 | + }); |
|
211 | + $this->registerService('TagMapper', function (Server $c) { |
|
212 | + return new TagMapper($c->getDatabaseConnection()); |
|
213 | + }); |
|
214 | + |
|
215 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
216 | + $tagMapper = $c->query('TagMapper'); |
|
217 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
218 | + }); |
|
219 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
220 | + |
|
221 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
222 | + $config = $c->getConfig(); |
|
223 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
224 | + /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
225 | + $factory = new $factoryClass($this); |
|
226 | + return $factory; |
|
227 | + }); |
|
228 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
229 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
230 | + }); |
|
231 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
232 | + |
|
233 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
234 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
235 | + }); |
|
236 | + $this->registerService('RootFolder', function (Server $c) { |
|
237 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
238 | + $view = new View(); |
|
239 | + $root = new Root( |
|
240 | + $manager, |
|
241 | + $view, |
|
242 | + null, |
|
243 | + $c->getUserMountCache(), |
|
244 | + $this->getLogger(), |
|
245 | + $this->getUserManager() |
|
246 | + ); |
|
247 | + $connector = new HookConnector($root, $view); |
|
248 | + $connector->viewToNode(); |
|
249 | + |
|
250 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
251 | + $previewConnector->connectWatcher(); |
|
252 | + |
|
253 | + return $root; |
|
254 | + }); |
|
255 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
256 | + |
|
257 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
258 | + return new LazyRoot(function() use ($c) { |
|
259 | + return $c->query('RootFolder'); |
|
260 | + }); |
|
261 | + }); |
|
262 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
263 | + |
|
264 | + $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
265 | + $config = $c->getConfig(); |
|
266 | + return new \OC\User\Manager($config); |
|
267 | + }); |
|
268 | + $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
269 | + |
|
270 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
271 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
272 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
273 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
274 | + }); |
|
275 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
276 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
277 | + }); |
|
278 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
279 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
280 | + }); |
|
281 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
282 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
283 | + }); |
|
284 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
285 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
286 | + }); |
|
287 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
288 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
289 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
290 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
291 | + }); |
|
292 | + return $groupManager; |
|
293 | + }); |
|
294 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
295 | + |
|
296 | + $this->registerService(Store::class, function(Server $c) { |
|
297 | + $session = $c->getSession(); |
|
298 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
299 | + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
300 | + } else { |
|
301 | + $tokenProvider = null; |
|
302 | + } |
|
303 | + $logger = $c->getLogger(); |
|
304 | + return new Store($session, $logger, $tokenProvider); |
|
305 | + }); |
|
306 | + $this->registerAlias(IStore::class, Store::class); |
|
307 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
308 | + $dbConnection = $c->getDatabaseConnection(); |
|
309 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
310 | + }); |
|
311 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
312 | + $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
313 | + $crypto = $c->getCrypto(); |
|
314 | + $config = $c->getConfig(); |
|
315 | + $logger = $c->getLogger(); |
|
316 | + $timeFactory = new TimeFactory(); |
|
317 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
318 | + }); |
|
319 | + $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
320 | + |
|
321 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
322 | + $manager = $c->getUserManager(); |
|
323 | + $session = new \OC\Session\Memory(''); |
|
324 | + $timeFactory = new TimeFactory(); |
|
325 | + // Token providers might require a working database. This code |
|
326 | + // might however be called when ownCloud is not yet setup. |
|
327 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
328 | + $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
329 | + } else { |
|
330 | + $defaultTokenProvider = null; |
|
331 | + } |
|
332 | + |
|
333 | + $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
|
334 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
335 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
336 | + }); |
|
337 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
338 | + /** @var $user \OC\User\User */ |
|
339 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
340 | + }); |
|
341 | + $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
342 | + /** @var $user \OC\User\User */ |
|
343 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
344 | + }); |
|
345 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
346 | + /** @var $user \OC\User\User */ |
|
347 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
348 | + }); |
|
349 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
350 | + /** @var $user \OC\User\User */ |
|
351 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
352 | + }); |
|
353 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
354 | + /** @var $user \OC\User\User */ |
|
355 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
356 | + }); |
|
357 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
358 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
359 | + }); |
|
360 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
361 | + /** @var $user \OC\User\User */ |
|
362 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
363 | + }); |
|
364 | + $userSession->listen('\OC\User', 'logout', function () { |
|
365 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
366 | + }); |
|
367 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
368 | + /** @var $user \OC\User\User */ |
|
369 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
370 | + }); |
|
371 | + return $userSession; |
|
372 | + }); |
|
373 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
374 | + |
|
375 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
376 | + return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
377 | + }); |
|
378 | + |
|
379 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
380 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
381 | + |
|
382 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
383 | + return new \OC\AllConfig( |
|
384 | + $c->getSystemConfig() |
|
385 | + ); |
|
386 | + }); |
|
387 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
388 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
389 | + |
|
390 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
391 | + return new \OC\SystemConfig($config); |
|
392 | + }); |
|
393 | + |
|
394 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
395 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
396 | + }); |
|
397 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
398 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
399 | + |
|
400 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
401 | + return new \OC\L10N\Factory( |
|
402 | + $c->getConfig(), |
|
403 | + $c->getRequest(), |
|
404 | + $c->getUserSession(), |
|
405 | + \OC::$SERVERROOT |
|
406 | + ); |
|
407 | + }); |
|
408 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
409 | + |
|
410 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
411 | + $config = $c->getConfig(); |
|
412 | + $cacheFactory = $c->getMemCacheFactory(); |
|
413 | + return new \OC\URLGenerator( |
|
414 | + $config, |
|
415 | + $cacheFactory |
|
416 | + ); |
|
417 | + }); |
|
418 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
419 | + |
|
420 | + $this->registerService('AppHelper', function ($c) { |
|
421 | + return new \OC\AppHelper(); |
|
422 | + }); |
|
423 | + $this->registerService('AppFetcher', function ($c) { |
|
424 | + return new AppFetcher( |
|
425 | + $this->getAppDataDir('appstore'), |
|
426 | + $this->getHTTPClientService(), |
|
427 | + $this->query(TimeFactory::class), |
|
428 | + $this->getConfig() |
|
429 | + ); |
|
430 | + }); |
|
431 | + $this->registerService('CategoryFetcher', function ($c) { |
|
432 | + return new CategoryFetcher( |
|
433 | + $this->getAppDataDir('appstore'), |
|
434 | + $this->getHTTPClientService(), |
|
435 | + $this->query(TimeFactory::class), |
|
436 | + $this->getConfig() |
|
437 | + ); |
|
438 | + }); |
|
439 | + |
|
440 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
441 | + return new Cache\File(); |
|
442 | + }); |
|
443 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
444 | + |
|
445 | + $this->registerService(Factory::class, function (Server $c) { |
|
446 | + $config = $c->getConfig(); |
|
447 | + |
|
448 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
449 | + $v = \OC_App::getAppVersions(); |
|
450 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
451 | + $version = implode(',', $v); |
|
452 | + $instanceId = \OC_Util::getInstanceId(); |
|
453 | + $path = \OC::$SERVERROOT; |
|
454 | + $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
455 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
456 | + $config->getSystemValue('memcache.local', null), |
|
457 | + $config->getSystemValue('memcache.distributed', null), |
|
458 | + $config->getSystemValue('memcache.locking', null) |
|
459 | + ); |
|
460 | + } |
|
461 | + |
|
462 | + return new \OC\Memcache\Factory('', $c->getLogger(), |
|
463 | + '\\OC\\Memcache\\ArrayCache', |
|
464 | + '\\OC\\Memcache\\ArrayCache', |
|
465 | + '\\OC\\Memcache\\ArrayCache' |
|
466 | + ); |
|
467 | + }); |
|
468 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
469 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
470 | + |
|
471 | + $this->registerService('RedisFactory', function (Server $c) { |
|
472 | + $systemConfig = $c->getSystemConfig(); |
|
473 | + return new RedisFactory($systemConfig); |
|
474 | + }); |
|
475 | + |
|
476 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
477 | + return new \OC\Activity\Manager( |
|
478 | + $c->getRequest(), |
|
479 | + $c->getUserSession(), |
|
480 | + $c->getConfig(), |
|
481 | + $c->query(IValidator::class) |
|
482 | + ); |
|
483 | + }); |
|
484 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
485 | + |
|
486 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
487 | + return new \OC\Activity\EventMerger( |
|
488 | + $c->getL10N('lib') |
|
489 | + ); |
|
490 | + }); |
|
491 | + $this->registerAlias(IValidator::class, Validator::class); |
|
492 | + |
|
493 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
494 | + return new AvatarManager( |
|
495 | + $c->getUserManager(), |
|
496 | + $c->getAppDataDir('avatar'), |
|
497 | + $c->getL10N('lib'), |
|
498 | + $c->getLogger(), |
|
499 | + $c->getConfig() |
|
500 | + ); |
|
501 | + }); |
|
502 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
503 | + |
|
504 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
505 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
506 | + $logger = Log::getLogClass($logType); |
|
507 | + call_user_func(array($logger, 'init')); |
|
508 | + |
|
509 | + return new Log($logger); |
|
510 | + }); |
|
511 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
512 | + |
|
513 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
514 | + $config = $c->getConfig(); |
|
515 | + return new \OC\BackgroundJob\JobList( |
|
516 | + $c->getDatabaseConnection(), |
|
517 | + $config, |
|
518 | + new TimeFactory() |
|
519 | + ); |
|
520 | + }); |
|
521 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
522 | + |
|
523 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
524 | + $cacheFactory = $c->getMemCacheFactory(); |
|
525 | + $logger = $c->getLogger(); |
|
526 | + if ($cacheFactory->isAvailable()) { |
|
527 | + $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
528 | + } else { |
|
529 | + $router = new \OC\Route\Router($logger); |
|
530 | + } |
|
531 | + return $router; |
|
532 | + }); |
|
533 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
534 | + |
|
535 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
536 | + return new Search(); |
|
537 | + }); |
|
538 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
539 | + |
|
540 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) { |
|
541 | + return new \OC\Security\RateLimiting\Limiter( |
|
542 | + $this->getUserSession(), |
|
543 | + $this->getRequest(), |
|
544 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
545 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
546 | + ); |
|
547 | + }); |
|
548 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
549 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
550 | + $this->getMemCacheFactory(), |
|
551 | + new \OC\AppFramework\Utility\TimeFactory() |
|
552 | + ); |
|
553 | + }); |
|
554 | + |
|
555 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
556 | + return new SecureRandom(); |
|
557 | + }); |
|
558 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
559 | + |
|
560 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
561 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
562 | + }); |
|
563 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
564 | + |
|
565 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
566 | + return new Hasher($c->getConfig()); |
|
567 | + }); |
|
568 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
569 | + |
|
570 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
571 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
572 | + }); |
|
573 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
574 | + |
|
575 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
576 | + $systemConfig = $c->getSystemConfig(); |
|
577 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
578 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
579 | + if (!$factory->isValidType($type)) { |
|
580 | + throw new \OC\DatabaseException('Invalid database type'); |
|
581 | + } |
|
582 | + $connectionParams = $factory->createConnectionParams(); |
|
583 | + $connection = $factory->getConnection($type, $connectionParams); |
|
584 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
585 | + return $connection; |
|
586 | + }); |
|
587 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
588 | + |
|
589 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
590 | + $config = $c->getConfig(); |
|
591 | + return new HTTPHelper( |
|
592 | + $config, |
|
593 | + $c->getHTTPClientService() |
|
594 | + ); |
|
595 | + }); |
|
596 | + |
|
597 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
598 | + $user = \OC_User::getUser(); |
|
599 | + $uid = $user ? $user : null; |
|
600 | + return new ClientService( |
|
601 | + $c->getConfig(), |
|
602 | + new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
603 | + ); |
|
604 | + }); |
|
605 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
606 | + |
|
607 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
608 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
609 | + return new EventLogger(); |
|
610 | + } else { |
|
611 | + return new NullEventLogger(); |
|
612 | + } |
|
613 | + }); |
|
614 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
615 | + |
|
616 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
617 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
618 | + return new QueryLogger(); |
|
619 | + } else { |
|
620 | + return new NullQueryLogger(); |
|
621 | + } |
|
622 | + }); |
|
623 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
624 | + |
|
625 | + $this->registerService(TempManager::class, function (Server $c) { |
|
626 | + return new TempManager( |
|
627 | + $c->getLogger(), |
|
628 | + $c->getConfig() |
|
629 | + ); |
|
630 | + }); |
|
631 | + $this->registerAlias('TempManager', TempManager::class); |
|
632 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
633 | + |
|
634 | + $this->registerService(AppManager::class, function (Server $c) { |
|
635 | + return new \OC\App\AppManager( |
|
636 | + $c->getUserSession(), |
|
637 | + $c->getAppConfig(), |
|
638 | + $c->getGroupManager(), |
|
639 | + $c->getMemCacheFactory(), |
|
640 | + $c->getEventDispatcher() |
|
641 | + ); |
|
642 | + }); |
|
643 | + $this->registerAlias('AppManager', AppManager::class); |
|
644 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
645 | + |
|
646 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
647 | + return new DateTimeZone( |
|
648 | + $c->getConfig(), |
|
649 | + $c->getSession() |
|
650 | + ); |
|
651 | + }); |
|
652 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
653 | + |
|
654 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
655 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
656 | + |
|
657 | + return new DateTimeFormatter( |
|
658 | + $c->getDateTimeZone()->getTimeZone(), |
|
659 | + $c->getL10N('lib', $language) |
|
660 | + ); |
|
661 | + }); |
|
662 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
663 | + |
|
664 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
665 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
666 | + $listener = new UserMountCacheListener($mountCache); |
|
667 | + $listener->listen($c->getUserManager()); |
|
668 | + return $mountCache; |
|
669 | + }); |
|
670 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
671 | + |
|
672 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
673 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
674 | + $mountCache = $c->query('UserMountCache'); |
|
675 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
676 | + |
|
677 | + // builtin providers |
|
678 | + |
|
679 | + $config = $c->getConfig(); |
|
680 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
681 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
682 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
683 | + |
|
684 | + return $manager; |
|
685 | + }); |
|
686 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
687 | + |
|
688 | + $this->registerService('IniWrapper', function ($c) { |
|
689 | + return new IniGetWrapper(); |
|
690 | + }); |
|
691 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
692 | + $jobList = $c->getJobList(); |
|
693 | + return new AsyncBus($jobList); |
|
694 | + }); |
|
695 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
696 | + return new TrustedDomainHelper($this->getConfig()); |
|
697 | + }); |
|
698 | + $this->registerService('Throttler', function(Server $c) { |
|
699 | + return new Throttler( |
|
700 | + $c->getDatabaseConnection(), |
|
701 | + new TimeFactory(), |
|
702 | + $c->getLogger(), |
|
703 | + $c->getConfig() |
|
704 | + ); |
|
705 | + }); |
|
706 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
707 | + // IConfig and IAppManager requires a working database. This code |
|
708 | + // might however be called when ownCloud is not yet setup. |
|
709 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
710 | + $config = $c->getConfig(); |
|
711 | + $appManager = $c->getAppManager(); |
|
712 | + } else { |
|
713 | + $config = null; |
|
714 | + $appManager = null; |
|
715 | + } |
|
716 | + |
|
717 | + return new Checker( |
|
718 | + new EnvironmentHelper(), |
|
719 | + new FileAccessHelper(), |
|
720 | + new AppLocator(), |
|
721 | + $config, |
|
722 | + $c->getMemCacheFactory(), |
|
723 | + $appManager, |
|
724 | + $c->getTempManager() |
|
725 | + ); |
|
726 | + }); |
|
727 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
728 | + if (isset($this['urlParams'])) { |
|
729 | + $urlParams = $this['urlParams']; |
|
730 | + } else { |
|
731 | + $urlParams = []; |
|
732 | + } |
|
733 | + |
|
734 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
735 | + && in_array('fakeinput', stream_get_wrappers()) |
|
736 | + ) { |
|
737 | + $stream = 'fakeinput://data'; |
|
738 | + } else { |
|
739 | + $stream = 'php://input'; |
|
740 | + } |
|
741 | + |
|
742 | + return new Request( |
|
743 | + [ |
|
744 | + 'get' => $_GET, |
|
745 | + 'post' => $_POST, |
|
746 | + 'files' => $_FILES, |
|
747 | + 'server' => $_SERVER, |
|
748 | + 'env' => $_ENV, |
|
749 | + 'cookies' => $_COOKIE, |
|
750 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
751 | + ? $_SERVER['REQUEST_METHOD'] |
|
752 | + : null, |
|
753 | + 'urlParams' => $urlParams, |
|
754 | + ], |
|
755 | + $this->getSecureRandom(), |
|
756 | + $this->getConfig(), |
|
757 | + $this->getCsrfTokenManager(), |
|
758 | + $stream |
|
759 | + ); |
|
760 | + }); |
|
761 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
762 | + |
|
763 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
764 | + return new Mailer( |
|
765 | + $c->getConfig(), |
|
766 | + $c->getLogger(), |
|
767 | + $c->query(Defaults::class), |
|
768 | + $c->getURLGenerator(), |
|
769 | + $c->getL10N('lib') |
|
770 | + ); |
|
771 | + }); |
|
772 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
773 | + |
|
774 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
775 | + $config = $c->getConfig(); |
|
776 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
777 | + if(is_null($factoryClass)) { |
|
778 | + throw new \Exception('ldapProviderFactory not set'); |
|
779 | + } |
|
780 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
781 | + $factory = new $factoryClass($this); |
|
782 | + return $factory->getLDAPProvider(); |
|
783 | + }); |
|
784 | + $this->registerService('LockingProvider', function (Server $c) { |
|
785 | + $ini = $c->getIniWrapper(); |
|
786 | + $config = $c->getConfig(); |
|
787 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
788 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
789 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
790 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
791 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
792 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
793 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
794 | + } |
|
795 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
796 | + } |
|
797 | + return new NoopLockingProvider(); |
|
798 | + }); |
|
799 | + |
|
800 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
801 | + return new \OC\Files\Mount\Manager(); |
|
802 | + }); |
|
803 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
804 | + |
|
805 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
806 | + return new \OC\Files\Type\Detection( |
|
807 | + $c->getURLGenerator(), |
|
808 | + \OC::$configDir, |
|
809 | + \OC::$SERVERROOT . '/resources/config/' |
|
810 | + ); |
|
811 | + }); |
|
812 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
813 | + |
|
814 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
815 | + return new \OC\Files\Type\Loader( |
|
816 | + $c->getDatabaseConnection() |
|
817 | + ); |
|
818 | + }); |
|
819 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
820 | + $this->registerService(BundleFetcher::class, function () { |
|
821 | + return new BundleFetcher($this->getL10N('lib')); |
|
822 | + }); |
|
823 | + $this->registerService(AppFetcher::class, function() { |
|
824 | + return $this->getAppFetcher(); |
|
825 | + }); |
|
826 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
827 | + return new Manager( |
|
828 | + $c->query(IValidator::class) |
|
829 | + ); |
|
830 | + }); |
|
831 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
832 | + |
|
833 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
834 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
835 | + $manager->registerCapability(function () use ($c) { |
|
836 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
837 | + }); |
|
838 | + return $manager; |
|
839 | + }); |
|
840 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
841 | + |
|
842 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
843 | + $config = $c->getConfig(); |
|
844 | + $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
845 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
846 | + $factory = new $factoryClass($this); |
|
847 | + return $factory->getManager(); |
|
848 | + }); |
|
849 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
850 | + |
|
851 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
852 | + /* |
|
853 | 853 | * Dark magic for autoloader. |
854 | 854 | * If we do a class_exists it will try to load the class which will |
855 | 855 | * make composer cache the result. Resulting in errors when enabling |
856 | 856 | * the theming app. |
857 | 857 | */ |
858 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
859 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
860 | - $classExists = true; |
|
861 | - } else { |
|
862 | - $classExists = false; |
|
863 | - } |
|
864 | - |
|
865 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
866 | - return new ThemingDefaults( |
|
867 | - $c->getConfig(), |
|
868 | - $c->getL10N('theming'), |
|
869 | - $c->getURLGenerator(), |
|
870 | - new \OC_Defaults(), |
|
871 | - $c->getAppDataDir('theming'), |
|
872 | - $c->getMemCacheFactory(), |
|
873 | - new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager()) |
|
874 | - ); |
|
875 | - } |
|
876 | - return new \OC_Defaults(); |
|
877 | - }); |
|
878 | - $this->registerService(SCSSCacher::class, function(Server $c) { |
|
879 | - /** @var Factory $cacheFactory */ |
|
880 | - $cacheFactory = $c->query(Factory::class); |
|
881 | - return new SCSSCacher( |
|
882 | - $c->getLogger(), |
|
883 | - $c->query(\OC\Files\AppData\Factory::class), |
|
884 | - $c->getURLGenerator(), |
|
885 | - $c->getConfig(), |
|
886 | - $c->getThemingDefaults(), |
|
887 | - \OC::$SERVERROOT, |
|
888 | - $cacheFactory->createLocal('SCSS') |
|
889 | - ); |
|
890 | - }); |
|
891 | - $this->registerService(EventDispatcher::class, function () { |
|
892 | - return new EventDispatcher(); |
|
893 | - }); |
|
894 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
895 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
896 | - |
|
897 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
898 | - // FIXME: Instantiiated here due to cyclic dependency |
|
899 | - $request = new Request( |
|
900 | - [ |
|
901 | - 'get' => $_GET, |
|
902 | - 'post' => $_POST, |
|
903 | - 'files' => $_FILES, |
|
904 | - 'server' => $_SERVER, |
|
905 | - 'env' => $_ENV, |
|
906 | - 'cookies' => $_COOKIE, |
|
907 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
908 | - ? $_SERVER['REQUEST_METHOD'] |
|
909 | - : null, |
|
910 | - ], |
|
911 | - $c->getSecureRandom(), |
|
912 | - $c->getConfig() |
|
913 | - ); |
|
914 | - |
|
915 | - return new CryptoWrapper( |
|
916 | - $c->getConfig(), |
|
917 | - $c->getCrypto(), |
|
918 | - $c->getSecureRandom(), |
|
919 | - $request |
|
920 | - ); |
|
921 | - }); |
|
922 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
923 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
924 | - |
|
925 | - return new CsrfTokenManager( |
|
926 | - $tokenGenerator, |
|
927 | - $c->query(SessionStorage::class) |
|
928 | - ); |
|
929 | - }); |
|
930 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
931 | - return new SessionStorage($c->getSession()); |
|
932 | - }); |
|
933 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
934 | - return new ContentSecurityPolicyManager(); |
|
935 | - }); |
|
936 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
937 | - |
|
938 | - $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
939 | - return new ContentSecurityPolicyNonceManager( |
|
940 | - $c->getCsrfTokenManager(), |
|
941 | - $c->getRequest() |
|
942 | - ); |
|
943 | - }); |
|
944 | - |
|
945 | - $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
946 | - $config = $c->getConfig(); |
|
947 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
948 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
949 | - $factory = new $factoryClass($this); |
|
950 | - |
|
951 | - $manager = new \OC\Share20\Manager( |
|
952 | - $c->getLogger(), |
|
953 | - $c->getConfig(), |
|
954 | - $c->getSecureRandom(), |
|
955 | - $c->getHasher(), |
|
956 | - $c->getMountManager(), |
|
957 | - $c->getGroupManager(), |
|
958 | - $c->getL10N('core'), |
|
959 | - $factory, |
|
960 | - $c->getUserManager(), |
|
961 | - $c->getLazyRootFolder(), |
|
962 | - $c->getEventDispatcher() |
|
963 | - ); |
|
964 | - |
|
965 | - return $manager; |
|
966 | - }); |
|
967 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
968 | - |
|
969 | - $this->registerService('SettingsManager', function(Server $c) { |
|
970 | - $manager = new \OC\Settings\Manager( |
|
971 | - $c->getLogger(), |
|
972 | - $c->getDatabaseConnection(), |
|
973 | - $c->getL10N('lib'), |
|
974 | - $c->getConfig(), |
|
975 | - $c->getEncryptionManager(), |
|
976 | - $c->getUserManager(), |
|
977 | - $c->getLockingProvider(), |
|
978 | - $c->getRequest(), |
|
979 | - new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
980 | - $c->getURLGenerator() |
|
981 | - ); |
|
982 | - return $manager; |
|
983 | - }); |
|
984 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
985 | - return new \OC\Files\AppData\Factory( |
|
986 | - $c->getRootFolder(), |
|
987 | - $c->getSystemConfig() |
|
988 | - ); |
|
989 | - }); |
|
990 | - |
|
991 | - $this->registerService('LockdownManager', function (Server $c) { |
|
992 | - return new LockdownManager(function() use ($c) { |
|
993 | - return $c->getSession(); |
|
994 | - }); |
|
995 | - }); |
|
996 | - |
|
997 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
998 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
999 | - }); |
|
1000 | - |
|
1001 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1002 | - return new CloudIdManager(); |
|
1003 | - }); |
|
1004 | - |
|
1005 | - /* To trick DI since we don't extend the DIContainer here */ |
|
1006 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
1007 | - return new CleanPreviewsBackgroundJob( |
|
1008 | - $c->getRootFolder(), |
|
1009 | - $c->getLogger(), |
|
1010 | - $c->getJobList(), |
|
1011 | - new TimeFactory() |
|
1012 | - ); |
|
1013 | - }); |
|
1014 | - |
|
1015 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1016 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1017 | - |
|
1018 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1019 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1020 | - |
|
1021 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1022 | - return new Defaults( |
|
1023 | - $c->getThemingDefaults() |
|
1024 | - ); |
|
1025 | - }); |
|
1026 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1027 | - |
|
1028 | - $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
1029 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1030 | - }); |
|
1031 | - |
|
1032 | - $this->registerService(IShareHelper::class, function(Server $c) { |
|
1033 | - return new ShareHelper( |
|
1034 | - $c->query(\OCP\Share\IManager::class) |
|
1035 | - ); |
|
1036 | - }); |
|
1037 | - } |
|
1038 | - |
|
1039 | - /** |
|
1040 | - * @return \OCP\Contacts\IManager |
|
1041 | - */ |
|
1042 | - public function getContactsManager() { |
|
1043 | - return $this->query('ContactsManager'); |
|
1044 | - } |
|
1045 | - |
|
1046 | - /** |
|
1047 | - * @return \OC\Encryption\Manager |
|
1048 | - */ |
|
1049 | - public function getEncryptionManager() { |
|
1050 | - return $this->query('EncryptionManager'); |
|
1051 | - } |
|
1052 | - |
|
1053 | - /** |
|
1054 | - * @return \OC\Encryption\File |
|
1055 | - */ |
|
1056 | - public function getEncryptionFilesHelper() { |
|
1057 | - return $this->query('EncryptionFileHelper'); |
|
1058 | - } |
|
1059 | - |
|
1060 | - /** |
|
1061 | - * @return \OCP\Encryption\Keys\IStorage |
|
1062 | - */ |
|
1063 | - public function getEncryptionKeyStorage() { |
|
1064 | - return $this->query('EncryptionKeyStorage'); |
|
1065 | - } |
|
1066 | - |
|
1067 | - /** |
|
1068 | - * The current request object holding all information about the request |
|
1069 | - * currently being processed is returned from this method. |
|
1070 | - * In case the current execution was not initiated by a web request null is returned |
|
1071 | - * |
|
1072 | - * @return \OCP\IRequest |
|
1073 | - */ |
|
1074 | - public function getRequest() { |
|
1075 | - return $this->query('Request'); |
|
1076 | - } |
|
1077 | - |
|
1078 | - /** |
|
1079 | - * Returns the preview manager which can create preview images for a given file |
|
1080 | - * |
|
1081 | - * @return \OCP\IPreview |
|
1082 | - */ |
|
1083 | - public function getPreviewManager() { |
|
1084 | - return $this->query('PreviewManager'); |
|
1085 | - } |
|
1086 | - |
|
1087 | - /** |
|
1088 | - * Returns the tag manager which can get and set tags for different object types |
|
1089 | - * |
|
1090 | - * @see \OCP\ITagManager::load() |
|
1091 | - * @return \OCP\ITagManager |
|
1092 | - */ |
|
1093 | - public function getTagManager() { |
|
1094 | - return $this->query('TagManager'); |
|
1095 | - } |
|
1096 | - |
|
1097 | - /** |
|
1098 | - * Returns the system-tag manager |
|
1099 | - * |
|
1100 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1101 | - * |
|
1102 | - * @since 9.0.0 |
|
1103 | - */ |
|
1104 | - public function getSystemTagManager() { |
|
1105 | - return $this->query('SystemTagManager'); |
|
1106 | - } |
|
1107 | - |
|
1108 | - /** |
|
1109 | - * Returns the system-tag object mapper |
|
1110 | - * |
|
1111 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1112 | - * |
|
1113 | - * @since 9.0.0 |
|
1114 | - */ |
|
1115 | - public function getSystemTagObjectMapper() { |
|
1116 | - return $this->query('SystemTagObjectMapper'); |
|
1117 | - } |
|
1118 | - |
|
1119 | - /** |
|
1120 | - * Returns the avatar manager, used for avatar functionality |
|
1121 | - * |
|
1122 | - * @return \OCP\IAvatarManager |
|
1123 | - */ |
|
1124 | - public function getAvatarManager() { |
|
1125 | - return $this->query('AvatarManager'); |
|
1126 | - } |
|
1127 | - |
|
1128 | - /** |
|
1129 | - * Returns the root folder of ownCloud's data directory |
|
1130 | - * |
|
1131 | - * @return \OCP\Files\IRootFolder |
|
1132 | - */ |
|
1133 | - public function getRootFolder() { |
|
1134 | - return $this->query('LazyRootFolder'); |
|
1135 | - } |
|
1136 | - |
|
1137 | - /** |
|
1138 | - * Returns the root folder of ownCloud's data directory |
|
1139 | - * This is the lazy variant so this gets only initialized once it |
|
1140 | - * is actually used. |
|
1141 | - * |
|
1142 | - * @return \OCP\Files\IRootFolder |
|
1143 | - */ |
|
1144 | - public function getLazyRootFolder() { |
|
1145 | - return $this->query('LazyRootFolder'); |
|
1146 | - } |
|
1147 | - |
|
1148 | - /** |
|
1149 | - * Returns a view to ownCloud's files folder |
|
1150 | - * |
|
1151 | - * @param string $userId user ID |
|
1152 | - * @return \OCP\Files\Folder|null |
|
1153 | - */ |
|
1154 | - public function getUserFolder($userId = null) { |
|
1155 | - if ($userId === null) { |
|
1156 | - $user = $this->getUserSession()->getUser(); |
|
1157 | - if (!$user) { |
|
1158 | - return null; |
|
1159 | - } |
|
1160 | - $userId = $user->getUID(); |
|
1161 | - } |
|
1162 | - $root = $this->getRootFolder(); |
|
1163 | - return $root->getUserFolder($userId); |
|
1164 | - } |
|
1165 | - |
|
1166 | - /** |
|
1167 | - * Returns an app-specific view in ownClouds data directory |
|
1168 | - * |
|
1169 | - * @return \OCP\Files\Folder |
|
1170 | - * @deprecated since 9.2.0 use IAppData |
|
1171 | - */ |
|
1172 | - public function getAppFolder() { |
|
1173 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1174 | - $root = $this->getRootFolder(); |
|
1175 | - if (!$root->nodeExists($dir)) { |
|
1176 | - $folder = $root->newFolder($dir); |
|
1177 | - } else { |
|
1178 | - $folder = $root->get($dir); |
|
1179 | - } |
|
1180 | - return $folder; |
|
1181 | - } |
|
1182 | - |
|
1183 | - /** |
|
1184 | - * @return \OC\User\Manager |
|
1185 | - */ |
|
1186 | - public function getUserManager() { |
|
1187 | - return $this->query('UserManager'); |
|
1188 | - } |
|
1189 | - |
|
1190 | - /** |
|
1191 | - * @return \OC\Group\Manager |
|
1192 | - */ |
|
1193 | - public function getGroupManager() { |
|
1194 | - return $this->query('GroupManager'); |
|
1195 | - } |
|
1196 | - |
|
1197 | - /** |
|
1198 | - * @return \OC\User\Session |
|
1199 | - */ |
|
1200 | - public function getUserSession() { |
|
1201 | - return $this->query('UserSession'); |
|
1202 | - } |
|
1203 | - |
|
1204 | - /** |
|
1205 | - * @return \OCP\ISession |
|
1206 | - */ |
|
1207 | - public function getSession() { |
|
1208 | - return $this->query('UserSession')->getSession(); |
|
1209 | - } |
|
1210 | - |
|
1211 | - /** |
|
1212 | - * @param \OCP\ISession $session |
|
1213 | - */ |
|
1214 | - public function setSession(\OCP\ISession $session) { |
|
1215 | - $this->query(SessionStorage::class)->setSession($session); |
|
1216 | - $this->query('UserSession')->setSession($session); |
|
1217 | - $this->query(Store::class)->setSession($session); |
|
1218 | - } |
|
1219 | - |
|
1220 | - /** |
|
1221 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1222 | - */ |
|
1223 | - public function getTwoFactorAuthManager() { |
|
1224 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1225 | - } |
|
1226 | - |
|
1227 | - /** |
|
1228 | - * @return \OC\NavigationManager |
|
1229 | - */ |
|
1230 | - public function getNavigationManager() { |
|
1231 | - return $this->query('NavigationManager'); |
|
1232 | - } |
|
1233 | - |
|
1234 | - /** |
|
1235 | - * @return \OCP\IConfig |
|
1236 | - */ |
|
1237 | - public function getConfig() { |
|
1238 | - return $this->query('AllConfig'); |
|
1239 | - } |
|
1240 | - |
|
1241 | - /** |
|
1242 | - * @internal For internal use only |
|
1243 | - * @return \OC\SystemConfig |
|
1244 | - */ |
|
1245 | - public function getSystemConfig() { |
|
1246 | - return $this->query('SystemConfig'); |
|
1247 | - } |
|
1248 | - |
|
1249 | - /** |
|
1250 | - * Returns the app config manager |
|
1251 | - * |
|
1252 | - * @return \OCP\IAppConfig |
|
1253 | - */ |
|
1254 | - public function getAppConfig() { |
|
1255 | - return $this->query('AppConfig'); |
|
1256 | - } |
|
1257 | - |
|
1258 | - /** |
|
1259 | - * @return \OCP\L10N\IFactory |
|
1260 | - */ |
|
1261 | - public function getL10NFactory() { |
|
1262 | - return $this->query('L10NFactory'); |
|
1263 | - } |
|
1264 | - |
|
1265 | - /** |
|
1266 | - * get an L10N instance |
|
1267 | - * |
|
1268 | - * @param string $app appid |
|
1269 | - * @param string $lang |
|
1270 | - * @return IL10N |
|
1271 | - */ |
|
1272 | - public function getL10N($app, $lang = null) { |
|
1273 | - return $this->getL10NFactory()->get($app, $lang); |
|
1274 | - } |
|
1275 | - |
|
1276 | - /** |
|
1277 | - * @return \OCP\IURLGenerator |
|
1278 | - */ |
|
1279 | - public function getURLGenerator() { |
|
1280 | - return $this->query('URLGenerator'); |
|
1281 | - } |
|
1282 | - |
|
1283 | - /** |
|
1284 | - * @return \OCP\IHelper |
|
1285 | - */ |
|
1286 | - public function getHelper() { |
|
1287 | - return $this->query('AppHelper'); |
|
1288 | - } |
|
1289 | - |
|
1290 | - /** |
|
1291 | - * @return AppFetcher |
|
1292 | - */ |
|
1293 | - public function getAppFetcher() { |
|
1294 | - return $this->query('AppFetcher'); |
|
1295 | - } |
|
1296 | - |
|
1297 | - /** |
|
1298 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1299 | - * getMemCacheFactory() instead. |
|
1300 | - * |
|
1301 | - * @return \OCP\ICache |
|
1302 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1303 | - */ |
|
1304 | - public function getCache() { |
|
1305 | - return $this->query('UserCache'); |
|
1306 | - } |
|
1307 | - |
|
1308 | - /** |
|
1309 | - * Returns an \OCP\CacheFactory instance |
|
1310 | - * |
|
1311 | - * @return \OCP\ICacheFactory |
|
1312 | - */ |
|
1313 | - public function getMemCacheFactory() { |
|
1314 | - return $this->query('MemCacheFactory'); |
|
1315 | - } |
|
1316 | - |
|
1317 | - /** |
|
1318 | - * Returns an \OC\RedisFactory instance |
|
1319 | - * |
|
1320 | - * @return \OC\RedisFactory |
|
1321 | - */ |
|
1322 | - public function getGetRedisFactory() { |
|
1323 | - return $this->query('RedisFactory'); |
|
1324 | - } |
|
1325 | - |
|
1326 | - |
|
1327 | - /** |
|
1328 | - * Returns the current session |
|
1329 | - * |
|
1330 | - * @return \OCP\IDBConnection |
|
1331 | - */ |
|
1332 | - public function getDatabaseConnection() { |
|
1333 | - return $this->query('DatabaseConnection'); |
|
1334 | - } |
|
1335 | - |
|
1336 | - /** |
|
1337 | - * Returns the activity manager |
|
1338 | - * |
|
1339 | - * @return \OCP\Activity\IManager |
|
1340 | - */ |
|
1341 | - public function getActivityManager() { |
|
1342 | - return $this->query('ActivityManager'); |
|
1343 | - } |
|
1344 | - |
|
1345 | - /** |
|
1346 | - * Returns an job list for controlling background jobs |
|
1347 | - * |
|
1348 | - * @return \OCP\BackgroundJob\IJobList |
|
1349 | - */ |
|
1350 | - public function getJobList() { |
|
1351 | - return $this->query('JobList'); |
|
1352 | - } |
|
1353 | - |
|
1354 | - /** |
|
1355 | - * Returns a logger instance |
|
1356 | - * |
|
1357 | - * @return \OCP\ILogger |
|
1358 | - */ |
|
1359 | - public function getLogger() { |
|
1360 | - return $this->query('Logger'); |
|
1361 | - } |
|
1362 | - |
|
1363 | - /** |
|
1364 | - * Returns a router for generating and matching urls |
|
1365 | - * |
|
1366 | - * @return \OCP\Route\IRouter |
|
1367 | - */ |
|
1368 | - public function getRouter() { |
|
1369 | - return $this->query('Router'); |
|
1370 | - } |
|
1371 | - |
|
1372 | - /** |
|
1373 | - * Returns a search instance |
|
1374 | - * |
|
1375 | - * @return \OCP\ISearch |
|
1376 | - */ |
|
1377 | - public function getSearch() { |
|
1378 | - return $this->query('Search'); |
|
1379 | - } |
|
1380 | - |
|
1381 | - /** |
|
1382 | - * Returns a SecureRandom instance |
|
1383 | - * |
|
1384 | - * @return \OCP\Security\ISecureRandom |
|
1385 | - */ |
|
1386 | - public function getSecureRandom() { |
|
1387 | - return $this->query('SecureRandom'); |
|
1388 | - } |
|
1389 | - |
|
1390 | - /** |
|
1391 | - * Returns a Crypto instance |
|
1392 | - * |
|
1393 | - * @return \OCP\Security\ICrypto |
|
1394 | - */ |
|
1395 | - public function getCrypto() { |
|
1396 | - return $this->query('Crypto'); |
|
1397 | - } |
|
1398 | - |
|
1399 | - /** |
|
1400 | - * Returns a Hasher instance |
|
1401 | - * |
|
1402 | - * @return \OCP\Security\IHasher |
|
1403 | - */ |
|
1404 | - public function getHasher() { |
|
1405 | - return $this->query('Hasher'); |
|
1406 | - } |
|
1407 | - |
|
1408 | - /** |
|
1409 | - * Returns a CredentialsManager instance |
|
1410 | - * |
|
1411 | - * @return \OCP\Security\ICredentialsManager |
|
1412 | - */ |
|
1413 | - public function getCredentialsManager() { |
|
1414 | - return $this->query('CredentialsManager'); |
|
1415 | - } |
|
1416 | - |
|
1417 | - /** |
|
1418 | - * Returns an instance of the HTTP helper class |
|
1419 | - * |
|
1420 | - * @deprecated Use getHTTPClientService() |
|
1421 | - * @return \OC\HTTPHelper |
|
1422 | - */ |
|
1423 | - public function getHTTPHelper() { |
|
1424 | - return $this->query('HTTPHelper'); |
|
1425 | - } |
|
1426 | - |
|
1427 | - /** |
|
1428 | - * Get the certificate manager for the user |
|
1429 | - * |
|
1430 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1431 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1432 | - */ |
|
1433 | - public function getCertificateManager($userId = '') { |
|
1434 | - if ($userId === '') { |
|
1435 | - $userSession = $this->getUserSession(); |
|
1436 | - $user = $userSession->getUser(); |
|
1437 | - if (is_null($user)) { |
|
1438 | - return null; |
|
1439 | - } |
|
1440 | - $userId = $user->getUID(); |
|
1441 | - } |
|
1442 | - return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1443 | - } |
|
1444 | - |
|
1445 | - /** |
|
1446 | - * Returns an instance of the HTTP client service |
|
1447 | - * |
|
1448 | - * @return \OCP\Http\Client\IClientService |
|
1449 | - */ |
|
1450 | - public function getHTTPClientService() { |
|
1451 | - return $this->query('HttpClientService'); |
|
1452 | - } |
|
1453 | - |
|
1454 | - /** |
|
1455 | - * Create a new event source |
|
1456 | - * |
|
1457 | - * @return \OCP\IEventSource |
|
1458 | - */ |
|
1459 | - public function createEventSource() { |
|
1460 | - return new \OC_EventSource(); |
|
1461 | - } |
|
1462 | - |
|
1463 | - /** |
|
1464 | - * Get the active event logger |
|
1465 | - * |
|
1466 | - * The returned logger only logs data when debug mode is enabled |
|
1467 | - * |
|
1468 | - * @return \OCP\Diagnostics\IEventLogger |
|
1469 | - */ |
|
1470 | - public function getEventLogger() { |
|
1471 | - return $this->query('EventLogger'); |
|
1472 | - } |
|
1473 | - |
|
1474 | - /** |
|
1475 | - * Get the active query logger |
|
1476 | - * |
|
1477 | - * The returned logger only logs data when debug mode is enabled |
|
1478 | - * |
|
1479 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1480 | - */ |
|
1481 | - public function getQueryLogger() { |
|
1482 | - return $this->query('QueryLogger'); |
|
1483 | - } |
|
1484 | - |
|
1485 | - /** |
|
1486 | - * Get the manager for temporary files and folders |
|
1487 | - * |
|
1488 | - * @return \OCP\ITempManager |
|
1489 | - */ |
|
1490 | - public function getTempManager() { |
|
1491 | - return $this->query('TempManager'); |
|
1492 | - } |
|
1493 | - |
|
1494 | - /** |
|
1495 | - * Get the app manager |
|
1496 | - * |
|
1497 | - * @return \OCP\App\IAppManager |
|
1498 | - */ |
|
1499 | - public function getAppManager() { |
|
1500 | - return $this->query('AppManager'); |
|
1501 | - } |
|
1502 | - |
|
1503 | - /** |
|
1504 | - * Creates a new mailer |
|
1505 | - * |
|
1506 | - * @return \OCP\Mail\IMailer |
|
1507 | - */ |
|
1508 | - public function getMailer() { |
|
1509 | - return $this->query('Mailer'); |
|
1510 | - } |
|
1511 | - |
|
1512 | - /** |
|
1513 | - * Get the webroot |
|
1514 | - * |
|
1515 | - * @return string |
|
1516 | - */ |
|
1517 | - public function getWebRoot() { |
|
1518 | - return $this->webRoot; |
|
1519 | - } |
|
1520 | - |
|
1521 | - /** |
|
1522 | - * @return \OC\OCSClient |
|
1523 | - */ |
|
1524 | - public function getOcsClient() { |
|
1525 | - return $this->query('OcsClient'); |
|
1526 | - } |
|
1527 | - |
|
1528 | - /** |
|
1529 | - * @return \OCP\IDateTimeZone |
|
1530 | - */ |
|
1531 | - public function getDateTimeZone() { |
|
1532 | - return $this->query('DateTimeZone'); |
|
1533 | - } |
|
1534 | - |
|
1535 | - /** |
|
1536 | - * @return \OCP\IDateTimeFormatter |
|
1537 | - */ |
|
1538 | - public function getDateTimeFormatter() { |
|
1539 | - return $this->query('DateTimeFormatter'); |
|
1540 | - } |
|
1541 | - |
|
1542 | - /** |
|
1543 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1544 | - */ |
|
1545 | - public function getMountProviderCollection() { |
|
1546 | - return $this->query('MountConfigManager'); |
|
1547 | - } |
|
1548 | - |
|
1549 | - /** |
|
1550 | - * Get the IniWrapper |
|
1551 | - * |
|
1552 | - * @return IniGetWrapper |
|
1553 | - */ |
|
1554 | - public function getIniWrapper() { |
|
1555 | - return $this->query('IniWrapper'); |
|
1556 | - } |
|
1557 | - |
|
1558 | - /** |
|
1559 | - * @return \OCP\Command\IBus |
|
1560 | - */ |
|
1561 | - public function getCommandBus() { |
|
1562 | - return $this->query('AsyncCommandBus'); |
|
1563 | - } |
|
1564 | - |
|
1565 | - /** |
|
1566 | - * Get the trusted domain helper |
|
1567 | - * |
|
1568 | - * @return TrustedDomainHelper |
|
1569 | - */ |
|
1570 | - public function getTrustedDomainHelper() { |
|
1571 | - return $this->query('TrustedDomainHelper'); |
|
1572 | - } |
|
1573 | - |
|
1574 | - /** |
|
1575 | - * Get the locking provider |
|
1576 | - * |
|
1577 | - * @return \OCP\Lock\ILockingProvider |
|
1578 | - * @since 8.1.0 |
|
1579 | - */ |
|
1580 | - public function getLockingProvider() { |
|
1581 | - return $this->query('LockingProvider'); |
|
1582 | - } |
|
1583 | - |
|
1584 | - /** |
|
1585 | - * @return \OCP\Files\Mount\IMountManager |
|
1586 | - **/ |
|
1587 | - function getMountManager() { |
|
1588 | - return $this->query('MountManager'); |
|
1589 | - } |
|
1590 | - |
|
1591 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1592 | - function getUserMountCache() { |
|
1593 | - return $this->query('UserMountCache'); |
|
1594 | - } |
|
1595 | - |
|
1596 | - /** |
|
1597 | - * Get the MimeTypeDetector |
|
1598 | - * |
|
1599 | - * @return \OCP\Files\IMimeTypeDetector |
|
1600 | - */ |
|
1601 | - public function getMimeTypeDetector() { |
|
1602 | - return $this->query('MimeTypeDetector'); |
|
1603 | - } |
|
1604 | - |
|
1605 | - /** |
|
1606 | - * Get the MimeTypeLoader |
|
1607 | - * |
|
1608 | - * @return \OCP\Files\IMimeTypeLoader |
|
1609 | - */ |
|
1610 | - public function getMimeTypeLoader() { |
|
1611 | - return $this->query('MimeTypeLoader'); |
|
1612 | - } |
|
1613 | - |
|
1614 | - /** |
|
1615 | - * Get the manager of all the capabilities |
|
1616 | - * |
|
1617 | - * @return \OC\CapabilitiesManager |
|
1618 | - */ |
|
1619 | - public function getCapabilitiesManager() { |
|
1620 | - return $this->query('CapabilitiesManager'); |
|
1621 | - } |
|
1622 | - |
|
1623 | - /** |
|
1624 | - * Get the EventDispatcher |
|
1625 | - * |
|
1626 | - * @return EventDispatcherInterface |
|
1627 | - * @since 8.2.0 |
|
1628 | - */ |
|
1629 | - public function getEventDispatcher() { |
|
1630 | - return $this->query('EventDispatcher'); |
|
1631 | - } |
|
1632 | - |
|
1633 | - /** |
|
1634 | - * Get the Notification Manager |
|
1635 | - * |
|
1636 | - * @return \OCP\Notification\IManager |
|
1637 | - * @since 8.2.0 |
|
1638 | - */ |
|
1639 | - public function getNotificationManager() { |
|
1640 | - return $this->query('NotificationManager'); |
|
1641 | - } |
|
1642 | - |
|
1643 | - /** |
|
1644 | - * @return \OCP\Comments\ICommentsManager |
|
1645 | - */ |
|
1646 | - public function getCommentsManager() { |
|
1647 | - return $this->query('CommentsManager'); |
|
1648 | - } |
|
1649 | - |
|
1650 | - /** |
|
1651 | - * @return \OCA\Theming\ThemingDefaults |
|
1652 | - */ |
|
1653 | - public function getThemingDefaults() { |
|
1654 | - return $this->query('ThemingDefaults'); |
|
1655 | - } |
|
1656 | - |
|
1657 | - /** |
|
1658 | - * @return \OC\IntegrityCheck\Checker |
|
1659 | - */ |
|
1660 | - public function getIntegrityCodeChecker() { |
|
1661 | - return $this->query('IntegrityCodeChecker'); |
|
1662 | - } |
|
1663 | - |
|
1664 | - /** |
|
1665 | - * @return \OC\Session\CryptoWrapper |
|
1666 | - */ |
|
1667 | - public function getSessionCryptoWrapper() { |
|
1668 | - return $this->query('CryptoWrapper'); |
|
1669 | - } |
|
1670 | - |
|
1671 | - /** |
|
1672 | - * @return CsrfTokenManager |
|
1673 | - */ |
|
1674 | - public function getCsrfTokenManager() { |
|
1675 | - return $this->query('CsrfTokenManager'); |
|
1676 | - } |
|
1677 | - |
|
1678 | - /** |
|
1679 | - * @return Throttler |
|
1680 | - */ |
|
1681 | - public function getBruteForceThrottler() { |
|
1682 | - return $this->query('Throttler'); |
|
1683 | - } |
|
1684 | - |
|
1685 | - /** |
|
1686 | - * @return IContentSecurityPolicyManager |
|
1687 | - */ |
|
1688 | - public function getContentSecurityPolicyManager() { |
|
1689 | - return $this->query('ContentSecurityPolicyManager'); |
|
1690 | - } |
|
1691 | - |
|
1692 | - /** |
|
1693 | - * @return ContentSecurityPolicyNonceManager |
|
1694 | - */ |
|
1695 | - public function getContentSecurityPolicyNonceManager() { |
|
1696 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1697 | - } |
|
1698 | - |
|
1699 | - /** |
|
1700 | - * Not a public API as of 8.2, wait for 9.0 |
|
1701 | - * |
|
1702 | - * @return \OCA\Files_External\Service\BackendService |
|
1703 | - */ |
|
1704 | - public function getStoragesBackendService() { |
|
1705 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1706 | - } |
|
1707 | - |
|
1708 | - /** |
|
1709 | - * Not a public API as of 8.2, wait for 9.0 |
|
1710 | - * |
|
1711 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1712 | - */ |
|
1713 | - public function getGlobalStoragesService() { |
|
1714 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1715 | - } |
|
1716 | - |
|
1717 | - /** |
|
1718 | - * Not a public API as of 8.2, wait for 9.0 |
|
1719 | - * |
|
1720 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1721 | - */ |
|
1722 | - public function getUserGlobalStoragesService() { |
|
1723 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1724 | - } |
|
1725 | - |
|
1726 | - /** |
|
1727 | - * Not a public API as of 8.2, wait for 9.0 |
|
1728 | - * |
|
1729 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1730 | - */ |
|
1731 | - public function getUserStoragesService() { |
|
1732 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1733 | - } |
|
1734 | - |
|
1735 | - /** |
|
1736 | - * @return \OCP\Share\IManager |
|
1737 | - */ |
|
1738 | - public function getShareManager() { |
|
1739 | - return $this->query('ShareManager'); |
|
1740 | - } |
|
1741 | - |
|
1742 | - /** |
|
1743 | - * Returns the LDAP Provider |
|
1744 | - * |
|
1745 | - * @return \OCP\LDAP\ILDAPProvider |
|
1746 | - */ |
|
1747 | - public function getLDAPProvider() { |
|
1748 | - return $this->query('LDAPProvider'); |
|
1749 | - } |
|
1750 | - |
|
1751 | - /** |
|
1752 | - * @return \OCP\Settings\IManager |
|
1753 | - */ |
|
1754 | - public function getSettingsManager() { |
|
1755 | - return $this->query('SettingsManager'); |
|
1756 | - } |
|
1757 | - |
|
1758 | - /** |
|
1759 | - * @return \OCP\Files\IAppData |
|
1760 | - */ |
|
1761 | - public function getAppDataDir($app) { |
|
1762 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1763 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1764 | - return $factory->get($app); |
|
1765 | - } |
|
1766 | - |
|
1767 | - /** |
|
1768 | - * @return \OCP\Lockdown\ILockdownManager |
|
1769 | - */ |
|
1770 | - public function getLockdownManager() { |
|
1771 | - return $this->query('LockdownManager'); |
|
1772 | - } |
|
1773 | - |
|
1774 | - /** |
|
1775 | - * @return \OCP\Federation\ICloudIdManager |
|
1776 | - */ |
|
1777 | - public function getCloudIdManager() { |
|
1778 | - return $this->query(ICloudIdManager::class); |
|
1779 | - } |
|
858 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
859 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
860 | + $classExists = true; |
|
861 | + } else { |
|
862 | + $classExists = false; |
|
863 | + } |
|
864 | + |
|
865 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
866 | + return new ThemingDefaults( |
|
867 | + $c->getConfig(), |
|
868 | + $c->getL10N('theming'), |
|
869 | + $c->getURLGenerator(), |
|
870 | + new \OC_Defaults(), |
|
871 | + $c->getAppDataDir('theming'), |
|
872 | + $c->getMemCacheFactory(), |
|
873 | + new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager()) |
|
874 | + ); |
|
875 | + } |
|
876 | + return new \OC_Defaults(); |
|
877 | + }); |
|
878 | + $this->registerService(SCSSCacher::class, function(Server $c) { |
|
879 | + /** @var Factory $cacheFactory */ |
|
880 | + $cacheFactory = $c->query(Factory::class); |
|
881 | + return new SCSSCacher( |
|
882 | + $c->getLogger(), |
|
883 | + $c->query(\OC\Files\AppData\Factory::class), |
|
884 | + $c->getURLGenerator(), |
|
885 | + $c->getConfig(), |
|
886 | + $c->getThemingDefaults(), |
|
887 | + \OC::$SERVERROOT, |
|
888 | + $cacheFactory->createLocal('SCSS') |
|
889 | + ); |
|
890 | + }); |
|
891 | + $this->registerService(EventDispatcher::class, function () { |
|
892 | + return new EventDispatcher(); |
|
893 | + }); |
|
894 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
895 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
896 | + |
|
897 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
898 | + // FIXME: Instantiiated here due to cyclic dependency |
|
899 | + $request = new Request( |
|
900 | + [ |
|
901 | + 'get' => $_GET, |
|
902 | + 'post' => $_POST, |
|
903 | + 'files' => $_FILES, |
|
904 | + 'server' => $_SERVER, |
|
905 | + 'env' => $_ENV, |
|
906 | + 'cookies' => $_COOKIE, |
|
907 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
908 | + ? $_SERVER['REQUEST_METHOD'] |
|
909 | + : null, |
|
910 | + ], |
|
911 | + $c->getSecureRandom(), |
|
912 | + $c->getConfig() |
|
913 | + ); |
|
914 | + |
|
915 | + return new CryptoWrapper( |
|
916 | + $c->getConfig(), |
|
917 | + $c->getCrypto(), |
|
918 | + $c->getSecureRandom(), |
|
919 | + $request |
|
920 | + ); |
|
921 | + }); |
|
922 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
923 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
924 | + |
|
925 | + return new CsrfTokenManager( |
|
926 | + $tokenGenerator, |
|
927 | + $c->query(SessionStorage::class) |
|
928 | + ); |
|
929 | + }); |
|
930 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
931 | + return new SessionStorage($c->getSession()); |
|
932 | + }); |
|
933 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
934 | + return new ContentSecurityPolicyManager(); |
|
935 | + }); |
|
936 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
937 | + |
|
938 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
939 | + return new ContentSecurityPolicyNonceManager( |
|
940 | + $c->getCsrfTokenManager(), |
|
941 | + $c->getRequest() |
|
942 | + ); |
|
943 | + }); |
|
944 | + |
|
945 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
946 | + $config = $c->getConfig(); |
|
947 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
948 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
949 | + $factory = new $factoryClass($this); |
|
950 | + |
|
951 | + $manager = new \OC\Share20\Manager( |
|
952 | + $c->getLogger(), |
|
953 | + $c->getConfig(), |
|
954 | + $c->getSecureRandom(), |
|
955 | + $c->getHasher(), |
|
956 | + $c->getMountManager(), |
|
957 | + $c->getGroupManager(), |
|
958 | + $c->getL10N('core'), |
|
959 | + $factory, |
|
960 | + $c->getUserManager(), |
|
961 | + $c->getLazyRootFolder(), |
|
962 | + $c->getEventDispatcher() |
|
963 | + ); |
|
964 | + |
|
965 | + return $manager; |
|
966 | + }); |
|
967 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
968 | + |
|
969 | + $this->registerService('SettingsManager', function(Server $c) { |
|
970 | + $manager = new \OC\Settings\Manager( |
|
971 | + $c->getLogger(), |
|
972 | + $c->getDatabaseConnection(), |
|
973 | + $c->getL10N('lib'), |
|
974 | + $c->getConfig(), |
|
975 | + $c->getEncryptionManager(), |
|
976 | + $c->getUserManager(), |
|
977 | + $c->getLockingProvider(), |
|
978 | + $c->getRequest(), |
|
979 | + new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
980 | + $c->getURLGenerator() |
|
981 | + ); |
|
982 | + return $manager; |
|
983 | + }); |
|
984 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
985 | + return new \OC\Files\AppData\Factory( |
|
986 | + $c->getRootFolder(), |
|
987 | + $c->getSystemConfig() |
|
988 | + ); |
|
989 | + }); |
|
990 | + |
|
991 | + $this->registerService('LockdownManager', function (Server $c) { |
|
992 | + return new LockdownManager(function() use ($c) { |
|
993 | + return $c->getSession(); |
|
994 | + }); |
|
995 | + }); |
|
996 | + |
|
997 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
998 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
999 | + }); |
|
1000 | + |
|
1001 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1002 | + return new CloudIdManager(); |
|
1003 | + }); |
|
1004 | + |
|
1005 | + /* To trick DI since we don't extend the DIContainer here */ |
|
1006 | + $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
1007 | + return new CleanPreviewsBackgroundJob( |
|
1008 | + $c->getRootFolder(), |
|
1009 | + $c->getLogger(), |
|
1010 | + $c->getJobList(), |
|
1011 | + new TimeFactory() |
|
1012 | + ); |
|
1013 | + }); |
|
1014 | + |
|
1015 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1016 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1017 | + |
|
1018 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1019 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1020 | + |
|
1021 | + $this->registerService(Defaults::class, function (Server $c) { |
|
1022 | + return new Defaults( |
|
1023 | + $c->getThemingDefaults() |
|
1024 | + ); |
|
1025 | + }); |
|
1026 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1027 | + |
|
1028 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
1029 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1030 | + }); |
|
1031 | + |
|
1032 | + $this->registerService(IShareHelper::class, function(Server $c) { |
|
1033 | + return new ShareHelper( |
|
1034 | + $c->query(\OCP\Share\IManager::class) |
|
1035 | + ); |
|
1036 | + }); |
|
1037 | + } |
|
1038 | + |
|
1039 | + /** |
|
1040 | + * @return \OCP\Contacts\IManager |
|
1041 | + */ |
|
1042 | + public function getContactsManager() { |
|
1043 | + return $this->query('ContactsManager'); |
|
1044 | + } |
|
1045 | + |
|
1046 | + /** |
|
1047 | + * @return \OC\Encryption\Manager |
|
1048 | + */ |
|
1049 | + public function getEncryptionManager() { |
|
1050 | + return $this->query('EncryptionManager'); |
|
1051 | + } |
|
1052 | + |
|
1053 | + /** |
|
1054 | + * @return \OC\Encryption\File |
|
1055 | + */ |
|
1056 | + public function getEncryptionFilesHelper() { |
|
1057 | + return $this->query('EncryptionFileHelper'); |
|
1058 | + } |
|
1059 | + |
|
1060 | + /** |
|
1061 | + * @return \OCP\Encryption\Keys\IStorage |
|
1062 | + */ |
|
1063 | + public function getEncryptionKeyStorage() { |
|
1064 | + return $this->query('EncryptionKeyStorage'); |
|
1065 | + } |
|
1066 | + |
|
1067 | + /** |
|
1068 | + * The current request object holding all information about the request |
|
1069 | + * currently being processed is returned from this method. |
|
1070 | + * In case the current execution was not initiated by a web request null is returned |
|
1071 | + * |
|
1072 | + * @return \OCP\IRequest |
|
1073 | + */ |
|
1074 | + public function getRequest() { |
|
1075 | + return $this->query('Request'); |
|
1076 | + } |
|
1077 | + |
|
1078 | + /** |
|
1079 | + * Returns the preview manager which can create preview images for a given file |
|
1080 | + * |
|
1081 | + * @return \OCP\IPreview |
|
1082 | + */ |
|
1083 | + public function getPreviewManager() { |
|
1084 | + return $this->query('PreviewManager'); |
|
1085 | + } |
|
1086 | + |
|
1087 | + /** |
|
1088 | + * Returns the tag manager which can get and set tags for different object types |
|
1089 | + * |
|
1090 | + * @see \OCP\ITagManager::load() |
|
1091 | + * @return \OCP\ITagManager |
|
1092 | + */ |
|
1093 | + public function getTagManager() { |
|
1094 | + return $this->query('TagManager'); |
|
1095 | + } |
|
1096 | + |
|
1097 | + /** |
|
1098 | + * Returns the system-tag manager |
|
1099 | + * |
|
1100 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1101 | + * |
|
1102 | + * @since 9.0.0 |
|
1103 | + */ |
|
1104 | + public function getSystemTagManager() { |
|
1105 | + return $this->query('SystemTagManager'); |
|
1106 | + } |
|
1107 | + |
|
1108 | + /** |
|
1109 | + * Returns the system-tag object mapper |
|
1110 | + * |
|
1111 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1112 | + * |
|
1113 | + * @since 9.0.0 |
|
1114 | + */ |
|
1115 | + public function getSystemTagObjectMapper() { |
|
1116 | + return $this->query('SystemTagObjectMapper'); |
|
1117 | + } |
|
1118 | + |
|
1119 | + /** |
|
1120 | + * Returns the avatar manager, used for avatar functionality |
|
1121 | + * |
|
1122 | + * @return \OCP\IAvatarManager |
|
1123 | + */ |
|
1124 | + public function getAvatarManager() { |
|
1125 | + return $this->query('AvatarManager'); |
|
1126 | + } |
|
1127 | + |
|
1128 | + /** |
|
1129 | + * Returns the root folder of ownCloud's data directory |
|
1130 | + * |
|
1131 | + * @return \OCP\Files\IRootFolder |
|
1132 | + */ |
|
1133 | + public function getRootFolder() { |
|
1134 | + return $this->query('LazyRootFolder'); |
|
1135 | + } |
|
1136 | + |
|
1137 | + /** |
|
1138 | + * Returns the root folder of ownCloud's data directory |
|
1139 | + * This is the lazy variant so this gets only initialized once it |
|
1140 | + * is actually used. |
|
1141 | + * |
|
1142 | + * @return \OCP\Files\IRootFolder |
|
1143 | + */ |
|
1144 | + public function getLazyRootFolder() { |
|
1145 | + return $this->query('LazyRootFolder'); |
|
1146 | + } |
|
1147 | + |
|
1148 | + /** |
|
1149 | + * Returns a view to ownCloud's files folder |
|
1150 | + * |
|
1151 | + * @param string $userId user ID |
|
1152 | + * @return \OCP\Files\Folder|null |
|
1153 | + */ |
|
1154 | + public function getUserFolder($userId = null) { |
|
1155 | + if ($userId === null) { |
|
1156 | + $user = $this->getUserSession()->getUser(); |
|
1157 | + if (!$user) { |
|
1158 | + return null; |
|
1159 | + } |
|
1160 | + $userId = $user->getUID(); |
|
1161 | + } |
|
1162 | + $root = $this->getRootFolder(); |
|
1163 | + return $root->getUserFolder($userId); |
|
1164 | + } |
|
1165 | + |
|
1166 | + /** |
|
1167 | + * Returns an app-specific view in ownClouds data directory |
|
1168 | + * |
|
1169 | + * @return \OCP\Files\Folder |
|
1170 | + * @deprecated since 9.2.0 use IAppData |
|
1171 | + */ |
|
1172 | + public function getAppFolder() { |
|
1173 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1174 | + $root = $this->getRootFolder(); |
|
1175 | + if (!$root->nodeExists($dir)) { |
|
1176 | + $folder = $root->newFolder($dir); |
|
1177 | + } else { |
|
1178 | + $folder = $root->get($dir); |
|
1179 | + } |
|
1180 | + return $folder; |
|
1181 | + } |
|
1182 | + |
|
1183 | + /** |
|
1184 | + * @return \OC\User\Manager |
|
1185 | + */ |
|
1186 | + public function getUserManager() { |
|
1187 | + return $this->query('UserManager'); |
|
1188 | + } |
|
1189 | + |
|
1190 | + /** |
|
1191 | + * @return \OC\Group\Manager |
|
1192 | + */ |
|
1193 | + public function getGroupManager() { |
|
1194 | + return $this->query('GroupManager'); |
|
1195 | + } |
|
1196 | + |
|
1197 | + /** |
|
1198 | + * @return \OC\User\Session |
|
1199 | + */ |
|
1200 | + public function getUserSession() { |
|
1201 | + return $this->query('UserSession'); |
|
1202 | + } |
|
1203 | + |
|
1204 | + /** |
|
1205 | + * @return \OCP\ISession |
|
1206 | + */ |
|
1207 | + public function getSession() { |
|
1208 | + return $this->query('UserSession')->getSession(); |
|
1209 | + } |
|
1210 | + |
|
1211 | + /** |
|
1212 | + * @param \OCP\ISession $session |
|
1213 | + */ |
|
1214 | + public function setSession(\OCP\ISession $session) { |
|
1215 | + $this->query(SessionStorage::class)->setSession($session); |
|
1216 | + $this->query('UserSession')->setSession($session); |
|
1217 | + $this->query(Store::class)->setSession($session); |
|
1218 | + } |
|
1219 | + |
|
1220 | + /** |
|
1221 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1222 | + */ |
|
1223 | + public function getTwoFactorAuthManager() { |
|
1224 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1225 | + } |
|
1226 | + |
|
1227 | + /** |
|
1228 | + * @return \OC\NavigationManager |
|
1229 | + */ |
|
1230 | + public function getNavigationManager() { |
|
1231 | + return $this->query('NavigationManager'); |
|
1232 | + } |
|
1233 | + |
|
1234 | + /** |
|
1235 | + * @return \OCP\IConfig |
|
1236 | + */ |
|
1237 | + public function getConfig() { |
|
1238 | + return $this->query('AllConfig'); |
|
1239 | + } |
|
1240 | + |
|
1241 | + /** |
|
1242 | + * @internal For internal use only |
|
1243 | + * @return \OC\SystemConfig |
|
1244 | + */ |
|
1245 | + public function getSystemConfig() { |
|
1246 | + return $this->query('SystemConfig'); |
|
1247 | + } |
|
1248 | + |
|
1249 | + /** |
|
1250 | + * Returns the app config manager |
|
1251 | + * |
|
1252 | + * @return \OCP\IAppConfig |
|
1253 | + */ |
|
1254 | + public function getAppConfig() { |
|
1255 | + return $this->query('AppConfig'); |
|
1256 | + } |
|
1257 | + |
|
1258 | + /** |
|
1259 | + * @return \OCP\L10N\IFactory |
|
1260 | + */ |
|
1261 | + public function getL10NFactory() { |
|
1262 | + return $this->query('L10NFactory'); |
|
1263 | + } |
|
1264 | + |
|
1265 | + /** |
|
1266 | + * get an L10N instance |
|
1267 | + * |
|
1268 | + * @param string $app appid |
|
1269 | + * @param string $lang |
|
1270 | + * @return IL10N |
|
1271 | + */ |
|
1272 | + public function getL10N($app, $lang = null) { |
|
1273 | + return $this->getL10NFactory()->get($app, $lang); |
|
1274 | + } |
|
1275 | + |
|
1276 | + /** |
|
1277 | + * @return \OCP\IURLGenerator |
|
1278 | + */ |
|
1279 | + public function getURLGenerator() { |
|
1280 | + return $this->query('URLGenerator'); |
|
1281 | + } |
|
1282 | + |
|
1283 | + /** |
|
1284 | + * @return \OCP\IHelper |
|
1285 | + */ |
|
1286 | + public function getHelper() { |
|
1287 | + return $this->query('AppHelper'); |
|
1288 | + } |
|
1289 | + |
|
1290 | + /** |
|
1291 | + * @return AppFetcher |
|
1292 | + */ |
|
1293 | + public function getAppFetcher() { |
|
1294 | + return $this->query('AppFetcher'); |
|
1295 | + } |
|
1296 | + |
|
1297 | + /** |
|
1298 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1299 | + * getMemCacheFactory() instead. |
|
1300 | + * |
|
1301 | + * @return \OCP\ICache |
|
1302 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1303 | + */ |
|
1304 | + public function getCache() { |
|
1305 | + return $this->query('UserCache'); |
|
1306 | + } |
|
1307 | + |
|
1308 | + /** |
|
1309 | + * Returns an \OCP\CacheFactory instance |
|
1310 | + * |
|
1311 | + * @return \OCP\ICacheFactory |
|
1312 | + */ |
|
1313 | + public function getMemCacheFactory() { |
|
1314 | + return $this->query('MemCacheFactory'); |
|
1315 | + } |
|
1316 | + |
|
1317 | + /** |
|
1318 | + * Returns an \OC\RedisFactory instance |
|
1319 | + * |
|
1320 | + * @return \OC\RedisFactory |
|
1321 | + */ |
|
1322 | + public function getGetRedisFactory() { |
|
1323 | + return $this->query('RedisFactory'); |
|
1324 | + } |
|
1325 | + |
|
1326 | + |
|
1327 | + /** |
|
1328 | + * Returns the current session |
|
1329 | + * |
|
1330 | + * @return \OCP\IDBConnection |
|
1331 | + */ |
|
1332 | + public function getDatabaseConnection() { |
|
1333 | + return $this->query('DatabaseConnection'); |
|
1334 | + } |
|
1335 | + |
|
1336 | + /** |
|
1337 | + * Returns the activity manager |
|
1338 | + * |
|
1339 | + * @return \OCP\Activity\IManager |
|
1340 | + */ |
|
1341 | + public function getActivityManager() { |
|
1342 | + return $this->query('ActivityManager'); |
|
1343 | + } |
|
1344 | + |
|
1345 | + /** |
|
1346 | + * Returns an job list for controlling background jobs |
|
1347 | + * |
|
1348 | + * @return \OCP\BackgroundJob\IJobList |
|
1349 | + */ |
|
1350 | + public function getJobList() { |
|
1351 | + return $this->query('JobList'); |
|
1352 | + } |
|
1353 | + |
|
1354 | + /** |
|
1355 | + * Returns a logger instance |
|
1356 | + * |
|
1357 | + * @return \OCP\ILogger |
|
1358 | + */ |
|
1359 | + public function getLogger() { |
|
1360 | + return $this->query('Logger'); |
|
1361 | + } |
|
1362 | + |
|
1363 | + /** |
|
1364 | + * Returns a router for generating and matching urls |
|
1365 | + * |
|
1366 | + * @return \OCP\Route\IRouter |
|
1367 | + */ |
|
1368 | + public function getRouter() { |
|
1369 | + return $this->query('Router'); |
|
1370 | + } |
|
1371 | + |
|
1372 | + /** |
|
1373 | + * Returns a search instance |
|
1374 | + * |
|
1375 | + * @return \OCP\ISearch |
|
1376 | + */ |
|
1377 | + public function getSearch() { |
|
1378 | + return $this->query('Search'); |
|
1379 | + } |
|
1380 | + |
|
1381 | + /** |
|
1382 | + * Returns a SecureRandom instance |
|
1383 | + * |
|
1384 | + * @return \OCP\Security\ISecureRandom |
|
1385 | + */ |
|
1386 | + public function getSecureRandom() { |
|
1387 | + return $this->query('SecureRandom'); |
|
1388 | + } |
|
1389 | + |
|
1390 | + /** |
|
1391 | + * Returns a Crypto instance |
|
1392 | + * |
|
1393 | + * @return \OCP\Security\ICrypto |
|
1394 | + */ |
|
1395 | + public function getCrypto() { |
|
1396 | + return $this->query('Crypto'); |
|
1397 | + } |
|
1398 | + |
|
1399 | + /** |
|
1400 | + * Returns a Hasher instance |
|
1401 | + * |
|
1402 | + * @return \OCP\Security\IHasher |
|
1403 | + */ |
|
1404 | + public function getHasher() { |
|
1405 | + return $this->query('Hasher'); |
|
1406 | + } |
|
1407 | + |
|
1408 | + /** |
|
1409 | + * Returns a CredentialsManager instance |
|
1410 | + * |
|
1411 | + * @return \OCP\Security\ICredentialsManager |
|
1412 | + */ |
|
1413 | + public function getCredentialsManager() { |
|
1414 | + return $this->query('CredentialsManager'); |
|
1415 | + } |
|
1416 | + |
|
1417 | + /** |
|
1418 | + * Returns an instance of the HTTP helper class |
|
1419 | + * |
|
1420 | + * @deprecated Use getHTTPClientService() |
|
1421 | + * @return \OC\HTTPHelper |
|
1422 | + */ |
|
1423 | + public function getHTTPHelper() { |
|
1424 | + return $this->query('HTTPHelper'); |
|
1425 | + } |
|
1426 | + |
|
1427 | + /** |
|
1428 | + * Get the certificate manager for the user |
|
1429 | + * |
|
1430 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1431 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1432 | + */ |
|
1433 | + public function getCertificateManager($userId = '') { |
|
1434 | + if ($userId === '') { |
|
1435 | + $userSession = $this->getUserSession(); |
|
1436 | + $user = $userSession->getUser(); |
|
1437 | + if (is_null($user)) { |
|
1438 | + return null; |
|
1439 | + } |
|
1440 | + $userId = $user->getUID(); |
|
1441 | + } |
|
1442 | + return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1443 | + } |
|
1444 | + |
|
1445 | + /** |
|
1446 | + * Returns an instance of the HTTP client service |
|
1447 | + * |
|
1448 | + * @return \OCP\Http\Client\IClientService |
|
1449 | + */ |
|
1450 | + public function getHTTPClientService() { |
|
1451 | + return $this->query('HttpClientService'); |
|
1452 | + } |
|
1453 | + |
|
1454 | + /** |
|
1455 | + * Create a new event source |
|
1456 | + * |
|
1457 | + * @return \OCP\IEventSource |
|
1458 | + */ |
|
1459 | + public function createEventSource() { |
|
1460 | + return new \OC_EventSource(); |
|
1461 | + } |
|
1462 | + |
|
1463 | + /** |
|
1464 | + * Get the active event logger |
|
1465 | + * |
|
1466 | + * The returned logger only logs data when debug mode is enabled |
|
1467 | + * |
|
1468 | + * @return \OCP\Diagnostics\IEventLogger |
|
1469 | + */ |
|
1470 | + public function getEventLogger() { |
|
1471 | + return $this->query('EventLogger'); |
|
1472 | + } |
|
1473 | + |
|
1474 | + /** |
|
1475 | + * Get the active query logger |
|
1476 | + * |
|
1477 | + * The returned logger only logs data when debug mode is enabled |
|
1478 | + * |
|
1479 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1480 | + */ |
|
1481 | + public function getQueryLogger() { |
|
1482 | + return $this->query('QueryLogger'); |
|
1483 | + } |
|
1484 | + |
|
1485 | + /** |
|
1486 | + * Get the manager for temporary files and folders |
|
1487 | + * |
|
1488 | + * @return \OCP\ITempManager |
|
1489 | + */ |
|
1490 | + public function getTempManager() { |
|
1491 | + return $this->query('TempManager'); |
|
1492 | + } |
|
1493 | + |
|
1494 | + /** |
|
1495 | + * Get the app manager |
|
1496 | + * |
|
1497 | + * @return \OCP\App\IAppManager |
|
1498 | + */ |
|
1499 | + public function getAppManager() { |
|
1500 | + return $this->query('AppManager'); |
|
1501 | + } |
|
1502 | + |
|
1503 | + /** |
|
1504 | + * Creates a new mailer |
|
1505 | + * |
|
1506 | + * @return \OCP\Mail\IMailer |
|
1507 | + */ |
|
1508 | + public function getMailer() { |
|
1509 | + return $this->query('Mailer'); |
|
1510 | + } |
|
1511 | + |
|
1512 | + /** |
|
1513 | + * Get the webroot |
|
1514 | + * |
|
1515 | + * @return string |
|
1516 | + */ |
|
1517 | + public function getWebRoot() { |
|
1518 | + return $this->webRoot; |
|
1519 | + } |
|
1520 | + |
|
1521 | + /** |
|
1522 | + * @return \OC\OCSClient |
|
1523 | + */ |
|
1524 | + public function getOcsClient() { |
|
1525 | + return $this->query('OcsClient'); |
|
1526 | + } |
|
1527 | + |
|
1528 | + /** |
|
1529 | + * @return \OCP\IDateTimeZone |
|
1530 | + */ |
|
1531 | + public function getDateTimeZone() { |
|
1532 | + return $this->query('DateTimeZone'); |
|
1533 | + } |
|
1534 | + |
|
1535 | + /** |
|
1536 | + * @return \OCP\IDateTimeFormatter |
|
1537 | + */ |
|
1538 | + public function getDateTimeFormatter() { |
|
1539 | + return $this->query('DateTimeFormatter'); |
|
1540 | + } |
|
1541 | + |
|
1542 | + /** |
|
1543 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1544 | + */ |
|
1545 | + public function getMountProviderCollection() { |
|
1546 | + return $this->query('MountConfigManager'); |
|
1547 | + } |
|
1548 | + |
|
1549 | + /** |
|
1550 | + * Get the IniWrapper |
|
1551 | + * |
|
1552 | + * @return IniGetWrapper |
|
1553 | + */ |
|
1554 | + public function getIniWrapper() { |
|
1555 | + return $this->query('IniWrapper'); |
|
1556 | + } |
|
1557 | + |
|
1558 | + /** |
|
1559 | + * @return \OCP\Command\IBus |
|
1560 | + */ |
|
1561 | + public function getCommandBus() { |
|
1562 | + return $this->query('AsyncCommandBus'); |
|
1563 | + } |
|
1564 | + |
|
1565 | + /** |
|
1566 | + * Get the trusted domain helper |
|
1567 | + * |
|
1568 | + * @return TrustedDomainHelper |
|
1569 | + */ |
|
1570 | + public function getTrustedDomainHelper() { |
|
1571 | + return $this->query('TrustedDomainHelper'); |
|
1572 | + } |
|
1573 | + |
|
1574 | + /** |
|
1575 | + * Get the locking provider |
|
1576 | + * |
|
1577 | + * @return \OCP\Lock\ILockingProvider |
|
1578 | + * @since 8.1.0 |
|
1579 | + */ |
|
1580 | + public function getLockingProvider() { |
|
1581 | + return $this->query('LockingProvider'); |
|
1582 | + } |
|
1583 | + |
|
1584 | + /** |
|
1585 | + * @return \OCP\Files\Mount\IMountManager |
|
1586 | + **/ |
|
1587 | + function getMountManager() { |
|
1588 | + return $this->query('MountManager'); |
|
1589 | + } |
|
1590 | + |
|
1591 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1592 | + function getUserMountCache() { |
|
1593 | + return $this->query('UserMountCache'); |
|
1594 | + } |
|
1595 | + |
|
1596 | + /** |
|
1597 | + * Get the MimeTypeDetector |
|
1598 | + * |
|
1599 | + * @return \OCP\Files\IMimeTypeDetector |
|
1600 | + */ |
|
1601 | + public function getMimeTypeDetector() { |
|
1602 | + return $this->query('MimeTypeDetector'); |
|
1603 | + } |
|
1604 | + |
|
1605 | + /** |
|
1606 | + * Get the MimeTypeLoader |
|
1607 | + * |
|
1608 | + * @return \OCP\Files\IMimeTypeLoader |
|
1609 | + */ |
|
1610 | + public function getMimeTypeLoader() { |
|
1611 | + return $this->query('MimeTypeLoader'); |
|
1612 | + } |
|
1613 | + |
|
1614 | + /** |
|
1615 | + * Get the manager of all the capabilities |
|
1616 | + * |
|
1617 | + * @return \OC\CapabilitiesManager |
|
1618 | + */ |
|
1619 | + public function getCapabilitiesManager() { |
|
1620 | + return $this->query('CapabilitiesManager'); |
|
1621 | + } |
|
1622 | + |
|
1623 | + /** |
|
1624 | + * Get the EventDispatcher |
|
1625 | + * |
|
1626 | + * @return EventDispatcherInterface |
|
1627 | + * @since 8.2.0 |
|
1628 | + */ |
|
1629 | + public function getEventDispatcher() { |
|
1630 | + return $this->query('EventDispatcher'); |
|
1631 | + } |
|
1632 | + |
|
1633 | + /** |
|
1634 | + * Get the Notification Manager |
|
1635 | + * |
|
1636 | + * @return \OCP\Notification\IManager |
|
1637 | + * @since 8.2.0 |
|
1638 | + */ |
|
1639 | + public function getNotificationManager() { |
|
1640 | + return $this->query('NotificationManager'); |
|
1641 | + } |
|
1642 | + |
|
1643 | + /** |
|
1644 | + * @return \OCP\Comments\ICommentsManager |
|
1645 | + */ |
|
1646 | + public function getCommentsManager() { |
|
1647 | + return $this->query('CommentsManager'); |
|
1648 | + } |
|
1649 | + |
|
1650 | + /** |
|
1651 | + * @return \OCA\Theming\ThemingDefaults |
|
1652 | + */ |
|
1653 | + public function getThemingDefaults() { |
|
1654 | + return $this->query('ThemingDefaults'); |
|
1655 | + } |
|
1656 | + |
|
1657 | + /** |
|
1658 | + * @return \OC\IntegrityCheck\Checker |
|
1659 | + */ |
|
1660 | + public function getIntegrityCodeChecker() { |
|
1661 | + return $this->query('IntegrityCodeChecker'); |
|
1662 | + } |
|
1663 | + |
|
1664 | + /** |
|
1665 | + * @return \OC\Session\CryptoWrapper |
|
1666 | + */ |
|
1667 | + public function getSessionCryptoWrapper() { |
|
1668 | + return $this->query('CryptoWrapper'); |
|
1669 | + } |
|
1670 | + |
|
1671 | + /** |
|
1672 | + * @return CsrfTokenManager |
|
1673 | + */ |
|
1674 | + public function getCsrfTokenManager() { |
|
1675 | + return $this->query('CsrfTokenManager'); |
|
1676 | + } |
|
1677 | + |
|
1678 | + /** |
|
1679 | + * @return Throttler |
|
1680 | + */ |
|
1681 | + public function getBruteForceThrottler() { |
|
1682 | + return $this->query('Throttler'); |
|
1683 | + } |
|
1684 | + |
|
1685 | + /** |
|
1686 | + * @return IContentSecurityPolicyManager |
|
1687 | + */ |
|
1688 | + public function getContentSecurityPolicyManager() { |
|
1689 | + return $this->query('ContentSecurityPolicyManager'); |
|
1690 | + } |
|
1691 | + |
|
1692 | + /** |
|
1693 | + * @return ContentSecurityPolicyNonceManager |
|
1694 | + */ |
|
1695 | + public function getContentSecurityPolicyNonceManager() { |
|
1696 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1697 | + } |
|
1698 | + |
|
1699 | + /** |
|
1700 | + * Not a public API as of 8.2, wait for 9.0 |
|
1701 | + * |
|
1702 | + * @return \OCA\Files_External\Service\BackendService |
|
1703 | + */ |
|
1704 | + public function getStoragesBackendService() { |
|
1705 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1706 | + } |
|
1707 | + |
|
1708 | + /** |
|
1709 | + * Not a public API as of 8.2, wait for 9.0 |
|
1710 | + * |
|
1711 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1712 | + */ |
|
1713 | + public function getGlobalStoragesService() { |
|
1714 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1715 | + } |
|
1716 | + |
|
1717 | + /** |
|
1718 | + * Not a public API as of 8.2, wait for 9.0 |
|
1719 | + * |
|
1720 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1721 | + */ |
|
1722 | + public function getUserGlobalStoragesService() { |
|
1723 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1724 | + } |
|
1725 | + |
|
1726 | + /** |
|
1727 | + * Not a public API as of 8.2, wait for 9.0 |
|
1728 | + * |
|
1729 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1730 | + */ |
|
1731 | + public function getUserStoragesService() { |
|
1732 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1733 | + } |
|
1734 | + |
|
1735 | + /** |
|
1736 | + * @return \OCP\Share\IManager |
|
1737 | + */ |
|
1738 | + public function getShareManager() { |
|
1739 | + return $this->query('ShareManager'); |
|
1740 | + } |
|
1741 | + |
|
1742 | + /** |
|
1743 | + * Returns the LDAP Provider |
|
1744 | + * |
|
1745 | + * @return \OCP\LDAP\ILDAPProvider |
|
1746 | + */ |
|
1747 | + public function getLDAPProvider() { |
|
1748 | + return $this->query('LDAPProvider'); |
|
1749 | + } |
|
1750 | + |
|
1751 | + /** |
|
1752 | + * @return \OCP\Settings\IManager |
|
1753 | + */ |
|
1754 | + public function getSettingsManager() { |
|
1755 | + return $this->query('SettingsManager'); |
|
1756 | + } |
|
1757 | + |
|
1758 | + /** |
|
1759 | + * @return \OCP\Files\IAppData |
|
1760 | + */ |
|
1761 | + public function getAppDataDir($app) { |
|
1762 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1763 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1764 | + return $factory->get($app); |
|
1765 | + } |
|
1766 | + |
|
1767 | + /** |
|
1768 | + * @return \OCP\Lockdown\ILockdownManager |
|
1769 | + */ |
|
1770 | + public function getLockdownManager() { |
|
1771 | + return $this->query('LockdownManager'); |
|
1772 | + } |
|
1773 | + |
|
1774 | + /** |
|
1775 | + * @return \OCP\Federation\ICloudIdManager |
|
1776 | + */ |
|
1777 | + public function getCloudIdManager() { |
|
1778 | + return $this->query(ICloudIdManager::class); |
|
1779 | + } |
|
1780 | 1780 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | |
150 | 150 | |
151 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
151 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
152 | 152 | return new PreviewManager( |
153 | 153 | $c->getConfig(), |
154 | 154 | $c->getRootFolder(), |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | }); |
160 | 160 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
161 | 161 | |
162 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
162 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
163 | 163 | return new \OC\Preview\Watcher( |
164 | 164 | $c->getAppDataDir('preview') |
165 | 165 | ); |
166 | 166 | }); |
167 | 167 | |
168 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
168 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
169 | 169 | $view = new View(); |
170 | 170 | $util = new Encryption\Util( |
171 | 171 | $view, |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | ); |
184 | 184 | }); |
185 | 185 | |
186 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
186 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
187 | 187 | $util = new Encryption\Util( |
188 | 188 | new View(), |
189 | 189 | $c->getUserManager(), |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | ); |
198 | 198 | }); |
199 | 199 | |
200 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
200 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
201 | 201 | $view = new View(); |
202 | 202 | $util = new Encryption\Util( |
203 | 203 | $view, |
@@ -208,32 +208,32 @@ discard block |
||
208 | 208 | |
209 | 209 | return new Encryption\Keys\Storage($view, $util); |
210 | 210 | }); |
211 | - $this->registerService('TagMapper', function (Server $c) { |
|
211 | + $this->registerService('TagMapper', function(Server $c) { |
|
212 | 212 | return new TagMapper($c->getDatabaseConnection()); |
213 | 213 | }); |
214 | 214 | |
215 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
215 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
216 | 216 | $tagMapper = $c->query('TagMapper'); |
217 | 217 | return new TagManager($tagMapper, $c->getUserSession()); |
218 | 218 | }); |
219 | 219 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
220 | 220 | |
221 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
221 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
222 | 222 | $config = $c->getConfig(); |
223 | 223 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
224 | 224 | /** @var \OC\SystemTag\ManagerFactory $factory */ |
225 | 225 | $factory = new $factoryClass($this); |
226 | 226 | return $factory; |
227 | 227 | }); |
228 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
228 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
229 | 229 | return $c->query('SystemTagManagerFactory')->getManager(); |
230 | 230 | }); |
231 | 231 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
232 | 232 | |
233 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
233 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
234 | 234 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
235 | 235 | }); |
236 | - $this->registerService('RootFolder', function (Server $c) { |
|
236 | + $this->registerService('RootFolder', function(Server $c) { |
|
237 | 237 | $manager = \OC\Files\Filesystem::getMountManager(null); |
238 | 238 | $view = new View(); |
239 | 239 | $root = new Root( |
@@ -261,30 +261,30 @@ discard block |
||
261 | 261 | }); |
262 | 262 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
263 | 263 | |
264 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
264 | + $this->registerService(\OCP\IUserManager::class, function(Server $c) { |
|
265 | 265 | $config = $c->getConfig(); |
266 | 266 | return new \OC\User\Manager($config); |
267 | 267 | }); |
268 | 268 | $this->registerAlias('UserManager', \OCP\IUserManager::class); |
269 | 269 | |
270 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
270 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
271 | 271 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
272 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
272 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
273 | 273 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
274 | 274 | }); |
275 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
275 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
276 | 276 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
277 | 277 | }); |
278 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
278 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
279 | 279 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
280 | 280 | }); |
281 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
281 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
282 | 282 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
283 | 283 | }); |
284 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
284 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
285 | 285 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
286 | 286 | }); |
287 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
287 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
288 | 288 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
289 | 289 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
290 | 290 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -304,11 +304,11 @@ discard block |
||
304 | 304 | return new Store($session, $logger, $tokenProvider); |
305 | 305 | }); |
306 | 306 | $this->registerAlias(IStore::class, Store::class); |
307 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
307 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) { |
|
308 | 308 | $dbConnection = $c->getDatabaseConnection(); |
309 | 309 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
310 | 310 | }); |
311 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
311 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) { |
|
312 | 312 | $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
313 | 313 | $crypto = $c->getCrypto(); |
314 | 314 | $config = $c->getConfig(); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | }); |
319 | 319 | $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
320 | 320 | |
321 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
321 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
322 | 322 | $manager = $c->getUserManager(); |
323 | 323 | $session = new \OC\Session\Memory(''); |
324 | 324 | $timeFactory = new TimeFactory(); |
@@ -331,40 +331,40 @@ discard block |
||
331 | 331 | } |
332 | 332 | |
333 | 333 | $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
334 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
334 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
335 | 335 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
336 | 336 | }); |
337 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
337 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
338 | 338 | /** @var $user \OC\User\User */ |
339 | 339 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
340 | 340 | }); |
341 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
341 | + $userSession->listen('\OC\User', 'preDelete', function($user) { |
|
342 | 342 | /** @var $user \OC\User\User */ |
343 | 343 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
344 | 344 | }); |
345 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
345 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
346 | 346 | /** @var $user \OC\User\User */ |
347 | 347 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
348 | 348 | }); |
349 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
349 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
350 | 350 | /** @var $user \OC\User\User */ |
351 | 351 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
352 | 352 | }); |
353 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
353 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
354 | 354 | /** @var $user \OC\User\User */ |
355 | 355 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
356 | 356 | }); |
357 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
357 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
358 | 358 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
359 | 359 | }); |
360 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
360 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
361 | 361 | /** @var $user \OC\User\User */ |
362 | 362 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
363 | 363 | }); |
364 | - $userSession->listen('\OC\User', 'logout', function () { |
|
364 | + $userSession->listen('\OC\User', 'logout', function() { |
|
365 | 365 | \OC_Hook::emit('OC_User', 'logout', array()); |
366 | 366 | }); |
367 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
367 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) { |
|
368 | 368 | /** @var $user \OC\User\User */ |
369 | 369 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
370 | 370 | }); |
@@ -372,14 +372,14 @@ discard block |
||
372 | 372 | }); |
373 | 373 | $this->registerAlias('UserSession', \OCP\IUserSession::class); |
374 | 374 | |
375 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
375 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
376 | 376 | return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
377 | 377 | }); |
378 | 378 | |
379 | 379 | $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
380 | 380 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
381 | 381 | |
382 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
382 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
383 | 383 | return new \OC\AllConfig( |
384 | 384 | $c->getSystemConfig() |
385 | 385 | ); |
@@ -387,17 +387,17 @@ discard block |
||
387 | 387 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
388 | 388 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
389 | 389 | |
390 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
390 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
391 | 391 | return new \OC\SystemConfig($config); |
392 | 392 | }); |
393 | 393 | |
394 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
394 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
395 | 395 | return new \OC\AppConfig($c->getDatabaseConnection()); |
396 | 396 | }); |
397 | 397 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
398 | 398 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
399 | 399 | |
400 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
400 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
401 | 401 | return new \OC\L10N\Factory( |
402 | 402 | $c->getConfig(), |
403 | 403 | $c->getRequest(), |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | }); |
408 | 408 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
409 | 409 | |
410 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
410 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
411 | 411 | $config = $c->getConfig(); |
412 | 412 | $cacheFactory = $c->getMemCacheFactory(); |
413 | 413 | return new \OC\URLGenerator( |
@@ -417,10 +417,10 @@ discard block |
||
417 | 417 | }); |
418 | 418 | $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
419 | 419 | |
420 | - $this->registerService('AppHelper', function ($c) { |
|
420 | + $this->registerService('AppHelper', function($c) { |
|
421 | 421 | return new \OC\AppHelper(); |
422 | 422 | }); |
423 | - $this->registerService('AppFetcher', function ($c) { |
|
423 | + $this->registerService('AppFetcher', function($c) { |
|
424 | 424 | return new AppFetcher( |
425 | 425 | $this->getAppDataDir('appstore'), |
426 | 426 | $this->getHTTPClientService(), |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | $this->getConfig() |
429 | 429 | ); |
430 | 430 | }); |
431 | - $this->registerService('CategoryFetcher', function ($c) { |
|
431 | + $this->registerService('CategoryFetcher', function($c) { |
|
432 | 432 | return new CategoryFetcher( |
433 | 433 | $this->getAppDataDir('appstore'), |
434 | 434 | $this->getHTTPClientService(), |
@@ -437,21 +437,21 @@ discard block |
||
437 | 437 | ); |
438 | 438 | }); |
439 | 439 | |
440 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
440 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
441 | 441 | return new Cache\File(); |
442 | 442 | }); |
443 | 443 | $this->registerAlias('UserCache', \OCP\ICache::class); |
444 | 444 | |
445 | - $this->registerService(Factory::class, function (Server $c) { |
|
445 | + $this->registerService(Factory::class, function(Server $c) { |
|
446 | 446 | $config = $c->getConfig(); |
447 | 447 | |
448 | 448 | if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
449 | 449 | $v = \OC_App::getAppVersions(); |
450 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
450 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT.'/version.php')); |
|
451 | 451 | $version = implode(',', $v); |
452 | 452 | $instanceId = \OC_Util::getInstanceId(); |
453 | 453 | $path = \OC::$SERVERROOT; |
454 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
454 | + $prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.\OC::$WEBROOT); |
|
455 | 455 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
456 | 456 | $config->getSystemValue('memcache.local', null), |
457 | 457 | $config->getSystemValue('memcache.distributed', null), |
@@ -468,12 +468,12 @@ discard block |
||
468 | 468 | $this->registerAlias('MemCacheFactory', Factory::class); |
469 | 469 | $this->registerAlias(ICacheFactory::class, Factory::class); |
470 | 470 | |
471 | - $this->registerService('RedisFactory', function (Server $c) { |
|
471 | + $this->registerService('RedisFactory', function(Server $c) { |
|
472 | 472 | $systemConfig = $c->getSystemConfig(); |
473 | 473 | return new RedisFactory($systemConfig); |
474 | 474 | }); |
475 | 475 | |
476 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
476 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
477 | 477 | return new \OC\Activity\Manager( |
478 | 478 | $c->getRequest(), |
479 | 479 | $c->getUserSession(), |
@@ -483,14 +483,14 @@ discard block |
||
483 | 483 | }); |
484 | 484 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
485 | 485 | |
486 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
486 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
487 | 487 | return new \OC\Activity\EventMerger( |
488 | 488 | $c->getL10N('lib') |
489 | 489 | ); |
490 | 490 | }); |
491 | 491 | $this->registerAlias(IValidator::class, Validator::class); |
492 | 492 | |
493 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
493 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
494 | 494 | return new AvatarManager( |
495 | 495 | $c->getUserManager(), |
496 | 496 | $c->getAppDataDir('avatar'), |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | }); |
502 | 502 | $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
503 | 503 | |
504 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
504 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
505 | 505 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
506 | 506 | $logger = Log::getLogClass($logType); |
507 | 507 | call_user_func(array($logger, 'init')); |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | }); |
511 | 511 | $this->registerAlias('Logger', \OCP\ILogger::class); |
512 | 512 | |
513 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
513 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
514 | 514 | $config = $c->getConfig(); |
515 | 515 | return new \OC\BackgroundJob\JobList( |
516 | 516 | $c->getDatabaseConnection(), |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | }); |
521 | 521 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
522 | 522 | |
523 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
523 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
524 | 524 | $cacheFactory = $c->getMemCacheFactory(); |
525 | 525 | $logger = $c->getLogger(); |
526 | 526 | if ($cacheFactory->isAvailable()) { |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | }); |
533 | 533 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
534 | 534 | |
535 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
535 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
536 | 536 | return new Search(); |
537 | 537 | }); |
538 | 538 | $this->registerAlias('Search', \OCP\ISearch::class); |
@@ -552,27 +552,27 @@ discard block |
||
552 | 552 | ); |
553 | 553 | }); |
554 | 554 | |
555 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
555 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
556 | 556 | return new SecureRandom(); |
557 | 557 | }); |
558 | 558 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
559 | 559 | |
560 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
560 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
561 | 561 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
562 | 562 | }); |
563 | 563 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
564 | 564 | |
565 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
565 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
566 | 566 | return new Hasher($c->getConfig()); |
567 | 567 | }); |
568 | 568 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
569 | 569 | |
570 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
570 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
571 | 571 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
572 | 572 | }); |
573 | 573 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
574 | 574 | |
575 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
575 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
576 | 576 | $systemConfig = $c->getSystemConfig(); |
577 | 577 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
578 | 578 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | }); |
587 | 587 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
588 | 588 | |
589 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
589 | + $this->registerService('HTTPHelper', function(Server $c) { |
|
590 | 590 | $config = $c->getConfig(); |
591 | 591 | return new HTTPHelper( |
592 | 592 | $config, |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | ); |
595 | 595 | }); |
596 | 596 | |
597 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
597 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
598 | 598 | $user = \OC_User::getUser(); |
599 | 599 | $uid = $user ? $user : null; |
600 | 600 | return new ClientService( |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | }); |
605 | 605 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
606 | 606 | |
607 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
607 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
608 | 608 | if ($c->getSystemConfig()->getValue('debug', false)) { |
609 | 609 | return new EventLogger(); |
610 | 610 | } else { |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | }); |
614 | 614 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
615 | 615 | |
616 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
616 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
617 | 617 | if ($c->getSystemConfig()->getValue('debug', false)) { |
618 | 618 | return new QueryLogger(); |
619 | 619 | } else { |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | }); |
623 | 623 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
624 | 624 | |
625 | - $this->registerService(TempManager::class, function (Server $c) { |
|
625 | + $this->registerService(TempManager::class, function(Server $c) { |
|
626 | 626 | return new TempManager( |
627 | 627 | $c->getLogger(), |
628 | 628 | $c->getConfig() |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | $this->registerAlias('TempManager', TempManager::class); |
632 | 632 | $this->registerAlias(ITempManager::class, TempManager::class); |
633 | 633 | |
634 | - $this->registerService(AppManager::class, function (Server $c) { |
|
634 | + $this->registerService(AppManager::class, function(Server $c) { |
|
635 | 635 | return new \OC\App\AppManager( |
636 | 636 | $c->getUserSession(), |
637 | 637 | $c->getAppConfig(), |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | $this->registerAlias('AppManager', AppManager::class); |
644 | 644 | $this->registerAlias(IAppManager::class, AppManager::class); |
645 | 645 | |
646 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
646 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
647 | 647 | return new DateTimeZone( |
648 | 648 | $c->getConfig(), |
649 | 649 | $c->getSession() |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | }); |
652 | 652 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
653 | 653 | |
654 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
654 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
655 | 655 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
656 | 656 | |
657 | 657 | return new DateTimeFormatter( |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | }); |
662 | 662 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
663 | 663 | |
664 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
664 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
665 | 665 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
666 | 666 | $listener = new UserMountCacheListener($mountCache); |
667 | 667 | $listener->listen($c->getUserManager()); |
@@ -669,10 +669,10 @@ discard block |
||
669 | 669 | }); |
670 | 670 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
671 | 671 | |
672 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
672 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
673 | 673 | $loader = \OC\Files\Filesystem::getLoader(); |
674 | 674 | $mountCache = $c->query('UserMountCache'); |
675 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
675 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
676 | 676 | |
677 | 677 | // builtin providers |
678 | 678 | |
@@ -685,14 +685,14 @@ discard block |
||
685 | 685 | }); |
686 | 686 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
687 | 687 | |
688 | - $this->registerService('IniWrapper', function ($c) { |
|
688 | + $this->registerService('IniWrapper', function($c) { |
|
689 | 689 | return new IniGetWrapper(); |
690 | 690 | }); |
691 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
691 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
692 | 692 | $jobList = $c->getJobList(); |
693 | 693 | return new AsyncBus($jobList); |
694 | 694 | }); |
695 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
695 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
696 | 696 | return new TrustedDomainHelper($this->getConfig()); |
697 | 697 | }); |
698 | 698 | $this->registerService('Throttler', function(Server $c) { |
@@ -703,10 +703,10 @@ discard block |
||
703 | 703 | $c->getConfig() |
704 | 704 | ); |
705 | 705 | }); |
706 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
706 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
707 | 707 | // IConfig and IAppManager requires a working database. This code |
708 | 708 | // might however be called when ownCloud is not yet setup. |
709 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
709 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
710 | 710 | $config = $c->getConfig(); |
711 | 711 | $appManager = $c->getAppManager(); |
712 | 712 | } else { |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | $c->getTempManager() |
725 | 725 | ); |
726 | 726 | }); |
727 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
727 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
728 | 728 | if (isset($this['urlParams'])) { |
729 | 729 | $urlParams = $this['urlParams']; |
730 | 730 | } else { |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | }); |
761 | 761 | $this->registerAlias('Request', \OCP\IRequest::class); |
762 | 762 | |
763 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
763 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
764 | 764 | return new Mailer( |
765 | 765 | $c->getConfig(), |
766 | 766 | $c->getLogger(), |
@@ -774,14 +774,14 @@ discard block |
||
774 | 774 | $this->registerService('LDAPProvider', function(Server $c) { |
775 | 775 | $config = $c->getConfig(); |
776 | 776 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
777 | - if(is_null($factoryClass)) { |
|
777 | + if (is_null($factoryClass)) { |
|
778 | 778 | throw new \Exception('ldapProviderFactory not set'); |
779 | 779 | } |
780 | 780 | /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
781 | 781 | $factory = new $factoryClass($this); |
782 | 782 | return $factory->getLDAPProvider(); |
783 | 783 | }); |
784 | - $this->registerService('LockingProvider', function (Server $c) { |
|
784 | + $this->registerService('LockingProvider', function(Server $c) { |
|
785 | 785 | $ini = $c->getIniWrapper(); |
786 | 786 | $config = $c->getConfig(); |
787 | 787 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -797,42 +797,42 @@ discard block |
||
797 | 797 | return new NoopLockingProvider(); |
798 | 798 | }); |
799 | 799 | |
800 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
800 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
801 | 801 | return new \OC\Files\Mount\Manager(); |
802 | 802 | }); |
803 | 803 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
804 | 804 | |
805 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
805 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
806 | 806 | return new \OC\Files\Type\Detection( |
807 | 807 | $c->getURLGenerator(), |
808 | 808 | \OC::$configDir, |
809 | - \OC::$SERVERROOT . '/resources/config/' |
|
809 | + \OC::$SERVERROOT.'/resources/config/' |
|
810 | 810 | ); |
811 | 811 | }); |
812 | 812 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
813 | 813 | |
814 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
814 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
815 | 815 | return new \OC\Files\Type\Loader( |
816 | 816 | $c->getDatabaseConnection() |
817 | 817 | ); |
818 | 818 | }); |
819 | 819 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
820 | - $this->registerService(BundleFetcher::class, function () { |
|
820 | + $this->registerService(BundleFetcher::class, function() { |
|
821 | 821 | return new BundleFetcher($this->getL10N('lib')); |
822 | 822 | }); |
823 | 823 | $this->registerService(AppFetcher::class, function() { |
824 | 824 | return $this->getAppFetcher(); |
825 | 825 | }); |
826 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
826 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
827 | 827 | return new Manager( |
828 | 828 | $c->query(IValidator::class) |
829 | 829 | ); |
830 | 830 | }); |
831 | 831 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
832 | 832 | |
833 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
833 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
834 | 834 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
835 | - $manager->registerCapability(function () use ($c) { |
|
835 | + $manager->registerCapability(function() use ($c) { |
|
836 | 836 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
837 | 837 | }); |
838 | 838 | return $manager; |
@@ -888,13 +888,13 @@ discard block |
||
888 | 888 | $cacheFactory->createLocal('SCSS') |
889 | 889 | ); |
890 | 890 | }); |
891 | - $this->registerService(EventDispatcher::class, function () { |
|
891 | + $this->registerService(EventDispatcher::class, function() { |
|
892 | 892 | return new EventDispatcher(); |
893 | 893 | }); |
894 | 894 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
895 | 895 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
896 | 896 | |
897 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
897 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
898 | 898 | // FIXME: Instantiiated here due to cyclic dependency |
899 | 899 | $request = new Request( |
900 | 900 | [ |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | $request |
920 | 920 | ); |
921 | 921 | }); |
922 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
922 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
923 | 923 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
924 | 924 | |
925 | 925 | return new CsrfTokenManager( |
@@ -927,10 +927,10 @@ discard block |
||
927 | 927 | $c->query(SessionStorage::class) |
928 | 928 | ); |
929 | 929 | }); |
930 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
930 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
931 | 931 | return new SessionStorage($c->getSession()); |
932 | 932 | }); |
933 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
933 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
934 | 934 | return new ContentSecurityPolicyManager(); |
935 | 935 | }); |
936 | 936 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
@@ -981,29 +981,29 @@ discard block |
||
981 | 981 | ); |
982 | 982 | return $manager; |
983 | 983 | }); |
984 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
984 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
985 | 985 | return new \OC\Files\AppData\Factory( |
986 | 986 | $c->getRootFolder(), |
987 | 987 | $c->getSystemConfig() |
988 | 988 | ); |
989 | 989 | }); |
990 | 990 | |
991 | - $this->registerService('LockdownManager', function (Server $c) { |
|
991 | + $this->registerService('LockdownManager', function(Server $c) { |
|
992 | 992 | return new LockdownManager(function() use ($c) { |
993 | 993 | return $c->getSession(); |
994 | 994 | }); |
995 | 995 | }); |
996 | 996 | |
997 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
997 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) { |
|
998 | 998 | return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
999 | 999 | }); |
1000 | 1000 | |
1001 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1001 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
1002 | 1002 | return new CloudIdManager(); |
1003 | 1003 | }); |
1004 | 1004 | |
1005 | 1005 | /* To trick DI since we don't extend the DIContainer here */ |
1006 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
1006 | + $this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) { |
|
1007 | 1007 | return new CleanPreviewsBackgroundJob( |
1008 | 1008 | $c->getRootFolder(), |
1009 | 1009 | $c->getLogger(), |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
1019 | 1019 | $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
1020 | 1020 | |
1021 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1021 | + $this->registerService(Defaults::class, function(Server $c) { |
|
1022 | 1022 | return new Defaults( |
1023 | 1023 | $c->getThemingDefaults() |
1024 | 1024 | ); |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | * @deprecated since 9.2.0 use IAppData |
1171 | 1171 | */ |
1172 | 1172 | public function getAppFolder() { |
1173 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1173 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
1174 | 1174 | $root = $this->getRootFolder(); |
1175 | 1175 | if (!$root->nodeExists($dir)) { |
1176 | 1176 | $folder = $root->newFolder($dir); |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | </li> |
23 | 23 | {{/each}} |
24 | 24 | |
25 | -<?php if($_['appstoreEnabled']): ?> |
|
25 | +<?php if ($_['appstoreEnabled']): ?> |
|
26 | 26 | <li> |
27 | - <a class="app-external" target="_blank" rel="noreferrer" href="https://docs.nextcloud.org/server/12/developer_manual/"><?php p($l->t('Developer documentation'));?> ↗</a> |
|
27 | + <a class="app-external" target="_blank" rel="noreferrer" href="https://docs.nextcloud.org/server/12/developer_manual/"><?php p($l->t('Developer documentation')); ?> ↗</a> |
|
28 | 28 | </li> |
29 | 29 | <?php endif; ?> |
30 | 30 | </script> |
31 | 31 | |
32 | 32 | <script id="app-template-installed" type="text/x-handlebars"> |
33 | 33 | {{#if newCategory}} |
34 | -<h2>{{categoryName}} <input class="enable" type="submit" data-bundleid="{{bundleId}}" data-active="true" value="<?php p($l->t('Enable all'));?>"/></h2> |
|
34 | +<h2>{{categoryName}} <input class="enable" type="submit" data-bundleid="{{bundleId}}" data-active="true" value="<?php p($l->t('Enable all')); ?>"/></h2> |
|
35 | 35 | {{/if}} |
36 | 36 | <div class="section" id="app-{{id}}"> |
37 | 37 | <div class="app-image app-image-icon"></div> |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | </div> |
45 | 45 | <div class="app-version">{{version}}</div> |
46 | 46 | <div class="app-level"> |
47 | - {{{level}}}{{#unless internal}}<a href="https://apps.nextcloud.com/apps/{{id}}"><?php p($l->t('View in store'));?> ↗</a>{{/unless}} |
|
47 | + {{{level}}}{{#unless internal}}<a href="https://apps.nextcloud.com/apps/{{id}}"><?php p($l->t('View in store')); ?> ↗</a>{{/unless}} |
|
48 | 48 | </div> |
49 | 49 | |
50 | 50 | <div class="app-groups"> |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | <input class="uninstall" type="submit" value="<?php p($l->t('Remove')); ?>" data-appid="{{id}}" /> |
68 | 68 | {{/if}} |
69 | 69 | {{#if active}} |
70 | - <input class="enable" type="submit" data-appid="{{id}}" data-active="true" value="<?php p($l->t("Disable"));?>"/> |
|
70 | + <input class="enable" type="submit" data-appid="{{id}}" data-active="true" value="<?php p($l->t("Disable")); ?>"/> |
|
71 | 71 | {{else}} |
72 | - <input class="enable{{#if needsDownload}} needs-download{{/if}}" type="submit" data-appid="{{id}}" data-active="false" {{#unless canInstall}}disabled="disabled"{{/unless}} value="<?php p($l->t("Enable"));?>"/> |
|
72 | + <input class="enable{{#if needsDownload}} needs-download{{/if}}" type="submit" data-appid="{{id}}" data-active="false" {{#unless canInstall}}disabled="disabled"{{/unless}} value="<?php p($l->t("Enable")); ?>"/> |
|
73 | 73 | {{/if}} |
74 | 74 | </div> |
75 | 75 | </div> |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | <div class="app-description-container hidden"> |
100 | 100 | <div class="app-version">{{version}}</div> |
101 | 101 | {{#if profilepage}}<a href="{{profilepage}}" target="_blank" rel="noreferrer">{{/if}} |
102 | - <div class="app-author"><?php p($l->t('by %s', ['{{author}}']));?> |
|
102 | + <div class="app-author"><?php p($l->t('by %s', ['{{author}}'])); ?> |
|
103 | 103 | {{#if licence}} |
104 | 104 | (<?php p($l->t('%s-licensed', ['{{licence}}'])); ?>) |
105 | 105 | {{/if}} |
@@ -109,37 +109,37 @@ discard block |
||
109 | 109 | <!--<div class="app-changed">{{changed}}</div>--> |
110 | 110 | {{#if documentation}} |
111 | 111 | <p class="documentation"> |
112 | - <?php p($l->t("Documentation:"));?> |
|
112 | + <?php p($l->t("Documentation:")); ?> |
|
113 | 113 | {{#if documentation.user}} |
114 | 114 | <span class="userDocumentation"> |
115 | - <a id="userDocumentation" class="appslink" href="{{documentation.user}}" target="_blank" rel="noreferrer"><?php p($l->t('User documentation'));?> ↗</a> |
|
115 | + <a id="userDocumentation" class="appslink" href="{{documentation.user}}" target="_blank" rel="noreferrer"><?php p($l->t('User documentation')); ?> ↗</a> |
|
116 | 116 | </span> |
117 | 117 | {{/if}} |
118 | 118 | |
119 | 119 | {{#if documentation.admin}} |
120 | 120 | <span class="adminDocumentation"> |
121 | - <a id="adminDocumentation" class="appslink" href="{{documentation.admin}}" target="_blank" rel="noreferrer"><?php p($l->t('Admin documentation'));?> ↗</a> |
|
121 | + <a id="adminDocumentation" class="appslink" href="{{documentation.admin}}" target="_blank" rel="noreferrer"><?php p($l->t('Admin documentation')); ?> ↗</a> |
|
122 | 122 | </span> |
123 | 123 | {{/if}} |
124 | 124 | |
125 | 125 | {{#if documentation.developer}} |
126 | 126 | <span class="developerDocumentation"> |
127 | - <a id="developerDocumentation" class="appslink" href="{{documentation.developer}}" target="_blank" rel="noreferrer"><?php p($l->t('Developer documentation'));?> ↗</a> |
|
127 | + <a id="developerDocumentation" class="appslink" href="{{documentation.developer}}" target="_blank" rel="noreferrer"><?php p($l->t('Developer documentation')); ?> ↗</a> |
|
128 | 128 | </span> |
129 | 129 | {{/if}} |
130 | 130 | </p> |
131 | 131 | {{/if}} |
132 | 132 | |
133 | 133 | {{#if website}} |
134 | - <a id="userDocumentation" class="appslink" href="{{website}}" target="_blank" rel="noreferrer"><?php p($l->t('Visit website'));?> ↗</a> |
|
134 | + <a id="userDocumentation" class="appslink" href="{{website}}" target="_blank" rel="noreferrer"><?php p($l->t('Visit website')); ?> ↗</a> |
|
135 | 135 | {{/if}} |
136 | 136 | |
137 | 137 | {{#if bugs}} |
138 | - <a id="adminDocumentation" class="appslink" href="{{bugs}}" target="_blank" rel="noreferrer"><?php p($l->t('Report a bug'));?> ↗</a> |
|
138 | + <a id="adminDocumentation" class="appslink" href="{{bugs}}" target="_blank" rel="noreferrer"><?php p($l->t('Report a bug')); ?> ↗</a> |
|
139 | 139 | {{/if}} |
140 | 140 | </div><!-- end app-description-container --> |
141 | - <div class="app-description-toggle-show" role="link"><?php p($l->t("Show description …"));?></div> |
|
142 | - <div class="app-description-toggle-hide hidden" role="link"><?php p($l->t("Hide description …"));?></div> |
|
141 | + <div class="app-description-toggle-show" role="link"><?php p($l->t("Show description …")); ?></div> |
|
142 | + <div class="app-description-toggle-hide hidden" role="link"><?php p($l->t("Hide description …")); ?></div> |
|
143 | 143 | |
144 | 144 | <div class="app-dependencies update hidden"> |
145 | 145 | <p><?php p($l->t('This app has an update available.')); ?></p> |
@@ -170,14 +170,14 @@ discard block |
||
170 | 170 | |
171 | 171 | <input class="update hidden" type="submit" value="<?php p($l->t('Update to %s', array('{{update}}'))); ?>" data-appid="{{id}}" /> |
172 | 172 | {{#if active}} |
173 | - <input class="enable" type="submit" data-appid="{{id}}" data-active="true" value="<?php p($l->t("Disable"));?>"/> |
|
173 | + <input class="enable" type="submit" data-appid="{{id}}" data-active="true" value="<?php p($l->t("Disable")); ?>"/> |
|
174 | 174 | <div class="groups-enable"> |
175 | 175 | <input type="checkbox" class="groups-enable__checkbox checkbox" id="groups_enable-{{id}}"/> |
176 | 176 | <label for="groups_enable-{{id}}"><?php p($l->t('Enable only for specific groups')); ?></label> |
177 | 177 | </div> |
178 | 178 | <input type="hidden" id="group_select" title="<?php p($l->t('All')); ?>" style="width: 200px"> |
179 | 179 | {{else}} |
180 | - <input class="enable{{#if needsDownload}} needs-download{{/if}}" type="submit" data-appid="{{id}}" data-active="false" {{#unless canInstall}}disabled="disabled"{{/unless}} value="<?php p($l->t("Enable"));?>"/> |
|
180 | + <input class="enable{{#if needsDownload}} needs-download{{/if}}" type="submit" data-appid="{{id}}" data-active="false" {{#unless canInstall}}disabled="disabled"{{/unless}} value="<?php p($l->t("Enable")); ?>"/> |
|
181 | 181 | {{/if}} |
182 | 182 | {{#if canUnInstall}} |
183 | 183 | <input class="uninstall" type="submit" value="<?php p($l->t('Remove')); ?>" data-appid="{{id}}" /> |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | </div> |
189 | 189 | </script> |
190 | 190 | |
191 | -<div id="app-navigation" class="icon-loading" data-category="<?php p($_['category']);?>"> |
|
191 | +<div id="app-navigation" class="icon-loading" data-category="<?php p($_['category']); ?>"> |
|
192 | 192 | <ul id="apps-categories"> |
193 | 193 | |
194 | 194 | </ul> |