@@ -33,30 +33,30 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | abstract class AbstractNodesEvent extends Event { |
| 35 | 35 | |
| 36 | - /** @var Node */ |
|
| 37 | - private $source; |
|
| 38 | - /** @var Node */ |
|
| 39 | - private $target; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @since 20.0.0 |
|
| 43 | - */ |
|
| 44 | - public function __construct(Node $source, Node $target) { |
|
| 45 | - $this->source = $source; |
|
| 46 | - $this->target = $target; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @since 20.0.0 |
|
| 51 | - */ |
|
| 52 | - public function getSource(): Node { |
|
| 53 | - return $this->source; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @since 20.0.0 |
|
| 58 | - */ |
|
| 59 | - public function getTarget(): Node { |
|
| 60 | - return $this->target; |
|
| 61 | - } |
|
| 36 | + /** @var Node */ |
|
| 37 | + private $source; |
|
| 38 | + /** @var Node */ |
|
| 39 | + private $target; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @since 20.0.0 |
|
| 43 | + */ |
|
| 44 | + public function __construct(Node $source, Node $target) { |
|
| 45 | + $this->source = $source; |
|
| 46 | + $this->target = $target; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @since 20.0.0 |
|
| 51 | + */ |
|
| 52 | + public function getSource(): Node { |
|
| 53 | + return $this->source; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @since 20.0.0 |
|
| 58 | + */ |
|
| 59 | + public function getTarget(): Node { |
|
| 60 | + return $this->target; |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -33,20 +33,20 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | abstract class AbstractNodeEvent extends Event { |
| 35 | 35 | |
| 36 | - /** @var Node */ |
|
| 37 | - private $node; |
|
| 36 | + /** @var Node */ |
|
| 37 | + private $node; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @since 20.0.0 |
|
| 41 | - */ |
|
| 42 | - public function __construct(Node $node) { |
|
| 43 | - $this->node = $node; |
|
| 44 | - } |
|
| 39 | + /** |
|
| 40 | + * @since 20.0.0 |
|
| 41 | + */ |
|
| 42 | + public function __construct(Node $node) { |
|
| 43 | + $this->node = $node; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @since 20.0.0 |
|
| 48 | - */ |
|
| 49 | - public function getNode(): Node { |
|
| 50 | - return $this->node; |
|
| 51 | - } |
|
| 46 | + /** |
|
| 47 | + * @since 20.0.0 |
|
| 48 | + */ |
|
| 49 | + public function getNode(): Node { |
|
| 50 | + return $this->node; |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -75,1017 +75,1017 @@ |
||
| 75 | 75 | * OC_autoload! |
| 76 | 76 | */ |
| 77 | 77 | class OC { |
| 78 | - /** |
|
| 79 | - * Associative array for autoloading. classname => filename |
|
| 80 | - */ |
|
| 81 | - public static $CLASSPATH = []; |
|
| 82 | - /** |
|
| 83 | - * The installation path for Nextcloud on the server (e.g. /srv/http/nextcloud) |
|
| 84 | - */ |
|
| 85 | - public static $SERVERROOT = ''; |
|
| 86 | - /** |
|
| 87 | - * the current request path relative to the Nextcloud root (e.g. files/index.php) |
|
| 88 | - */ |
|
| 89 | - private static $SUBURI = ''; |
|
| 90 | - /** |
|
| 91 | - * the Nextcloud root path for http requests (e.g. nextcloud/) |
|
| 92 | - */ |
|
| 93 | - public static $WEBROOT = ''; |
|
| 94 | - /** |
|
| 95 | - * The installation path array of the apps folder on the server (e.g. /srv/http/nextcloud) 'path' and |
|
| 96 | - * web path in 'url' |
|
| 97 | - */ |
|
| 98 | - public static $APPSROOTS = []; |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * @var string |
|
| 102 | - */ |
|
| 103 | - public static $configDir; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * requested app |
|
| 107 | - */ |
|
| 108 | - public static $REQUESTEDAPP = ''; |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * check if Nextcloud runs in cli mode |
|
| 112 | - */ |
|
| 113 | - public static $CLI = false; |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @var \OC\Autoloader $loader |
|
| 117 | - */ |
|
| 118 | - public static $loader = null; |
|
| 119 | - |
|
| 120 | - /** @var \Composer\Autoload\ClassLoader $composerAutoloader */ |
|
| 121 | - public static $composerAutoloader = null; |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * @var \OC\Server |
|
| 125 | - */ |
|
| 126 | - public static $server = null; |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @var \OC\Config |
|
| 130 | - */ |
|
| 131 | - private static $config = null; |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * @throws \RuntimeException when the 3rdparty directory is missing or |
|
| 135 | - * the app path list is empty or contains an invalid path |
|
| 136 | - */ |
|
| 137 | - public static function initPaths() { |
|
| 138 | - if (defined('PHPUNIT_CONFIG_DIR')) { |
|
| 139 | - self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; |
|
| 140 | - } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { |
|
| 141 | - self::$configDir = OC::$SERVERROOT . '/tests/config/'; |
|
| 142 | - } elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
| 143 | - self::$configDir = rtrim($dir, '/') . '/'; |
|
| 144 | - } else { |
|
| 145 | - self::$configDir = OC::$SERVERROOT . '/config/'; |
|
| 146 | - } |
|
| 147 | - self::$config = new \OC\Config(self::$configDir); |
|
| 148 | - |
|
| 149 | - OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT))); |
|
| 150 | - /** |
|
| 151 | - * FIXME: The following lines are required because we can't yet instantiate |
|
| 152 | - * \OC::$server->getRequest() since \OC::$server does not yet exist. |
|
| 153 | - */ |
|
| 154 | - $params = [ |
|
| 155 | - 'server' => [ |
|
| 156 | - 'SCRIPT_NAME' => $_SERVER['SCRIPT_NAME'], |
|
| 157 | - 'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME'], |
|
| 158 | - ], |
|
| 159 | - ]; |
|
| 160 | - $fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig(self::$config))); |
|
| 161 | - $scriptName = $fakeRequest->getScriptName(); |
|
| 162 | - if (substr($scriptName, -1) == '/') { |
|
| 163 | - $scriptName .= 'index.php'; |
|
| 164 | - //make sure suburi follows the same rules as scriptName |
|
| 165 | - if (substr(OC::$SUBURI, -9) != 'index.php') { |
|
| 166 | - if (substr(OC::$SUBURI, -1) != '/') { |
|
| 167 | - OC::$SUBURI = OC::$SUBURI . '/'; |
|
| 168 | - } |
|
| 169 | - OC::$SUBURI = OC::$SUBURI . 'index.php'; |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - if (OC::$CLI) { |
|
| 175 | - OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); |
|
| 176 | - } else { |
|
| 177 | - if (substr($scriptName, 0 - strlen(OC::$SUBURI)) === OC::$SUBURI) { |
|
| 178 | - OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
|
| 179 | - |
|
| 180 | - if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
|
| 181 | - OC::$WEBROOT = '/' . OC::$WEBROOT; |
|
| 182 | - } |
|
| 183 | - } else { |
|
| 184 | - // The scriptName is not ending with OC::$SUBURI |
|
| 185 | - // This most likely means that we are calling from CLI. |
|
| 186 | - // However some cron jobs still need to generate |
|
| 187 | - // a web URL, so we use overwritewebroot as a fallback. |
|
| 188 | - OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - // Resolve /nextcloud to /nextcloud/ to ensure to always have a trailing |
|
| 192 | - // slash which is required by URL generation. |
|
| 193 | - if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] === \OC::$WEBROOT && |
|
| 194 | - substr($_SERVER['REQUEST_URI'], -1) !== '/') { |
|
| 195 | - header('Location: '.\OC::$WEBROOT.'/'); |
|
| 196 | - exit(); |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - // search the apps folder |
|
| 201 | - $config_paths = self::$config->getValue('apps_paths', []); |
|
| 202 | - if (!empty($config_paths)) { |
|
| 203 | - foreach ($config_paths as $paths) { |
|
| 204 | - if (isset($paths['url']) && isset($paths['path'])) { |
|
| 205 | - $paths['url'] = rtrim($paths['url'], '/'); |
|
| 206 | - $paths['path'] = rtrim($paths['path'], '/'); |
|
| 207 | - OC::$APPSROOTS[] = $paths; |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - } elseif (file_exists(OC::$SERVERROOT . '/apps')) { |
|
| 211 | - OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true]; |
|
| 212 | - } elseif (file_exists(OC::$SERVERROOT . '/../apps')) { |
|
| 213 | - OC::$APPSROOTS[] = [ |
|
| 214 | - 'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', |
|
| 215 | - 'url' => '/apps', |
|
| 216 | - 'writable' => true |
|
| 217 | - ]; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - if (empty(OC::$APPSROOTS)) { |
|
| 221 | - throw new \RuntimeException('apps directory not found! Please put the Nextcloud apps folder in the Nextcloud folder' |
|
| 222 | - . ' or the folder above. You can also configure the location in the config.php file.'); |
|
| 223 | - } |
|
| 224 | - $paths = []; |
|
| 225 | - foreach (OC::$APPSROOTS as $path) { |
|
| 226 | - $paths[] = $path['path']; |
|
| 227 | - if (!is_dir($path['path'])) { |
|
| 228 | - throw new \RuntimeException(sprintf('App directory "%s" not found! Please put the Nextcloud apps folder in the' |
|
| 229 | - . ' Nextcloud folder or the folder above. You can also configure the location in the' |
|
| 230 | - . ' config.php file.', $path['path'])); |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - // set the right include path |
|
| 235 | - set_include_path( |
|
| 236 | - implode(PATH_SEPARATOR, $paths) |
|
| 237 | - ); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - public static function checkConfig() { |
|
| 241 | - $l = \OC::$server->getL10N('lib'); |
|
| 242 | - |
|
| 243 | - // Create config if it does not already exist |
|
| 244 | - $configFilePath = self::$configDir .'/config.php'; |
|
| 245 | - if (!file_exists($configFilePath)) { |
|
| 246 | - @touch($configFilePath); |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - // Check if config is writable |
|
| 250 | - $configFileWritable = is_writable($configFilePath); |
|
| 251 | - if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled() |
|
| 252 | - || !$configFileWritable && \OCP\Util::needUpgrade()) { |
|
| 253 | - $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 254 | - |
|
| 255 | - if (self::$CLI) { |
|
| 256 | - echo $l->t('Cannot write into "config" directory!')."\n"; |
|
| 257 | - echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; |
|
| 258 | - echo "\n"; |
|
| 259 | - echo $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.')."\n"; |
|
| 260 | - echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ])."\n"; |
|
| 261 | - exit; |
|
| 262 | - } else { |
|
| 263 | - OC_Template::printErrorPage( |
|
| 264 | - $l->t('Cannot write into "config" directory!'), |
|
| 265 | - $l->t('This can usually be fixed by giving the webserver write access to the config directory.') . '. ' |
|
| 266 | - . $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it. See %s', |
|
| 267 | - [ $urlGenerator->linkToDocs('admin-config') ]), |
|
| 268 | - 503 |
|
| 269 | - ); |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - public static function checkInstalled() { |
|
| 275 | - if (defined('OC_CONSOLE')) { |
|
| 276 | - return; |
|
| 277 | - } |
|
| 278 | - // Redirect to installer if not installed |
|
| 279 | - if (!\OC::$server->getSystemConfig()->getValue('installed', false) && OC::$SUBURI !== '/index.php' && OC::$SUBURI !== '/status.php') { |
|
| 280 | - if (OC::$CLI) { |
|
| 281 | - throw new Exception('Not installed'); |
|
| 282 | - } else { |
|
| 283 | - $url = OC::$WEBROOT . '/index.php'; |
|
| 284 | - header('Location: ' . $url); |
|
| 285 | - } |
|
| 286 | - exit(); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - public static function checkMaintenanceMode() { |
|
| 291 | - // Allow ajax update script to execute without being stopped |
|
| 292 | - if (((bool) \OC::$server->getSystemConfig()->getValue('maintenance', false)) && OC::$SUBURI != '/core/ajax/update.php') { |
|
| 293 | - // send http status 503 |
|
| 294 | - http_response_code(503); |
|
| 295 | - header('Retry-After: 120'); |
|
| 296 | - |
|
| 297 | - // render error page |
|
| 298 | - $template = new OC_Template('', 'update.user', 'guest'); |
|
| 299 | - OC_Util::addScript('dist/maintenance'); |
|
| 300 | - OC_Util::addStyle('core', 'guest'); |
|
| 301 | - $template->printPage(); |
|
| 302 | - die(); |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * Prints the upgrade page |
|
| 308 | - * |
|
| 309 | - * @param \OC\SystemConfig $systemConfig |
|
| 310 | - */ |
|
| 311 | - private static function printUpgradePage(\OC\SystemConfig $systemConfig) { |
|
| 312 | - $disableWebUpdater = $systemConfig->getValue('upgrade.disable-web', false); |
|
| 313 | - $tooBig = false; |
|
| 314 | - if (!$disableWebUpdater) { |
|
| 315 | - $apps = \OC::$server->getAppManager(); |
|
| 316 | - if ($apps->isInstalled('user_ldap')) { |
|
| 317 | - $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); |
|
| 318 | - |
|
| 319 | - $result = $qb->select($qb->func()->count('*', 'user_count')) |
|
| 320 | - ->from('ldap_user_mapping') |
|
| 321 | - ->execute(); |
|
| 322 | - $row = $result->fetch(); |
|
| 323 | - $result->closeCursor(); |
|
| 324 | - |
|
| 325 | - $tooBig = ($row['user_count'] > 50); |
|
| 326 | - } |
|
| 327 | - if (!$tooBig && $apps->isInstalled('user_saml')) { |
|
| 328 | - $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); |
|
| 329 | - |
|
| 330 | - $result = $qb->select($qb->func()->count('*', 'user_count')) |
|
| 331 | - ->from('user_saml_users') |
|
| 332 | - ->execute(); |
|
| 333 | - $row = $result->fetch(); |
|
| 334 | - $result->closeCursor(); |
|
| 335 | - |
|
| 336 | - $tooBig = ($row['user_count'] > 50); |
|
| 337 | - } |
|
| 338 | - if (!$tooBig) { |
|
| 339 | - // count users |
|
| 340 | - $stats = \OC::$server->getUserManager()->countUsers(); |
|
| 341 | - $totalUsers = array_sum($stats); |
|
| 342 | - $tooBig = ($totalUsers > 50); |
|
| 343 | - } |
|
| 344 | - } |
|
| 345 | - $ignoreTooBigWarning = isset($_GET['IKnowThatThisIsABigInstanceAndTheUpdateRequestCouldRunIntoATimeoutAndHowToRestoreABackup']) && |
|
| 346 | - $_GET['IKnowThatThisIsABigInstanceAndTheUpdateRequestCouldRunIntoATimeoutAndHowToRestoreABackup'] === 'IAmSuperSureToDoThis'; |
|
| 347 | - |
|
| 348 | - if ($disableWebUpdater || ($tooBig && !$ignoreTooBigWarning)) { |
|
| 349 | - // send http status 503 |
|
| 350 | - http_response_code(503); |
|
| 351 | - header('Retry-After: 120'); |
|
| 352 | - |
|
| 353 | - // render error page |
|
| 354 | - $template = new OC_Template('', 'update.use-cli', 'guest'); |
|
| 355 | - $template->assign('productName', 'nextcloud'); // for now |
|
| 356 | - $template->assign('version', OC_Util::getVersionString()); |
|
| 357 | - $template->assign('tooBig', $tooBig); |
|
| 358 | - |
|
| 359 | - $template->printPage(); |
|
| 360 | - die(); |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - // check whether this is a core update or apps update |
|
| 364 | - $installedVersion = $systemConfig->getValue('version', '0.0.0'); |
|
| 365 | - $currentVersion = implode('.', \OCP\Util::getVersion()); |
|
| 366 | - |
|
| 367 | - // if not a core upgrade, then it's apps upgrade |
|
| 368 | - $isAppsOnlyUpgrade = version_compare($currentVersion, $installedVersion, '='); |
|
| 369 | - |
|
| 370 | - $oldTheme = $systemConfig->getValue('theme'); |
|
| 371 | - $systemConfig->setValue('theme', ''); |
|
| 372 | - OC_Util::addScript('config'); // needed for web root |
|
| 373 | - OC_Util::addScript('update'); |
|
| 374 | - |
|
| 375 | - /** @var \OC\App\AppManager $appManager */ |
|
| 376 | - $appManager = \OC::$server->getAppManager(); |
|
| 377 | - |
|
| 378 | - $tmpl = new OC_Template('', 'update.admin', 'guest'); |
|
| 379 | - $tmpl->assign('version', OC_Util::getVersionString()); |
|
| 380 | - $tmpl->assign('isAppsOnlyUpgrade', $isAppsOnlyUpgrade); |
|
| 381 | - |
|
| 382 | - // get third party apps |
|
| 383 | - $ocVersion = \OCP\Util::getVersion(); |
|
| 384 | - $ocVersion = implode('.', $ocVersion); |
|
| 385 | - $incompatibleApps = $appManager->getIncompatibleApps($ocVersion); |
|
| 386 | - $incompatibleShippedApps = []; |
|
| 387 | - foreach ($incompatibleApps as $appInfo) { |
|
| 388 | - if ($appManager->isShipped($appInfo['id'])) { |
|
| 389 | - $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - if (!empty($incompatibleShippedApps)) { |
|
| 394 | - $l = \OC::$server->getL10N('core'); |
|
| 395 | - $hint = $l->t('The files of the app %1$s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]); |
|
| 396 | - 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); |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
|
| 400 | - $tmpl->assign('incompatibleAppsList', $incompatibleApps); |
|
| 401 | - $tmpl->assign('productName', 'Nextcloud'); // for now |
|
| 402 | - $tmpl->assign('oldTheme', $oldTheme); |
|
| 403 | - $tmpl->printPage(); |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - public static function initSession() { |
|
| 407 | - if (self::$server->getRequest()->getServerProtocol() === 'https') { |
|
| 408 | - ini_set('session.cookie_secure', true); |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - // prevents javascript from accessing php session cookies |
|
| 412 | - ini_set('session.cookie_httponly', 'true'); |
|
| 413 | - |
|
| 414 | - // set the cookie path to the Nextcloud directory |
|
| 415 | - $cookie_path = OC::$WEBROOT ? : '/'; |
|
| 416 | - ini_set('session.cookie_path', $cookie_path); |
|
| 417 | - |
|
| 418 | - // Let the session name be changed in the initSession Hook |
|
| 419 | - $sessionName = OC_Util::getInstanceId(); |
|
| 420 | - |
|
| 421 | - try { |
|
| 422 | - // Allow session apps to create a custom session object |
|
| 423 | - $useCustomSession = false; |
|
| 424 | - $session = self::$server->getSession(); |
|
| 425 | - OC_Hook::emit('OC', 'initSession', ['session' => &$session, 'sessionName' => &$sessionName, 'useCustomSession' => &$useCustomSession]); |
|
| 426 | - if (!$useCustomSession) { |
|
| 427 | - // set the session name to the instance id - which is unique |
|
| 428 | - $session = new \OC\Session\Internal($sessionName); |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - $cryptoWrapper = \OC::$server->getSessionCryptoWrapper(); |
|
| 432 | - $session = $cryptoWrapper->wrapSession($session); |
|
| 433 | - self::$server->setSession($session); |
|
| 434 | - |
|
| 435 | - // if session can't be started break with http 500 error |
|
| 436 | - } catch (Exception $e) { |
|
| 437 | - \OC::$server->getLogger()->logException($e, ['app' => 'base']); |
|
| 438 | - //show the user a detailed error page |
|
| 439 | - OC_Template::printExceptionErrorPage($e, 500); |
|
| 440 | - die(); |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - $sessionLifeTime = self::getSessionLifeTime(); |
|
| 444 | - |
|
| 445 | - // session timeout |
|
| 446 | - if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
|
| 447 | - if (isset($_COOKIE[session_name()])) { |
|
| 448 | - setcookie(session_name(), '', -1, self::$WEBROOT ? : '/'); |
|
| 449 | - } |
|
| 450 | - \OC::$server->getUserSession()->logout(); |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - $session->set('LAST_ACTIVITY', time()); |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * @return string |
|
| 458 | - */ |
|
| 459 | - private static function getSessionLifeTime() { |
|
| 460 | - return \OC::$server->getConfig()->getSystemValue('session_lifetime', 60 * 60 * 24); |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - /** |
|
| 464 | - * Try to set some values to the required Nextcloud default |
|
| 465 | - */ |
|
| 466 | - public static function setRequiredIniValues() { |
|
| 467 | - @ini_set('default_charset', 'UTF-8'); |
|
| 468 | - @ini_set('gd.jpeg_ignore_warning', '1'); |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - /** |
|
| 472 | - * Send the same site cookies |
|
| 473 | - */ |
|
| 474 | - private static function sendSameSiteCookies() { |
|
| 475 | - $cookieParams = session_get_cookie_params(); |
|
| 476 | - $secureCookie = ($cookieParams['secure'] === true) ? 'secure; ' : ''; |
|
| 477 | - $policies = [ |
|
| 478 | - 'lax', |
|
| 479 | - 'strict', |
|
| 480 | - ]; |
|
| 481 | - |
|
| 482 | - // Append __Host to the cookie if it meets the requirements |
|
| 483 | - $cookiePrefix = ''; |
|
| 484 | - if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
| 485 | - $cookiePrefix = '__Host-'; |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - foreach ($policies as $policy) { |
|
| 489 | - header( |
|
| 490 | - sprintf( |
|
| 491 | - 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
| 492 | - $cookiePrefix, |
|
| 493 | - $policy, |
|
| 494 | - $cookieParams['path'], |
|
| 495 | - $policy |
|
| 496 | - ), |
|
| 497 | - false |
|
| 498 | - ); |
|
| 499 | - } |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - /** |
|
| 503 | - * Same Site cookie to further mitigate CSRF attacks. This cookie has to |
|
| 504 | - * be set in every request if cookies are sent to add a second level of |
|
| 505 | - * defense against CSRF. |
|
| 506 | - * |
|
| 507 | - * If the cookie is not sent this will set the cookie and reload the page. |
|
| 508 | - * We use an additional cookie since we want to protect logout CSRF and |
|
| 509 | - * also we can't directly interfere with PHP's session mechanism. |
|
| 510 | - */ |
|
| 511 | - private static function performSameSiteCookieProtection() { |
|
| 512 | - $request = \OC::$server->getRequest(); |
|
| 513 | - |
|
| 514 | - // Some user agents are notorious and don't really properly follow HTTP |
|
| 515 | - // specifications. For those, have an automated opt-out. Since the protection |
|
| 516 | - // for remote.php is applied in base.php as starting point we need to opt out |
|
| 517 | - // here. |
|
| 518 | - $incompatibleUserAgents = \OC::$server->getConfig()->getSystemValue('csrf.optout'); |
|
| 519 | - |
|
| 520 | - // Fallback, if csrf.optout is unset |
|
| 521 | - if (!is_array($incompatibleUserAgents)) { |
|
| 522 | - $incompatibleUserAgents = [ |
|
| 523 | - // OS X Finder |
|
| 524 | - '/^WebDAVFS/', |
|
| 525 | - // Windows webdav drive |
|
| 526 | - '/^Microsoft-WebDAV-MiniRedir/', |
|
| 527 | - ]; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - if ($request->isUserAgent($incompatibleUserAgents)) { |
|
| 531 | - return; |
|
| 532 | - } |
|
| 533 | - |
|
| 534 | - if (count($_COOKIE) > 0) { |
|
| 535 | - $requestUri = $request->getScriptName(); |
|
| 536 | - $processingScript = explode('/', $requestUri); |
|
| 537 | - $processingScript = $processingScript[count($processingScript)-1]; |
|
| 538 | - |
|
| 539 | - // index.php routes are handled in the middleware |
|
| 540 | - if ($processingScript === 'index.php') { |
|
| 541 | - return; |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - // All other endpoints require the lax and the strict cookie |
|
| 545 | - if (!$request->passesStrictCookieCheck()) { |
|
| 546 | - self::sendSameSiteCookies(); |
|
| 547 | - // Debug mode gets access to the resources without strict cookie |
|
| 548 | - // due to the fact that the SabreDAV browser also lives there. |
|
| 549 | - if (!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 550 | - http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); |
|
| 551 | - exit(); |
|
| 552 | - } |
|
| 553 | - } |
|
| 554 | - } elseif (!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
| 555 | - self::sendSameSiteCookies(); |
|
| 556 | - } |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - public static function init() { |
|
| 560 | - // calculate the root directories |
|
| 561 | - OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4)); |
|
| 562 | - |
|
| 563 | - // register autoloader |
|
| 564 | - $loaderStart = microtime(true); |
|
| 565 | - require_once __DIR__ . '/autoloader.php'; |
|
| 566 | - self::$loader = new \OC\Autoloader([ |
|
| 567 | - OC::$SERVERROOT . '/lib/private/legacy', |
|
| 568 | - ]); |
|
| 569 | - if (defined('PHPUNIT_RUN')) { |
|
| 570 | - self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
|
| 571 | - } |
|
| 572 | - spl_autoload_register([self::$loader, 'load']); |
|
| 573 | - $loaderEnd = microtime(true); |
|
| 574 | - |
|
| 575 | - self::$CLI = (php_sapi_name() == 'cli'); |
|
| 576 | - |
|
| 577 | - // Add default composer PSR-4 autoloader |
|
| 578 | - self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
|
| 579 | - |
|
| 580 | - try { |
|
| 581 | - self::initPaths(); |
|
| 582 | - // setup 3rdparty autoloader |
|
| 583 | - $vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php'; |
|
| 584 | - if (!file_exists($vendorAutoLoad)) { |
|
| 585 | - 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".'); |
|
| 586 | - } |
|
| 587 | - require_once $vendorAutoLoad; |
|
| 588 | - } catch (\RuntimeException $e) { |
|
| 589 | - if (!self::$CLI) { |
|
| 590 | - http_response_code(503); |
|
| 591 | - } |
|
| 592 | - // we can't use the template error page here, because this needs the |
|
| 593 | - // DI container which isn't available yet |
|
| 594 | - print($e->getMessage()); |
|
| 595 | - exit(); |
|
| 596 | - } |
|
| 597 | - |
|
| 598 | - // setup the basic server |
|
| 599 | - self::$server = new \OC\Server(\OC::$WEBROOT, self::$config); |
|
| 600 | - self::$server->boot(); |
|
| 601 | - \OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd); |
|
| 602 | - \OC::$server->getEventLogger()->start('boot', 'Initialize'); |
|
| 603 | - |
|
| 604 | - // Override php.ini and log everything if we're troubleshooting |
|
| 605 | - if (self::$config->getValue('loglevel') === ILogger::DEBUG) { |
|
| 606 | - error_reporting(E_ALL); |
|
| 607 | - } |
|
| 608 | - |
|
| 609 | - // Don't display errors and log them |
|
| 610 | - @ini_set('display_errors', '0'); |
|
| 611 | - @ini_set('log_errors', '1'); |
|
| 612 | - |
|
| 613 | - if (!date_default_timezone_set('UTC')) { |
|
| 614 | - throw new \RuntimeException('Could not set timezone to UTC'); |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - //try to configure php to enable big file uploads. |
|
| 618 | - //this doesn´t work always depending on the webserver and php configuration. |
|
| 619 | - //Let´s try to overwrite some defaults anyway |
|
| 620 | - |
|
| 621 | - //try to set the maximum execution time to 60min |
|
| 622 | - if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
| 623 | - @set_time_limit(3600); |
|
| 624 | - } |
|
| 625 | - @ini_set('max_execution_time', '3600'); |
|
| 626 | - @ini_set('max_input_time', '3600'); |
|
| 627 | - |
|
| 628 | - //try to set the maximum filesize to 10G |
|
| 629 | - @ini_set('upload_max_filesize', '10G'); |
|
| 630 | - @ini_set('post_max_size', '10G'); |
|
| 631 | - @ini_set('file_uploads', '50'); |
|
| 632 | - |
|
| 633 | - self::setRequiredIniValues(); |
|
| 634 | - self::handleAuthHeaders(); |
|
| 635 | - self::registerAutoloaderCache(); |
|
| 636 | - |
|
| 637 | - // initialize intl fallback is necessary |
|
| 638 | - \Patchwork\Utf8\Bootup::initIntl(); |
|
| 639 | - OC_Util::isSetLocaleWorking(); |
|
| 640 | - |
|
| 641 | - if (!defined('PHPUNIT_RUN')) { |
|
| 642 | - OC\Log\ErrorHandler::setLogger(\OC::$server->getLogger()); |
|
| 643 | - $debug = \OC::$server->getConfig()->getSystemValue('debug', false); |
|
| 644 | - OC\Log\ErrorHandler::register($debug); |
|
| 645 | - } |
|
| 646 | - |
|
| 647 | - \OC::$server->getEventLogger()->start('init_session', 'Initialize session'); |
|
| 648 | - OC_App::loadApps(['session']); |
|
| 649 | - if (!self::$CLI) { |
|
| 650 | - self::initSession(); |
|
| 651 | - } |
|
| 652 | - \OC::$server->getEventLogger()->end('init_session'); |
|
| 653 | - self::checkConfig(); |
|
| 654 | - self::checkInstalled(); |
|
| 655 | - |
|
| 656 | - OC_Response::addSecurityHeaders(); |
|
| 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 | - http_response_code(503); |
|
| 665 | - OC_Util::addStyle('guest'); |
|
| 666 | - try { |
|
| 667 | - OC_Template::printGuestPage('', 'error', ['errors' => $errors]); |
|
| 668 | - exit; |
|
| 669 | - } catch (\Exception $e) { |
|
| 670 | - // In case any error happens when showing the error page, we simply fall back to posting the text. |
|
| 671 | - // This might be the case when e.g. the data directory is broken and we can not load/write SCSS to/from it. |
|
| 672 | - } |
|
| 673 | - } |
|
| 674 | - |
|
| 675 | - // Convert l10n string into regular string for usage in database |
|
| 676 | - $staticErrors = []; |
|
| 677 | - foreach ($errors as $error) { |
|
| 678 | - echo $error['error'] . "\n"; |
|
| 679 | - echo $error['hint'] . "\n\n"; |
|
| 680 | - $staticErrors[] = [ |
|
| 681 | - 'error' => (string)$error['error'], |
|
| 682 | - 'hint' => (string)$error['hint'], |
|
| 683 | - ]; |
|
| 684 | - } |
|
| 685 | - |
|
| 686 | - try { |
|
| 687 | - \OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors)); |
|
| 688 | - } catch (\Exception $e) { |
|
| 689 | - echo('Writing to database failed'); |
|
| 690 | - } |
|
| 691 | - exit(1); |
|
| 692 | - } elseif (self::$CLI && \OC::$server->getConfig()->getSystemValue('installed', false)) { |
|
| 693 | - \OC::$server->getConfig()->deleteAppValue('core', 'cronErrors'); |
|
| 694 | - } |
|
| 695 | - } |
|
| 696 | - //try to set the session lifetime |
|
| 697 | - $sessionLifeTime = self::getSessionLifeTime(); |
|
| 698 | - @ini_set('gc_maxlifetime', (string)$sessionLifeTime); |
|
| 699 | - |
|
| 700 | - $systemConfig = \OC::$server->getSystemConfig(); |
|
| 701 | - |
|
| 702 | - // User and Groups |
|
| 703 | - if (!$systemConfig->getValue("installed", false)) { |
|
| 704 | - self::$server->getSession()->set('user_id', ''); |
|
| 705 | - } |
|
| 706 | - |
|
| 707 | - OC_User::useBackend(new \OC\User\Database()); |
|
| 708 | - \OC::$server->getGroupManager()->addBackend(new \OC\Group\Database()); |
|
| 709 | - |
|
| 710 | - // Subscribe to the hook |
|
| 711 | - \OCP\Util::connectHook( |
|
| 712 | - '\OCA\Files_Sharing\API\Server2Server', |
|
| 713 | - 'preLoginNameUsedAsUserName', |
|
| 714 | - '\OC\User\Database', |
|
| 715 | - 'preLoginNameUsedAsUserName' |
|
| 716 | - ); |
|
| 717 | - |
|
| 718 | - //setup extra user backends |
|
| 719 | - if (!\OCP\Util::needUpgrade()) { |
|
| 720 | - OC_User::setupBackends(); |
|
| 721 | - } else { |
|
| 722 | - // Run upgrades in incognito mode |
|
| 723 | - OC_User::setIncognitoMode(true); |
|
| 724 | - } |
|
| 725 | - |
|
| 726 | - self::registerCleanupHooks(); |
|
| 727 | - self::registerFilesystemHooks(); |
|
| 728 | - self::registerShareHooks(); |
|
| 729 | - self::registerEncryptionWrapper(); |
|
| 730 | - self::registerEncryptionHooks(); |
|
| 731 | - self::registerAccountHooks(); |
|
| 732 | - self::registerResourceCollectionHooks(); |
|
| 733 | - self::registerAppRestrictionsHooks(); |
|
| 734 | - |
|
| 735 | - // Make sure that the application class is not loaded before the database is setup |
|
| 736 | - if ($systemConfig->getValue("installed", false)) { |
|
| 737 | - OC_App::loadApp('settings'); |
|
| 738 | - $settings = \OC::$server->query(\OCA\Settings\AppInfo\Application::class); |
|
| 739 | - $settings->register(); |
|
| 740 | - } |
|
| 741 | - |
|
| 742 | - //make sure temporary files are cleaned up |
|
| 743 | - $tmpManager = \OC::$server->getTempManager(); |
|
| 744 | - register_shutdown_function([$tmpManager, 'clean']); |
|
| 745 | - $lockProvider = \OC::$server->getLockingProvider(); |
|
| 746 | - register_shutdown_function([$lockProvider, 'releaseAll']); |
|
| 747 | - |
|
| 748 | - // Check whether the sample configuration has been copied |
|
| 749 | - if ($systemConfig->getValue('copied_sample_config', false)) { |
|
| 750 | - $l = \OC::$server->getL10N('lib'); |
|
| 751 | - OC_Template::printErrorPage( |
|
| 752 | - $l->t('Sample configuration detected'), |
|
| 753 | - $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'), |
|
| 754 | - 503 |
|
| 755 | - ); |
|
| 756 | - return; |
|
| 757 | - } |
|
| 758 | - |
|
| 759 | - $request = \OC::$server->getRequest(); |
|
| 760 | - $host = $request->getInsecureServerHost(); |
|
| 761 | - /** |
|
| 762 | - * if the host passed in headers isn't trusted |
|
| 763 | - * FIXME: Should not be in here at all :see_no_evil: |
|
| 764 | - */ |
|
| 765 | - if (!OC::$CLI |
|
| 766 | - && !\OC::$server->getTrustedDomainHelper()->isTrustedDomain($host) |
|
| 767 | - && self::$server->getConfig()->getSystemValue('installed', false) |
|
| 768 | - ) { |
|
| 769 | - // Allow access to CSS resources |
|
| 770 | - $isScssRequest = false; |
|
| 771 | - if (strpos($request->getPathInfo(), '/css/') === 0) { |
|
| 772 | - $isScssRequest = true; |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - if (substr($request->getRequestUri(), -11) === '/status.php') { |
|
| 776 | - http_response_code(400); |
|
| 777 | - header('Content-Type: application/json'); |
|
| 778 | - echo '{"error": "Trusted domain error.", "code": 15}'; |
|
| 779 | - exit(); |
|
| 780 | - } |
|
| 781 | - |
|
| 782 | - if (!$isScssRequest) { |
|
| 783 | - http_response_code(400); |
|
| 784 | - |
|
| 785 | - \OC::$server->getLogger()->info( |
|
| 786 | - 'Trusted domain error. "{remoteAddress}" tried to access using "{host}" as host.', |
|
| 787 | - [ |
|
| 788 | - 'app' => 'core', |
|
| 789 | - 'remoteAddress' => $request->getRemoteAddress(), |
|
| 790 | - 'host' => $host, |
|
| 791 | - ] |
|
| 792 | - ); |
|
| 793 | - |
|
| 794 | - $tmpl = new OCP\Template('core', 'untrustedDomain', 'guest'); |
|
| 795 | - $tmpl->assign('docUrl', \OC::$server->getURLGenerator()->linkToDocs('admin-trusted-domains')); |
|
| 796 | - $tmpl->printPage(); |
|
| 797 | - |
|
| 798 | - exit(); |
|
| 799 | - } |
|
| 800 | - } |
|
| 801 | - \OC::$server->getEventLogger()->end('boot'); |
|
| 802 | - } |
|
| 803 | - |
|
| 804 | - /** |
|
| 805 | - * register hooks for the cleanup of cache and bruteforce protection |
|
| 806 | - */ |
|
| 807 | - public static function registerCleanupHooks() { |
|
| 808 | - //don't try to do this before we are properly setup |
|
| 809 | - if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) { |
|
| 810 | - |
|
| 811 | - // NOTE: This will be replaced to use OCP |
|
| 812 | - $userSession = self::$server->getUserSession(); |
|
| 813 | - $userSession->listen('\OC\User', 'postLogin', function () use ($userSession) { |
|
| 814 | - if (!defined('PHPUNIT_RUN') && $userSession->isLoggedIn()) { |
|
| 815 | - // reset brute force delay for this IP address and username |
|
| 816 | - $uid = \OC::$server->getUserSession()->getUser()->getUID(); |
|
| 817 | - $request = \OC::$server->getRequest(); |
|
| 818 | - $throttler = \OC::$server->getBruteForceThrottler(); |
|
| 819 | - $throttler->resetDelay($request->getRemoteAddress(), 'login', ['user' => $uid]); |
|
| 820 | - } |
|
| 821 | - |
|
| 822 | - try { |
|
| 823 | - $cache = new \OC\Cache\File(); |
|
| 824 | - $cache->gc(); |
|
| 825 | - } catch (\OC\ServerNotAvailableException $e) { |
|
| 826 | - // not a GC exception, pass it on |
|
| 827 | - throw $e; |
|
| 828 | - } catch (\OC\ForbiddenException $e) { |
|
| 829 | - // filesystem blocked for this request, ignore |
|
| 830 | - } catch (\Exception $e) { |
|
| 831 | - // a GC exception should not prevent users from using OC, |
|
| 832 | - // so log the exception |
|
| 833 | - \OC::$server->getLogger()->logException($e, [ |
|
| 834 | - 'message' => 'Exception when running cache gc.', |
|
| 835 | - 'level' => ILogger::WARN, |
|
| 836 | - 'app' => 'core', |
|
| 837 | - ]); |
|
| 838 | - } |
|
| 839 | - }); |
|
| 840 | - } |
|
| 841 | - } |
|
| 842 | - |
|
| 843 | - private static function registerEncryptionWrapper() { |
|
| 844 | - $manager = self::$server->getEncryptionManager(); |
|
| 845 | - \OCP\Util::connectHook('OC_Filesystem', 'preSetup', $manager, 'setupStorage'); |
|
| 846 | - } |
|
| 847 | - |
|
| 848 | - private static function registerEncryptionHooks() { |
|
| 849 | - $enabled = self::$server->getEncryptionManager()->isEnabled(); |
|
| 850 | - if ($enabled) { |
|
| 851 | - \OCP\Util::connectHook(Share::class, 'post_shared', HookManager::class, 'postShared'); |
|
| 852 | - \OCP\Util::connectHook(Share::class, 'post_unshare', HookManager::class, 'postUnshared'); |
|
| 853 | - \OCP\Util::connectHook('OC_Filesystem', 'post_rename', HookManager::class, 'postRename'); |
|
| 854 | - \OCP\Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', HookManager::class, 'postRestore'); |
|
| 855 | - } |
|
| 856 | - } |
|
| 857 | - |
|
| 858 | - private static function registerAccountHooks() { |
|
| 859 | - $hookHandler = new \OC\Accounts\Hooks(\OC::$server->getLogger()); |
|
| 860 | - \OCP\Util::connectHook('OC_User', 'changeUser', $hookHandler, 'changeUserHook'); |
|
| 861 | - } |
|
| 862 | - |
|
| 863 | - private static function registerAppRestrictionsHooks() { |
|
| 864 | - $groupManager = self::$server->query(\OCP\IGroupManager::class); |
|
| 865 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OCP\IGroup $group) { |
|
| 866 | - $appManager = self::$server->getAppManager(); |
|
| 867 | - $apps = $appManager->getEnabledAppsForGroup($group); |
|
| 868 | - foreach ($apps as $appId) { |
|
| 869 | - $restrictions = $appManager->getAppRestriction($appId); |
|
| 870 | - if (empty($restrictions)) { |
|
| 871 | - continue; |
|
| 872 | - } |
|
| 873 | - $key = array_search($group->getGID(), $restrictions); |
|
| 874 | - unset($restrictions[$key]); |
|
| 875 | - $restrictions = array_values($restrictions); |
|
| 876 | - if (empty($restrictions)) { |
|
| 877 | - $appManager->disableApp($appId); |
|
| 878 | - } else { |
|
| 879 | - $appManager->enableAppForGroups($appId, $restrictions); |
|
| 880 | - } |
|
| 881 | - } |
|
| 882 | - }); |
|
| 883 | - } |
|
| 884 | - |
|
| 885 | - private static function registerResourceCollectionHooks() { |
|
| 886 | - \OC\Collaboration\Resources\Listener::register(\OC::$server->getEventDispatcher()); |
|
| 887 | - } |
|
| 888 | - |
|
| 889 | - /** |
|
| 890 | - * register hooks for the filesystem |
|
| 891 | - */ |
|
| 892 | - public static function registerFilesystemHooks() { |
|
| 893 | - // Check for blacklisted files |
|
| 894 | - OC_Hook::connect('OC_Filesystem', 'write', Filesystem::class, 'isBlacklisted'); |
|
| 895 | - OC_Hook::connect('OC_Filesystem', 'rename', Filesystem::class, 'isBlacklisted'); |
|
| 896 | - } |
|
| 897 | - |
|
| 898 | - /** |
|
| 899 | - * register hooks for sharing |
|
| 900 | - */ |
|
| 901 | - public static function registerShareHooks() { |
|
| 902 | - if (\OC::$server->getSystemConfig()->getValue('installed')) { |
|
| 903 | - OC_Hook::connect('OC_User', 'post_deleteUser', Hooks::class, 'post_deleteUser'); |
|
| 904 | - OC_Hook::connect('OC_User', 'post_removeFromGroup', Hooks::class, 'post_removeFromGroup'); |
|
| 905 | - OC_Hook::connect('OC_User', 'post_deleteGroup', Hooks::class, 'post_deleteGroup'); |
|
| 906 | - } |
|
| 907 | - } |
|
| 908 | - |
|
| 909 | - protected static function registerAutoloaderCache() { |
|
| 910 | - // The class loader takes an optional low-latency cache, which MUST be |
|
| 911 | - // namespaced. The instanceid is used for namespacing, but might be |
|
| 912 | - // unavailable at this point. Furthermore, it might not be possible to |
|
| 913 | - // generate an instanceid via \OC_Util::getInstanceId() because the |
|
| 914 | - // config file may not be writable. As such, we only register a class |
|
| 915 | - // loader cache if instanceid is available without trying to create one. |
|
| 916 | - $instanceId = \OC::$server->getSystemConfig()->getValue('instanceid', null); |
|
| 917 | - if ($instanceId) { |
|
| 918 | - try { |
|
| 919 | - $memcacheFactory = \OC::$server->getMemCacheFactory(); |
|
| 920 | - self::$loader->setMemoryCache($memcacheFactory->createLocal('Autoloader')); |
|
| 921 | - } catch (\Exception $ex) { |
|
| 922 | - } |
|
| 923 | - } |
|
| 924 | - } |
|
| 925 | - |
|
| 926 | - /** |
|
| 927 | - * Handle the request |
|
| 928 | - */ |
|
| 929 | - public static function handleRequest() { |
|
| 930 | - \OC::$server->getEventLogger()->start('handle_request', 'Handle request'); |
|
| 931 | - $systemConfig = \OC::$server->getSystemConfig(); |
|
| 932 | - |
|
| 933 | - // Check if Nextcloud is installed or in maintenance (update) mode |
|
| 934 | - if (!$systemConfig->getValue('installed', false)) { |
|
| 935 | - \OC::$server->getSession()->clear(); |
|
| 936 | - $setupHelper = new OC\Setup( |
|
| 937 | - $systemConfig, |
|
| 938 | - \OC::$server->getIniWrapper(), |
|
| 939 | - \OC::$server->getL10N('lib'), |
|
| 940 | - \OC::$server->query(\OCP\Defaults::class), |
|
| 941 | - \OC::$server->getLogger(), |
|
| 942 | - \OC::$server->getSecureRandom(), |
|
| 943 | - \OC::$server->query(\OC\Installer::class) |
|
| 944 | - ); |
|
| 945 | - $controller = new OC\Core\Controller\SetupController($setupHelper); |
|
| 946 | - $controller->run($_POST); |
|
| 947 | - exit(); |
|
| 948 | - } |
|
| 949 | - |
|
| 950 | - $request = \OC::$server->getRequest(); |
|
| 951 | - $requestPath = $request->getRawPathInfo(); |
|
| 952 | - if ($requestPath === '/heartbeat') { |
|
| 953 | - return; |
|
| 954 | - } |
|
| 955 | - if (substr($requestPath, -3) !== '.js') { // we need these files during the upgrade |
|
| 956 | - self::checkMaintenanceMode(); |
|
| 957 | - |
|
| 958 | - if (\OCP\Util::needUpgrade()) { |
|
| 959 | - if (function_exists('opcache_reset')) { |
|
| 960 | - opcache_reset(); |
|
| 961 | - } |
|
| 962 | - if (!((bool) $systemConfig->getValue('maintenance', false))) { |
|
| 963 | - self::printUpgradePage($systemConfig); |
|
| 964 | - exit(); |
|
| 965 | - } |
|
| 966 | - } |
|
| 967 | - } |
|
| 968 | - |
|
| 969 | - // emergency app disabling |
|
| 970 | - if ($requestPath === '/disableapp' |
|
| 971 | - && $request->getMethod() === 'POST' |
|
| 972 | - && ((array)$request->getParam('appid')) !== '' |
|
| 973 | - ) { |
|
| 974 | - \OC_JSON::callCheck(); |
|
| 975 | - \OC_JSON::checkAdminUser(); |
|
| 976 | - $appIds = (array)$request->getParam('appid'); |
|
| 977 | - foreach ($appIds as $appId) { |
|
| 978 | - $appId = \OC_App::cleanAppId($appId); |
|
| 979 | - \OC::$server->getAppManager()->disableApp($appId); |
|
| 980 | - } |
|
| 981 | - \OC_JSON::success(); |
|
| 982 | - exit(); |
|
| 983 | - } |
|
| 984 | - |
|
| 985 | - // Always load authentication apps |
|
| 986 | - OC_App::loadApps(['authentication']); |
|
| 987 | - |
|
| 988 | - // Load minimum set of apps |
|
| 989 | - if (!\OCP\Util::needUpgrade() |
|
| 990 | - && !((bool) $systemConfig->getValue('maintenance', false))) { |
|
| 991 | - // For logged-in users: Load everything |
|
| 992 | - if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 993 | - OC_App::loadApps(); |
|
| 994 | - } else { |
|
| 995 | - // For guests: Load only filesystem and logging |
|
| 996 | - OC_App::loadApps(['filesystem', 'logging']); |
|
| 997 | - self::handleLogin($request); |
|
| 998 | - } |
|
| 999 | - } |
|
| 1000 | - |
|
| 1001 | - if (!self::$CLI) { |
|
| 1002 | - try { |
|
| 1003 | - if (!((bool) $systemConfig->getValue('maintenance', false)) && !\OCP\Util::needUpgrade()) { |
|
| 1004 | - OC_App::loadApps(['filesystem', 'logging']); |
|
| 1005 | - OC_App::loadApps(); |
|
| 1006 | - } |
|
| 1007 | - OC_Util::setupFS(); |
|
| 1008 | - OC::$server->getRouter()->match(\OC::$server->getRequest()->getRawPathInfo()); |
|
| 1009 | - return; |
|
| 1010 | - } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) { |
|
| 1011 | - //header('HTTP/1.0 404 Not Found'); |
|
| 1012 | - } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) { |
|
| 1013 | - http_response_code(405); |
|
| 1014 | - return; |
|
| 1015 | - } |
|
| 1016 | - } |
|
| 1017 | - |
|
| 1018 | - // Handle WebDAV |
|
| 1019 | - if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PROPFIND') { |
|
| 1020 | - // not allowed any more to prevent people |
|
| 1021 | - // mounting this root directly. |
|
| 1022 | - // Users need to mount remote.php/webdav instead. |
|
| 1023 | - http_response_code(405); |
|
| 1024 | - return; |
|
| 1025 | - } |
|
| 1026 | - |
|
| 1027 | - // Someone is logged in |
|
| 1028 | - if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 1029 | - OC_App::loadApps(); |
|
| 1030 | - OC_User::setupBackends(); |
|
| 1031 | - OC_Util::setupFS(); |
|
| 1032 | - // FIXME |
|
| 1033 | - // Redirect to default application |
|
| 1034 | - OC_Util::redirectToDefaultPage(); |
|
| 1035 | - } else { |
|
| 1036 | - // Not handled and not logged in |
|
| 1037 | - header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute('core.login.showLoginForm')); |
|
| 1038 | - } |
|
| 1039 | - } |
|
| 1040 | - |
|
| 1041 | - /** |
|
| 1042 | - * Check login: apache auth, auth token, basic auth |
|
| 1043 | - * |
|
| 1044 | - * @param OCP\IRequest $request |
|
| 1045 | - * @return boolean |
|
| 1046 | - */ |
|
| 1047 | - public static function handleLogin(OCP\IRequest $request) { |
|
| 1048 | - $userSession = self::$server->getUserSession(); |
|
| 1049 | - if (OC_User::handleApacheAuth()) { |
|
| 1050 | - return true; |
|
| 1051 | - } |
|
| 1052 | - if ($userSession->tryTokenLogin($request)) { |
|
| 1053 | - return true; |
|
| 1054 | - } |
|
| 1055 | - if (isset($_COOKIE['nc_username']) |
|
| 1056 | - && isset($_COOKIE['nc_token']) |
|
| 1057 | - && isset($_COOKIE['nc_session_id']) |
|
| 1058 | - && $userSession->loginWithCookie($_COOKIE['nc_username'], $_COOKIE['nc_token'], $_COOKIE['nc_session_id'])) { |
|
| 1059 | - return true; |
|
| 1060 | - } |
|
| 1061 | - if ($userSession->tryBasicAuthLogin($request, \OC::$server->getBruteForceThrottler())) { |
|
| 1062 | - return true; |
|
| 1063 | - } |
|
| 1064 | - return false; |
|
| 1065 | - } |
|
| 1066 | - |
|
| 1067 | - protected static function handleAuthHeaders() { |
|
| 1068 | - //copy http auth headers for apache+php-fcgid work around |
|
| 1069 | - if (isset($_SERVER['HTTP_XAUTHORIZATION']) && !isset($_SERVER['HTTP_AUTHORIZATION'])) { |
|
| 1070 | - $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_XAUTHORIZATION']; |
|
| 1071 | - } |
|
| 1072 | - |
|
| 1073 | - // Extract PHP_AUTH_USER/PHP_AUTH_PW from other headers if necessary. |
|
| 1074 | - $vars = [ |
|
| 1075 | - 'HTTP_AUTHORIZATION', // apache+php-cgi work around |
|
| 1076 | - 'REDIRECT_HTTP_AUTHORIZATION', // apache+php-cgi alternative |
|
| 1077 | - ]; |
|
| 1078 | - foreach ($vars as $var) { |
|
| 1079 | - if (isset($_SERVER[$var]) && preg_match('/Basic\s+(.*)$/i', $_SERVER[$var], $matches)) { |
|
| 1080 | - $credentials = explode(':', base64_decode($matches[1]), 2); |
|
| 1081 | - if (count($credentials) === 2) { |
|
| 1082 | - $_SERVER['PHP_AUTH_USER'] = $credentials[0]; |
|
| 1083 | - $_SERVER['PHP_AUTH_PW'] = $credentials[1]; |
|
| 1084 | - break; |
|
| 1085 | - } |
|
| 1086 | - } |
|
| 1087 | - } |
|
| 1088 | - } |
|
| 78 | + /** |
|
| 79 | + * Associative array for autoloading. classname => filename |
|
| 80 | + */ |
|
| 81 | + public static $CLASSPATH = []; |
|
| 82 | + /** |
|
| 83 | + * The installation path for Nextcloud on the server (e.g. /srv/http/nextcloud) |
|
| 84 | + */ |
|
| 85 | + public static $SERVERROOT = ''; |
|
| 86 | + /** |
|
| 87 | + * the current request path relative to the Nextcloud root (e.g. files/index.php) |
|
| 88 | + */ |
|
| 89 | + private static $SUBURI = ''; |
|
| 90 | + /** |
|
| 91 | + * the Nextcloud root path for http requests (e.g. nextcloud/) |
|
| 92 | + */ |
|
| 93 | + public static $WEBROOT = ''; |
|
| 94 | + /** |
|
| 95 | + * The installation path array of the apps folder on the server (e.g. /srv/http/nextcloud) 'path' and |
|
| 96 | + * web path in 'url' |
|
| 97 | + */ |
|
| 98 | + public static $APPSROOTS = []; |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * @var string |
|
| 102 | + */ |
|
| 103 | + public static $configDir; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * requested app |
|
| 107 | + */ |
|
| 108 | + public static $REQUESTEDAPP = ''; |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * check if Nextcloud runs in cli mode |
|
| 112 | + */ |
|
| 113 | + public static $CLI = false; |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @var \OC\Autoloader $loader |
|
| 117 | + */ |
|
| 118 | + public static $loader = null; |
|
| 119 | + |
|
| 120 | + /** @var \Composer\Autoload\ClassLoader $composerAutoloader */ |
|
| 121 | + public static $composerAutoloader = null; |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * @var \OC\Server |
|
| 125 | + */ |
|
| 126 | + public static $server = null; |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @var \OC\Config |
|
| 130 | + */ |
|
| 131 | + private static $config = null; |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @throws \RuntimeException when the 3rdparty directory is missing or |
|
| 135 | + * the app path list is empty or contains an invalid path |
|
| 136 | + */ |
|
| 137 | + public static function initPaths() { |
|
| 138 | + if (defined('PHPUNIT_CONFIG_DIR')) { |
|
| 139 | + self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; |
|
| 140 | + } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { |
|
| 141 | + self::$configDir = OC::$SERVERROOT . '/tests/config/'; |
|
| 142 | + } elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
| 143 | + self::$configDir = rtrim($dir, '/') . '/'; |
|
| 144 | + } else { |
|
| 145 | + self::$configDir = OC::$SERVERROOT . '/config/'; |
|
| 146 | + } |
|
| 147 | + self::$config = new \OC\Config(self::$configDir); |
|
| 148 | + |
|
| 149 | + OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT))); |
|
| 150 | + /** |
|
| 151 | + * FIXME: The following lines are required because we can't yet instantiate |
|
| 152 | + * \OC::$server->getRequest() since \OC::$server does not yet exist. |
|
| 153 | + */ |
|
| 154 | + $params = [ |
|
| 155 | + 'server' => [ |
|
| 156 | + 'SCRIPT_NAME' => $_SERVER['SCRIPT_NAME'], |
|
| 157 | + 'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME'], |
|
| 158 | + ], |
|
| 159 | + ]; |
|
| 160 | + $fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig(self::$config))); |
|
| 161 | + $scriptName = $fakeRequest->getScriptName(); |
|
| 162 | + if (substr($scriptName, -1) == '/') { |
|
| 163 | + $scriptName .= 'index.php'; |
|
| 164 | + //make sure suburi follows the same rules as scriptName |
|
| 165 | + if (substr(OC::$SUBURI, -9) != 'index.php') { |
|
| 166 | + if (substr(OC::$SUBURI, -1) != '/') { |
|
| 167 | + OC::$SUBURI = OC::$SUBURI . '/'; |
|
| 168 | + } |
|
| 169 | + OC::$SUBURI = OC::$SUBURI . 'index.php'; |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + if (OC::$CLI) { |
|
| 175 | + OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); |
|
| 176 | + } else { |
|
| 177 | + if (substr($scriptName, 0 - strlen(OC::$SUBURI)) === OC::$SUBURI) { |
|
| 178 | + OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
|
| 179 | + |
|
| 180 | + if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
|
| 181 | + OC::$WEBROOT = '/' . OC::$WEBROOT; |
|
| 182 | + } |
|
| 183 | + } else { |
|
| 184 | + // The scriptName is not ending with OC::$SUBURI |
|
| 185 | + // This most likely means that we are calling from CLI. |
|
| 186 | + // However some cron jobs still need to generate |
|
| 187 | + // a web URL, so we use overwritewebroot as a fallback. |
|
| 188 | + OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + // Resolve /nextcloud to /nextcloud/ to ensure to always have a trailing |
|
| 192 | + // slash which is required by URL generation. |
|
| 193 | + if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] === \OC::$WEBROOT && |
|
| 194 | + substr($_SERVER['REQUEST_URI'], -1) !== '/') { |
|
| 195 | + header('Location: '.\OC::$WEBROOT.'/'); |
|
| 196 | + exit(); |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + // search the apps folder |
|
| 201 | + $config_paths = self::$config->getValue('apps_paths', []); |
|
| 202 | + if (!empty($config_paths)) { |
|
| 203 | + foreach ($config_paths as $paths) { |
|
| 204 | + if (isset($paths['url']) && isset($paths['path'])) { |
|
| 205 | + $paths['url'] = rtrim($paths['url'], '/'); |
|
| 206 | + $paths['path'] = rtrim($paths['path'], '/'); |
|
| 207 | + OC::$APPSROOTS[] = $paths; |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + } elseif (file_exists(OC::$SERVERROOT . '/apps')) { |
|
| 211 | + OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true]; |
|
| 212 | + } elseif (file_exists(OC::$SERVERROOT . '/../apps')) { |
|
| 213 | + OC::$APPSROOTS[] = [ |
|
| 214 | + 'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', |
|
| 215 | + 'url' => '/apps', |
|
| 216 | + 'writable' => true |
|
| 217 | + ]; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + if (empty(OC::$APPSROOTS)) { |
|
| 221 | + throw new \RuntimeException('apps directory not found! Please put the Nextcloud apps folder in the Nextcloud folder' |
|
| 222 | + . ' or the folder above. You can also configure the location in the config.php file.'); |
|
| 223 | + } |
|
| 224 | + $paths = []; |
|
| 225 | + foreach (OC::$APPSROOTS as $path) { |
|
| 226 | + $paths[] = $path['path']; |
|
| 227 | + if (!is_dir($path['path'])) { |
|
| 228 | + throw new \RuntimeException(sprintf('App directory "%s" not found! Please put the Nextcloud apps folder in the' |
|
| 229 | + . ' Nextcloud folder or the folder above. You can also configure the location in the' |
|
| 230 | + . ' config.php file.', $path['path'])); |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + // set the right include path |
|
| 235 | + set_include_path( |
|
| 236 | + implode(PATH_SEPARATOR, $paths) |
|
| 237 | + ); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + public static function checkConfig() { |
|
| 241 | + $l = \OC::$server->getL10N('lib'); |
|
| 242 | + |
|
| 243 | + // Create config if it does not already exist |
|
| 244 | + $configFilePath = self::$configDir .'/config.php'; |
|
| 245 | + if (!file_exists($configFilePath)) { |
|
| 246 | + @touch($configFilePath); |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + // Check if config is writable |
|
| 250 | + $configFileWritable = is_writable($configFilePath); |
|
| 251 | + if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled() |
|
| 252 | + || !$configFileWritable && \OCP\Util::needUpgrade()) { |
|
| 253 | + $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 254 | + |
|
| 255 | + if (self::$CLI) { |
|
| 256 | + echo $l->t('Cannot write into "config" directory!')."\n"; |
|
| 257 | + echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; |
|
| 258 | + echo "\n"; |
|
| 259 | + echo $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.')."\n"; |
|
| 260 | + echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ])."\n"; |
|
| 261 | + exit; |
|
| 262 | + } else { |
|
| 263 | + OC_Template::printErrorPage( |
|
| 264 | + $l->t('Cannot write into "config" directory!'), |
|
| 265 | + $l->t('This can usually be fixed by giving the webserver write access to the config directory.') . '. ' |
|
| 266 | + . $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it. See %s', |
|
| 267 | + [ $urlGenerator->linkToDocs('admin-config') ]), |
|
| 268 | + 503 |
|
| 269 | + ); |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + public static function checkInstalled() { |
|
| 275 | + if (defined('OC_CONSOLE')) { |
|
| 276 | + return; |
|
| 277 | + } |
|
| 278 | + // Redirect to installer if not installed |
|
| 279 | + if (!\OC::$server->getSystemConfig()->getValue('installed', false) && OC::$SUBURI !== '/index.php' && OC::$SUBURI !== '/status.php') { |
|
| 280 | + if (OC::$CLI) { |
|
| 281 | + throw new Exception('Not installed'); |
|
| 282 | + } else { |
|
| 283 | + $url = OC::$WEBROOT . '/index.php'; |
|
| 284 | + header('Location: ' . $url); |
|
| 285 | + } |
|
| 286 | + exit(); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + public static function checkMaintenanceMode() { |
|
| 291 | + // Allow ajax update script to execute without being stopped |
|
| 292 | + if (((bool) \OC::$server->getSystemConfig()->getValue('maintenance', false)) && OC::$SUBURI != '/core/ajax/update.php') { |
|
| 293 | + // send http status 503 |
|
| 294 | + http_response_code(503); |
|
| 295 | + header('Retry-After: 120'); |
|
| 296 | + |
|
| 297 | + // render error page |
|
| 298 | + $template = new OC_Template('', 'update.user', 'guest'); |
|
| 299 | + OC_Util::addScript('dist/maintenance'); |
|
| 300 | + OC_Util::addStyle('core', 'guest'); |
|
| 301 | + $template->printPage(); |
|
| 302 | + die(); |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * Prints the upgrade page |
|
| 308 | + * |
|
| 309 | + * @param \OC\SystemConfig $systemConfig |
|
| 310 | + */ |
|
| 311 | + private static function printUpgradePage(\OC\SystemConfig $systemConfig) { |
|
| 312 | + $disableWebUpdater = $systemConfig->getValue('upgrade.disable-web', false); |
|
| 313 | + $tooBig = false; |
|
| 314 | + if (!$disableWebUpdater) { |
|
| 315 | + $apps = \OC::$server->getAppManager(); |
|
| 316 | + if ($apps->isInstalled('user_ldap')) { |
|
| 317 | + $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); |
|
| 318 | + |
|
| 319 | + $result = $qb->select($qb->func()->count('*', 'user_count')) |
|
| 320 | + ->from('ldap_user_mapping') |
|
| 321 | + ->execute(); |
|
| 322 | + $row = $result->fetch(); |
|
| 323 | + $result->closeCursor(); |
|
| 324 | + |
|
| 325 | + $tooBig = ($row['user_count'] > 50); |
|
| 326 | + } |
|
| 327 | + if (!$tooBig && $apps->isInstalled('user_saml')) { |
|
| 328 | + $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); |
|
| 329 | + |
|
| 330 | + $result = $qb->select($qb->func()->count('*', 'user_count')) |
|
| 331 | + ->from('user_saml_users') |
|
| 332 | + ->execute(); |
|
| 333 | + $row = $result->fetch(); |
|
| 334 | + $result->closeCursor(); |
|
| 335 | + |
|
| 336 | + $tooBig = ($row['user_count'] > 50); |
|
| 337 | + } |
|
| 338 | + if (!$tooBig) { |
|
| 339 | + // count users |
|
| 340 | + $stats = \OC::$server->getUserManager()->countUsers(); |
|
| 341 | + $totalUsers = array_sum($stats); |
|
| 342 | + $tooBig = ($totalUsers > 50); |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | + $ignoreTooBigWarning = isset($_GET['IKnowThatThisIsABigInstanceAndTheUpdateRequestCouldRunIntoATimeoutAndHowToRestoreABackup']) && |
|
| 346 | + $_GET['IKnowThatThisIsABigInstanceAndTheUpdateRequestCouldRunIntoATimeoutAndHowToRestoreABackup'] === 'IAmSuperSureToDoThis'; |
|
| 347 | + |
|
| 348 | + if ($disableWebUpdater || ($tooBig && !$ignoreTooBigWarning)) { |
|
| 349 | + // send http status 503 |
|
| 350 | + http_response_code(503); |
|
| 351 | + header('Retry-After: 120'); |
|
| 352 | + |
|
| 353 | + // render error page |
|
| 354 | + $template = new OC_Template('', 'update.use-cli', 'guest'); |
|
| 355 | + $template->assign('productName', 'nextcloud'); // for now |
|
| 356 | + $template->assign('version', OC_Util::getVersionString()); |
|
| 357 | + $template->assign('tooBig', $tooBig); |
|
| 358 | + |
|
| 359 | + $template->printPage(); |
|
| 360 | + die(); |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + // check whether this is a core update or apps update |
|
| 364 | + $installedVersion = $systemConfig->getValue('version', '0.0.0'); |
|
| 365 | + $currentVersion = implode('.', \OCP\Util::getVersion()); |
|
| 366 | + |
|
| 367 | + // if not a core upgrade, then it's apps upgrade |
|
| 368 | + $isAppsOnlyUpgrade = version_compare($currentVersion, $installedVersion, '='); |
|
| 369 | + |
|
| 370 | + $oldTheme = $systemConfig->getValue('theme'); |
|
| 371 | + $systemConfig->setValue('theme', ''); |
|
| 372 | + OC_Util::addScript('config'); // needed for web root |
|
| 373 | + OC_Util::addScript('update'); |
|
| 374 | + |
|
| 375 | + /** @var \OC\App\AppManager $appManager */ |
|
| 376 | + $appManager = \OC::$server->getAppManager(); |
|
| 377 | + |
|
| 378 | + $tmpl = new OC_Template('', 'update.admin', 'guest'); |
|
| 379 | + $tmpl->assign('version', OC_Util::getVersionString()); |
|
| 380 | + $tmpl->assign('isAppsOnlyUpgrade', $isAppsOnlyUpgrade); |
|
| 381 | + |
|
| 382 | + // get third party apps |
|
| 383 | + $ocVersion = \OCP\Util::getVersion(); |
|
| 384 | + $ocVersion = implode('.', $ocVersion); |
|
| 385 | + $incompatibleApps = $appManager->getIncompatibleApps($ocVersion); |
|
| 386 | + $incompatibleShippedApps = []; |
|
| 387 | + foreach ($incompatibleApps as $appInfo) { |
|
| 388 | + if ($appManager->isShipped($appInfo['id'])) { |
|
| 389 | + $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + if (!empty($incompatibleShippedApps)) { |
|
| 394 | + $l = \OC::$server->getL10N('core'); |
|
| 395 | + $hint = $l->t('The files of the app %1$s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]); |
|
| 396 | + 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); |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
|
| 400 | + $tmpl->assign('incompatibleAppsList', $incompatibleApps); |
|
| 401 | + $tmpl->assign('productName', 'Nextcloud'); // for now |
|
| 402 | + $tmpl->assign('oldTheme', $oldTheme); |
|
| 403 | + $tmpl->printPage(); |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + public static function initSession() { |
|
| 407 | + if (self::$server->getRequest()->getServerProtocol() === 'https') { |
|
| 408 | + ini_set('session.cookie_secure', true); |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + // prevents javascript from accessing php session cookies |
|
| 412 | + ini_set('session.cookie_httponly', 'true'); |
|
| 413 | + |
|
| 414 | + // set the cookie path to the Nextcloud directory |
|
| 415 | + $cookie_path = OC::$WEBROOT ? : '/'; |
|
| 416 | + ini_set('session.cookie_path', $cookie_path); |
|
| 417 | + |
|
| 418 | + // Let the session name be changed in the initSession Hook |
|
| 419 | + $sessionName = OC_Util::getInstanceId(); |
|
| 420 | + |
|
| 421 | + try { |
|
| 422 | + // Allow session apps to create a custom session object |
|
| 423 | + $useCustomSession = false; |
|
| 424 | + $session = self::$server->getSession(); |
|
| 425 | + OC_Hook::emit('OC', 'initSession', ['session' => &$session, 'sessionName' => &$sessionName, 'useCustomSession' => &$useCustomSession]); |
|
| 426 | + if (!$useCustomSession) { |
|
| 427 | + // set the session name to the instance id - which is unique |
|
| 428 | + $session = new \OC\Session\Internal($sessionName); |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + $cryptoWrapper = \OC::$server->getSessionCryptoWrapper(); |
|
| 432 | + $session = $cryptoWrapper->wrapSession($session); |
|
| 433 | + self::$server->setSession($session); |
|
| 434 | + |
|
| 435 | + // if session can't be started break with http 500 error |
|
| 436 | + } catch (Exception $e) { |
|
| 437 | + \OC::$server->getLogger()->logException($e, ['app' => 'base']); |
|
| 438 | + //show the user a detailed error page |
|
| 439 | + OC_Template::printExceptionErrorPage($e, 500); |
|
| 440 | + die(); |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + $sessionLifeTime = self::getSessionLifeTime(); |
|
| 444 | + |
|
| 445 | + // session timeout |
|
| 446 | + if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
|
| 447 | + if (isset($_COOKIE[session_name()])) { |
|
| 448 | + setcookie(session_name(), '', -1, self::$WEBROOT ? : '/'); |
|
| 449 | + } |
|
| 450 | + \OC::$server->getUserSession()->logout(); |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + $session->set('LAST_ACTIVITY', time()); |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * @return string |
|
| 458 | + */ |
|
| 459 | + private static function getSessionLifeTime() { |
|
| 460 | + return \OC::$server->getConfig()->getSystemValue('session_lifetime', 60 * 60 * 24); |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + /** |
|
| 464 | + * Try to set some values to the required Nextcloud default |
|
| 465 | + */ |
|
| 466 | + public static function setRequiredIniValues() { |
|
| 467 | + @ini_set('default_charset', 'UTF-8'); |
|
| 468 | + @ini_set('gd.jpeg_ignore_warning', '1'); |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + /** |
|
| 472 | + * Send the same site cookies |
|
| 473 | + */ |
|
| 474 | + private static function sendSameSiteCookies() { |
|
| 475 | + $cookieParams = session_get_cookie_params(); |
|
| 476 | + $secureCookie = ($cookieParams['secure'] === true) ? 'secure; ' : ''; |
|
| 477 | + $policies = [ |
|
| 478 | + 'lax', |
|
| 479 | + 'strict', |
|
| 480 | + ]; |
|
| 481 | + |
|
| 482 | + // Append __Host to the cookie if it meets the requirements |
|
| 483 | + $cookiePrefix = ''; |
|
| 484 | + if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
| 485 | + $cookiePrefix = '__Host-'; |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + foreach ($policies as $policy) { |
|
| 489 | + header( |
|
| 490 | + sprintf( |
|
| 491 | + 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
| 492 | + $cookiePrefix, |
|
| 493 | + $policy, |
|
| 494 | + $cookieParams['path'], |
|
| 495 | + $policy |
|
| 496 | + ), |
|
| 497 | + false |
|
| 498 | + ); |
|
| 499 | + } |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + /** |
|
| 503 | + * Same Site cookie to further mitigate CSRF attacks. This cookie has to |
|
| 504 | + * be set in every request if cookies are sent to add a second level of |
|
| 505 | + * defense against CSRF. |
|
| 506 | + * |
|
| 507 | + * If the cookie is not sent this will set the cookie and reload the page. |
|
| 508 | + * We use an additional cookie since we want to protect logout CSRF and |
|
| 509 | + * also we can't directly interfere with PHP's session mechanism. |
|
| 510 | + */ |
|
| 511 | + private static function performSameSiteCookieProtection() { |
|
| 512 | + $request = \OC::$server->getRequest(); |
|
| 513 | + |
|
| 514 | + // Some user agents are notorious and don't really properly follow HTTP |
|
| 515 | + // specifications. For those, have an automated opt-out. Since the protection |
|
| 516 | + // for remote.php is applied in base.php as starting point we need to opt out |
|
| 517 | + // here. |
|
| 518 | + $incompatibleUserAgents = \OC::$server->getConfig()->getSystemValue('csrf.optout'); |
|
| 519 | + |
|
| 520 | + // Fallback, if csrf.optout is unset |
|
| 521 | + if (!is_array($incompatibleUserAgents)) { |
|
| 522 | + $incompatibleUserAgents = [ |
|
| 523 | + // OS X Finder |
|
| 524 | + '/^WebDAVFS/', |
|
| 525 | + // Windows webdav drive |
|
| 526 | + '/^Microsoft-WebDAV-MiniRedir/', |
|
| 527 | + ]; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + if ($request->isUserAgent($incompatibleUserAgents)) { |
|
| 531 | + return; |
|
| 532 | + } |
|
| 533 | + |
|
| 534 | + if (count($_COOKIE) > 0) { |
|
| 535 | + $requestUri = $request->getScriptName(); |
|
| 536 | + $processingScript = explode('/', $requestUri); |
|
| 537 | + $processingScript = $processingScript[count($processingScript)-1]; |
|
| 538 | + |
|
| 539 | + // index.php routes are handled in the middleware |
|
| 540 | + if ($processingScript === 'index.php') { |
|
| 541 | + return; |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + // All other endpoints require the lax and the strict cookie |
|
| 545 | + if (!$request->passesStrictCookieCheck()) { |
|
| 546 | + self::sendSameSiteCookies(); |
|
| 547 | + // Debug mode gets access to the resources without strict cookie |
|
| 548 | + // due to the fact that the SabreDAV browser also lives there. |
|
| 549 | + if (!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 550 | + http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); |
|
| 551 | + exit(); |
|
| 552 | + } |
|
| 553 | + } |
|
| 554 | + } elseif (!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
| 555 | + self::sendSameSiteCookies(); |
|
| 556 | + } |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + public static function init() { |
|
| 560 | + // calculate the root directories |
|
| 561 | + OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4)); |
|
| 562 | + |
|
| 563 | + // register autoloader |
|
| 564 | + $loaderStart = microtime(true); |
|
| 565 | + require_once __DIR__ . '/autoloader.php'; |
|
| 566 | + self::$loader = new \OC\Autoloader([ |
|
| 567 | + OC::$SERVERROOT . '/lib/private/legacy', |
|
| 568 | + ]); |
|
| 569 | + if (defined('PHPUNIT_RUN')) { |
|
| 570 | + self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
|
| 571 | + } |
|
| 572 | + spl_autoload_register([self::$loader, 'load']); |
|
| 573 | + $loaderEnd = microtime(true); |
|
| 574 | + |
|
| 575 | + self::$CLI = (php_sapi_name() == 'cli'); |
|
| 576 | + |
|
| 577 | + // Add default composer PSR-4 autoloader |
|
| 578 | + self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
|
| 579 | + |
|
| 580 | + try { |
|
| 581 | + self::initPaths(); |
|
| 582 | + // setup 3rdparty autoloader |
|
| 583 | + $vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php'; |
|
| 584 | + if (!file_exists($vendorAutoLoad)) { |
|
| 585 | + 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".'); |
|
| 586 | + } |
|
| 587 | + require_once $vendorAutoLoad; |
|
| 588 | + } catch (\RuntimeException $e) { |
|
| 589 | + if (!self::$CLI) { |
|
| 590 | + http_response_code(503); |
|
| 591 | + } |
|
| 592 | + // we can't use the template error page here, because this needs the |
|
| 593 | + // DI container which isn't available yet |
|
| 594 | + print($e->getMessage()); |
|
| 595 | + exit(); |
|
| 596 | + } |
|
| 597 | + |
|
| 598 | + // setup the basic server |
|
| 599 | + self::$server = new \OC\Server(\OC::$WEBROOT, self::$config); |
|
| 600 | + self::$server->boot(); |
|
| 601 | + \OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd); |
|
| 602 | + \OC::$server->getEventLogger()->start('boot', 'Initialize'); |
|
| 603 | + |
|
| 604 | + // Override php.ini and log everything if we're troubleshooting |
|
| 605 | + if (self::$config->getValue('loglevel') === ILogger::DEBUG) { |
|
| 606 | + error_reporting(E_ALL); |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + // Don't display errors and log them |
|
| 610 | + @ini_set('display_errors', '0'); |
|
| 611 | + @ini_set('log_errors', '1'); |
|
| 612 | + |
|
| 613 | + if (!date_default_timezone_set('UTC')) { |
|
| 614 | + throw new \RuntimeException('Could not set timezone to UTC'); |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + //try to configure php to enable big file uploads. |
|
| 618 | + //this doesn´t work always depending on the webserver and php configuration. |
|
| 619 | + //Let´s try to overwrite some defaults anyway |
|
| 620 | + |
|
| 621 | + //try to set the maximum execution time to 60min |
|
| 622 | + if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
| 623 | + @set_time_limit(3600); |
|
| 624 | + } |
|
| 625 | + @ini_set('max_execution_time', '3600'); |
|
| 626 | + @ini_set('max_input_time', '3600'); |
|
| 627 | + |
|
| 628 | + //try to set the maximum filesize to 10G |
|
| 629 | + @ini_set('upload_max_filesize', '10G'); |
|
| 630 | + @ini_set('post_max_size', '10G'); |
|
| 631 | + @ini_set('file_uploads', '50'); |
|
| 632 | + |
|
| 633 | + self::setRequiredIniValues(); |
|
| 634 | + self::handleAuthHeaders(); |
|
| 635 | + self::registerAutoloaderCache(); |
|
| 636 | + |
|
| 637 | + // initialize intl fallback is necessary |
|
| 638 | + \Patchwork\Utf8\Bootup::initIntl(); |
|
| 639 | + OC_Util::isSetLocaleWorking(); |
|
| 640 | + |
|
| 641 | + if (!defined('PHPUNIT_RUN')) { |
|
| 642 | + OC\Log\ErrorHandler::setLogger(\OC::$server->getLogger()); |
|
| 643 | + $debug = \OC::$server->getConfig()->getSystemValue('debug', false); |
|
| 644 | + OC\Log\ErrorHandler::register($debug); |
|
| 645 | + } |
|
| 646 | + |
|
| 647 | + \OC::$server->getEventLogger()->start('init_session', 'Initialize session'); |
|
| 648 | + OC_App::loadApps(['session']); |
|
| 649 | + if (!self::$CLI) { |
|
| 650 | + self::initSession(); |
|
| 651 | + } |
|
| 652 | + \OC::$server->getEventLogger()->end('init_session'); |
|
| 653 | + self::checkConfig(); |
|
| 654 | + self::checkInstalled(); |
|
| 655 | + |
|
| 656 | + OC_Response::addSecurityHeaders(); |
|
| 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 | + http_response_code(503); |
|
| 665 | + OC_Util::addStyle('guest'); |
|
| 666 | + try { |
|
| 667 | + OC_Template::printGuestPage('', 'error', ['errors' => $errors]); |
|
| 668 | + exit; |
|
| 669 | + } catch (\Exception $e) { |
|
| 670 | + // In case any error happens when showing the error page, we simply fall back to posting the text. |
|
| 671 | + // This might be the case when e.g. the data directory is broken and we can not load/write SCSS to/from it. |
|
| 672 | + } |
|
| 673 | + } |
|
| 674 | + |
|
| 675 | + // Convert l10n string into regular string for usage in database |
|
| 676 | + $staticErrors = []; |
|
| 677 | + foreach ($errors as $error) { |
|
| 678 | + echo $error['error'] . "\n"; |
|
| 679 | + echo $error['hint'] . "\n\n"; |
|
| 680 | + $staticErrors[] = [ |
|
| 681 | + 'error' => (string)$error['error'], |
|
| 682 | + 'hint' => (string)$error['hint'], |
|
| 683 | + ]; |
|
| 684 | + } |
|
| 685 | + |
|
| 686 | + try { |
|
| 687 | + \OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors)); |
|
| 688 | + } catch (\Exception $e) { |
|
| 689 | + echo('Writing to database failed'); |
|
| 690 | + } |
|
| 691 | + exit(1); |
|
| 692 | + } elseif (self::$CLI && \OC::$server->getConfig()->getSystemValue('installed', false)) { |
|
| 693 | + \OC::$server->getConfig()->deleteAppValue('core', 'cronErrors'); |
|
| 694 | + } |
|
| 695 | + } |
|
| 696 | + //try to set the session lifetime |
|
| 697 | + $sessionLifeTime = self::getSessionLifeTime(); |
|
| 698 | + @ini_set('gc_maxlifetime', (string)$sessionLifeTime); |
|
| 699 | + |
|
| 700 | + $systemConfig = \OC::$server->getSystemConfig(); |
|
| 701 | + |
|
| 702 | + // User and Groups |
|
| 703 | + if (!$systemConfig->getValue("installed", false)) { |
|
| 704 | + self::$server->getSession()->set('user_id', ''); |
|
| 705 | + } |
|
| 706 | + |
|
| 707 | + OC_User::useBackend(new \OC\User\Database()); |
|
| 708 | + \OC::$server->getGroupManager()->addBackend(new \OC\Group\Database()); |
|
| 709 | + |
|
| 710 | + // Subscribe to the hook |
|
| 711 | + \OCP\Util::connectHook( |
|
| 712 | + '\OCA\Files_Sharing\API\Server2Server', |
|
| 713 | + 'preLoginNameUsedAsUserName', |
|
| 714 | + '\OC\User\Database', |
|
| 715 | + 'preLoginNameUsedAsUserName' |
|
| 716 | + ); |
|
| 717 | + |
|
| 718 | + //setup extra user backends |
|
| 719 | + if (!\OCP\Util::needUpgrade()) { |
|
| 720 | + OC_User::setupBackends(); |
|
| 721 | + } else { |
|
| 722 | + // Run upgrades in incognito mode |
|
| 723 | + OC_User::setIncognitoMode(true); |
|
| 724 | + } |
|
| 725 | + |
|
| 726 | + self::registerCleanupHooks(); |
|
| 727 | + self::registerFilesystemHooks(); |
|
| 728 | + self::registerShareHooks(); |
|
| 729 | + self::registerEncryptionWrapper(); |
|
| 730 | + self::registerEncryptionHooks(); |
|
| 731 | + self::registerAccountHooks(); |
|
| 732 | + self::registerResourceCollectionHooks(); |
|
| 733 | + self::registerAppRestrictionsHooks(); |
|
| 734 | + |
|
| 735 | + // Make sure that the application class is not loaded before the database is setup |
|
| 736 | + if ($systemConfig->getValue("installed", false)) { |
|
| 737 | + OC_App::loadApp('settings'); |
|
| 738 | + $settings = \OC::$server->query(\OCA\Settings\AppInfo\Application::class); |
|
| 739 | + $settings->register(); |
|
| 740 | + } |
|
| 741 | + |
|
| 742 | + //make sure temporary files are cleaned up |
|
| 743 | + $tmpManager = \OC::$server->getTempManager(); |
|
| 744 | + register_shutdown_function([$tmpManager, 'clean']); |
|
| 745 | + $lockProvider = \OC::$server->getLockingProvider(); |
|
| 746 | + register_shutdown_function([$lockProvider, 'releaseAll']); |
|
| 747 | + |
|
| 748 | + // Check whether the sample configuration has been copied |
|
| 749 | + if ($systemConfig->getValue('copied_sample_config', false)) { |
|
| 750 | + $l = \OC::$server->getL10N('lib'); |
|
| 751 | + OC_Template::printErrorPage( |
|
| 752 | + $l->t('Sample configuration detected'), |
|
| 753 | + $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'), |
|
| 754 | + 503 |
|
| 755 | + ); |
|
| 756 | + return; |
|
| 757 | + } |
|
| 758 | + |
|
| 759 | + $request = \OC::$server->getRequest(); |
|
| 760 | + $host = $request->getInsecureServerHost(); |
|
| 761 | + /** |
|
| 762 | + * if the host passed in headers isn't trusted |
|
| 763 | + * FIXME: Should not be in here at all :see_no_evil: |
|
| 764 | + */ |
|
| 765 | + if (!OC::$CLI |
|
| 766 | + && !\OC::$server->getTrustedDomainHelper()->isTrustedDomain($host) |
|
| 767 | + && self::$server->getConfig()->getSystemValue('installed', false) |
|
| 768 | + ) { |
|
| 769 | + // Allow access to CSS resources |
|
| 770 | + $isScssRequest = false; |
|
| 771 | + if (strpos($request->getPathInfo(), '/css/') === 0) { |
|
| 772 | + $isScssRequest = true; |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + if (substr($request->getRequestUri(), -11) === '/status.php') { |
|
| 776 | + http_response_code(400); |
|
| 777 | + header('Content-Type: application/json'); |
|
| 778 | + echo '{"error": "Trusted domain error.", "code": 15}'; |
|
| 779 | + exit(); |
|
| 780 | + } |
|
| 781 | + |
|
| 782 | + if (!$isScssRequest) { |
|
| 783 | + http_response_code(400); |
|
| 784 | + |
|
| 785 | + \OC::$server->getLogger()->info( |
|
| 786 | + 'Trusted domain error. "{remoteAddress}" tried to access using "{host}" as host.', |
|
| 787 | + [ |
|
| 788 | + 'app' => 'core', |
|
| 789 | + 'remoteAddress' => $request->getRemoteAddress(), |
|
| 790 | + 'host' => $host, |
|
| 791 | + ] |
|
| 792 | + ); |
|
| 793 | + |
|
| 794 | + $tmpl = new OCP\Template('core', 'untrustedDomain', 'guest'); |
|
| 795 | + $tmpl->assign('docUrl', \OC::$server->getURLGenerator()->linkToDocs('admin-trusted-domains')); |
|
| 796 | + $tmpl->printPage(); |
|
| 797 | + |
|
| 798 | + exit(); |
|
| 799 | + } |
|
| 800 | + } |
|
| 801 | + \OC::$server->getEventLogger()->end('boot'); |
|
| 802 | + } |
|
| 803 | + |
|
| 804 | + /** |
|
| 805 | + * register hooks for the cleanup of cache and bruteforce protection |
|
| 806 | + */ |
|
| 807 | + public static function registerCleanupHooks() { |
|
| 808 | + //don't try to do this before we are properly setup |
|
| 809 | + if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) { |
|
| 810 | + |
|
| 811 | + // NOTE: This will be replaced to use OCP |
|
| 812 | + $userSession = self::$server->getUserSession(); |
|
| 813 | + $userSession->listen('\OC\User', 'postLogin', function () use ($userSession) { |
|
| 814 | + if (!defined('PHPUNIT_RUN') && $userSession->isLoggedIn()) { |
|
| 815 | + // reset brute force delay for this IP address and username |
|
| 816 | + $uid = \OC::$server->getUserSession()->getUser()->getUID(); |
|
| 817 | + $request = \OC::$server->getRequest(); |
|
| 818 | + $throttler = \OC::$server->getBruteForceThrottler(); |
|
| 819 | + $throttler->resetDelay($request->getRemoteAddress(), 'login', ['user' => $uid]); |
|
| 820 | + } |
|
| 821 | + |
|
| 822 | + try { |
|
| 823 | + $cache = new \OC\Cache\File(); |
|
| 824 | + $cache->gc(); |
|
| 825 | + } catch (\OC\ServerNotAvailableException $e) { |
|
| 826 | + // not a GC exception, pass it on |
|
| 827 | + throw $e; |
|
| 828 | + } catch (\OC\ForbiddenException $e) { |
|
| 829 | + // filesystem blocked for this request, ignore |
|
| 830 | + } catch (\Exception $e) { |
|
| 831 | + // a GC exception should not prevent users from using OC, |
|
| 832 | + // so log the exception |
|
| 833 | + \OC::$server->getLogger()->logException($e, [ |
|
| 834 | + 'message' => 'Exception when running cache gc.', |
|
| 835 | + 'level' => ILogger::WARN, |
|
| 836 | + 'app' => 'core', |
|
| 837 | + ]); |
|
| 838 | + } |
|
| 839 | + }); |
|
| 840 | + } |
|
| 841 | + } |
|
| 842 | + |
|
| 843 | + private static function registerEncryptionWrapper() { |
|
| 844 | + $manager = self::$server->getEncryptionManager(); |
|
| 845 | + \OCP\Util::connectHook('OC_Filesystem', 'preSetup', $manager, 'setupStorage'); |
|
| 846 | + } |
|
| 847 | + |
|
| 848 | + private static function registerEncryptionHooks() { |
|
| 849 | + $enabled = self::$server->getEncryptionManager()->isEnabled(); |
|
| 850 | + if ($enabled) { |
|
| 851 | + \OCP\Util::connectHook(Share::class, 'post_shared', HookManager::class, 'postShared'); |
|
| 852 | + \OCP\Util::connectHook(Share::class, 'post_unshare', HookManager::class, 'postUnshared'); |
|
| 853 | + \OCP\Util::connectHook('OC_Filesystem', 'post_rename', HookManager::class, 'postRename'); |
|
| 854 | + \OCP\Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', HookManager::class, 'postRestore'); |
|
| 855 | + } |
|
| 856 | + } |
|
| 857 | + |
|
| 858 | + private static function registerAccountHooks() { |
|
| 859 | + $hookHandler = new \OC\Accounts\Hooks(\OC::$server->getLogger()); |
|
| 860 | + \OCP\Util::connectHook('OC_User', 'changeUser', $hookHandler, 'changeUserHook'); |
|
| 861 | + } |
|
| 862 | + |
|
| 863 | + private static function registerAppRestrictionsHooks() { |
|
| 864 | + $groupManager = self::$server->query(\OCP\IGroupManager::class); |
|
| 865 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OCP\IGroup $group) { |
|
| 866 | + $appManager = self::$server->getAppManager(); |
|
| 867 | + $apps = $appManager->getEnabledAppsForGroup($group); |
|
| 868 | + foreach ($apps as $appId) { |
|
| 869 | + $restrictions = $appManager->getAppRestriction($appId); |
|
| 870 | + if (empty($restrictions)) { |
|
| 871 | + continue; |
|
| 872 | + } |
|
| 873 | + $key = array_search($group->getGID(), $restrictions); |
|
| 874 | + unset($restrictions[$key]); |
|
| 875 | + $restrictions = array_values($restrictions); |
|
| 876 | + if (empty($restrictions)) { |
|
| 877 | + $appManager->disableApp($appId); |
|
| 878 | + } else { |
|
| 879 | + $appManager->enableAppForGroups($appId, $restrictions); |
|
| 880 | + } |
|
| 881 | + } |
|
| 882 | + }); |
|
| 883 | + } |
|
| 884 | + |
|
| 885 | + private static function registerResourceCollectionHooks() { |
|
| 886 | + \OC\Collaboration\Resources\Listener::register(\OC::$server->getEventDispatcher()); |
|
| 887 | + } |
|
| 888 | + |
|
| 889 | + /** |
|
| 890 | + * register hooks for the filesystem |
|
| 891 | + */ |
|
| 892 | + public static function registerFilesystemHooks() { |
|
| 893 | + // Check for blacklisted files |
|
| 894 | + OC_Hook::connect('OC_Filesystem', 'write', Filesystem::class, 'isBlacklisted'); |
|
| 895 | + OC_Hook::connect('OC_Filesystem', 'rename', Filesystem::class, 'isBlacklisted'); |
|
| 896 | + } |
|
| 897 | + |
|
| 898 | + /** |
|
| 899 | + * register hooks for sharing |
|
| 900 | + */ |
|
| 901 | + public static function registerShareHooks() { |
|
| 902 | + if (\OC::$server->getSystemConfig()->getValue('installed')) { |
|
| 903 | + OC_Hook::connect('OC_User', 'post_deleteUser', Hooks::class, 'post_deleteUser'); |
|
| 904 | + OC_Hook::connect('OC_User', 'post_removeFromGroup', Hooks::class, 'post_removeFromGroup'); |
|
| 905 | + OC_Hook::connect('OC_User', 'post_deleteGroup', Hooks::class, 'post_deleteGroup'); |
|
| 906 | + } |
|
| 907 | + } |
|
| 908 | + |
|
| 909 | + protected static function registerAutoloaderCache() { |
|
| 910 | + // The class loader takes an optional low-latency cache, which MUST be |
|
| 911 | + // namespaced. The instanceid is used for namespacing, but might be |
|
| 912 | + // unavailable at this point. Furthermore, it might not be possible to |
|
| 913 | + // generate an instanceid via \OC_Util::getInstanceId() because the |
|
| 914 | + // config file may not be writable. As such, we only register a class |
|
| 915 | + // loader cache if instanceid is available without trying to create one. |
|
| 916 | + $instanceId = \OC::$server->getSystemConfig()->getValue('instanceid', null); |
|
| 917 | + if ($instanceId) { |
|
| 918 | + try { |
|
| 919 | + $memcacheFactory = \OC::$server->getMemCacheFactory(); |
|
| 920 | + self::$loader->setMemoryCache($memcacheFactory->createLocal('Autoloader')); |
|
| 921 | + } catch (\Exception $ex) { |
|
| 922 | + } |
|
| 923 | + } |
|
| 924 | + } |
|
| 925 | + |
|
| 926 | + /** |
|
| 927 | + * Handle the request |
|
| 928 | + */ |
|
| 929 | + public static function handleRequest() { |
|
| 930 | + \OC::$server->getEventLogger()->start('handle_request', 'Handle request'); |
|
| 931 | + $systemConfig = \OC::$server->getSystemConfig(); |
|
| 932 | + |
|
| 933 | + // Check if Nextcloud is installed or in maintenance (update) mode |
|
| 934 | + if (!$systemConfig->getValue('installed', false)) { |
|
| 935 | + \OC::$server->getSession()->clear(); |
|
| 936 | + $setupHelper = new OC\Setup( |
|
| 937 | + $systemConfig, |
|
| 938 | + \OC::$server->getIniWrapper(), |
|
| 939 | + \OC::$server->getL10N('lib'), |
|
| 940 | + \OC::$server->query(\OCP\Defaults::class), |
|
| 941 | + \OC::$server->getLogger(), |
|
| 942 | + \OC::$server->getSecureRandom(), |
|
| 943 | + \OC::$server->query(\OC\Installer::class) |
|
| 944 | + ); |
|
| 945 | + $controller = new OC\Core\Controller\SetupController($setupHelper); |
|
| 946 | + $controller->run($_POST); |
|
| 947 | + exit(); |
|
| 948 | + } |
|
| 949 | + |
|
| 950 | + $request = \OC::$server->getRequest(); |
|
| 951 | + $requestPath = $request->getRawPathInfo(); |
|
| 952 | + if ($requestPath === '/heartbeat') { |
|
| 953 | + return; |
|
| 954 | + } |
|
| 955 | + if (substr($requestPath, -3) !== '.js') { // we need these files during the upgrade |
|
| 956 | + self::checkMaintenanceMode(); |
|
| 957 | + |
|
| 958 | + if (\OCP\Util::needUpgrade()) { |
|
| 959 | + if (function_exists('opcache_reset')) { |
|
| 960 | + opcache_reset(); |
|
| 961 | + } |
|
| 962 | + if (!((bool) $systemConfig->getValue('maintenance', false))) { |
|
| 963 | + self::printUpgradePage($systemConfig); |
|
| 964 | + exit(); |
|
| 965 | + } |
|
| 966 | + } |
|
| 967 | + } |
|
| 968 | + |
|
| 969 | + // emergency app disabling |
|
| 970 | + if ($requestPath === '/disableapp' |
|
| 971 | + && $request->getMethod() === 'POST' |
|
| 972 | + && ((array)$request->getParam('appid')) !== '' |
|
| 973 | + ) { |
|
| 974 | + \OC_JSON::callCheck(); |
|
| 975 | + \OC_JSON::checkAdminUser(); |
|
| 976 | + $appIds = (array)$request->getParam('appid'); |
|
| 977 | + foreach ($appIds as $appId) { |
|
| 978 | + $appId = \OC_App::cleanAppId($appId); |
|
| 979 | + \OC::$server->getAppManager()->disableApp($appId); |
|
| 980 | + } |
|
| 981 | + \OC_JSON::success(); |
|
| 982 | + exit(); |
|
| 983 | + } |
|
| 984 | + |
|
| 985 | + // Always load authentication apps |
|
| 986 | + OC_App::loadApps(['authentication']); |
|
| 987 | + |
|
| 988 | + // Load minimum set of apps |
|
| 989 | + if (!\OCP\Util::needUpgrade() |
|
| 990 | + && !((bool) $systemConfig->getValue('maintenance', false))) { |
|
| 991 | + // For logged-in users: Load everything |
|
| 992 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 993 | + OC_App::loadApps(); |
|
| 994 | + } else { |
|
| 995 | + // For guests: Load only filesystem and logging |
|
| 996 | + OC_App::loadApps(['filesystem', 'logging']); |
|
| 997 | + self::handleLogin($request); |
|
| 998 | + } |
|
| 999 | + } |
|
| 1000 | + |
|
| 1001 | + if (!self::$CLI) { |
|
| 1002 | + try { |
|
| 1003 | + if (!((bool) $systemConfig->getValue('maintenance', false)) && !\OCP\Util::needUpgrade()) { |
|
| 1004 | + OC_App::loadApps(['filesystem', 'logging']); |
|
| 1005 | + OC_App::loadApps(); |
|
| 1006 | + } |
|
| 1007 | + OC_Util::setupFS(); |
|
| 1008 | + OC::$server->getRouter()->match(\OC::$server->getRequest()->getRawPathInfo()); |
|
| 1009 | + return; |
|
| 1010 | + } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) { |
|
| 1011 | + //header('HTTP/1.0 404 Not Found'); |
|
| 1012 | + } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) { |
|
| 1013 | + http_response_code(405); |
|
| 1014 | + return; |
|
| 1015 | + } |
|
| 1016 | + } |
|
| 1017 | + |
|
| 1018 | + // Handle WebDAV |
|
| 1019 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PROPFIND') { |
|
| 1020 | + // not allowed any more to prevent people |
|
| 1021 | + // mounting this root directly. |
|
| 1022 | + // Users need to mount remote.php/webdav instead. |
|
| 1023 | + http_response_code(405); |
|
| 1024 | + return; |
|
| 1025 | + } |
|
| 1026 | + |
|
| 1027 | + // Someone is logged in |
|
| 1028 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 1029 | + OC_App::loadApps(); |
|
| 1030 | + OC_User::setupBackends(); |
|
| 1031 | + OC_Util::setupFS(); |
|
| 1032 | + // FIXME |
|
| 1033 | + // Redirect to default application |
|
| 1034 | + OC_Util::redirectToDefaultPage(); |
|
| 1035 | + } else { |
|
| 1036 | + // Not handled and not logged in |
|
| 1037 | + header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute('core.login.showLoginForm')); |
|
| 1038 | + } |
|
| 1039 | + } |
|
| 1040 | + |
|
| 1041 | + /** |
|
| 1042 | + * Check login: apache auth, auth token, basic auth |
|
| 1043 | + * |
|
| 1044 | + * @param OCP\IRequest $request |
|
| 1045 | + * @return boolean |
|
| 1046 | + */ |
|
| 1047 | + public static function handleLogin(OCP\IRequest $request) { |
|
| 1048 | + $userSession = self::$server->getUserSession(); |
|
| 1049 | + if (OC_User::handleApacheAuth()) { |
|
| 1050 | + return true; |
|
| 1051 | + } |
|
| 1052 | + if ($userSession->tryTokenLogin($request)) { |
|
| 1053 | + return true; |
|
| 1054 | + } |
|
| 1055 | + if (isset($_COOKIE['nc_username']) |
|
| 1056 | + && isset($_COOKIE['nc_token']) |
|
| 1057 | + && isset($_COOKIE['nc_session_id']) |
|
| 1058 | + && $userSession->loginWithCookie($_COOKIE['nc_username'], $_COOKIE['nc_token'], $_COOKIE['nc_session_id'])) { |
|
| 1059 | + return true; |
|
| 1060 | + } |
|
| 1061 | + if ($userSession->tryBasicAuthLogin($request, \OC::$server->getBruteForceThrottler())) { |
|
| 1062 | + return true; |
|
| 1063 | + } |
|
| 1064 | + return false; |
|
| 1065 | + } |
|
| 1066 | + |
|
| 1067 | + protected static function handleAuthHeaders() { |
|
| 1068 | + //copy http auth headers for apache+php-fcgid work around |
|
| 1069 | + if (isset($_SERVER['HTTP_XAUTHORIZATION']) && !isset($_SERVER['HTTP_AUTHORIZATION'])) { |
|
| 1070 | + $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_XAUTHORIZATION']; |
|
| 1071 | + } |
|
| 1072 | + |
|
| 1073 | + // Extract PHP_AUTH_USER/PHP_AUTH_PW from other headers if necessary. |
|
| 1074 | + $vars = [ |
|
| 1075 | + 'HTTP_AUTHORIZATION', // apache+php-cgi work around |
|
| 1076 | + 'REDIRECT_HTTP_AUTHORIZATION', // apache+php-cgi alternative |
|
| 1077 | + ]; |
|
| 1078 | + foreach ($vars as $var) { |
|
| 1079 | + if (isset($_SERVER[$var]) && preg_match('/Basic\s+(.*)$/i', $_SERVER[$var], $matches)) { |
|
| 1080 | + $credentials = explode(':', base64_decode($matches[1]), 2); |
|
| 1081 | + if (count($credentials) === 2) { |
|
| 1082 | + $_SERVER['PHP_AUTH_USER'] = $credentials[0]; |
|
| 1083 | + $_SERVER['PHP_AUTH_PW'] = $credentials[1]; |
|
| 1084 | + break; |
|
| 1085 | + } |
|
| 1086 | + } |
|
| 1087 | + } |
|
| 1088 | + } |
|
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | 1091 | OC::init(); |
@@ -47,202 +47,202 @@ |
||
| 47 | 47 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
| 48 | 48 | |
| 49 | 49 | class HookConnector { |
| 50 | - /** @var IRootFolder */ |
|
| 51 | - private $root; |
|
| 52 | - |
|
| 53 | - /** @var View */ |
|
| 54 | - private $view; |
|
| 55 | - |
|
| 56 | - /** @var FileInfo[] */ |
|
| 57 | - private $deleteMetaCache = []; |
|
| 58 | - |
|
| 59 | - /** @var EventDispatcherInterface */ |
|
| 60 | - private $legacyDispatcher; |
|
| 61 | - |
|
| 62 | - /** @var IEventDispatcher */ |
|
| 63 | - private $dispatcher; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * HookConnector constructor. |
|
| 67 | - * |
|
| 68 | - * @param Root $root |
|
| 69 | - * @param View $view |
|
| 70 | - */ |
|
| 71 | - public function __construct( |
|
| 72 | - IRootFolder $root, |
|
| 73 | - View $view, |
|
| 74 | - EventDispatcherInterface $legacyDispatcher, |
|
| 75 | - IEventDispatcher $dispatcher) { |
|
| 76 | - $this->root = $root; |
|
| 77 | - $this->view = $view; |
|
| 78 | - $this->legacyDispatcher = $legacyDispatcher; |
|
| 79 | - $this->dispatcher = $dispatcher; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - public function viewToNode() { |
|
| 83 | - Util::connectHook('OC_Filesystem', 'write', $this, 'write'); |
|
| 84 | - Util::connectHook('OC_Filesystem', 'post_write', $this, 'postWrite'); |
|
| 85 | - |
|
| 86 | - Util::connectHook('OC_Filesystem', 'create', $this, 'create'); |
|
| 87 | - Util::connectHook('OC_Filesystem', 'post_create', $this, 'postCreate'); |
|
| 88 | - |
|
| 89 | - Util::connectHook('OC_Filesystem', 'delete', $this, 'delete'); |
|
| 90 | - Util::connectHook('OC_Filesystem', 'post_delete', $this, 'postDelete'); |
|
| 91 | - |
|
| 92 | - Util::connectHook('OC_Filesystem', 'rename', $this, 'rename'); |
|
| 93 | - Util::connectHook('OC_Filesystem', 'post_rename', $this, 'postRename'); |
|
| 94 | - |
|
| 95 | - Util::connectHook('OC_Filesystem', 'copy', $this, 'copy'); |
|
| 96 | - Util::connectHook('OC_Filesystem', 'post_copy', $this, 'postCopy'); |
|
| 97 | - |
|
| 98 | - Util::connectHook('OC_Filesystem', 'touch', $this, 'touch'); |
|
| 99 | - Util::connectHook('OC_Filesystem', 'post_touch', $this, 'postTouch'); |
|
| 100 | - |
|
| 101 | - Util::connectHook('OC_Filesystem', 'read', $this, 'read'); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - public function write($arguments) { |
|
| 105 | - $node = $this->getNodeForPath($arguments['path']); |
|
| 106 | - $this->root->emit('\OC\Files', 'preWrite', [$node]); |
|
| 107 | - $this->legacyDispatcher->dispatch('\OCP\Files::preWrite', new GenericEvent($node)); |
|
| 108 | - |
|
| 109 | - $event = new BeforeNodeWrittenEvent($node); |
|
| 110 | - $this->dispatcher->dispatchTyped($event); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - public function postWrite($arguments) { |
|
| 114 | - $node = $this->getNodeForPath($arguments['path']); |
|
| 115 | - $this->root->emit('\OC\Files', 'postWrite', [$node]); |
|
| 116 | - $this->legacyDispatcher->dispatch('\OCP\Files::postWrite', new GenericEvent($node)); |
|
| 117 | - |
|
| 118 | - $event = new NodeWrittenEvent($node); |
|
| 119 | - $this->dispatcher->dispatchTyped($event); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - public function create($arguments) { |
|
| 123 | - $node = $this->getNodeForPath($arguments['path']); |
|
| 124 | - $this->root->emit('\OC\Files', 'preCreate', [$node]); |
|
| 125 | - $this->legacyDispatcher->dispatch('\OCP\Files::preCreate', new GenericEvent($node)); |
|
| 126 | - |
|
| 127 | - $event = new BeforeNodeCreatedEvent($node); |
|
| 128 | - $this->dispatcher->dispatchTyped($event); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - public function postCreate($arguments) { |
|
| 132 | - $node = $this->getNodeForPath($arguments['path']); |
|
| 133 | - $this->root->emit('\OC\Files', 'postCreate', [$node]); |
|
| 134 | - $this->legacyDispatcher->dispatch('\OCP\Files::postCreate', new GenericEvent($node)); |
|
| 135 | - |
|
| 136 | - $event = new NodeCreatedEvent($node); |
|
| 137 | - $this->dispatcher->dispatchTyped($event); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - public function delete($arguments) { |
|
| 141 | - $node = $this->getNodeForPath($arguments['path']); |
|
| 142 | - $this->deleteMetaCache[$node->getPath()] = $node->getFileInfo(); |
|
| 143 | - $this->root->emit('\OC\Files', 'preDelete', [$node]); |
|
| 144 | - $this->legacyDispatcher->dispatch('\OCP\Files::preDelete', new GenericEvent($node)); |
|
| 145 | - |
|
| 146 | - $event = new BeforeNodeDeletedEvent($node); |
|
| 147 | - $this->dispatcher->dispatchTyped($event); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - public function postDelete($arguments) { |
|
| 151 | - $node = $this->getNodeForPath($arguments['path']); |
|
| 152 | - unset($this->deleteMetaCache[$node->getPath()]); |
|
| 153 | - $this->root->emit('\OC\Files', 'postDelete', [$node]); |
|
| 154 | - $this->legacyDispatcher->dispatch('\OCP\Files::postDelete', new GenericEvent($node)); |
|
| 155 | - |
|
| 156 | - $event = new NodeDeletedEvent($node); |
|
| 157 | - $this->dispatcher->dispatchTyped($event); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - public function touch($arguments) { |
|
| 161 | - $node = $this->getNodeForPath($arguments['path']); |
|
| 162 | - $this->root->emit('\OC\Files', 'preTouch', [$node]); |
|
| 163 | - $this->legacyDispatcher->dispatch('\OCP\Files::preTouch', new GenericEvent($node)); |
|
| 164 | - |
|
| 165 | - $event = new BeforeNodeTouchedEvent($node); |
|
| 166 | - $this->dispatcher->dispatchTyped($event); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - public function postTouch($arguments) { |
|
| 170 | - $node = $this->getNodeForPath($arguments['path']); |
|
| 171 | - $this->root->emit('\OC\Files', 'postTouch', [$node]); |
|
| 172 | - $this->legacyDispatcher->dispatch('\OCP\Files::postTouch', new GenericEvent($node)); |
|
| 173 | - |
|
| 174 | - $event = new NodeTouchedEvent($node); |
|
| 175 | - $this->dispatcher->dispatchTyped($event); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - public function rename($arguments) { |
|
| 179 | - $source = $this->getNodeForPath($arguments['oldpath']); |
|
| 180 | - $target = $this->getNodeForPath($arguments['newpath']); |
|
| 181 | - $this->root->emit('\OC\Files', 'preRename', [$source, $target]); |
|
| 182 | - $this->legacyDispatcher->dispatch('\OCP\Files::preRename', new GenericEvent([$source, $target])); |
|
| 183 | - |
|
| 184 | - $event = new BeforeNodeRenamedEvent($source, $target); |
|
| 185 | - $this->dispatcher->dispatchTyped($event); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - public function postRename($arguments) { |
|
| 189 | - $source = $this->getNodeForPath($arguments['oldpath']); |
|
| 190 | - $target = $this->getNodeForPath($arguments['newpath']); |
|
| 191 | - $this->root->emit('\OC\Files', 'postRename', [$source, $target]); |
|
| 192 | - $this->legacyDispatcher->dispatch('\OCP\Files::postRename', new GenericEvent([$source, $target])); |
|
| 193 | - |
|
| 194 | - $event = new NodeRenamedEvent($source, $target); |
|
| 195 | - $this->dispatcher->dispatchTyped($event); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - public function copy($arguments) { |
|
| 199 | - $source = $this->getNodeForPath($arguments['oldpath']); |
|
| 200 | - $target = $this->getNodeForPath($arguments['newpath']); |
|
| 201 | - $this->root->emit('\OC\Files', 'preCopy', [$source, $target]); |
|
| 202 | - $this->legacyDispatcher->dispatch('\OCP\Files::preCopy', new GenericEvent([$source, $target])); |
|
| 203 | - |
|
| 204 | - $event = new BeforeNodeCopiedEvent($source, $target); |
|
| 205 | - $this->dispatcher->dispatchTyped($event); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - public function postCopy($arguments) { |
|
| 209 | - $source = $this->getNodeForPath($arguments['oldpath']); |
|
| 210 | - $target = $this->getNodeForPath($arguments['newpath']); |
|
| 211 | - $this->root->emit('\OC\Files', 'postCopy', [$source, $target]); |
|
| 212 | - $this->legacyDispatcher->dispatch('\OCP\Files::postCopy', new GenericEvent([$source, $target])); |
|
| 213 | - |
|
| 214 | - $event = new NodeCopiedEvent($source, $target); |
|
| 215 | - $this->dispatcher->dispatchTyped($event); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - public function read($arguments) { |
|
| 219 | - $node = $this->getNodeForPath($arguments['path']); |
|
| 220 | - $this->root->emit('\OC\Files', 'read', [$node]); |
|
| 221 | - $this->legacyDispatcher->dispatch('\OCP\Files::read', new GenericEvent([$node])); |
|
| 222 | - |
|
| 223 | - $event = new BeforeNodeReadEvent($node); |
|
| 224 | - $this->dispatcher->dispatchTyped($event); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - private function getNodeForPath($path) { |
|
| 228 | - $info = Filesystem::getView()->getFileInfo($path); |
|
| 229 | - if (!$info) { |
|
| 230 | - $fullPath = Filesystem::getView()->getAbsolutePath($path); |
|
| 231 | - if (isset($this->deleteMetaCache[$fullPath])) { |
|
| 232 | - $info = $this->deleteMetaCache[$fullPath]; |
|
| 233 | - } else { |
|
| 234 | - $info = null; |
|
| 235 | - } |
|
| 236 | - if (Filesystem::is_dir($path)) { |
|
| 237 | - return new NonExistingFolder($this->root, $this->view, $fullPath, $info); |
|
| 238 | - } else { |
|
| 239 | - return new NonExistingFile($this->root, $this->view, $fullPath, $info); |
|
| 240 | - } |
|
| 241 | - } |
|
| 242 | - if ($info->getType() === FileInfo::TYPE_FILE) { |
|
| 243 | - return new File($this->root, $this->view, $info->getPath(), $info); |
|
| 244 | - } else { |
|
| 245 | - return new Folder($this->root, $this->view, $info->getPath(), $info); |
|
| 246 | - } |
|
| 247 | - } |
|
| 50 | + /** @var IRootFolder */ |
|
| 51 | + private $root; |
|
| 52 | + |
|
| 53 | + /** @var View */ |
|
| 54 | + private $view; |
|
| 55 | + |
|
| 56 | + /** @var FileInfo[] */ |
|
| 57 | + private $deleteMetaCache = []; |
|
| 58 | + |
|
| 59 | + /** @var EventDispatcherInterface */ |
|
| 60 | + private $legacyDispatcher; |
|
| 61 | + |
|
| 62 | + /** @var IEventDispatcher */ |
|
| 63 | + private $dispatcher; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * HookConnector constructor. |
|
| 67 | + * |
|
| 68 | + * @param Root $root |
|
| 69 | + * @param View $view |
|
| 70 | + */ |
|
| 71 | + public function __construct( |
|
| 72 | + IRootFolder $root, |
|
| 73 | + View $view, |
|
| 74 | + EventDispatcherInterface $legacyDispatcher, |
|
| 75 | + IEventDispatcher $dispatcher) { |
|
| 76 | + $this->root = $root; |
|
| 77 | + $this->view = $view; |
|
| 78 | + $this->legacyDispatcher = $legacyDispatcher; |
|
| 79 | + $this->dispatcher = $dispatcher; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + public function viewToNode() { |
|
| 83 | + Util::connectHook('OC_Filesystem', 'write', $this, 'write'); |
|
| 84 | + Util::connectHook('OC_Filesystem', 'post_write', $this, 'postWrite'); |
|
| 85 | + |
|
| 86 | + Util::connectHook('OC_Filesystem', 'create', $this, 'create'); |
|
| 87 | + Util::connectHook('OC_Filesystem', 'post_create', $this, 'postCreate'); |
|
| 88 | + |
|
| 89 | + Util::connectHook('OC_Filesystem', 'delete', $this, 'delete'); |
|
| 90 | + Util::connectHook('OC_Filesystem', 'post_delete', $this, 'postDelete'); |
|
| 91 | + |
|
| 92 | + Util::connectHook('OC_Filesystem', 'rename', $this, 'rename'); |
|
| 93 | + Util::connectHook('OC_Filesystem', 'post_rename', $this, 'postRename'); |
|
| 94 | + |
|
| 95 | + Util::connectHook('OC_Filesystem', 'copy', $this, 'copy'); |
|
| 96 | + Util::connectHook('OC_Filesystem', 'post_copy', $this, 'postCopy'); |
|
| 97 | + |
|
| 98 | + Util::connectHook('OC_Filesystem', 'touch', $this, 'touch'); |
|
| 99 | + Util::connectHook('OC_Filesystem', 'post_touch', $this, 'postTouch'); |
|
| 100 | + |
|
| 101 | + Util::connectHook('OC_Filesystem', 'read', $this, 'read'); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + public function write($arguments) { |
|
| 105 | + $node = $this->getNodeForPath($arguments['path']); |
|
| 106 | + $this->root->emit('\OC\Files', 'preWrite', [$node]); |
|
| 107 | + $this->legacyDispatcher->dispatch('\OCP\Files::preWrite', new GenericEvent($node)); |
|
| 108 | + |
|
| 109 | + $event = new BeforeNodeWrittenEvent($node); |
|
| 110 | + $this->dispatcher->dispatchTyped($event); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + public function postWrite($arguments) { |
|
| 114 | + $node = $this->getNodeForPath($arguments['path']); |
|
| 115 | + $this->root->emit('\OC\Files', 'postWrite', [$node]); |
|
| 116 | + $this->legacyDispatcher->dispatch('\OCP\Files::postWrite', new GenericEvent($node)); |
|
| 117 | + |
|
| 118 | + $event = new NodeWrittenEvent($node); |
|
| 119 | + $this->dispatcher->dispatchTyped($event); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + public function create($arguments) { |
|
| 123 | + $node = $this->getNodeForPath($arguments['path']); |
|
| 124 | + $this->root->emit('\OC\Files', 'preCreate', [$node]); |
|
| 125 | + $this->legacyDispatcher->dispatch('\OCP\Files::preCreate', new GenericEvent($node)); |
|
| 126 | + |
|
| 127 | + $event = new BeforeNodeCreatedEvent($node); |
|
| 128 | + $this->dispatcher->dispatchTyped($event); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + public function postCreate($arguments) { |
|
| 132 | + $node = $this->getNodeForPath($arguments['path']); |
|
| 133 | + $this->root->emit('\OC\Files', 'postCreate', [$node]); |
|
| 134 | + $this->legacyDispatcher->dispatch('\OCP\Files::postCreate', new GenericEvent($node)); |
|
| 135 | + |
|
| 136 | + $event = new NodeCreatedEvent($node); |
|
| 137 | + $this->dispatcher->dispatchTyped($event); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + public function delete($arguments) { |
|
| 141 | + $node = $this->getNodeForPath($arguments['path']); |
|
| 142 | + $this->deleteMetaCache[$node->getPath()] = $node->getFileInfo(); |
|
| 143 | + $this->root->emit('\OC\Files', 'preDelete', [$node]); |
|
| 144 | + $this->legacyDispatcher->dispatch('\OCP\Files::preDelete', new GenericEvent($node)); |
|
| 145 | + |
|
| 146 | + $event = new BeforeNodeDeletedEvent($node); |
|
| 147 | + $this->dispatcher->dispatchTyped($event); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + public function postDelete($arguments) { |
|
| 151 | + $node = $this->getNodeForPath($arguments['path']); |
|
| 152 | + unset($this->deleteMetaCache[$node->getPath()]); |
|
| 153 | + $this->root->emit('\OC\Files', 'postDelete', [$node]); |
|
| 154 | + $this->legacyDispatcher->dispatch('\OCP\Files::postDelete', new GenericEvent($node)); |
|
| 155 | + |
|
| 156 | + $event = new NodeDeletedEvent($node); |
|
| 157 | + $this->dispatcher->dispatchTyped($event); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + public function touch($arguments) { |
|
| 161 | + $node = $this->getNodeForPath($arguments['path']); |
|
| 162 | + $this->root->emit('\OC\Files', 'preTouch', [$node]); |
|
| 163 | + $this->legacyDispatcher->dispatch('\OCP\Files::preTouch', new GenericEvent($node)); |
|
| 164 | + |
|
| 165 | + $event = new BeforeNodeTouchedEvent($node); |
|
| 166 | + $this->dispatcher->dispatchTyped($event); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + public function postTouch($arguments) { |
|
| 170 | + $node = $this->getNodeForPath($arguments['path']); |
|
| 171 | + $this->root->emit('\OC\Files', 'postTouch', [$node]); |
|
| 172 | + $this->legacyDispatcher->dispatch('\OCP\Files::postTouch', new GenericEvent($node)); |
|
| 173 | + |
|
| 174 | + $event = new NodeTouchedEvent($node); |
|
| 175 | + $this->dispatcher->dispatchTyped($event); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + public function rename($arguments) { |
|
| 179 | + $source = $this->getNodeForPath($arguments['oldpath']); |
|
| 180 | + $target = $this->getNodeForPath($arguments['newpath']); |
|
| 181 | + $this->root->emit('\OC\Files', 'preRename', [$source, $target]); |
|
| 182 | + $this->legacyDispatcher->dispatch('\OCP\Files::preRename', new GenericEvent([$source, $target])); |
|
| 183 | + |
|
| 184 | + $event = new BeforeNodeRenamedEvent($source, $target); |
|
| 185 | + $this->dispatcher->dispatchTyped($event); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + public function postRename($arguments) { |
|
| 189 | + $source = $this->getNodeForPath($arguments['oldpath']); |
|
| 190 | + $target = $this->getNodeForPath($arguments['newpath']); |
|
| 191 | + $this->root->emit('\OC\Files', 'postRename', [$source, $target]); |
|
| 192 | + $this->legacyDispatcher->dispatch('\OCP\Files::postRename', new GenericEvent([$source, $target])); |
|
| 193 | + |
|
| 194 | + $event = new NodeRenamedEvent($source, $target); |
|
| 195 | + $this->dispatcher->dispatchTyped($event); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + public function copy($arguments) { |
|
| 199 | + $source = $this->getNodeForPath($arguments['oldpath']); |
|
| 200 | + $target = $this->getNodeForPath($arguments['newpath']); |
|
| 201 | + $this->root->emit('\OC\Files', 'preCopy', [$source, $target]); |
|
| 202 | + $this->legacyDispatcher->dispatch('\OCP\Files::preCopy', new GenericEvent([$source, $target])); |
|
| 203 | + |
|
| 204 | + $event = new BeforeNodeCopiedEvent($source, $target); |
|
| 205 | + $this->dispatcher->dispatchTyped($event); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + public function postCopy($arguments) { |
|
| 209 | + $source = $this->getNodeForPath($arguments['oldpath']); |
|
| 210 | + $target = $this->getNodeForPath($arguments['newpath']); |
|
| 211 | + $this->root->emit('\OC\Files', 'postCopy', [$source, $target]); |
|
| 212 | + $this->legacyDispatcher->dispatch('\OCP\Files::postCopy', new GenericEvent([$source, $target])); |
|
| 213 | + |
|
| 214 | + $event = new NodeCopiedEvent($source, $target); |
|
| 215 | + $this->dispatcher->dispatchTyped($event); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + public function read($arguments) { |
|
| 219 | + $node = $this->getNodeForPath($arguments['path']); |
|
| 220 | + $this->root->emit('\OC\Files', 'read', [$node]); |
|
| 221 | + $this->legacyDispatcher->dispatch('\OCP\Files::read', new GenericEvent([$node])); |
|
| 222 | + |
|
| 223 | + $event = new BeforeNodeReadEvent($node); |
|
| 224 | + $this->dispatcher->dispatchTyped($event); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + private function getNodeForPath($path) { |
|
| 228 | + $info = Filesystem::getView()->getFileInfo($path); |
|
| 229 | + if (!$info) { |
|
| 230 | + $fullPath = Filesystem::getView()->getAbsolutePath($path); |
|
| 231 | + if (isset($this->deleteMetaCache[$fullPath])) { |
|
| 232 | + $info = $this->deleteMetaCache[$fullPath]; |
|
| 233 | + } else { |
|
| 234 | + $info = null; |
|
| 235 | + } |
|
| 236 | + if (Filesystem::is_dir($path)) { |
|
| 237 | + return new NonExistingFolder($this->root, $this->view, $fullPath, $info); |
|
| 238 | + } else { |
|
| 239 | + return new NonExistingFile($this->root, $this->view, $fullPath, $info); |
|
| 240 | + } |
|
| 241 | + } |
|
| 242 | + if ($info->getType() === FileInfo::TYPE_FILE) { |
|
| 243 | + return new File($this->root, $this->view, $info->getPath(), $info); |
|
| 244 | + } else { |
|
| 245 | + return new Folder($this->root, $this->view, $info->getPath(), $info); |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | 248 | } |
@@ -242,2022 +242,2022 @@ |
||
| 242 | 242 | * TODO: hookup all manager classes |
| 243 | 243 | */ |
| 244 | 244 | class Server extends ServerContainer implements IServerContainer { |
| 245 | - /** @var string */ |
|
| 246 | - private $webRoot; |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * @param string $webRoot |
|
| 250 | - * @param \OC\Config $config |
|
| 251 | - */ |
|
| 252 | - public function __construct($webRoot, \OC\Config $config) { |
|
| 253 | - parent::__construct(); |
|
| 254 | - $this->webRoot = $webRoot; |
|
| 255 | - |
|
| 256 | - // To find out if we are running from CLI or not |
|
| 257 | - $this->registerParameter('isCLI', \OC::$CLI); |
|
| 258 | - |
|
| 259 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
| 260 | - return $c; |
|
| 261 | - }); |
|
| 262 | - |
|
| 263 | - $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
| 264 | - $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
| 265 | - |
|
| 266 | - $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
| 267 | - $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
| 268 | - |
|
| 269 | - $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
| 270 | - $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
| 271 | - |
|
| 272 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
| 273 | - $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
| 274 | - |
|
| 275 | - $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class); |
|
| 276 | - |
|
| 277 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
| 278 | - |
|
| 279 | - |
|
| 280 | - $this->registerService(IPreview::class, function (Server $c) { |
|
| 281 | - return new PreviewManager( |
|
| 282 | - $c->getConfig(), |
|
| 283 | - $c->getRootFolder(), |
|
| 284 | - new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig(), 'preview'), |
|
| 285 | - $c->getEventDispatcher(), |
|
| 286 | - $c->getGeneratorHelper(), |
|
| 287 | - $c->getSession()->get('user_id') |
|
| 288 | - ); |
|
| 289 | - }); |
|
| 290 | - $this->registerDeprecatedAlias('PreviewManager', IPreview::class); |
|
| 291 | - |
|
| 292 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 293 | - return new \OC\Preview\Watcher( |
|
| 294 | - new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig(), 'preview') |
|
| 295 | - ); |
|
| 296 | - }); |
|
| 297 | - |
|
| 298 | - $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { |
|
| 299 | - $view = new View(); |
|
| 300 | - $util = new Encryption\Util( |
|
| 301 | - $view, |
|
| 302 | - $c->getUserManager(), |
|
| 303 | - $c->getGroupManager(), |
|
| 304 | - $c->getConfig() |
|
| 305 | - ); |
|
| 306 | - return new Encryption\Manager( |
|
| 307 | - $c->getConfig(), |
|
| 308 | - $c->getLogger(), |
|
| 309 | - $c->getL10N('core'), |
|
| 310 | - new View(), |
|
| 311 | - $util, |
|
| 312 | - new ArrayCache() |
|
| 313 | - ); |
|
| 314 | - }); |
|
| 315 | - $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class); |
|
| 316 | - |
|
| 317 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 318 | - $util = new Encryption\Util( |
|
| 319 | - new View(), |
|
| 320 | - $c->getUserManager(), |
|
| 321 | - $c->getGroupManager(), |
|
| 322 | - $c->getConfig() |
|
| 323 | - ); |
|
| 324 | - return new Encryption\File( |
|
| 325 | - $util, |
|
| 326 | - $c->getRootFolder(), |
|
| 327 | - $c->getShareManager() |
|
| 328 | - ); |
|
| 329 | - }); |
|
| 330 | - |
|
| 331 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 332 | - $view = new View(); |
|
| 333 | - $util = new Encryption\Util( |
|
| 334 | - $view, |
|
| 335 | - $c->getUserManager(), |
|
| 336 | - $c->getGroupManager(), |
|
| 337 | - $c->getConfig() |
|
| 338 | - ); |
|
| 339 | - |
|
| 340 | - return new Encryption\Keys\Storage($view, $util); |
|
| 341 | - }); |
|
| 342 | - $this->registerService('TagMapper', function (Server $c) { |
|
| 343 | - return new TagMapper($c->getDatabaseConnection()); |
|
| 344 | - }); |
|
| 345 | - |
|
| 346 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
| 347 | - $tagMapper = $c->query('TagMapper'); |
|
| 348 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
| 349 | - }); |
|
| 350 | - $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class); |
|
| 351 | - |
|
| 352 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 353 | - $config = $c->getConfig(); |
|
| 354 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
| 355 | - return new $factoryClass($this); |
|
| 356 | - }); |
|
| 357 | - $this->registerService(ISystemTagManager::class, function (Server $c) { |
|
| 358 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
| 359 | - }); |
|
| 360 | - $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class); |
|
| 361 | - |
|
| 362 | - $this->registerService(ISystemTagObjectMapper::class, function (Server $c) { |
|
| 363 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
| 364 | - }); |
|
| 365 | - $this->registerService('RootFolder', function (Server $c) { |
|
| 366 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
| 367 | - $view = new View(); |
|
| 368 | - $root = new Root( |
|
| 369 | - $manager, |
|
| 370 | - $view, |
|
| 371 | - null, |
|
| 372 | - $c->getUserMountCache(), |
|
| 373 | - $this->getLogger(), |
|
| 374 | - $this->getUserManager() |
|
| 375 | - ); |
|
| 376 | - |
|
| 377 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
| 378 | - $previewConnector->connectWatcher(); |
|
| 379 | - |
|
| 380 | - return $root; |
|
| 381 | - }); |
|
| 382 | - $this->registerService(HookConnector::class, function (Server $c) { |
|
| 383 | - return new HookConnector( |
|
| 384 | - $c->query(IRootFolder::class), |
|
| 385 | - new View(), |
|
| 386 | - $c->query(\OC\EventDispatcher\SymfonyAdapter::class), |
|
| 387 | - $c->query(IEventDispatcher::class) |
|
| 388 | - ); |
|
| 389 | - }); |
|
| 390 | - |
|
| 391 | - $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class); |
|
| 392 | - |
|
| 393 | - $this->registerService(IRootFolder::class, function (Server $c) { |
|
| 394 | - return new LazyRoot(function () use ($c) { |
|
| 395 | - return $c->query('RootFolder'); |
|
| 396 | - }); |
|
| 397 | - }); |
|
| 398 | - $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class); |
|
| 399 | - |
|
| 400 | - $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class); |
|
| 401 | - $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
| 402 | - |
|
| 403 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 404 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); |
|
| 405 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 406 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]); |
|
| 407 | - |
|
| 408 | - /** @var IEventDispatcher $dispatcher */ |
|
| 409 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 410 | - $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid)); |
|
| 411 | - }); |
|
| 412 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) { |
|
| 413 | - \OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]); |
|
| 414 | - |
|
| 415 | - /** @var IEventDispatcher $dispatcher */ |
|
| 416 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 417 | - $dispatcher->dispatchTyped(new GroupCreatedEvent($group)); |
|
| 418 | - }); |
|
| 419 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 420 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]); |
|
| 421 | - |
|
| 422 | - /** @var IEventDispatcher $dispatcher */ |
|
| 423 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 424 | - $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group)); |
|
| 425 | - }); |
|
| 426 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 427 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]); |
|
| 428 | - |
|
| 429 | - /** @var IEventDispatcher $dispatcher */ |
|
| 430 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 431 | - $dispatcher->dispatchTyped(new GroupDeletedEvent($group)); |
|
| 432 | - }); |
|
| 433 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 434 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]); |
|
| 435 | - |
|
| 436 | - /** @var IEventDispatcher $dispatcher */ |
|
| 437 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 438 | - $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user)); |
|
| 439 | - }); |
|
| 440 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 441 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); |
|
| 442 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
| 443 | - \OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); |
|
| 444 | - |
|
| 445 | - /** @var IEventDispatcher $dispatcher */ |
|
| 446 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 447 | - $dispatcher->dispatchTyped(new UserAddedEvent($group, $user)); |
|
| 448 | - }); |
|
| 449 | - $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 450 | - /** @var IEventDispatcher $dispatcher */ |
|
| 451 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 452 | - $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user)); |
|
| 453 | - }); |
|
| 454 | - $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 455 | - /** @var IEventDispatcher $dispatcher */ |
|
| 456 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 457 | - $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user)); |
|
| 458 | - }); |
|
| 459 | - return $groupManager; |
|
| 460 | - }); |
|
| 461 | - $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class); |
|
| 462 | - |
|
| 463 | - $this->registerService(Store::class, function (Server $c) { |
|
| 464 | - $session = $c->getSession(); |
|
| 465 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 466 | - $tokenProvider = $c->query(IProvider::class); |
|
| 467 | - } else { |
|
| 468 | - $tokenProvider = null; |
|
| 469 | - } |
|
| 470 | - $logger = $c->getLogger(); |
|
| 471 | - return new Store($session, $logger, $tokenProvider); |
|
| 472 | - }); |
|
| 473 | - $this->registerAlias(IStore::class, Store::class); |
|
| 474 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
| 475 | - $dbConnection = $c->getDatabaseConnection(); |
|
| 476 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
| 477 | - }); |
|
| 478 | - $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
|
| 479 | - |
|
| 480 | - $this->registerService(\OC\User\Session::class, function (Server $c) { |
|
| 481 | - $manager = $c->getUserManager(); |
|
| 482 | - $session = new \OC\Session\Memory(''); |
|
| 483 | - $timeFactory = new TimeFactory(); |
|
| 484 | - // Token providers might require a working database. This code |
|
| 485 | - // might however be called when ownCloud is not yet setup. |
|
| 486 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 487 | - $defaultTokenProvider = $c->query(IProvider::class); |
|
| 488 | - } else { |
|
| 489 | - $defaultTokenProvider = null; |
|
| 490 | - } |
|
| 491 | - |
|
| 492 | - $legacyDispatcher = $c->getEventDispatcher(); |
|
| 493 | - |
|
| 494 | - $userSession = new \OC\User\Session( |
|
| 495 | - $manager, |
|
| 496 | - $session, |
|
| 497 | - $timeFactory, |
|
| 498 | - $defaultTokenProvider, |
|
| 499 | - $c->getConfig(), |
|
| 500 | - $c->getSecureRandom(), |
|
| 501 | - $c->getLockdownManager(), |
|
| 502 | - $c->getLogger(), |
|
| 503 | - $c->query(IEventDispatcher::class) |
|
| 504 | - ); |
|
| 505 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 506 | - \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]); |
|
| 507 | - |
|
| 508 | - /** @var IEventDispatcher $dispatcher */ |
|
| 509 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 510 | - $dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password)); |
|
| 511 | - }); |
|
| 512 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 513 | - /** @var $user \OC\User\User */ |
|
| 514 | - \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]); |
|
| 515 | - |
|
| 516 | - /** @var IEventDispatcher $dispatcher */ |
|
| 517 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 518 | - $dispatcher->dispatchTyped(new UserCreatedEvent($user, $password)); |
|
| 519 | - }); |
|
| 520 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) { |
|
| 521 | - /** @var $user \OC\User\User */ |
|
| 522 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]); |
|
| 523 | - $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
| 524 | - |
|
| 525 | - /** @var IEventDispatcher $dispatcher */ |
|
| 526 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 527 | - $dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user)); |
|
| 528 | - }); |
|
| 529 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 530 | - /** @var $user \OC\User\User */ |
|
| 531 | - \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]); |
|
| 532 | - |
|
| 533 | - /** @var IEventDispatcher $dispatcher */ |
|
| 534 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 535 | - $dispatcher->dispatchTyped(new UserDeletedEvent($user)); |
|
| 536 | - }); |
|
| 537 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 538 | - /** @var $user \OC\User\User */ |
|
| 539 | - \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); |
|
| 540 | - |
|
| 541 | - /** @var IEventDispatcher $dispatcher */ |
|
| 542 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 543 | - $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword)); |
|
| 544 | - }); |
|
| 545 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 546 | - /** @var $user \OC\User\User */ |
|
| 547 | - \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); |
|
| 548 | - |
|
| 549 | - /** @var IEventDispatcher $dispatcher */ |
|
| 550 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 551 | - $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword)); |
|
| 552 | - }); |
|
| 553 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 554 | - \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]); |
|
| 555 | - |
|
| 556 | - /** @var IEventDispatcher $dispatcher */ |
|
| 557 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 558 | - $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password)); |
|
| 559 | - }); |
|
| 560 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { |
|
| 561 | - /** @var $user \OC\User\User */ |
|
| 562 | - \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin]); |
|
| 563 | - |
|
| 564 | - /** @var IEventDispatcher $dispatcher */ |
|
| 565 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 566 | - $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin)); |
|
| 567 | - }); |
|
| 568 | - $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) { |
|
| 569 | - /** @var IEventDispatcher $dispatcher */ |
|
| 570 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 571 | - $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid)); |
|
| 572 | - }); |
|
| 573 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
| 574 | - /** @var $user \OC\User\User */ |
|
| 575 | - \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]); |
|
| 576 | - |
|
| 577 | - /** @var IEventDispatcher $dispatcher */ |
|
| 578 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 579 | - $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password)); |
|
| 580 | - }); |
|
| 581 | - $userSession->listen('\OC\User', 'logout', function ($user) { |
|
| 582 | - \OC_Hook::emit('OC_User', 'logout', []); |
|
| 583 | - |
|
| 584 | - /** @var IEventDispatcher $dispatcher */ |
|
| 585 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 586 | - $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user)); |
|
| 587 | - }); |
|
| 588 | - $userSession->listen('\OC\User', 'postLogout', function ($user) { |
|
| 589 | - /** @var IEventDispatcher $dispatcher */ |
|
| 590 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 591 | - $dispatcher->dispatchTyped(new UserLoggedOutEvent($user)); |
|
| 592 | - }); |
|
| 593 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
| 594 | - /** @var $user \OC\User\User */ |
|
| 595 | - \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]); |
|
| 596 | - |
|
| 597 | - /** @var IEventDispatcher $dispatcher */ |
|
| 598 | - $dispatcher = $this->query(IEventDispatcher::class); |
|
| 599 | - $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue)); |
|
| 600 | - }); |
|
| 601 | - return $userSession; |
|
| 602 | - }); |
|
| 603 | - $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class); |
|
| 604 | - $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class); |
|
| 605 | - |
|
| 606 | - $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); |
|
| 607 | - |
|
| 608 | - $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class); |
|
| 609 | - $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class); |
|
| 610 | - |
|
| 611 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
| 612 | - return new \OC\AllConfig( |
|
| 613 | - $c->getSystemConfig() |
|
| 614 | - ); |
|
| 615 | - }); |
|
| 616 | - $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class); |
|
| 617 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
| 618 | - |
|
| 619 | - $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) { |
|
| 620 | - return new \OC\SystemConfig($config); |
|
| 621 | - }); |
|
| 622 | - $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class); |
|
| 623 | - |
|
| 624 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
| 625 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
| 626 | - }); |
|
| 627 | - $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class); |
|
| 628 | - $this->registerAlias(IAppConfig::class, \OC\AppConfig::class); |
|
| 629 | - |
|
| 630 | - $this->registerService(IFactory::class, function (Server $c) { |
|
| 631 | - return new \OC\L10N\Factory( |
|
| 632 | - $c->getConfig(), |
|
| 633 | - $c->getRequest(), |
|
| 634 | - $c->getUserSession(), |
|
| 635 | - \OC::$SERVERROOT |
|
| 636 | - ); |
|
| 637 | - }); |
|
| 638 | - $this->registerDeprecatedAlias('L10NFactory', IFactory::class); |
|
| 639 | - |
|
| 640 | - $this->registerService(IURLGenerator::class, function (Server $c) { |
|
| 641 | - $config = $c->getConfig(); |
|
| 642 | - $cacheFactory = $c->getMemCacheFactory(); |
|
| 643 | - $request = $c->getRequest(); |
|
| 644 | - return new \OC\URLGenerator( |
|
| 645 | - $config, |
|
| 646 | - $cacheFactory, |
|
| 647 | - $request |
|
| 648 | - ); |
|
| 649 | - }); |
|
| 650 | - $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class); |
|
| 651 | - |
|
| 652 | - $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class); |
|
| 653 | - $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class); |
|
| 654 | - |
|
| 655 | - $this->registerService(ICache::class, function ($c) { |
|
| 656 | - return new Cache\File(); |
|
| 657 | - }); |
|
| 658 | - $this->registerDeprecatedAlias('UserCache', ICache::class); |
|
| 659 | - |
|
| 660 | - $this->registerService(Factory::class, function (Server $c) { |
|
| 661 | - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
| 662 | - ArrayCache::class, |
|
| 663 | - ArrayCache::class, |
|
| 664 | - ArrayCache::class |
|
| 665 | - ); |
|
| 666 | - $config = $c->getConfig(); |
|
| 667 | - |
|
| 668 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 669 | - $v = \OC_App::getAppVersions(); |
|
| 670 | - $v['core'] = implode(',', \OC_Util::getVersion()); |
|
| 671 | - $version = implode(',', $v); |
|
| 672 | - $instanceId = \OC_Util::getInstanceId(); |
|
| 673 | - $path = \OC::$SERVERROOT; |
|
| 674 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
| 675 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
| 676 | - $config->getSystemValue('memcache.local', null), |
|
| 677 | - $config->getSystemValue('memcache.distributed', null), |
|
| 678 | - $config->getSystemValue('memcache.locking', null) |
|
| 679 | - ); |
|
| 680 | - } |
|
| 681 | - return $arrayCacheFactory; |
|
| 682 | - }); |
|
| 683 | - $this->registerDeprecatedAlias('MemCacheFactory', Factory::class); |
|
| 684 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
| 685 | - |
|
| 686 | - $this->registerService('RedisFactory', function (Server $c) { |
|
| 687 | - $systemConfig = $c->getSystemConfig(); |
|
| 688 | - return new RedisFactory($systemConfig); |
|
| 689 | - }); |
|
| 690 | - |
|
| 691 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 692 | - return new \OC\Activity\Manager( |
|
| 693 | - $c->getRequest(), |
|
| 694 | - $c->getUserSession(), |
|
| 695 | - $c->getConfig(), |
|
| 696 | - $c->query(IValidator::class) |
|
| 697 | - ); |
|
| 698 | - }); |
|
| 699 | - $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
| 700 | - |
|
| 701 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 702 | - return new \OC\Activity\EventMerger( |
|
| 703 | - $c->getL10N('lib') |
|
| 704 | - ); |
|
| 705 | - }); |
|
| 706 | - $this->registerAlias(IValidator::class, Validator::class); |
|
| 707 | - |
|
| 708 | - $this->registerService(AvatarManager::class, function (Server $c) { |
|
| 709 | - return new AvatarManager( |
|
| 710 | - $c->query(\OC\User\Manager::class), |
|
| 711 | - $c->getAppDataDir('avatar'), |
|
| 712 | - $c->getL10N('lib'), |
|
| 713 | - $c->getLogger(), |
|
| 714 | - $c->getConfig() |
|
| 715 | - ); |
|
| 716 | - }); |
|
| 717 | - $this->registerAlias(IAvatarManager::class, AvatarManager::class); |
|
| 718 | - $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class); |
|
| 719 | - |
|
| 720 | - $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
| 721 | - $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class); |
|
| 722 | - |
|
| 723 | - $this->registerService(\OC\Log::class, function (Server $c) { |
|
| 724 | - $logType = $c->query(AllConfig::class)->getSystemValue('log_type', 'file'); |
|
| 725 | - $factory = new LogFactory($c, $this->getSystemConfig()); |
|
| 726 | - $logger = $factory->get($logType); |
|
| 727 | - $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
| 728 | - |
|
| 729 | - return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
| 730 | - }); |
|
| 731 | - $this->registerAlias(ILogger::class, \OC\Log::class); |
|
| 732 | - $this->registerDeprecatedAlias('Logger', \OC\Log::class); |
|
| 733 | - // PSR-3 logger |
|
| 734 | - $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class); |
|
| 735 | - |
|
| 736 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
| 737 | - return new LogFactory($c, $this->getSystemConfig()); |
|
| 738 | - }); |
|
| 739 | - |
|
| 740 | - $this->registerService(IJobList::class, function (Server $c) { |
|
| 741 | - $config = $c->getConfig(); |
|
| 742 | - return new \OC\BackgroundJob\JobList( |
|
| 743 | - $c->getDatabaseConnection(), |
|
| 744 | - $config, |
|
| 745 | - new TimeFactory() |
|
| 746 | - ); |
|
| 747 | - }); |
|
| 748 | - $this->registerDeprecatedAlias('JobList', IJobList::class); |
|
| 749 | - |
|
| 750 | - $this->registerService(IRouter::class, function (Server $c) { |
|
| 751 | - $cacheFactory = $c->getMemCacheFactory(); |
|
| 752 | - $logger = $c->getLogger(); |
|
| 753 | - if ($cacheFactory->isLocalCacheAvailable()) { |
|
| 754 | - $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
| 755 | - } else { |
|
| 756 | - $router = new \OC\Route\Router($logger); |
|
| 757 | - } |
|
| 758 | - return $router; |
|
| 759 | - }); |
|
| 760 | - $this->registerDeprecatedAlias('Router', IRouter::class); |
|
| 761 | - |
|
| 762 | - $this->registerService(ISearch::class, function ($c) { |
|
| 763 | - return new Search(); |
|
| 764 | - }); |
|
| 765 | - $this->registerDeprecatedAlias('Search', ISearch::class); |
|
| 766 | - |
|
| 767 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
| 768 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
| 769 | - $this->getMemCacheFactory(), |
|
| 770 | - new \OC\AppFramework\Utility\TimeFactory() |
|
| 771 | - ); |
|
| 772 | - }); |
|
| 773 | - |
|
| 774 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
| 775 | - return new SecureRandom(); |
|
| 776 | - }); |
|
| 777 | - $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
| 778 | - |
|
| 779 | - $this->registerService(ICrypto::class, function (Server $c) { |
|
| 780 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
| 781 | - }); |
|
| 782 | - $this->registerDeprecatedAlias('Crypto', ICrypto::class); |
|
| 783 | - |
|
| 784 | - $this->registerService(IHasher::class, function (Server $c) { |
|
| 785 | - return new Hasher($c->getConfig()); |
|
| 786 | - }); |
|
| 787 | - $this->registerDeprecatedAlias('Hasher', IHasher::class); |
|
| 788 | - |
|
| 789 | - $this->registerService(ICredentialsManager::class, function (Server $c) { |
|
| 790 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
| 791 | - }); |
|
| 792 | - $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class); |
|
| 793 | - |
|
| 794 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 795 | - $systemConfig = $c->getSystemConfig(); |
|
| 796 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
| 797 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
| 798 | - if (!$factory->isValidType($type)) { |
|
| 799 | - throw new \OC\DatabaseException('Invalid database type'); |
|
| 800 | - } |
|
| 801 | - $connectionParams = $factory->createConnectionParams(); |
|
| 802 | - $connection = $factory->getConnection($type, $connectionParams); |
|
| 803 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
| 804 | - return $connection; |
|
| 805 | - }); |
|
| 806 | - $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class); |
|
| 807 | - |
|
| 808 | - |
|
| 809 | - $this->registerService(IClientService::class, function (Server $c) { |
|
| 810 | - $user = \OC_User::getUser(); |
|
| 811 | - $uid = $user ? $user : null; |
|
| 812 | - return new ClientService( |
|
| 813 | - $c->getConfig(), |
|
| 814 | - $c->getLogger(), |
|
| 815 | - new \OC\Security\CertificateManager( |
|
| 816 | - $uid, |
|
| 817 | - new View(), |
|
| 818 | - $c->getConfig(), |
|
| 819 | - $c->getLogger(), |
|
| 820 | - $c->getSecureRandom() |
|
| 821 | - ) |
|
| 822 | - ); |
|
| 823 | - }); |
|
| 824 | - $this->registerDeprecatedAlias('HttpClientService', IClientService::class); |
|
| 825 | - $this->registerService(IEventLogger::class, function (Server $c) { |
|
| 826 | - $eventLogger = new EventLogger(); |
|
| 827 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 828 | - // In debug mode, module is being activated by default |
|
| 829 | - $eventLogger->activate(); |
|
| 830 | - } |
|
| 831 | - return $eventLogger; |
|
| 832 | - }); |
|
| 833 | - $this->registerDeprecatedAlias('EventLogger', IEventLogger::class); |
|
| 834 | - |
|
| 835 | - $this->registerService(IQueryLogger::class, function (Server $c) { |
|
| 836 | - $queryLogger = new QueryLogger(); |
|
| 837 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 838 | - // In debug mode, module is being activated by default |
|
| 839 | - $queryLogger->activate(); |
|
| 840 | - } |
|
| 841 | - return $queryLogger; |
|
| 842 | - }); |
|
| 843 | - $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class); |
|
| 844 | - |
|
| 845 | - $this->registerService(TempManager::class, function (Server $c) { |
|
| 846 | - return new TempManager( |
|
| 847 | - $c->getLogger(), |
|
| 848 | - $c->getConfig() |
|
| 849 | - ); |
|
| 850 | - }); |
|
| 851 | - $this->registerDeprecatedAlias('TempManager', TempManager::class); |
|
| 852 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
| 853 | - |
|
| 854 | - $this->registerService(AppManager::class, function (Server $c) { |
|
| 855 | - return new \OC\App\AppManager( |
|
| 856 | - $c->getUserSession(), |
|
| 857 | - $c->getConfig(), |
|
| 858 | - $c->query(\OC\AppConfig::class), |
|
| 859 | - $c->getGroupManager(), |
|
| 860 | - $c->getMemCacheFactory(), |
|
| 861 | - $c->getEventDispatcher(), |
|
| 862 | - $c->getLogger() |
|
| 863 | - ); |
|
| 864 | - }); |
|
| 865 | - $this->registerDeprecatedAlias('AppManager', AppManager::class); |
|
| 866 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
| 867 | - |
|
| 868 | - $this->registerService(IDateTimeZone::class, function (Server $c) { |
|
| 869 | - return new DateTimeZone( |
|
| 870 | - $c->getConfig(), |
|
| 871 | - $c->getSession() |
|
| 872 | - ); |
|
| 873 | - }); |
|
| 874 | - $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class); |
|
| 875 | - |
|
| 876 | - $this->registerService(IDateTimeFormatter::class, function (Server $c) { |
|
| 877 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
| 878 | - |
|
| 879 | - return new DateTimeFormatter( |
|
| 880 | - $c->getDateTimeZone()->getTimeZone(), |
|
| 881 | - $c->getL10N('lib', $language) |
|
| 882 | - ); |
|
| 883 | - }); |
|
| 884 | - $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class); |
|
| 885 | - |
|
| 886 | - $this->registerService(IUserMountCache::class, function (Server $c) { |
|
| 887 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
| 888 | - $listener = new UserMountCacheListener($mountCache); |
|
| 889 | - $listener->listen($c->getUserManager()); |
|
| 890 | - return $mountCache; |
|
| 891 | - }); |
|
| 892 | - $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class); |
|
| 893 | - |
|
| 894 | - $this->registerService(IMountProviderCollection::class, function (Server $c) { |
|
| 895 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
| 896 | - $mountCache = $c->query(IUserMountCache::class); |
|
| 897 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
| 898 | - |
|
| 899 | - // builtin providers |
|
| 900 | - |
|
| 901 | - $config = $c->getConfig(); |
|
| 902 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
| 903 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
| 904 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
| 905 | - |
|
| 906 | - return $manager; |
|
| 907 | - }); |
|
| 908 | - $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class); |
|
| 909 | - |
|
| 910 | - $this->registerService('IniWrapper', function ($c) { |
|
| 911 | - return new IniGetWrapper(); |
|
| 912 | - }); |
|
| 913 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 914 | - $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
| 915 | - if ($busClass) { |
|
| 916 | - list($app, $class) = explode('::', $busClass, 2); |
|
| 917 | - if ($c->getAppManager()->isInstalled($app)) { |
|
| 918 | - \OC_App::loadApp($app); |
|
| 919 | - return $c->query($class); |
|
| 920 | - } else { |
|
| 921 | - throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
| 922 | - } |
|
| 923 | - } else { |
|
| 924 | - $jobList = $c->getJobList(); |
|
| 925 | - return new CronBus($jobList); |
|
| 926 | - } |
|
| 927 | - }); |
|
| 928 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
| 929 | - return new TrustedDomainHelper($this->getConfig()); |
|
| 930 | - }); |
|
| 931 | - $this->registerService(Throttler::class, function (Server $c) { |
|
| 932 | - return new Throttler( |
|
| 933 | - $c->getDatabaseConnection(), |
|
| 934 | - new TimeFactory(), |
|
| 935 | - $c->getLogger(), |
|
| 936 | - $c->getConfig() |
|
| 937 | - ); |
|
| 938 | - }); |
|
| 939 | - $this->registerDeprecatedAlias('Throttler', Throttler::class); |
|
| 940 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 941 | - // IConfig and IAppManager requires a working database. This code |
|
| 942 | - // might however be called when ownCloud is not yet setup. |
|
| 943 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 944 | - $config = $c->getConfig(); |
|
| 945 | - $appManager = $c->getAppManager(); |
|
| 946 | - } else { |
|
| 947 | - $config = null; |
|
| 948 | - $appManager = null; |
|
| 949 | - } |
|
| 950 | - |
|
| 951 | - return new Checker( |
|
| 952 | - new EnvironmentHelper(), |
|
| 953 | - new FileAccessHelper(), |
|
| 954 | - new AppLocator(), |
|
| 955 | - $config, |
|
| 956 | - $c->getMemCacheFactory(), |
|
| 957 | - $appManager, |
|
| 958 | - $c->getTempManager(), |
|
| 959 | - $c->getMimeTypeDetector() |
|
| 960 | - ); |
|
| 961 | - }); |
|
| 962 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 963 | - if (isset($this['urlParams'])) { |
|
| 964 | - $urlParams = $this['urlParams']; |
|
| 965 | - } else { |
|
| 966 | - $urlParams = []; |
|
| 967 | - } |
|
| 968 | - |
|
| 969 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
| 970 | - && in_array('fakeinput', stream_get_wrappers()) |
|
| 971 | - ) { |
|
| 972 | - $stream = 'fakeinput://data'; |
|
| 973 | - } else { |
|
| 974 | - $stream = 'php://input'; |
|
| 975 | - } |
|
| 976 | - |
|
| 977 | - return new Request( |
|
| 978 | - [ |
|
| 979 | - 'get' => $_GET, |
|
| 980 | - 'post' => $_POST, |
|
| 981 | - 'files' => $_FILES, |
|
| 982 | - 'server' => $_SERVER, |
|
| 983 | - 'env' => $_ENV, |
|
| 984 | - 'cookies' => $_COOKIE, |
|
| 985 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 986 | - ? $_SERVER['REQUEST_METHOD'] |
|
| 987 | - : '', |
|
| 988 | - 'urlParams' => $urlParams, |
|
| 989 | - ], |
|
| 990 | - $this->getSecureRandom(), |
|
| 991 | - $this->getConfig(), |
|
| 992 | - $this->getCsrfTokenManager(), |
|
| 993 | - $stream |
|
| 994 | - ); |
|
| 995 | - }); |
|
| 996 | - $this->registerDeprecatedAlias('Request', \OCP\IRequest::class); |
|
| 997 | - |
|
| 998 | - $this->registerService(IMailer::class, function (Server $c) { |
|
| 999 | - return new Mailer( |
|
| 1000 | - $c->getConfig(), |
|
| 1001 | - $c->getLogger(), |
|
| 1002 | - $c->query(Defaults::class), |
|
| 1003 | - $c->getURLGenerator(), |
|
| 1004 | - $c->getL10N('lib'), |
|
| 1005 | - $c->query(IEventDispatcher::class), |
|
| 1006 | - $c->getL10NFactory() |
|
| 1007 | - ); |
|
| 1008 | - }); |
|
| 1009 | - $this->registerDeprecatedAlias('Mailer', IMailer::class); |
|
| 1010 | - |
|
| 1011 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
| 1012 | - $config = $c->getConfig(); |
|
| 1013 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
| 1014 | - if (is_null($factoryClass)) { |
|
| 1015 | - throw new \Exception('ldapProviderFactory not set'); |
|
| 1016 | - } |
|
| 1017 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
| 1018 | - $factory = new $factoryClass($this); |
|
| 1019 | - return $factory->getLDAPProvider(); |
|
| 1020 | - }); |
|
| 1021 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
| 1022 | - $ini = $c->getIniWrapper(); |
|
| 1023 | - $config = $c->getConfig(); |
|
| 1024 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
| 1025 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 1026 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
| 1027 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
| 1028 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
| 1029 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
| 1030 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
| 1031 | - } |
|
| 1032 | - return new DBLockingProvider( |
|
| 1033 | - $c->getDatabaseConnection(), |
|
| 1034 | - $c->getLogger(), |
|
| 1035 | - new TimeFactory(), |
|
| 1036 | - $ttl, |
|
| 1037 | - !\OC::$CLI |
|
| 1038 | - ); |
|
| 1039 | - } |
|
| 1040 | - return new NoopLockingProvider(); |
|
| 1041 | - }); |
|
| 1042 | - $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class); |
|
| 1043 | - |
|
| 1044 | - $this->registerService(IMountManager::class, function () { |
|
| 1045 | - return new \OC\Files\Mount\Manager(); |
|
| 1046 | - }); |
|
| 1047 | - $this->registerDeprecatedAlias('MountManager', IMountManager::class); |
|
| 1048 | - |
|
| 1049 | - $this->registerService(IMimeTypeDetector::class, function (Server $c) { |
|
| 1050 | - return new \OC\Files\Type\Detection( |
|
| 1051 | - $c->getURLGenerator(), |
|
| 1052 | - $c->getLogger(), |
|
| 1053 | - \OC::$configDir, |
|
| 1054 | - \OC::$SERVERROOT . '/resources/config/' |
|
| 1055 | - ); |
|
| 1056 | - }); |
|
| 1057 | - $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class); |
|
| 1058 | - |
|
| 1059 | - $this->registerService(IMimeTypeLoader::class, function (Server $c) { |
|
| 1060 | - return new \OC\Files\Type\Loader( |
|
| 1061 | - $c->getDatabaseConnection() |
|
| 1062 | - ); |
|
| 1063 | - }); |
|
| 1064 | - $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class); |
|
| 1065 | - $this->registerService(BundleFetcher::class, function () { |
|
| 1066 | - return new BundleFetcher($this->getL10N('lib')); |
|
| 1067 | - }); |
|
| 1068 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
| 1069 | - return new Manager( |
|
| 1070 | - $c->query(IValidator::class), |
|
| 1071 | - $c->getLogger() |
|
| 1072 | - ); |
|
| 1073 | - }); |
|
| 1074 | - $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
| 1075 | - |
|
| 1076 | - $this->registerService(CapabilitiesManager::class, function (Server $c) { |
|
| 1077 | - $manager = new CapabilitiesManager($c->getLogger()); |
|
| 1078 | - $manager->registerCapability(function () use ($c) { |
|
| 1079 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
| 1080 | - }); |
|
| 1081 | - $manager->registerCapability(function () use ($c) { |
|
| 1082 | - return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
| 1083 | - }); |
|
| 1084 | - return $manager; |
|
| 1085 | - }); |
|
| 1086 | - $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class); |
|
| 1087 | - |
|
| 1088 | - $this->registerService(ICommentsManager::class, function (Server $c) { |
|
| 1089 | - $config = $c->getConfig(); |
|
| 1090 | - $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
| 1091 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
| 1092 | - $factory = new $factoryClass($this); |
|
| 1093 | - $manager = $factory->getManager(); |
|
| 1094 | - |
|
| 1095 | - $manager->registerDisplayNameResolver('user', function ($id) use ($c) { |
|
| 1096 | - $manager = $c->getUserManager(); |
|
| 1097 | - $user = $manager->get($id); |
|
| 1098 | - if (is_null($user)) { |
|
| 1099 | - $l = $c->getL10N('core'); |
|
| 1100 | - $displayName = $l->t('Unknown user'); |
|
| 1101 | - } else { |
|
| 1102 | - $displayName = $user->getDisplayName(); |
|
| 1103 | - } |
|
| 1104 | - return $displayName; |
|
| 1105 | - }); |
|
| 1106 | - |
|
| 1107 | - return $manager; |
|
| 1108 | - }); |
|
| 1109 | - $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class); |
|
| 1110 | - |
|
| 1111 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
| 1112 | - /* |
|
| 245 | + /** @var string */ |
|
| 246 | + private $webRoot; |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * @param string $webRoot |
|
| 250 | + * @param \OC\Config $config |
|
| 251 | + */ |
|
| 252 | + public function __construct($webRoot, \OC\Config $config) { |
|
| 253 | + parent::__construct(); |
|
| 254 | + $this->webRoot = $webRoot; |
|
| 255 | + |
|
| 256 | + // To find out if we are running from CLI or not |
|
| 257 | + $this->registerParameter('isCLI', \OC::$CLI); |
|
| 258 | + |
|
| 259 | + $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
| 260 | + return $c; |
|
| 261 | + }); |
|
| 262 | + |
|
| 263 | + $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
| 264 | + $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
| 265 | + |
|
| 266 | + $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
| 267 | + $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
| 268 | + |
|
| 269 | + $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
| 270 | + $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
| 271 | + |
|
| 272 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
| 273 | + $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
| 274 | + |
|
| 275 | + $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class); |
|
| 276 | + |
|
| 277 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
| 278 | + |
|
| 279 | + |
|
| 280 | + $this->registerService(IPreview::class, function (Server $c) { |
|
| 281 | + return new PreviewManager( |
|
| 282 | + $c->getConfig(), |
|
| 283 | + $c->getRootFolder(), |
|
| 284 | + new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig(), 'preview'), |
|
| 285 | + $c->getEventDispatcher(), |
|
| 286 | + $c->getGeneratorHelper(), |
|
| 287 | + $c->getSession()->get('user_id') |
|
| 288 | + ); |
|
| 289 | + }); |
|
| 290 | + $this->registerDeprecatedAlias('PreviewManager', IPreview::class); |
|
| 291 | + |
|
| 292 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 293 | + return new \OC\Preview\Watcher( |
|
| 294 | + new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig(), 'preview') |
|
| 295 | + ); |
|
| 296 | + }); |
|
| 297 | + |
|
| 298 | + $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { |
|
| 299 | + $view = new View(); |
|
| 300 | + $util = new Encryption\Util( |
|
| 301 | + $view, |
|
| 302 | + $c->getUserManager(), |
|
| 303 | + $c->getGroupManager(), |
|
| 304 | + $c->getConfig() |
|
| 305 | + ); |
|
| 306 | + return new Encryption\Manager( |
|
| 307 | + $c->getConfig(), |
|
| 308 | + $c->getLogger(), |
|
| 309 | + $c->getL10N('core'), |
|
| 310 | + new View(), |
|
| 311 | + $util, |
|
| 312 | + new ArrayCache() |
|
| 313 | + ); |
|
| 314 | + }); |
|
| 315 | + $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class); |
|
| 316 | + |
|
| 317 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 318 | + $util = new Encryption\Util( |
|
| 319 | + new View(), |
|
| 320 | + $c->getUserManager(), |
|
| 321 | + $c->getGroupManager(), |
|
| 322 | + $c->getConfig() |
|
| 323 | + ); |
|
| 324 | + return new Encryption\File( |
|
| 325 | + $util, |
|
| 326 | + $c->getRootFolder(), |
|
| 327 | + $c->getShareManager() |
|
| 328 | + ); |
|
| 329 | + }); |
|
| 330 | + |
|
| 331 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 332 | + $view = new View(); |
|
| 333 | + $util = new Encryption\Util( |
|
| 334 | + $view, |
|
| 335 | + $c->getUserManager(), |
|
| 336 | + $c->getGroupManager(), |
|
| 337 | + $c->getConfig() |
|
| 338 | + ); |
|
| 339 | + |
|
| 340 | + return new Encryption\Keys\Storage($view, $util); |
|
| 341 | + }); |
|
| 342 | + $this->registerService('TagMapper', function (Server $c) { |
|
| 343 | + return new TagMapper($c->getDatabaseConnection()); |
|
| 344 | + }); |
|
| 345 | + |
|
| 346 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
| 347 | + $tagMapper = $c->query('TagMapper'); |
|
| 348 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
| 349 | + }); |
|
| 350 | + $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class); |
|
| 351 | + |
|
| 352 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 353 | + $config = $c->getConfig(); |
|
| 354 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
| 355 | + return new $factoryClass($this); |
|
| 356 | + }); |
|
| 357 | + $this->registerService(ISystemTagManager::class, function (Server $c) { |
|
| 358 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
| 359 | + }); |
|
| 360 | + $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class); |
|
| 361 | + |
|
| 362 | + $this->registerService(ISystemTagObjectMapper::class, function (Server $c) { |
|
| 363 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
| 364 | + }); |
|
| 365 | + $this->registerService('RootFolder', function (Server $c) { |
|
| 366 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
| 367 | + $view = new View(); |
|
| 368 | + $root = new Root( |
|
| 369 | + $manager, |
|
| 370 | + $view, |
|
| 371 | + null, |
|
| 372 | + $c->getUserMountCache(), |
|
| 373 | + $this->getLogger(), |
|
| 374 | + $this->getUserManager() |
|
| 375 | + ); |
|
| 376 | + |
|
| 377 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
| 378 | + $previewConnector->connectWatcher(); |
|
| 379 | + |
|
| 380 | + return $root; |
|
| 381 | + }); |
|
| 382 | + $this->registerService(HookConnector::class, function (Server $c) { |
|
| 383 | + return new HookConnector( |
|
| 384 | + $c->query(IRootFolder::class), |
|
| 385 | + new View(), |
|
| 386 | + $c->query(\OC\EventDispatcher\SymfonyAdapter::class), |
|
| 387 | + $c->query(IEventDispatcher::class) |
|
| 388 | + ); |
|
| 389 | + }); |
|
| 390 | + |
|
| 391 | + $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class); |
|
| 392 | + |
|
| 393 | + $this->registerService(IRootFolder::class, function (Server $c) { |
|
| 394 | + return new LazyRoot(function () use ($c) { |
|
| 395 | + return $c->query('RootFolder'); |
|
| 396 | + }); |
|
| 397 | + }); |
|
| 398 | + $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class); |
|
| 399 | + |
|
| 400 | + $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class); |
|
| 401 | + $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
| 402 | + |
|
| 403 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 404 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); |
|
| 405 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 406 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]); |
|
| 407 | + |
|
| 408 | + /** @var IEventDispatcher $dispatcher */ |
|
| 409 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 410 | + $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid)); |
|
| 411 | + }); |
|
| 412 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) { |
|
| 413 | + \OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]); |
|
| 414 | + |
|
| 415 | + /** @var IEventDispatcher $dispatcher */ |
|
| 416 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 417 | + $dispatcher->dispatchTyped(new GroupCreatedEvent($group)); |
|
| 418 | + }); |
|
| 419 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 420 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]); |
|
| 421 | + |
|
| 422 | + /** @var IEventDispatcher $dispatcher */ |
|
| 423 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 424 | + $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group)); |
|
| 425 | + }); |
|
| 426 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 427 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]); |
|
| 428 | + |
|
| 429 | + /** @var IEventDispatcher $dispatcher */ |
|
| 430 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 431 | + $dispatcher->dispatchTyped(new GroupDeletedEvent($group)); |
|
| 432 | + }); |
|
| 433 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 434 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]); |
|
| 435 | + |
|
| 436 | + /** @var IEventDispatcher $dispatcher */ |
|
| 437 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 438 | + $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user)); |
|
| 439 | + }); |
|
| 440 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 441 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); |
|
| 442 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
| 443 | + \OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); |
|
| 444 | + |
|
| 445 | + /** @var IEventDispatcher $dispatcher */ |
|
| 446 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 447 | + $dispatcher->dispatchTyped(new UserAddedEvent($group, $user)); |
|
| 448 | + }); |
|
| 449 | + $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 450 | + /** @var IEventDispatcher $dispatcher */ |
|
| 451 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 452 | + $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user)); |
|
| 453 | + }); |
|
| 454 | + $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 455 | + /** @var IEventDispatcher $dispatcher */ |
|
| 456 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 457 | + $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user)); |
|
| 458 | + }); |
|
| 459 | + return $groupManager; |
|
| 460 | + }); |
|
| 461 | + $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class); |
|
| 462 | + |
|
| 463 | + $this->registerService(Store::class, function (Server $c) { |
|
| 464 | + $session = $c->getSession(); |
|
| 465 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 466 | + $tokenProvider = $c->query(IProvider::class); |
|
| 467 | + } else { |
|
| 468 | + $tokenProvider = null; |
|
| 469 | + } |
|
| 470 | + $logger = $c->getLogger(); |
|
| 471 | + return new Store($session, $logger, $tokenProvider); |
|
| 472 | + }); |
|
| 473 | + $this->registerAlias(IStore::class, Store::class); |
|
| 474 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
| 475 | + $dbConnection = $c->getDatabaseConnection(); |
|
| 476 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
| 477 | + }); |
|
| 478 | + $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
|
| 479 | + |
|
| 480 | + $this->registerService(\OC\User\Session::class, function (Server $c) { |
|
| 481 | + $manager = $c->getUserManager(); |
|
| 482 | + $session = new \OC\Session\Memory(''); |
|
| 483 | + $timeFactory = new TimeFactory(); |
|
| 484 | + // Token providers might require a working database. This code |
|
| 485 | + // might however be called when ownCloud is not yet setup. |
|
| 486 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 487 | + $defaultTokenProvider = $c->query(IProvider::class); |
|
| 488 | + } else { |
|
| 489 | + $defaultTokenProvider = null; |
|
| 490 | + } |
|
| 491 | + |
|
| 492 | + $legacyDispatcher = $c->getEventDispatcher(); |
|
| 493 | + |
|
| 494 | + $userSession = new \OC\User\Session( |
|
| 495 | + $manager, |
|
| 496 | + $session, |
|
| 497 | + $timeFactory, |
|
| 498 | + $defaultTokenProvider, |
|
| 499 | + $c->getConfig(), |
|
| 500 | + $c->getSecureRandom(), |
|
| 501 | + $c->getLockdownManager(), |
|
| 502 | + $c->getLogger(), |
|
| 503 | + $c->query(IEventDispatcher::class) |
|
| 504 | + ); |
|
| 505 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 506 | + \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]); |
|
| 507 | + |
|
| 508 | + /** @var IEventDispatcher $dispatcher */ |
|
| 509 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 510 | + $dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password)); |
|
| 511 | + }); |
|
| 512 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 513 | + /** @var $user \OC\User\User */ |
|
| 514 | + \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]); |
|
| 515 | + |
|
| 516 | + /** @var IEventDispatcher $dispatcher */ |
|
| 517 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 518 | + $dispatcher->dispatchTyped(new UserCreatedEvent($user, $password)); |
|
| 519 | + }); |
|
| 520 | + $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) { |
|
| 521 | + /** @var $user \OC\User\User */ |
|
| 522 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]); |
|
| 523 | + $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
| 524 | + |
|
| 525 | + /** @var IEventDispatcher $dispatcher */ |
|
| 526 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 527 | + $dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user)); |
|
| 528 | + }); |
|
| 529 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 530 | + /** @var $user \OC\User\User */ |
|
| 531 | + \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]); |
|
| 532 | + |
|
| 533 | + /** @var IEventDispatcher $dispatcher */ |
|
| 534 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 535 | + $dispatcher->dispatchTyped(new UserDeletedEvent($user)); |
|
| 536 | + }); |
|
| 537 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 538 | + /** @var $user \OC\User\User */ |
|
| 539 | + \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); |
|
| 540 | + |
|
| 541 | + /** @var IEventDispatcher $dispatcher */ |
|
| 542 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 543 | + $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword)); |
|
| 544 | + }); |
|
| 545 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 546 | + /** @var $user \OC\User\User */ |
|
| 547 | + \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); |
|
| 548 | + |
|
| 549 | + /** @var IEventDispatcher $dispatcher */ |
|
| 550 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 551 | + $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword)); |
|
| 552 | + }); |
|
| 553 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 554 | + \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]); |
|
| 555 | + |
|
| 556 | + /** @var IEventDispatcher $dispatcher */ |
|
| 557 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 558 | + $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password)); |
|
| 559 | + }); |
|
| 560 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { |
|
| 561 | + /** @var $user \OC\User\User */ |
|
| 562 | + \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin]); |
|
| 563 | + |
|
| 564 | + /** @var IEventDispatcher $dispatcher */ |
|
| 565 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 566 | + $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin)); |
|
| 567 | + }); |
|
| 568 | + $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) { |
|
| 569 | + /** @var IEventDispatcher $dispatcher */ |
|
| 570 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 571 | + $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid)); |
|
| 572 | + }); |
|
| 573 | + $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
| 574 | + /** @var $user \OC\User\User */ |
|
| 575 | + \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]); |
|
| 576 | + |
|
| 577 | + /** @var IEventDispatcher $dispatcher */ |
|
| 578 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 579 | + $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password)); |
|
| 580 | + }); |
|
| 581 | + $userSession->listen('\OC\User', 'logout', function ($user) { |
|
| 582 | + \OC_Hook::emit('OC_User', 'logout', []); |
|
| 583 | + |
|
| 584 | + /** @var IEventDispatcher $dispatcher */ |
|
| 585 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 586 | + $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user)); |
|
| 587 | + }); |
|
| 588 | + $userSession->listen('\OC\User', 'postLogout', function ($user) { |
|
| 589 | + /** @var IEventDispatcher $dispatcher */ |
|
| 590 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 591 | + $dispatcher->dispatchTyped(new UserLoggedOutEvent($user)); |
|
| 592 | + }); |
|
| 593 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
| 594 | + /** @var $user \OC\User\User */ |
|
| 595 | + \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]); |
|
| 596 | + |
|
| 597 | + /** @var IEventDispatcher $dispatcher */ |
|
| 598 | + $dispatcher = $this->query(IEventDispatcher::class); |
|
| 599 | + $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue)); |
|
| 600 | + }); |
|
| 601 | + return $userSession; |
|
| 602 | + }); |
|
| 603 | + $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class); |
|
| 604 | + $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class); |
|
| 605 | + |
|
| 606 | + $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); |
|
| 607 | + |
|
| 608 | + $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class); |
|
| 609 | + $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class); |
|
| 610 | + |
|
| 611 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
| 612 | + return new \OC\AllConfig( |
|
| 613 | + $c->getSystemConfig() |
|
| 614 | + ); |
|
| 615 | + }); |
|
| 616 | + $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class); |
|
| 617 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
| 618 | + |
|
| 619 | + $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) { |
|
| 620 | + return new \OC\SystemConfig($config); |
|
| 621 | + }); |
|
| 622 | + $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class); |
|
| 623 | + |
|
| 624 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
| 625 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
| 626 | + }); |
|
| 627 | + $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class); |
|
| 628 | + $this->registerAlias(IAppConfig::class, \OC\AppConfig::class); |
|
| 629 | + |
|
| 630 | + $this->registerService(IFactory::class, function (Server $c) { |
|
| 631 | + return new \OC\L10N\Factory( |
|
| 632 | + $c->getConfig(), |
|
| 633 | + $c->getRequest(), |
|
| 634 | + $c->getUserSession(), |
|
| 635 | + \OC::$SERVERROOT |
|
| 636 | + ); |
|
| 637 | + }); |
|
| 638 | + $this->registerDeprecatedAlias('L10NFactory', IFactory::class); |
|
| 639 | + |
|
| 640 | + $this->registerService(IURLGenerator::class, function (Server $c) { |
|
| 641 | + $config = $c->getConfig(); |
|
| 642 | + $cacheFactory = $c->getMemCacheFactory(); |
|
| 643 | + $request = $c->getRequest(); |
|
| 644 | + return new \OC\URLGenerator( |
|
| 645 | + $config, |
|
| 646 | + $cacheFactory, |
|
| 647 | + $request |
|
| 648 | + ); |
|
| 649 | + }); |
|
| 650 | + $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class); |
|
| 651 | + |
|
| 652 | + $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class); |
|
| 653 | + $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class); |
|
| 654 | + |
|
| 655 | + $this->registerService(ICache::class, function ($c) { |
|
| 656 | + return new Cache\File(); |
|
| 657 | + }); |
|
| 658 | + $this->registerDeprecatedAlias('UserCache', ICache::class); |
|
| 659 | + |
|
| 660 | + $this->registerService(Factory::class, function (Server $c) { |
|
| 661 | + $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
| 662 | + ArrayCache::class, |
|
| 663 | + ArrayCache::class, |
|
| 664 | + ArrayCache::class |
|
| 665 | + ); |
|
| 666 | + $config = $c->getConfig(); |
|
| 667 | + |
|
| 668 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 669 | + $v = \OC_App::getAppVersions(); |
|
| 670 | + $v['core'] = implode(',', \OC_Util::getVersion()); |
|
| 671 | + $version = implode(',', $v); |
|
| 672 | + $instanceId = \OC_Util::getInstanceId(); |
|
| 673 | + $path = \OC::$SERVERROOT; |
|
| 674 | + $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
| 675 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
| 676 | + $config->getSystemValue('memcache.local', null), |
|
| 677 | + $config->getSystemValue('memcache.distributed', null), |
|
| 678 | + $config->getSystemValue('memcache.locking', null) |
|
| 679 | + ); |
|
| 680 | + } |
|
| 681 | + return $arrayCacheFactory; |
|
| 682 | + }); |
|
| 683 | + $this->registerDeprecatedAlias('MemCacheFactory', Factory::class); |
|
| 684 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
| 685 | + |
|
| 686 | + $this->registerService('RedisFactory', function (Server $c) { |
|
| 687 | + $systemConfig = $c->getSystemConfig(); |
|
| 688 | + return new RedisFactory($systemConfig); |
|
| 689 | + }); |
|
| 690 | + |
|
| 691 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 692 | + return new \OC\Activity\Manager( |
|
| 693 | + $c->getRequest(), |
|
| 694 | + $c->getUserSession(), |
|
| 695 | + $c->getConfig(), |
|
| 696 | + $c->query(IValidator::class) |
|
| 697 | + ); |
|
| 698 | + }); |
|
| 699 | + $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
| 700 | + |
|
| 701 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 702 | + return new \OC\Activity\EventMerger( |
|
| 703 | + $c->getL10N('lib') |
|
| 704 | + ); |
|
| 705 | + }); |
|
| 706 | + $this->registerAlias(IValidator::class, Validator::class); |
|
| 707 | + |
|
| 708 | + $this->registerService(AvatarManager::class, function (Server $c) { |
|
| 709 | + return new AvatarManager( |
|
| 710 | + $c->query(\OC\User\Manager::class), |
|
| 711 | + $c->getAppDataDir('avatar'), |
|
| 712 | + $c->getL10N('lib'), |
|
| 713 | + $c->getLogger(), |
|
| 714 | + $c->getConfig() |
|
| 715 | + ); |
|
| 716 | + }); |
|
| 717 | + $this->registerAlias(IAvatarManager::class, AvatarManager::class); |
|
| 718 | + $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class); |
|
| 719 | + |
|
| 720 | + $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
| 721 | + $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class); |
|
| 722 | + |
|
| 723 | + $this->registerService(\OC\Log::class, function (Server $c) { |
|
| 724 | + $logType = $c->query(AllConfig::class)->getSystemValue('log_type', 'file'); |
|
| 725 | + $factory = new LogFactory($c, $this->getSystemConfig()); |
|
| 726 | + $logger = $factory->get($logType); |
|
| 727 | + $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
| 728 | + |
|
| 729 | + return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
| 730 | + }); |
|
| 731 | + $this->registerAlias(ILogger::class, \OC\Log::class); |
|
| 732 | + $this->registerDeprecatedAlias('Logger', \OC\Log::class); |
|
| 733 | + // PSR-3 logger |
|
| 734 | + $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class); |
|
| 735 | + |
|
| 736 | + $this->registerService(ILogFactory::class, function (Server $c) { |
|
| 737 | + return new LogFactory($c, $this->getSystemConfig()); |
|
| 738 | + }); |
|
| 739 | + |
|
| 740 | + $this->registerService(IJobList::class, function (Server $c) { |
|
| 741 | + $config = $c->getConfig(); |
|
| 742 | + return new \OC\BackgroundJob\JobList( |
|
| 743 | + $c->getDatabaseConnection(), |
|
| 744 | + $config, |
|
| 745 | + new TimeFactory() |
|
| 746 | + ); |
|
| 747 | + }); |
|
| 748 | + $this->registerDeprecatedAlias('JobList', IJobList::class); |
|
| 749 | + |
|
| 750 | + $this->registerService(IRouter::class, function (Server $c) { |
|
| 751 | + $cacheFactory = $c->getMemCacheFactory(); |
|
| 752 | + $logger = $c->getLogger(); |
|
| 753 | + if ($cacheFactory->isLocalCacheAvailable()) { |
|
| 754 | + $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
| 755 | + } else { |
|
| 756 | + $router = new \OC\Route\Router($logger); |
|
| 757 | + } |
|
| 758 | + return $router; |
|
| 759 | + }); |
|
| 760 | + $this->registerDeprecatedAlias('Router', IRouter::class); |
|
| 761 | + |
|
| 762 | + $this->registerService(ISearch::class, function ($c) { |
|
| 763 | + return new Search(); |
|
| 764 | + }); |
|
| 765 | + $this->registerDeprecatedAlias('Search', ISearch::class); |
|
| 766 | + |
|
| 767 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
| 768 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
| 769 | + $this->getMemCacheFactory(), |
|
| 770 | + new \OC\AppFramework\Utility\TimeFactory() |
|
| 771 | + ); |
|
| 772 | + }); |
|
| 773 | + |
|
| 774 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
| 775 | + return new SecureRandom(); |
|
| 776 | + }); |
|
| 777 | + $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
| 778 | + |
|
| 779 | + $this->registerService(ICrypto::class, function (Server $c) { |
|
| 780 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
| 781 | + }); |
|
| 782 | + $this->registerDeprecatedAlias('Crypto', ICrypto::class); |
|
| 783 | + |
|
| 784 | + $this->registerService(IHasher::class, function (Server $c) { |
|
| 785 | + return new Hasher($c->getConfig()); |
|
| 786 | + }); |
|
| 787 | + $this->registerDeprecatedAlias('Hasher', IHasher::class); |
|
| 788 | + |
|
| 789 | + $this->registerService(ICredentialsManager::class, function (Server $c) { |
|
| 790 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
| 791 | + }); |
|
| 792 | + $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class); |
|
| 793 | + |
|
| 794 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 795 | + $systemConfig = $c->getSystemConfig(); |
|
| 796 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
| 797 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
| 798 | + if (!$factory->isValidType($type)) { |
|
| 799 | + throw new \OC\DatabaseException('Invalid database type'); |
|
| 800 | + } |
|
| 801 | + $connectionParams = $factory->createConnectionParams(); |
|
| 802 | + $connection = $factory->getConnection($type, $connectionParams); |
|
| 803 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
| 804 | + return $connection; |
|
| 805 | + }); |
|
| 806 | + $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class); |
|
| 807 | + |
|
| 808 | + |
|
| 809 | + $this->registerService(IClientService::class, function (Server $c) { |
|
| 810 | + $user = \OC_User::getUser(); |
|
| 811 | + $uid = $user ? $user : null; |
|
| 812 | + return new ClientService( |
|
| 813 | + $c->getConfig(), |
|
| 814 | + $c->getLogger(), |
|
| 815 | + new \OC\Security\CertificateManager( |
|
| 816 | + $uid, |
|
| 817 | + new View(), |
|
| 818 | + $c->getConfig(), |
|
| 819 | + $c->getLogger(), |
|
| 820 | + $c->getSecureRandom() |
|
| 821 | + ) |
|
| 822 | + ); |
|
| 823 | + }); |
|
| 824 | + $this->registerDeprecatedAlias('HttpClientService', IClientService::class); |
|
| 825 | + $this->registerService(IEventLogger::class, function (Server $c) { |
|
| 826 | + $eventLogger = new EventLogger(); |
|
| 827 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 828 | + // In debug mode, module is being activated by default |
|
| 829 | + $eventLogger->activate(); |
|
| 830 | + } |
|
| 831 | + return $eventLogger; |
|
| 832 | + }); |
|
| 833 | + $this->registerDeprecatedAlias('EventLogger', IEventLogger::class); |
|
| 834 | + |
|
| 835 | + $this->registerService(IQueryLogger::class, function (Server $c) { |
|
| 836 | + $queryLogger = new QueryLogger(); |
|
| 837 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 838 | + // In debug mode, module is being activated by default |
|
| 839 | + $queryLogger->activate(); |
|
| 840 | + } |
|
| 841 | + return $queryLogger; |
|
| 842 | + }); |
|
| 843 | + $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class); |
|
| 844 | + |
|
| 845 | + $this->registerService(TempManager::class, function (Server $c) { |
|
| 846 | + return new TempManager( |
|
| 847 | + $c->getLogger(), |
|
| 848 | + $c->getConfig() |
|
| 849 | + ); |
|
| 850 | + }); |
|
| 851 | + $this->registerDeprecatedAlias('TempManager', TempManager::class); |
|
| 852 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
| 853 | + |
|
| 854 | + $this->registerService(AppManager::class, function (Server $c) { |
|
| 855 | + return new \OC\App\AppManager( |
|
| 856 | + $c->getUserSession(), |
|
| 857 | + $c->getConfig(), |
|
| 858 | + $c->query(\OC\AppConfig::class), |
|
| 859 | + $c->getGroupManager(), |
|
| 860 | + $c->getMemCacheFactory(), |
|
| 861 | + $c->getEventDispatcher(), |
|
| 862 | + $c->getLogger() |
|
| 863 | + ); |
|
| 864 | + }); |
|
| 865 | + $this->registerDeprecatedAlias('AppManager', AppManager::class); |
|
| 866 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
| 867 | + |
|
| 868 | + $this->registerService(IDateTimeZone::class, function (Server $c) { |
|
| 869 | + return new DateTimeZone( |
|
| 870 | + $c->getConfig(), |
|
| 871 | + $c->getSession() |
|
| 872 | + ); |
|
| 873 | + }); |
|
| 874 | + $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class); |
|
| 875 | + |
|
| 876 | + $this->registerService(IDateTimeFormatter::class, function (Server $c) { |
|
| 877 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
| 878 | + |
|
| 879 | + return new DateTimeFormatter( |
|
| 880 | + $c->getDateTimeZone()->getTimeZone(), |
|
| 881 | + $c->getL10N('lib', $language) |
|
| 882 | + ); |
|
| 883 | + }); |
|
| 884 | + $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class); |
|
| 885 | + |
|
| 886 | + $this->registerService(IUserMountCache::class, function (Server $c) { |
|
| 887 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
| 888 | + $listener = new UserMountCacheListener($mountCache); |
|
| 889 | + $listener->listen($c->getUserManager()); |
|
| 890 | + return $mountCache; |
|
| 891 | + }); |
|
| 892 | + $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class); |
|
| 893 | + |
|
| 894 | + $this->registerService(IMountProviderCollection::class, function (Server $c) { |
|
| 895 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
| 896 | + $mountCache = $c->query(IUserMountCache::class); |
|
| 897 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
| 898 | + |
|
| 899 | + // builtin providers |
|
| 900 | + |
|
| 901 | + $config = $c->getConfig(); |
|
| 902 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
| 903 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
| 904 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
| 905 | + |
|
| 906 | + return $manager; |
|
| 907 | + }); |
|
| 908 | + $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class); |
|
| 909 | + |
|
| 910 | + $this->registerService('IniWrapper', function ($c) { |
|
| 911 | + return new IniGetWrapper(); |
|
| 912 | + }); |
|
| 913 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 914 | + $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
| 915 | + if ($busClass) { |
|
| 916 | + list($app, $class) = explode('::', $busClass, 2); |
|
| 917 | + if ($c->getAppManager()->isInstalled($app)) { |
|
| 918 | + \OC_App::loadApp($app); |
|
| 919 | + return $c->query($class); |
|
| 920 | + } else { |
|
| 921 | + throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
| 922 | + } |
|
| 923 | + } else { |
|
| 924 | + $jobList = $c->getJobList(); |
|
| 925 | + return new CronBus($jobList); |
|
| 926 | + } |
|
| 927 | + }); |
|
| 928 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
| 929 | + return new TrustedDomainHelper($this->getConfig()); |
|
| 930 | + }); |
|
| 931 | + $this->registerService(Throttler::class, function (Server $c) { |
|
| 932 | + return new Throttler( |
|
| 933 | + $c->getDatabaseConnection(), |
|
| 934 | + new TimeFactory(), |
|
| 935 | + $c->getLogger(), |
|
| 936 | + $c->getConfig() |
|
| 937 | + ); |
|
| 938 | + }); |
|
| 939 | + $this->registerDeprecatedAlias('Throttler', Throttler::class); |
|
| 940 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 941 | + // IConfig and IAppManager requires a working database. This code |
|
| 942 | + // might however be called when ownCloud is not yet setup. |
|
| 943 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 944 | + $config = $c->getConfig(); |
|
| 945 | + $appManager = $c->getAppManager(); |
|
| 946 | + } else { |
|
| 947 | + $config = null; |
|
| 948 | + $appManager = null; |
|
| 949 | + } |
|
| 950 | + |
|
| 951 | + return new Checker( |
|
| 952 | + new EnvironmentHelper(), |
|
| 953 | + new FileAccessHelper(), |
|
| 954 | + new AppLocator(), |
|
| 955 | + $config, |
|
| 956 | + $c->getMemCacheFactory(), |
|
| 957 | + $appManager, |
|
| 958 | + $c->getTempManager(), |
|
| 959 | + $c->getMimeTypeDetector() |
|
| 960 | + ); |
|
| 961 | + }); |
|
| 962 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 963 | + if (isset($this['urlParams'])) { |
|
| 964 | + $urlParams = $this['urlParams']; |
|
| 965 | + } else { |
|
| 966 | + $urlParams = []; |
|
| 967 | + } |
|
| 968 | + |
|
| 969 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
| 970 | + && in_array('fakeinput', stream_get_wrappers()) |
|
| 971 | + ) { |
|
| 972 | + $stream = 'fakeinput://data'; |
|
| 973 | + } else { |
|
| 974 | + $stream = 'php://input'; |
|
| 975 | + } |
|
| 976 | + |
|
| 977 | + return new Request( |
|
| 978 | + [ |
|
| 979 | + 'get' => $_GET, |
|
| 980 | + 'post' => $_POST, |
|
| 981 | + 'files' => $_FILES, |
|
| 982 | + 'server' => $_SERVER, |
|
| 983 | + 'env' => $_ENV, |
|
| 984 | + 'cookies' => $_COOKIE, |
|
| 985 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 986 | + ? $_SERVER['REQUEST_METHOD'] |
|
| 987 | + : '', |
|
| 988 | + 'urlParams' => $urlParams, |
|
| 989 | + ], |
|
| 990 | + $this->getSecureRandom(), |
|
| 991 | + $this->getConfig(), |
|
| 992 | + $this->getCsrfTokenManager(), |
|
| 993 | + $stream |
|
| 994 | + ); |
|
| 995 | + }); |
|
| 996 | + $this->registerDeprecatedAlias('Request', \OCP\IRequest::class); |
|
| 997 | + |
|
| 998 | + $this->registerService(IMailer::class, function (Server $c) { |
|
| 999 | + return new Mailer( |
|
| 1000 | + $c->getConfig(), |
|
| 1001 | + $c->getLogger(), |
|
| 1002 | + $c->query(Defaults::class), |
|
| 1003 | + $c->getURLGenerator(), |
|
| 1004 | + $c->getL10N('lib'), |
|
| 1005 | + $c->query(IEventDispatcher::class), |
|
| 1006 | + $c->getL10NFactory() |
|
| 1007 | + ); |
|
| 1008 | + }); |
|
| 1009 | + $this->registerDeprecatedAlias('Mailer', IMailer::class); |
|
| 1010 | + |
|
| 1011 | + $this->registerService('LDAPProvider', function (Server $c) { |
|
| 1012 | + $config = $c->getConfig(); |
|
| 1013 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
| 1014 | + if (is_null($factoryClass)) { |
|
| 1015 | + throw new \Exception('ldapProviderFactory not set'); |
|
| 1016 | + } |
|
| 1017 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
| 1018 | + $factory = new $factoryClass($this); |
|
| 1019 | + return $factory->getLDAPProvider(); |
|
| 1020 | + }); |
|
| 1021 | + $this->registerService(ILockingProvider::class, function (Server $c) { |
|
| 1022 | + $ini = $c->getIniWrapper(); |
|
| 1023 | + $config = $c->getConfig(); |
|
| 1024 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
| 1025 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 1026 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
| 1027 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
| 1028 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
| 1029 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
| 1030 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
| 1031 | + } |
|
| 1032 | + return new DBLockingProvider( |
|
| 1033 | + $c->getDatabaseConnection(), |
|
| 1034 | + $c->getLogger(), |
|
| 1035 | + new TimeFactory(), |
|
| 1036 | + $ttl, |
|
| 1037 | + !\OC::$CLI |
|
| 1038 | + ); |
|
| 1039 | + } |
|
| 1040 | + return new NoopLockingProvider(); |
|
| 1041 | + }); |
|
| 1042 | + $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class); |
|
| 1043 | + |
|
| 1044 | + $this->registerService(IMountManager::class, function () { |
|
| 1045 | + return new \OC\Files\Mount\Manager(); |
|
| 1046 | + }); |
|
| 1047 | + $this->registerDeprecatedAlias('MountManager', IMountManager::class); |
|
| 1048 | + |
|
| 1049 | + $this->registerService(IMimeTypeDetector::class, function (Server $c) { |
|
| 1050 | + return new \OC\Files\Type\Detection( |
|
| 1051 | + $c->getURLGenerator(), |
|
| 1052 | + $c->getLogger(), |
|
| 1053 | + \OC::$configDir, |
|
| 1054 | + \OC::$SERVERROOT . '/resources/config/' |
|
| 1055 | + ); |
|
| 1056 | + }); |
|
| 1057 | + $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class); |
|
| 1058 | + |
|
| 1059 | + $this->registerService(IMimeTypeLoader::class, function (Server $c) { |
|
| 1060 | + return new \OC\Files\Type\Loader( |
|
| 1061 | + $c->getDatabaseConnection() |
|
| 1062 | + ); |
|
| 1063 | + }); |
|
| 1064 | + $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class); |
|
| 1065 | + $this->registerService(BundleFetcher::class, function () { |
|
| 1066 | + return new BundleFetcher($this->getL10N('lib')); |
|
| 1067 | + }); |
|
| 1068 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
| 1069 | + return new Manager( |
|
| 1070 | + $c->query(IValidator::class), |
|
| 1071 | + $c->getLogger() |
|
| 1072 | + ); |
|
| 1073 | + }); |
|
| 1074 | + $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
| 1075 | + |
|
| 1076 | + $this->registerService(CapabilitiesManager::class, function (Server $c) { |
|
| 1077 | + $manager = new CapabilitiesManager($c->getLogger()); |
|
| 1078 | + $manager->registerCapability(function () use ($c) { |
|
| 1079 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
| 1080 | + }); |
|
| 1081 | + $manager->registerCapability(function () use ($c) { |
|
| 1082 | + return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
| 1083 | + }); |
|
| 1084 | + return $manager; |
|
| 1085 | + }); |
|
| 1086 | + $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class); |
|
| 1087 | + |
|
| 1088 | + $this->registerService(ICommentsManager::class, function (Server $c) { |
|
| 1089 | + $config = $c->getConfig(); |
|
| 1090 | + $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
| 1091 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
| 1092 | + $factory = new $factoryClass($this); |
|
| 1093 | + $manager = $factory->getManager(); |
|
| 1094 | + |
|
| 1095 | + $manager->registerDisplayNameResolver('user', function ($id) use ($c) { |
|
| 1096 | + $manager = $c->getUserManager(); |
|
| 1097 | + $user = $manager->get($id); |
|
| 1098 | + if (is_null($user)) { |
|
| 1099 | + $l = $c->getL10N('core'); |
|
| 1100 | + $displayName = $l->t('Unknown user'); |
|
| 1101 | + } else { |
|
| 1102 | + $displayName = $user->getDisplayName(); |
|
| 1103 | + } |
|
| 1104 | + return $displayName; |
|
| 1105 | + }); |
|
| 1106 | + |
|
| 1107 | + return $manager; |
|
| 1108 | + }); |
|
| 1109 | + $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class); |
|
| 1110 | + |
|
| 1111 | + $this->registerService('ThemingDefaults', function (Server $c) { |
|
| 1112 | + /* |
|
| 1113 | 1113 | * Dark magic for autoloader. |
| 1114 | 1114 | * If we do a class_exists it will try to load the class which will |
| 1115 | 1115 | * make composer cache the result. Resulting in errors when enabling |
| 1116 | 1116 | * the theming app. |
| 1117 | 1117 | */ |
| 1118 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
| 1119 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
| 1120 | - $classExists = true; |
|
| 1121 | - } else { |
|
| 1122 | - $classExists = false; |
|
| 1123 | - } |
|
| 1124 | - |
|
| 1125 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
| 1126 | - return new ThemingDefaults( |
|
| 1127 | - $c->getConfig(), |
|
| 1128 | - $c->getL10N('theming'), |
|
| 1129 | - $c->getURLGenerator(), |
|
| 1130 | - $c->getMemCacheFactory(), |
|
| 1131 | - new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
| 1132 | - new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
| 1133 | - $c->getAppManager(), |
|
| 1134 | - $c->getNavigationManager() |
|
| 1135 | - ); |
|
| 1136 | - } |
|
| 1137 | - return new \OC_Defaults(); |
|
| 1138 | - }); |
|
| 1139 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
| 1140 | - return new SCSSCacher( |
|
| 1141 | - $c->getLogger(), |
|
| 1142 | - $c->query(\OC\Files\AppData\Factory::class), |
|
| 1143 | - $c->getURLGenerator(), |
|
| 1144 | - $c->getConfig(), |
|
| 1145 | - $c->getThemingDefaults(), |
|
| 1146 | - \OC::$SERVERROOT, |
|
| 1147 | - $this->getMemCacheFactory(), |
|
| 1148 | - $c->query(IconsCacher::class), |
|
| 1149 | - new TimeFactory() |
|
| 1150 | - ); |
|
| 1151 | - }); |
|
| 1152 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
| 1153 | - return new JSCombiner( |
|
| 1154 | - $c->getAppDataDir('js'), |
|
| 1155 | - $c->getURLGenerator(), |
|
| 1156 | - $this->getMemCacheFactory(), |
|
| 1157 | - $c->getSystemConfig(), |
|
| 1158 | - $c->getLogger() |
|
| 1159 | - ); |
|
| 1160 | - }); |
|
| 1161 | - $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class); |
|
| 1162 | - $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class); |
|
| 1163 | - $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class); |
|
| 1164 | - |
|
| 1165 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 1166 | - // FIXME: Instantiiated here due to cyclic dependency |
|
| 1167 | - $request = new Request( |
|
| 1168 | - [ |
|
| 1169 | - 'get' => $_GET, |
|
| 1170 | - 'post' => $_POST, |
|
| 1171 | - 'files' => $_FILES, |
|
| 1172 | - 'server' => $_SERVER, |
|
| 1173 | - 'env' => $_ENV, |
|
| 1174 | - 'cookies' => $_COOKIE, |
|
| 1175 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 1176 | - ? $_SERVER['REQUEST_METHOD'] |
|
| 1177 | - : null, |
|
| 1178 | - ], |
|
| 1179 | - $c->getSecureRandom(), |
|
| 1180 | - $c->getConfig() |
|
| 1181 | - ); |
|
| 1182 | - |
|
| 1183 | - return new CryptoWrapper( |
|
| 1184 | - $c->getConfig(), |
|
| 1185 | - $c->getCrypto(), |
|
| 1186 | - $c->getSecureRandom(), |
|
| 1187 | - $request |
|
| 1188 | - ); |
|
| 1189 | - }); |
|
| 1190 | - $this->registerService(CsrfTokenManager::class, function (Server $c) { |
|
| 1191 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
| 1192 | - |
|
| 1193 | - return new CsrfTokenManager( |
|
| 1194 | - $tokenGenerator, |
|
| 1195 | - $c->query(SessionStorage::class) |
|
| 1196 | - ); |
|
| 1197 | - }); |
|
| 1198 | - $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class); |
|
| 1199 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 1200 | - return new SessionStorage($c->getSession()); |
|
| 1201 | - }); |
|
| 1202 | - $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class); |
|
| 1203 | - $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class); |
|
| 1204 | - |
|
| 1205 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
| 1206 | - return new ContentSecurityPolicyNonceManager( |
|
| 1207 | - $c->getCsrfTokenManager(), |
|
| 1208 | - $c->getRequest() |
|
| 1209 | - ); |
|
| 1210 | - }); |
|
| 1211 | - |
|
| 1212 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
| 1213 | - $config = $c->getConfig(); |
|
| 1214 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
| 1215 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
| 1216 | - $factory = new $factoryClass($this); |
|
| 1217 | - |
|
| 1218 | - $manager = new \OC\Share20\Manager( |
|
| 1219 | - $c->getLogger(), |
|
| 1220 | - $c->getConfig(), |
|
| 1221 | - $c->getSecureRandom(), |
|
| 1222 | - $c->getHasher(), |
|
| 1223 | - $c->getMountManager(), |
|
| 1224 | - $c->getGroupManager(), |
|
| 1225 | - $c->getL10N('lib'), |
|
| 1226 | - $c->getL10NFactory(), |
|
| 1227 | - $factory, |
|
| 1228 | - $c->getUserManager(), |
|
| 1229 | - $c->getLazyRootFolder(), |
|
| 1230 | - $c->getEventDispatcher(), |
|
| 1231 | - $c->getMailer(), |
|
| 1232 | - $c->getURLGenerator(), |
|
| 1233 | - $c->getThemingDefaults(), |
|
| 1234 | - $c->query(IEventDispatcher::class) |
|
| 1235 | - ); |
|
| 1236 | - |
|
| 1237 | - return $manager; |
|
| 1238 | - }); |
|
| 1239 | - $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class); |
|
| 1240 | - |
|
| 1241 | - $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) { |
|
| 1242 | - $instance = new Collaboration\Collaborators\Search($c); |
|
| 1243 | - |
|
| 1244 | - // register default plugins |
|
| 1245 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
| 1246 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
| 1247 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
| 1248 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
| 1249 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]); |
|
| 1250 | - |
|
| 1251 | - return $instance; |
|
| 1252 | - }); |
|
| 1253 | - $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
| 1254 | - $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class); |
|
| 1255 | - |
|
| 1256 | - $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
| 1257 | - |
|
| 1258 | - $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class); |
|
| 1259 | - $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class); |
|
| 1260 | - |
|
| 1261 | - $this->registerService('SettingsManager', function (Server $c) { |
|
| 1262 | - $manager = new \OC\Settings\Manager( |
|
| 1263 | - $c->getLogger(), |
|
| 1264 | - $c->getL10NFactory(), |
|
| 1265 | - $c->getURLGenerator(), |
|
| 1266 | - $c |
|
| 1267 | - ); |
|
| 1268 | - return $manager; |
|
| 1269 | - }); |
|
| 1270 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 1271 | - return new \OC\Files\AppData\Factory( |
|
| 1272 | - $c->getRootFolder(), |
|
| 1273 | - $c->getSystemConfig() |
|
| 1274 | - ); |
|
| 1275 | - }); |
|
| 1276 | - |
|
| 1277 | - $this->registerService('LockdownManager', function (Server $c) { |
|
| 1278 | - return new LockdownManager(function () use ($c) { |
|
| 1279 | - return $c->getSession(); |
|
| 1280 | - }); |
|
| 1281 | - }); |
|
| 1282 | - |
|
| 1283 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 1284 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
| 1285 | - }); |
|
| 1286 | - |
|
| 1287 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 1288 | - return new CloudIdManager(); |
|
| 1289 | - }); |
|
| 1290 | - |
|
| 1291 | - $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class); |
|
| 1292 | - |
|
| 1293 | - $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
| 1294 | - return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
|
| 1295 | - }); |
|
| 1296 | - |
|
| 1297 | - $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
| 1298 | - return new CloudFederationFactory(); |
|
| 1299 | - }); |
|
| 1300 | - |
|
| 1301 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
| 1302 | - $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
| 1303 | - |
|
| 1304 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
| 1305 | - $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
| 1306 | - |
|
| 1307 | - $this->registerService(Defaults::class, function (Server $c) { |
|
| 1308 | - return new Defaults( |
|
| 1309 | - $c->getThemingDefaults() |
|
| 1310 | - ); |
|
| 1311 | - }); |
|
| 1312 | - $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class); |
|
| 1313 | - |
|
| 1314 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
| 1315 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
| 1316 | - }); |
|
| 1317 | - |
|
| 1318 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
| 1319 | - return new ShareHelper( |
|
| 1320 | - $c->query(\OCP\Share\IManager::class) |
|
| 1321 | - ); |
|
| 1322 | - }); |
|
| 1323 | - |
|
| 1324 | - $this->registerService(Installer::class, function (Server $c) { |
|
| 1325 | - return new Installer( |
|
| 1326 | - $c->getAppFetcher(), |
|
| 1327 | - $c->getHTTPClientService(), |
|
| 1328 | - $c->getTempManager(), |
|
| 1329 | - $c->getLogger(), |
|
| 1330 | - $c->getConfig(), |
|
| 1331 | - \OC::$CLI |
|
| 1332 | - ); |
|
| 1333 | - }); |
|
| 1334 | - |
|
| 1335 | - $this->registerService(IApiFactory::class, function (Server $c) { |
|
| 1336 | - return new ApiFactory($c->getHTTPClientService()); |
|
| 1337 | - }); |
|
| 1338 | - |
|
| 1339 | - $this->registerService(IInstanceFactory::class, function (Server $c) { |
|
| 1340 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
| 1341 | - return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
| 1342 | - }); |
|
| 1343 | - |
|
| 1344 | - $this->registerService(IContactsStore::class, function (Server $c) { |
|
| 1345 | - return new ContactsStore( |
|
| 1346 | - $c->getContactsManager(), |
|
| 1347 | - $c->getConfig(), |
|
| 1348 | - $c->getUserManager(), |
|
| 1349 | - $c->getGroupManager() |
|
| 1350 | - ); |
|
| 1351 | - }); |
|
| 1352 | - $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
| 1353 | - $this->registerAlias(IAccountManager::class, AccountManager::class); |
|
| 1354 | - |
|
| 1355 | - $this->registerService(IStorageFactory::class, function () { |
|
| 1356 | - return new StorageFactory(); |
|
| 1357 | - }); |
|
| 1358 | - |
|
| 1359 | - $this->registerAlias(IDashboardManager::class, DashboardManager::class); |
|
| 1360 | - $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); |
|
| 1361 | - |
|
| 1362 | - $this->registerAlias(ISubAdmin::class, SubAdmin::class); |
|
| 1363 | - |
|
| 1364 | - $this->registerAlias(IInitialStateService::class, InitialStateService::class); |
|
| 1365 | - |
|
| 1366 | - $this->connectDispatcher(); |
|
| 1367 | - } |
|
| 1368 | - |
|
| 1369 | - public function boot() { |
|
| 1370 | - /** @var HookConnector $hookConnector */ |
|
| 1371 | - $hookConnector = $this->query(HookConnector::class); |
|
| 1372 | - $hookConnector->viewToNode(); |
|
| 1373 | - } |
|
| 1374 | - |
|
| 1375 | - /** |
|
| 1376 | - * @return \OCP\Calendar\IManager |
|
| 1377 | - */ |
|
| 1378 | - public function getCalendarManager() { |
|
| 1379 | - return $this->query(\OC\Calendar\Manager::class); |
|
| 1380 | - } |
|
| 1381 | - |
|
| 1382 | - /** |
|
| 1383 | - * @return \OCP\Calendar\Resource\IManager |
|
| 1384 | - */ |
|
| 1385 | - public function getCalendarResourceBackendManager() { |
|
| 1386 | - return $this->query(\OC\Calendar\Resource\Manager::class); |
|
| 1387 | - } |
|
| 1388 | - |
|
| 1389 | - /** |
|
| 1390 | - * @return \OCP\Calendar\Room\IManager |
|
| 1391 | - */ |
|
| 1392 | - public function getCalendarRoomBackendManager() { |
|
| 1393 | - return $this->query(\OC\Calendar\Room\Manager::class); |
|
| 1394 | - } |
|
| 1395 | - |
|
| 1396 | - private function connectDispatcher() { |
|
| 1397 | - $dispatcher = $this->getEventDispatcher(); |
|
| 1398 | - |
|
| 1399 | - // Delete avatar on user deletion |
|
| 1400 | - $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) { |
|
| 1401 | - $logger = $this->getLogger(); |
|
| 1402 | - $manager = $this->getAvatarManager(); |
|
| 1403 | - /** @var IUser $user */ |
|
| 1404 | - $user = $e->getSubject(); |
|
| 1405 | - |
|
| 1406 | - try { |
|
| 1407 | - $avatar = $manager->getAvatar($user->getUID()); |
|
| 1408 | - $avatar->remove(); |
|
| 1409 | - } catch (NotFoundException $e) { |
|
| 1410 | - // no avatar to remove |
|
| 1411 | - } catch (\Exception $e) { |
|
| 1412 | - // Ignore exceptions |
|
| 1413 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
| 1414 | - } |
|
| 1415 | - }); |
|
| 1416 | - |
|
| 1417 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
| 1418 | - $manager = $this->getAvatarManager(); |
|
| 1419 | - /** @var IUser $user */ |
|
| 1420 | - $user = $e->getSubject(); |
|
| 1421 | - $feature = $e->getArgument('feature'); |
|
| 1422 | - $oldValue = $e->getArgument('oldValue'); |
|
| 1423 | - $value = $e->getArgument('value'); |
|
| 1424 | - |
|
| 1425 | - // We only change the avatar on display name changes |
|
| 1426 | - if ($feature !== 'displayName') { |
|
| 1427 | - return; |
|
| 1428 | - } |
|
| 1429 | - |
|
| 1430 | - try { |
|
| 1431 | - $avatar = $manager->getAvatar($user->getUID()); |
|
| 1432 | - $avatar->userChanged($feature, $oldValue, $value); |
|
| 1433 | - } catch (NotFoundException $e) { |
|
| 1434 | - // no avatar to remove |
|
| 1435 | - } |
|
| 1436 | - }); |
|
| 1437 | - |
|
| 1438 | - /** @var IEventDispatcher $eventDispatched */ |
|
| 1439 | - $eventDispatched = $this->query(IEventDispatcher::class); |
|
| 1440 | - $eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class); |
|
| 1441 | - } |
|
| 1442 | - |
|
| 1443 | - /** |
|
| 1444 | - * @return \OCP\Contacts\IManager |
|
| 1445 | - */ |
|
| 1446 | - public function getContactsManager() { |
|
| 1447 | - return $this->query(\OCP\Contacts\IManager::class); |
|
| 1448 | - } |
|
| 1449 | - |
|
| 1450 | - /** |
|
| 1451 | - * @return \OC\Encryption\Manager |
|
| 1452 | - */ |
|
| 1453 | - public function getEncryptionManager() { |
|
| 1454 | - return $this->query(\OCP\Encryption\IManager::class); |
|
| 1455 | - } |
|
| 1456 | - |
|
| 1457 | - /** |
|
| 1458 | - * @return \OC\Encryption\File |
|
| 1459 | - */ |
|
| 1460 | - public function getEncryptionFilesHelper() { |
|
| 1461 | - return $this->query('EncryptionFileHelper'); |
|
| 1462 | - } |
|
| 1463 | - |
|
| 1464 | - /** |
|
| 1465 | - * @return \OCP\Encryption\Keys\IStorage |
|
| 1466 | - */ |
|
| 1467 | - public function getEncryptionKeyStorage() { |
|
| 1468 | - return $this->query('EncryptionKeyStorage'); |
|
| 1469 | - } |
|
| 1470 | - |
|
| 1471 | - /** |
|
| 1472 | - * The current request object holding all information about the request |
|
| 1473 | - * currently being processed is returned from this method. |
|
| 1474 | - * In case the current execution was not initiated by a web request null is returned |
|
| 1475 | - * |
|
| 1476 | - * @return \OCP\IRequest |
|
| 1477 | - */ |
|
| 1478 | - public function getRequest() { |
|
| 1479 | - return $this->query(IRequest::class); |
|
| 1480 | - } |
|
| 1481 | - |
|
| 1482 | - /** |
|
| 1483 | - * Returns the preview manager which can create preview images for a given file |
|
| 1484 | - * |
|
| 1485 | - * @return IPreview |
|
| 1486 | - */ |
|
| 1487 | - public function getPreviewManager() { |
|
| 1488 | - return $this->query(IPreview::class); |
|
| 1489 | - } |
|
| 1490 | - |
|
| 1491 | - /** |
|
| 1492 | - * Returns the tag manager which can get and set tags for different object types |
|
| 1493 | - * |
|
| 1494 | - * @see \OCP\ITagManager::load() |
|
| 1495 | - * @return ITagManager |
|
| 1496 | - */ |
|
| 1497 | - public function getTagManager() { |
|
| 1498 | - return $this->query(ITagManager::class); |
|
| 1499 | - } |
|
| 1500 | - |
|
| 1501 | - /** |
|
| 1502 | - * Returns the system-tag manager |
|
| 1503 | - * |
|
| 1504 | - * @return ISystemTagManager |
|
| 1505 | - * |
|
| 1506 | - * @since 9.0.0 |
|
| 1507 | - */ |
|
| 1508 | - public function getSystemTagManager() { |
|
| 1509 | - return $this->query(ISystemTagManager::class); |
|
| 1510 | - } |
|
| 1511 | - |
|
| 1512 | - /** |
|
| 1513 | - * Returns the system-tag object mapper |
|
| 1514 | - * |
|
| 1515 | - * @return ISystemTagObjectMapper |
|
| 1516 | - * |
|
| 1517 | - * @since 9.0.0 |
|
| 1518 | - */ |
|
| 1519 | - public function getSystemTagObjectMapper() { |
|
| 1520 | - return $this->query(ISystemTagObjectMapper::class); |
|
| 1521 | - } |
|
| 1522 | - |
|
| 1523 | - /** |
|
| 1524 | - * Returns the avatar manager, used for avatar functionality |
|
| 1525 | - * |
|
| 1526 | - * @return IAvatarManager |
|
| 1527 | - */ |
|
| 1528 | - public function getAvatarManager() { |
|
| 1529 | - return $this->query(IAvatarManager::class); |
|
| 1530 | - } |
|
| 1531 | - |
|
| 1532 | - /** |
|
| 1533 | - * Returns the root folder of ownCloud's data directory |
|
| 1534 | - * |
|
| 1535 | - * @return IRootFolder |
|
| 1536 | - */ |
|
| 1537 | - public function getRootFolder() { |
|
| 1538 | - return $this->query(IRootFolder::class); |
|
| 1539 | - } |
|
| 1540 | - |
|
| 1541 | - /** |
|
| 1542 | - * Returns the root folder of ownCloud's data directory |
|
| 1543 | - * This is the lazy variant so this gets only initialized once it |
|
| 1544 | - * is actually used. |
|
| 1545 | - * |
|
| 1546 | - * @return IRootFolder |
|
| 1547 | - */ |
|
| 1548 | - public function getLazyRootFolder() { |
|
| 1549 | - return $this->query(IRootFolder::class); |
|
| 1550 | - } |
|
| 1551 | - |
|
| 1552 | - /** |
|
| 1553 | - * Returns a view to ownCloud's files folder |
|
| 1554 | - * |
|
| 1555 | - * @param string $userId user ID |
|
| 1556 | - * @return \OCP\Files\Folder|null |
|
| 1557 | - */ |
|
| 1558 | - public function getUserFolder($userId = null) { |
|
| 1559 | - if ($userId === null) { |
|
| 1560 | - $user = $this->getUserSession()->getUser(); |
|
| 1561 | - if (!$user) { |
|
| 1562 | - return null; |
|
| 1563 | - } |
|
| 1564 | - $userId = $user->getUID(); |
|
| 1565 | - } |
|
| 1566 | - $root = $this->getRootFolder(); |
|
| 1567 | - return $root->getUserFolder($userId); |
|
| 1568 | - } |
|
| 1569 | - |
|
| 1570 | - /** |
|
| 1571 | - * Returns an app-specific view in ownClouds data directory |
|
| 1572 | - * |
|
| 1573 | - * @return \OCP\Files\Folder |
|
| 1574 | - * @deprecated since 9.2.0 use IAppData |
|
| 1575 | - */ |
|
| 1576 | - public function getAppFolder() { |
|
| 1577 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
| 1578 | - $root = $this->getRootFolder(); |
|
| 1579 | - if (!$root->nodeExists($dir)) { |
|
| 1580 | - $folder = $root->newFolder($dir); |
|
| 1581 | - } else { |
|
| 1582 | - $folder = $root->get($dir); |
|
| 1583 | - } |
|
| 1584 | - return $folder; |
|
| 1585 | - } |
|
| 1586 | - |
|
| 1587 | - /** |
|
| 1588 | - * @return \OC\User\Manager |
|
| 1589 | - */ |
|
| 1590 | - public function getUserManager() { |
|
| 1591 | - return $this->query(IUserManager::class); |
|
| 1592 | - } |
|
| 1593 | - |
|
| 1594 | - /** |
|
| 1595 | - * @return \OC\Group\Manager |
|
| 1596 | - */ |
|
| 1597 | - public function getGroupManager() { |
|
| 1598 | - return $this->query(IGroupManager::class); |
|
| 1599 | - } |
|
| 1600 | - |
|
| 1601 | - /** |
|
| 1602 | - * @return \OC\User\Session |
|
| 1603 | - */ |
|
| 1604 | - public function getUserSession() { |
|
| 1605 | - return $this->query(IUserSession::class); |
|
| 1606 | - } |
|
| 1607 | - |
|
| 1608 | - /** |
|
| 1609 | - * @return \OCP\ISession |
|
| 1610 | - */ |
|
| 1611 | - public function getSession() { |
|
| 1612 | - return $this->getUserSession()->getSession(); |
|
| 1613 | - } |
|
| 1614 | - |
|
| 1615 | - /** |
|
| 1616 | - * @param \OCP\ISession $session |
|
| 1617 | - */ |
|
| 1618 | - public function setSession(\OCP\ISession $session) { |
|
| 1619 | - $this->query(SessionStorage::class)->setSession($session); |
|
| 1620 | - $this->getUserSession()->setSession($session); |
|
| 1621 | - $this->query(Store::class)->setSession($session); |
|
| 1622 | - } |
|
| 1623 | - |
|
| 1624 | - /** |
|
| 1625 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
| 1626 | - */ |
|
| 1627 | - public function getTwoFactorAuthManager() { |
|
| 1628 | - return $this->query(\OC\Authentication\TwoFactorAuth\Manager::class); |
|
| 1629 | - } |
|
| 1630 | - |
|
| 1631 | - /** |
|
| 1632 | - * @return \OC\NavigationManager |
|
| 1633 | - */ |
|
| 1634 | - public function getNavigationManager() { |
|
| 1635 | - return $this->query(INavigationManager::class); |
|
| 1636 | - } |
|
| 1637 | - |
|
| 1638 | - /** |
|
| 1639 | - * @return \OCP\IConfig |
|
| 1640 | - */ |
|
| 1641 | - public function getConfig() { |
|
| 1642 | - return $this->query(AllConfig::class); |
|
| 1643 | - } |
|
| 1644 | - |
|
| 1645 | - /** |
|
| 1646 | - * @return \OC\SystemConfig |
|
| 1647 | - */ |
|
| 1648 | - public function getSystemConfig() { |
|
| 1649 | - return $this->query(SystemConfig::class); |
|
| 1650 | - } |
|
| 1651 | - |
|
| 1652 | - /** |
|
| 1653 | - * Returns the app config manager |
|
| 1654 | - * |
|
| 1655 | - * @return IAppConfig |
|
| 1656 | - */ |
|
| 1657 | - public function getAppConfig() { |
|
| 1658 | - return $this->query(IAppConfig::class); |
|
| 1659 | - } |
|
| 1660 | - |
|
| 1661 | - /** |
|
| 1662 | - * @return IFactory |
|
| 1663 | - */ |
|
| 1664 | - public function getL10NFactory() { |
|
| 1665 | - return $this->query(IFactory::class); |
|
| 1666 | - } |
|
| 1667 | - |
|
| 1668 | - /** |
|
| 1669 | - * get an L10N instance |
|
| 1670 | - * |
|
| 1671 | - * @param string $app appid |
|
| 1672 | - * @param string $lang |
|
| 1673 | - * @return IL10N |
|
| 1674 | - */ |
|
| 1675 | - public function getL10N($app, $lang = null) { |
|
| 1676 | - return $this->getL10NFactory()->get($app, $lang); |
|
| 1677 | - } |
|
| 1678 | - |
|
| 1679 | - /** |
|
| 1680 | - * @return IURLGenerator |
|
| 1681 | - */ |
|
| 1682 | - public function getURLGenerator() { |
|
| 1683 | - return $this->query(IURLGenerator::class); |
|
| 1684 | - } |
|
| 1685 | - |
|
| 1686 | - /** |
|
| 1687 | - * @return AppFetcher |
|
| 1688 | - */ |
|
| 1689 | - public function getAppFetcher() { |
|
| 1690 | - return $this->query(AppFetcher::class); |
|
| 1691 | - } |
|
| 1692 | - |
|
| 1693 | - /** |
|
| 1694 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
| 1695 | - * getMemCacheFactory() instead. |
|
| 1696 | - * |
|
| 1697 | - * @return ICache |
|
| 1698 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
| 1699 | - */ |
|
| 1700 | - public function getCache() { |
|
| 1701 | - return $this->query(ICache::class); |
|
| 1702 | - } |
|
| 1703 | - |
|
| 1704 | - /** |
|
| 1705 | - * Returns an \OCP\CacheFactory instance |
|
| 1706 | - * |
|
| 1707 | - * @return \OCP\ICacheFactory |
|
| 1708 | - */ |
|
| 1709 | - public function getMemCacheFactory() { |
|
| 1710 | - return $this->query(Factory::class); |
|
| 1711 | - } |
|
| 1712 | - |
|
| 1713 | - /** |
|
| 1714 | - * Returns an \OC\RedisFactory instance |
|
| 1715 | - * |
|
| 1716 | - * @return \OC\RedisFactory |
|
| 1717 | - */ |
|
| 1718 | - public function getGetRedisFactory() { |
|
| 1719 | - return $this->query('RedisFactory'); |
|
| 1720 | - } |
|
| 1721 | - |
|
| 1722 | - |
|
| 1723 | - /** |
|
| 1724 | - * Returns the current session |
|
| 1725 | - * |
|
| 1726 | - * @return \OCP\IDBConnection |
|
| 1727 | - */ |
|
| 1728 | - public function getDatabaseConnection() { |
|
| 1729 | - return $this->query(IDBConnection::class); |
|
| 1730 | - } |
|
| 1731 | - |
|
| 1732 | - /** |
|
| 1733 | - * Returns the activity manager |
|
| 1734 | - * |
|
| 1735 | - * @return \OCP\Activity\IManager |
|
| 1736 | - */ |
|
| 1737 | - public function getActivityManager() { |
|
| 1738 | - return $this->query(\OCP\Activity\IManager::class); |
|
| 1739 | - } |
|
| 1740 | - |
|
| 1741 | - /** |
|
| 1742 | - * Returns an job list for controlling background jobs |
|
| 1743 | - * |
|
| 1744 | - * @return IJobList |
|
| 1745 | - */ |
|
| 1746 | - public function getJobList() { |
|
| 1747 | - return $this->query(IJobList::class); |
|
| 1748 | - } |
|
| 1749 | - |
|
| 1750 | - /** |
|
| 1751 | - * Returns a logger instance |
|
| 1752 | - * |
|
| 1753 | - * @return ILogger |
|
| 1754 | - */ |
|
| 1755 | - public function getLogger() { |
|
| 1756 | - return $this->query(ILogger::class); |
|
| 1757 | - } |
|
| 1758 | - |
|
| 1759 | - /** |
|
| 1760 | - * @return ILogFactory |
|
| 1761 | - * @throws \OCP\AppFramework\QueryException |
|
| 1762 | - */ |
|
| 1763 | - public function getLogFactory() { |
|
| 1764 | - return $this->query(ILogFactory::class); |
|
| 1765 | - } |
|
| 1766 | - |
|
| 1767 | - /** |
|
| 1768 | - * Returns a router for generating and matching urls |
|
| 1769 | - * |
|
| 1770 | - * @return IRouter |
|
| 1771 | - */ |
|
| 1772 | - public function getRouter() { |
|
| 1773 | - return $this->query(IRouter::class); |
|
| 1774 | - } |
|
| 1775 | - |
|
| 1776 | - /** |
|
| 1777 | - * Returns a search instance |
|
| 1778 | - * |
|
| 1779 | - * @return ISearch |
|
| 1780 | - */ |
|
| 1781 | - public function getSearch() { |
|
| 1782 | - return $this->query(ISearch::class); |
|
| 1783 | - } |
|
| 1784 | - |
|
| 1785 | - /** |
|
| 1786 | - * Returns a SecureRandom instance |
|
| 1787 | - * |
|
| 1788 | - * @return \OCP\Security\ISecureRandom |
|
| 1789 | - */ |
|
| 1790 | - public function getSecureRandom() { |
|
| 1791 | - return $this->query(ISecureRandom::class); |
|
| 1792 | - } |
|
| 1793 | - |
|
| 1794 | - /** |
|
| 1795 | - * Returns a Crypto instance |
|
| 1796 | - * |
|
| 1797 | - * @return ICrypto |
|
| 1798 | - */ |
|
| 1799 | - public function getCrypto() { |
|
| 1800 | - return $this->query(ICrypto::class); |
|
| 1801 | - } |
|
| 1802 | - |
|
| 1803 | - /** |
|
| 1804 | - * Returns a Hasher instance |
|
| 1805 | - * |
|
| 1806 | - * @return IHasher |
|
| 1807 | - */ |
|
| 1808 | - public function getHasher() { |
|
| 1809 | - return $this->query(IHasher::class); |
|
| 1810 | - } |
|
| 1811 | - |
|
| 1812 | - /** |
|
| 1813 | - * Returns a CredentialsManager instance |
|
| 1814 | - * |
|
| 1815 | - * @return ICredentialsManager |
|
| 1816 | - */ |
|
| 1817 | - public function getCredentialsManager() { |
|
| 1818 | - return $this->query(ICredentialsManager::class); |
|
| 1819 | - } |
|
| 1820 | - |
|
| 1821 | - /** |
|
| 1822 | - * Get the certificate manager for the user |
|
| 1823 | - * |
|
| 1824 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 1825 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
| 1826 | - */ |
|
| 1827 | - public function getCertificateManager($userId = '') { |
|
| 1828 | - if ($userId === '') { |
|
| 1829 | - $userSession = $this->getUserSession(); |
|
| 1830 | - $user = $userSession->getUser(); |
|
| 1831 | - if (is_null($user)) { |
|
| 1832 | - return null; |
|
| 1833 | - } |
|
| 1834 | - $userId = $user->getUID(); |
|
| 1835 | - } |
|
| 1836 | - return new CertificateManager( |
|
| 1837 | - $userId, |
|
| 1838 | - new View(), |
|
| 1839 | - $this->getConfig(), |
|
| 1840 | - $this->getLogger(), |
|
| 1841 | - $this->getSecureRandom() |
|
| 1842 | - ); |
|
| 1843 | - } |
|
| 1844 | - |
|
| 1845 | - /** |
|
| 1846 | - * Returns an instance of the HTTP client service |
|
| 1847 | - * |
|
| 1848 | - * @return IClientService |
|
| 1849 | - */ |
|
| 1850 | - public function getHTTPClientService() { |
|
| 1851 | - return $this->query(IClientService::class); |
|
| 1852 | - } |
|
| 1853 | - |
|
| 1854 | - /** |
|
| 1855 | - * Create a new event source |
|
| 1856 | - * |
|
| 1857 | - * @return \OCP\IEventSource |
|
| 1858 | - */ |
|
| 1859 | - public function createEventSource() { |
|
| 1860 | - return new \OC_EventSource(); |
|
| 1861 | - } |
|
| 1862 | - |
|
| 1863 | - /** |
|
| 1864 | - * Get the active event logger |
|
| 1865 | - * |
|
| 1866 | - * The returned logger only logs data when debug mode is enabled |
|
| 1867 | - * |
|
| 1868 | - * @return IEventLogger |
|
| 1869 | - */ |
|
| 1870 | - public function getEventLogger() { |
|
| 1871 | - return $this->query(IEventLogger::class); |
|
| 1872 | - } |
|
| 1873 | - |
|
| 1874 | - /** |
|
| 1875 | - * Get the active query logger |
|
| 1876 | - * |
|
| 1877 | - * The returned logger only logs data when debug mode is enabled |
|
| 1878 | - * |
|
| 1879 | - * @return IQueryLogger |
|
| 1880 | - */ |
|
| 1881 | - public function getQueryLogger() { |
|
| 1882 | - return $this->query(IQueryLogger::class); |
|
| 1883 | - } |
|
| 1884 | - |
|
| 1885 | - /** |
|
| 1886 | - * Get the manager for temporary files and folders |
|
| 1887 | - * |
|
| 1888 | - * @return \OCP\ITempManager |
|
| 1889 | - */ |
|
| 1890 | - public function getTempManager() { |
|
| 1891 | - return $this->query(ITempManager::class); |
|
| 1892 | - } |
|
| 1893 | - |
|
| 1894 | - /** |
|
| 1895 | - * Get the app manager |
|
| 1896 | - * |
|
| 1897 | - * @return \OCP\App\IAppManager |
|
| 1898 | - */ |
|
| 1899 | - public function getAppManager() { |
|
| 1900 | - return $this->query(IAppManager::class); |
|
| 1901 | - } |
|
| 1902 | - |
|
| 1903 | - /** |
|
| 1904 | - * Creates a new mailer |
|
| 1905 | - * |
|
| 1906 | - * @return IMailer |
|
| 1907 | - */ |
|
| 1908 | - public function getMailer() { |
|
| 1909 | - return $this->query(IMailer::class); |
|
| 1910 | - } |
|
| 1911 | - |
|
| 1912 | - /** |
|
| 1913 | - * Get the webroot |
|
| 1914 | - * |
|
| 1915 | - * @return string |
|
| 1916 | - */ |
|
| 1917 | - public function getWebRoot() { |
|
| 1918 | - return $this->webRoot; |
|
| 1919 | - } |
|
| 1920 | - |
|
| 1921 | - /** |
|
| 1922 | - * @return \OC\OCSClient |
|
| 1923 | - */ |
|
| 1924 | - public function getOcsClient() { |
|
| 1925 | - return $this->query('OcsClient'); |
|
| 1926 | - } |
|
| 1927 | - |
|
| 1928 | - /** |
|
| 1929 | - * @return IDateTimeZone |
|
| 1930 | - */ |
|
| 1931 | - public function getDateTimeZone() { |
|
| 1932 | - return $this->query(IDateTimeZone::class); |
|
| 1933 | - } |
|
| 1934 | - |
|
| 1935 | - /** |
|
| 1936 | - * @return IDateTimeFormatter |
|
| 1937 | - */ |
|
| 1938 | - public function getDateTimeFormatter() { |
|
| 1939 | - return $this->query(IDateTimeFormatter::class); |
|
| 1940 | - } |
|
| 1941 | - |
|
| 1942 | - /** |
|
| 1943 | - * @return IMountProviderCollection |
|
| 1944 | - */ |
|
| 1945 | - public function getMountProviderCollection() { |
|
| 1946 | - return $this->query(IMountProviderCollection::class); |
|
| 1947 | - } |
|
| 1948 | - |
|
| 1949 | - /** |
|
| 1950 | - * Get the IniWrapper |
|
| 1951 | - * |
|
| 1952 | - * @return IniGetWrapper |
|
| 1953 | - */ |
|
| 1954 | - public function getIniWrapper() { |
|
| 1955 | - return $this->query('IniWrapper'); |
|
| 1956 | - } |
|
| 1957 | - |
|
| 1958 | - /** |
|
| 1959 | - * @return \OCP\Command\IBus |
|
| 1960 | - */ |
|
| 1961 | - public function getCommandBus() { |
|
| 1962 | - return $this->query('AsyncCommandBus'); |
|
| 1963 | - } |
|
| 1964 | - |
|
| 1965 | - /** |
|
| 1966 | - * Get the trusted domain helper |
|
| 1967 | - * |
|
| 1968 | - * @return TrustedDomainHelper |
|
| 1969 | - */ |
|
| 1970 | - public function getTrustedDomainHelper() { |
|
| 1971 | - return $this->query('TrustedDomainHelper'); |
|
| 1972 | - } |
|
| 1973 | - |
|
| 1974 | - /** |
|
| 1975 | - * Get the locking provider |
|
| 1976 | - * |
|
| 1977 | - * @return ILockingProvider |
|
| 1978 | - * @since 8.1.0 |
|
| 1979 | - */ |
|
| 1980 | - public function getLockingProvider() { |
|
| 1981 | - return $this->query(ILockingProvider::class); |
|
| 1982 | - } |
|
| 1983 | - |
|
| 1984 | - /** |
|
| 1985 | - * @return IMountManager |
|
| 1986 | - **/ |
|
| 1987 | - public function getMountManager() { |
|
| 1988 | - return $this->query(IMountManager::class); |
|
| 1989 | - } |
|
| 1990 | - |
|
| 1991 | - /** |
|
| 1992 | - * @return IUserMountCache |
|
| 1993 | - */ |
|
| 1994 | - public function getUserMountCache() { |
|
| 1995 | - return $this->query(IUserMountCache::class); |
|
| 1996 | - } |
|
| 1997 | - |
|
| 1998 | - /** |
|
| 1999 | - * Get the MimeTypeDetector |
|
| 2000 | - * |
|
| 2001 | - * @return IMimeTypeDetector |
|
| 2002 | - */ |
|
| 2003 | - public function getMimeTypeDetector() { |
|
| 2004 | - return $this->query(IMimeTypeDetector::class); |
|
| 2005 | - } |
|
| 2006 | - |
|
| 2007 | - /** |
|
| 2008 | - * Get the MimeTypeLoader |
|
| 2009 | - * |
|
| 2010 | - * @return IMimeTypeLoader |
|
| 2011 | - */ |
|
| 2012 | - public function getMimeTypeLoader() { |
|
| 2013 | - return $this->query(IMimeTypeLoader::class); |
|
| 2014 | - } |
|
| 2015 | - |
|
| 2016 | - /** |
|
| 2017 | - * Get the manager of all the capabilities |
|
| 2018 | - * |
|
| 2019 | - * @return CapabilitiesManager |
|
| 2020 | - */ |
|
| 2021 | - public function getCapabilitiesManager() { |
|
| 2022 | - return $this->query(CapabilitiesManager::class); |
|
| 2023 | - } |
|
| 2024 | - |
|
| 2025 | - /** |
|
| 2026 | - * Get the EventDispatcher |
|
| 2027 | - * |
|
| 2028 | - * @return EventDispatcherInterface |
|
| 2029 | - * @since 8.2.0 |
|
| 2030 | - * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher |
|
| 2031 | - */ |
|
| 2032 | - public function getEventDispatcher() { |
|
| 2033 | - return $this->query(\OC\EventDispatcher\SymfonyAdapter::class); |
|
| 2034 | - } |
|
| 2035 | - |
|
| 2036 | - /** |
|
| 2037 | - * Get the Notification Manager |
|
| 2038 | - * |
|
| 2039 | - * @return \OCP\Notification\IManager |
|
| 2040 | - * @since 8.2.0 |
|
| 2041 | - */ |
|
| 2042 | - public function getNotificationManager() { |
|
| 2043 | - return $this->query(\OCP\Notification\IManager::class); |
|
| 2044 | - } |
|
| 2045 | - |
|
| 2046 | - /** |
|
| 2047 | - * @return ICommentsManager |
|
| 2048 | - */ |
|
| 2049 | - public function getCommentsManager() { |
|
| 2050 | - return $this->query(ICommentsManager::class); |
|
| 2051 | - } |
|
| 2052 | - |
|
| 2053 | - /** |
|
| 2054 | - * @return \OCA\Theming\ThemingDefaults |
|
| 2055 | - */ |
|
| 2056 | - public function getThemingDefaults() { |
|
| 2057 | - return $this->query('ThemingDefaults'); |
|
| 2058 | - } |
|
| 2059 | - |
|
| 2060 | - /** |
|
| 2061 | - * @return \OC\IntegrityCheck\Checker |
|
| 2062 | - */ |
|
| 2063 | - public function getIntegrityCodeChecker() { |
|
| 2064 | - return $this->query('IntegrityCodeChecker'); |
|
| 2065 | - } |
|
| 2066 | - |
|
| 2067 | - /** |
|
| 2068 | - * @return \OC\Session\CryptoWrapper |
|
| 2069 | - */ |
|
| 2070 | - public function getSessionCryptoWrapper() { |
|
| 2071 | - return $this->query('CryptoWrapper'); |
|
| 2072 | - } |
|
| 2073 | - |
|
| 2074 | - /** |
|
| 2075 | - * @return CsrfTokenManager |
|
| 2076 | - */ |
|
| 2077 | - public function getCsrfTokenManager() { |
|
| 2078 | - return $this->query(CsrfTokenManager::class); |
|
| 2079 | - } |
|
| 2080 | - |
|
| 2081 | - /** |
|
| 2082 | - * @return Throttler |
|
| 2083 | - */ |
|
| 2084 | - public function getBruteForceThrottler() { |
|
| 2085 | - return $this->query(Throttler::class); |
|
| 2086 | - } |
|
| 2087 | - |
|
| 2088 | - /** |
|
| 2089 | - * @return IContentSecurityPolicyManager |
|
| 2090 | - */ |
|
| 2091 | - public function getContentSecurityPolicyManager() { |
|
| 2092 | - return $this->query(ContentSecurityPolicyManager::class); |
|
| 2093 | - } |
|
| 2094 | - |
|
| 2095 | - /** |
|
| 2096 | - * @return ContentSecurityPolicyNonceManager |
|
| 2097 | - */ |
|
| 2098 | - public function getContentSecurityPolicyNonceManager() { |
|
| 2099 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
| 2100 | - } |
|
| 2101 | - |
|
| 2102 | - /** |
|
| 2103 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 2104 | - * |
|
| 2105 | - * @return \OCA\Files_External\Service\BackendService |
|
| 2106 | - */ |
|
| 2107 | - public function getStoragesBackendService() { |
|
| 2108 | - return $this->query(BackendService::class); |
|
| 2109 | - } |
|
| 2110 | - |
|
| 2111 | - /** |
|
| 2112 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 2113 | - * |
|
| 2114 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
| 2115 | - */ |
|
| 2116 | - public function getGlobalStoragesService() { |
|
| 2117 | - return $this->query(GlobalStoragesService::class); |
|
| 2118 | - } |
|
| 2119 | - |
|
| 2120 | - /** |
|
| 2121 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 2122 | - * |
|
| 2123 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
| 2124 | - */ |
|
| 2125 | - public function getUserGlobalStoragesService() { |
|
| 2126 | - return $this->query(UserGlobalStoragesService::class); |
|
| 2127 | - } |
|
| 2128 | - |
|
| 2129 | - /** |
|
| 2130 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 2131 | - * |
|
| 2132 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
| 2133 | - */ |
|
| 2134 | - public function getUserStoragesService() { |
|
| 2135 | - return $this->query(UserStoragesService::class); |
|
| 2136 | - } |
|
| 2137 | - |
|
| 2138 | - /** |
|
| 2139 | - * @return \OCP\Share\IManager |
|
| 2140 | - */ |
|
| 2141 | - public function getShareManager() { |
|
| 2142 | - return $this->query(\OCP\Share\IManager::class); |
|
| 2143 | - } |
|
| 2144 | - |
|
| 2145 | - /** |
|
| 2146 | - * @return \OCP\Collaboration\Collaborators\ISearch |
|
| 2147 | - */ |
|
| 2148 | - public function getCollaboratorSearch() { |
|
| 2149 | - return $this->query(\OCP\Collaboration\Collaborators\ISearch::class); |
|
| 2150 | - } |
|
| 2151 | - |
|
| 2152 | - /** |
|
| 2153 | - * @return \OCP\Collaboration\AutoComplete\IManager |
|
| 2154 | - */ |
|
| 2155 | - public function getAutoCompleteManager() { |
|
| 2156 | - return $this->query(IManager::class); |
|
| 2157 | - } |
|
| 2158 | - |
|
| 2159 | - /** |
|
| 2160 | - * Returns the LDAP Provider |
|
| 2161 | - * |
|
| 2162 | - * @return \OCP\LDAP\ILDAPProvider |
|
| 2163 | - */ |
|
| 2164 | - public function getLDAPProvider() { |
|
| 2165 | - return $this->query('LDAPProvider'); |
|
| 2166 | - } |
|
| 2167 | - |
|
| 2168 | - /** |
|
| 2169 | - * @return \OCP\Settings\IManager |
|
| 2170 | - */ |
|
| 2171 | - public function getSettingsManager() { |
|
| 2172 | - return $this->query('SettingsManager'); |
|
| 2173 | - } |
|
| 2174 | - |
|
| 2175 | - /** |
|
| 2176 | - * @return \OCP\Files\IAppData |
|
| 2177 | - */ |
|
| 2178 | - public function getAppDataDir($app) { |
|
| 2179 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
| 2180 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
| 2181 | - return $factory->get($app); |
|
| 2182 | - } |
|
| 2183 | - |
|
| 2184 | - /** |
|
| 2185 | - * @return \OCP\Lockdown\ILockdownManager |
|
| 2186 | - */ |
|
| 2187 | - public function getLockdownManager() { |
|
| 2188 | - return $this->query('LockdownManager'); |
|
| 2189 | - } |
|
| 2190 | - |
|
| 2191 | - /** |
|
| 2192 | - * @return \OCP\Federation\ICloudIdManager |
|
| 2193 | - */ |
|
| 2194 | - public function getCloudIdManager() { |
|
| 2195 | - return $this->query(ICloudIdManager::class); |
|
| 2196 | - } |
|
| 2197 | - |
|
| 2198 | - /** |
|
| 2199 | - * @return \OCP\GlobalScale\IConfig |
|
| 2200 | - */ |
|
| 2201 | - public function getGlobalScaleConfig() { |
|
| 2202 | - return $this->query(IConfig::class); |
|
| 2203 | - } |
|
| 2204 | - |
|
| 2205 | - /** |
|
| 2206 | - * @return \OCP\Federation\ICloudFederationProviderManager |
|
| 2207 | - */ |
|
| 2208 | - public function getCloudFederationProviderManager() { |
|
| 2209 | - return $this->query(ICloudFederationProviderManager::class); |
|
| 2210 | - } |
|
| 2211 | - |
|
| 2212 | - /** |
|
| 2213 | - * @return \OCP\Remote\Api\IApiFactory |
|
| 2214 | - */ |
|
| 2215 | - public function getRemoteApiFactory() { |
|
| 2216 | - return $this->query(IApiFactory::class); |
|
| 2217 | - } |
|
| 2218 | - |
|
| 2219 | - /** |
|
| 2220 | - * @return \OCP\Federation\ICloudFederationFactory |
|
| 2221 | - */ |
|
| 2222 | - public function getCloudFederationFactory() { |
|
| 2223 | - return $this->query(ICloudFederationFactory::class); |
|
| 2224 | - } |
|
| 2225 | - |
|
| 2226 | - /** |
|
| 2227 | - * @return \OCP\Remote\IInstanceFactory |
|
| 2228 | - */ |
|
| 2229 | - public function getRemoteInstanceFactory() { |
|
| 2230 | - return $this->query(IInstanceFactory::class); |
|
| 2231 | - } |
|
| 2232 | - |
|
| 2233 | - /** |
|
| 2234 | - * @return IStorageFactory |
|
| 2235 | - */ |
|
| 2236 | - public function getStorageFactory() { |
|
| 2237 | - return $this->query(IStorageFactory::class); |
|
| 2238 | - } |
|
| 2239 | - |
|
| 2240 | - /** |
|
| 2241 | - * Get the Preview GeneratorHelper |
|
| 2242 | - * |
|
| 2243 | - * @return GeneratorHelper |
|
| 2244 | - * @since 17.0.0 |
|
| 2245 | - */ |
|
| 2246 | - public function getGeneratorHelper() { |
|
| 2247 | - return $this->query(\OC\Preview\GeneratorHelper::class); |
|
| 2248 | - } |
|
| 2249 | - |
|
| 2250 | - private function registerDeprecatedAlias(string $alias, string $target) { |
|
| 2251 | - $this->registerService($alias, function (IContainer $container) use ($target, $alias) { |
|
| 2252 | - try { |
|
| 2253 | - /** @var ILogger $logger */ |
|
| 2254 | - $logger = $container->query(ILogger::class); |
|
| 2255 | - $logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']); |
|
| 2256 | - } catch (QueryException $e) { |
|
| 2257 | - // Could not get logger. Continue |
|
| 2258 | - } |
|
| 2259 | - |
|
| 2260 | - return $container->query($target); |
|
| 2261 | - }, false); |
|
| 2262 | - } |
|
| 1118 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
| 1119 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
| 1120 | + $classExists = true; |
|
| 1121 | + } else { |
|
| 1122 | + $classExists = false; |
|
| 1123 | + } |
|
| 1124 | + |
|
| 1125 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
| 1126 | + return new ThemingDefaults( |
|
| 1127 | + $c->getConfig(), |
|
| 1128 | + $c->getL10N('theming'), |
|
| 1129 | + $c->getURLGenerator(), |
|
| 1130 | + $c->getMemCacheFactory(), |
|
| 1131 | + new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
| 1132 | + new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
| 1133 | + $c->getAppManager(), |
|
| 1134 | + $c->getNavigationManager() |
|
| 1135 | + ); |
|
| 1136 | + } |
|
| 1137 | + return new \OC_Defaults(); |
|
| 1138 | + }); |
|
| 1139 | + $this->registerService(SCSSCacher::class, function (Server $c) { |
|
| 1140 | + return new SCSSCacher( |
|
| 1141 | + $c->getLogger(), |
|
| 1142 | + $c->query(\OC\Files\AppData\Factory::class), |
|
| 1143 | + $c->getURLGenerator(), |
|
| 1144 | + $c->getConfig(), |
|
| 1145 | + $c->getThemingDefaults(), |
|
| 1146 | + \OC::$SERVERROOT, |
|
| 1147 | + $this->getMemCacheFactory(), |
|
| 1148 | + $c->query(IconsCacher::class), |
|
| 1149 | + new TimeFactory() |
|
| 1150 | + ); |
|
| 1151 | + }); |
|
| 1152 | + $this->registerService(JSCombiner::class, function (Server $c) { |
|
| 1153 | + return new JSCombiner( |
|
| 1154 | + $c->getAppDataDir('js'), |
|
| 1155 | + $c->getURLGenerator(), |
|
| 1156 | + $this->getMemCacheFactory(), |
|
| 1157 | + $c->getSystemConfig(), |
|
| 1158 | + $c->getLogger() |
|
| 1159 | + ); |
|
| 1160 | + }); |
|
| 1161 | + $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class); |
|
| 1162 | + $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class); |
|
| 1163 | + $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class); |
|
| 1164 | + |
|
| 1165 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 1166 | + // FIXME: Instantiiated here due to cyclic dependency |
|
| 1167 | + $request = new Request( |
|
| 1168 | + [ |
|
| 1169 | + 'get' => $_GET, |
|
| 1170 | + 'post' => $_POST, |
|
| 1171 | + 'files' => $_FILES, |
|
| 1172 | + 'server' => $_SERVER, |
|
| 1173 | + 'env' => $_ENV, |
|
| 1174 | + 'cookies' => $_COOKIE, |
|
| 1175 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 1176 | + ? $_SERVER['REQUEST_METHOD'] |
|
| 1177 | + : null, |
|
| 1178 | + ], |
|
| 1179 | + $c->getSecureRandom(), |
|
| 1180 | + $c->getConfig() |
|
| 1181 | + ); |
|
| 1182 | + |
|
| 1183 | + return new CryptoWrapper( |
|
| 1184 | + $c->getConfig(), |
|
| 1185 | + $c->getCrypto(), |
|
| 1186 | + $c->getSecureRandom(), |
|
| 1187 | + $request |
|
| 1188 | + ); |
|
| 1189 | + }); |
|
| 1190 | + $this->registerService(CsrfTokenManager::class, function (Server $c) { |
|
| 1191 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
| 1192 | + |
|
| 1193 | + return new CsrfTokenManager( |
|
| 1194 | + $tokenGenerator, |
|
| 1195 | + $c->query(SessionStorage::class) |
|
| 1196 | + ); |
|
| 1197 | + }); |
|
| 1198 | + $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class); |
|
| 1199 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 1200 | + return new SessionStorage($c->getSession()); |
|
| 1201 | + }); |
|
| 1202 | + $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class); |
|
| 1203 | + $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class); |
|
| 1204 | + |
|
| 1205 | + $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
| 1206 | + return new ContentSecurityPolicyNonceManager( |
|
| 1207 | + $c->getCsrfTokenManager(), |
|
| 1208 | + $c->getRequest() |
|
| 1209 | + ); |
|
| 1210 | + }); |
|
| 1211 | + |
|
| 1212 | + $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
| 1213 | + $config = $c->getConfig(); |
|
| 1214 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
| 1215 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
| 1216 | + $factory = new $factoryClass($this); |
|
| 1217 | + |
|
| 1218 | + $manager = new \OC\Share20\Manager( |
|
| 1219 | + $c->getLogger(), |
|
| 1220 | + $c->getConfig(), |
|
| 1221 | + $c->getSecureRandom(), |
|
| 1222 | + $c->getHasher(), |
|
| 1223 | + $c->getMountManager(), |
|
| 1224 | + $c->getGroupManager(), |
|
| 1225 | + $c->getL10N('lib'), |
|
| 1226 | + $c->getL10NFactory(), |
|
| 1227 | + $factory, |
|
| 1228 | + $c->getUserManager(), |
|
| 1229 | + $c->getLazyRootFolder(), |
|
| 1230 | + $c->getEventDispatcher(), |
|
| 1231 | + $c->getMailer(), |
|
| 1232 | + $c->getURLGenerator(), |
|
| 1233 | + $c->getThemingDefaults(), |
|
| 1234 | + $c->query(IEventDispatcher::class) |
|
| 1235 | + ); |
|
| 1236 | + |
|
| 1237 | + return $manager; |
|
| 1238 | + }); |
|
| 1239 | + $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class); |
|
| 1240 | + |
|
| 1241 | + $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) { |
|
| 1242 | + $instance = new Collaboration\Collaborators\Search($c); |
|
| 1243 | + |
|
| 1244 | + // register default plugins |
|
| 1245 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
| 1246 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
| 1247 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
| 1248 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
| 1249 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]); |
|
| 1250 | + |
|
| 1251 | + return $instance; |
|
| 1252 | + }); |
|
| 1253 | + $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
| 1254 | + $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class); |
|
| 1255 | + |
|
| 1256 | + $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
| 1257 | + |
|
| 1258 | + $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class); |
|
| 1259 | + $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class); |
|
| 1260 | + |
|
| 1261 | + $this->registerService('SettingsManager', function (Server $c) { |
|
| 1262 | + $manager = new \OC\Settings\Manager( |
|
| 1263 | + $c->getLogger(), |
|
| 1264 | + $c->getL10NFactory(), |
|
| 1265 | + $c->getURLGenerator(), |
|
| 1266 | + $c |
|
| 1267 | + ); |
|
| 1268 | + return $manager; |
|
| 1269 | + }); |
|
| 1270 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 1271 | + return new \OC\Files\AppData\Factory( |
|
| 1272 | + $c->getRootFolder(), |
|
| 1273 | + $c->getSystemConfig() |
|
| 1274 | + ); |
|
| 1275 | + }); |
|
| 1276 | + |
|
| 1277 | + $this->registerService('LockdownManager', function (Server $c) { |
|
| 1278 | + return new LockdownManager(function () use ($c) { |
|
| 1279 | + return $c->getSession(); |
|
| 1280 | + }); |
|
| 1281 | + }); |
|
| 1282 | + |
|
| 1283 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 1284 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
| 1285 | + }); |
|
| 1286 | + |
|
| 1287 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 1288 | + return new CloudIdManager(); |
|
| 1289 | + }); |
|
| 1290 | + |
|
| 1291 | + $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class); |
|
| 1292 | + |
|
| 1293 | + $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
| 1294 | + return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
|
| 1295 | + }); |
|
| 1296 | + |
|
| 1297 | + $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
| 1298 | + return new CloudFederationFactory(); |
|
| 1299 | + }); |
|
| 1300 | + |
|
| 1301 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
| 1302 | + $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
| 1303 | + |
|
| 1304 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
| 1305 | + $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
| 1306 | + |
|
| 1307 | + $this->registerService(Defaults::class, function (Server $c) { |
|
| 1308 | + return new Defaults( |
|
| 1309 | + $c->getThemingDefaults() |
|
| 1310 | + ); |
|
| 1311 | + }); |
|
| 1312 | + $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class); |
|
| 1313 | + |
|
| 1314 | + $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
| 1315 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
| 1316 | + }); |
|
| 1317 | + |
|
| 1318 | + $this->registerService(IShareHelper::class, function (Server $c) { |
|
| 1319 | + return new ShareHelper( |
|
| 1320 | + $c->query(\OCP\Share\IManager::class) |
|
| 1321 | + ); |
|
| 1322 | + }); |
|
| 1323 | + |
|
| 1324 | + $this->registerService(Installer::class, function (Server $c) { |
|
| 1325 | + return new Installer( |
|
| 1326 | + $c->getAppFetcher(), |
|
| 1327 | + $c->getHTTPClientService(), |
|
| 1328 | + $c->getTempManager(), |
|
| 1329 | + $c->getLogger(), |
|
| 1330 | + $c->getConfig(), |
|
| 1331 | + \OC::$CLI |
|
| 1332 | + ); |
|
| 1333 | + }); |
|
| 1334 | + |
|
| 1335 | + $this->registerService(IApiFactory::class, function (Server $c) { |
|
| 1336 | + return new ApiFactory($c->getHTTPClientService()); |
|
| 1337 | + }); |
|
| 1338 | + |
|
| 1339 | + $this->registerService(IInstanceFactory::class, function (Server $c) { |
|
| 1340 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
| 1341 | + return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
| 1342 | + }); |
|
| 1343 | + |
|
| 1344 | + $this->registerService(IContactsStore::class, function (Server $c) { |
|
| 1345 | + return new ContactsStore( |
|
| 1346 | + $c->getContactsManager(), |
|
| 1347 | + $c->getConfig(), |
|
| 1348 | + $c->getUserManager(), |
|
| 1349 | + $c->getGroupManager() |
|
| 1350 | + ); |
|
| 1351 | + }); |
|
| 1352 | + $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
| 1353 | + $this->registerAlias(IAccountManager::class, AccountManager::class); |
|
| 1354 | + |
|
| 1355 | + $this->registerService(IStorageFactory::class, function () { |
|
| 1356 | + return new StorageFactory(); |
|
| 1357 | + }); |
|
| 1358 | + |
|
| 1359 | + $this->registerAlias(IDashboardManager::class, DashboardManager::class); |
|
| 1360 | + $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); |
|
| 1361 | + |
|
| 1362 | + $this->registerAlias(ISubAdmin::class, SubAdmin::class); |
|
| 1363 | + |
|
| 1364 | + $this->registerAlias(IInitialStateService::class, InitialStateService::class); |
|
| 1365 | + |
|
| 1366 | + $this->connectDispatcher(); |
|
| 1367 | + } |
|
| 1368 | + |
|
| 1369 | + public function boot() { |
|
| 1370 | + /** @var HookConnector $hookConnector */ |
|
| 1371 | + $hookConnector = $this->query(HookConnector::class); |
|
| 1372 | + $hookConnector->viewToNode(); |
|
| 1373 | + } |
|
| 1374 | + |
|
| 1375 | + /** |
|
| 1376 | + * @return \OCP\Calendar\IManager |
|
| 1377 | + */ |
|
| 1378 | + public function getCalendarManager() { |
|
| 1379 | + return $this->query(\OC\Calendar\Manager::class); |
|
| 1380 | + } |
|
| 1381 | + |
|
| 1382 | + /** |
|
| 1383 | + * @return \OCP\Calendar\Resource\IManager |
|
| 1384 | + */ |
|
| 1385 | + public function getCalendarResourceBackendManager() { |
|
| 1386 | + return $this->query(\OC\Calendar\Resource\Manager::class); |
|
| 1387 | + } |
|
| 1388 | + |
|
| 1389 | + /** |
|
| 1390 | + * @return \OCP\Calendar\Room\IManager |
|
| 1391 | + */ |
|
| 1392 | + public function getCalendarRoomBackendManager() { |
|
| 1393 | + return $this->query(\OC\Calendar\Room\Manager::class); |
|
| 1394 | + } |
|
| 1395 | + |
|
| 1396 | + private function connectDispatcher() { |
|
| 1397 | + $dispatcher = $this->getEventDispatcher(); |
|
| 1398 | + |
|
| 1399 | + // Delete avatar on user deletion |
|
| 1400 | + $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) { |
|
| 1401 | + $logger = $this->getLogger(); |
|
| 1402 | + $manager = $this->getAvatarManager(); |
|
| 1403 | + /** @var IUser $user */ |
|
| 1404 | + $user = $e->getSubject(); |
|
| 1405 | + |
|
| 1406 | + try { |
|
| 1407 | + $avatar = $manager->getAvatar($user->getUID()); |
|
| 1408 | + $avatar->remove(); |
|
| 1409 | + } catch (NotFoundException $e) { |
|
| 1410 | + // no avatar to remove |
|
| 1411 | + } catch (\Exception $e) { |
|
| 1412 | + // Ignore exceptions |
|
| 1413 | + $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
| 1414 | + } |
|
| 1415 | + }); |
|
| 1416 | + |
|
| 1417 | + $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
| 1418 | + $manager = $this->getAvatarManager(); |
|
| 1419 | + /** @var IUser $user */ |
|
| 1420 | + $user = $e->getSubject(); |
|
| 1421 | + $feature = $e->getArgument('feature'); |
|
| 1422 | + $oldValue = $e->getArgument('oldValue'); |
|
| 1423 | + $value = $e->getArgument('value'); |
|
| 1424 | + |
|
| 1425 | + // We only change the avatar on display name changes |
|
| 1426 | + if ($feature !== 'displayName') { |
|
| 1427 | + return; |
|
| 1428 | + } |
|
| 1429 | + |
|
| 1430 | + try { |
|
| 1431 | + $avatar = $manager->getAvatar($user->getUID()); |
|
| 1432 | + $avatar->userChanged($feature, $oldValue, $value); |
|
| 1433 | + } catch (NotFoundException $e) { |
|
| 1434 | + // no avatar to remove |
|
| 1435 | + } |
|
| 1436 | + }); |
|
| 1437 | + |
|
| 1438 | + /** @var IEventDispatcher $eventDispatched */ |
|
| 1439 | + $eventDispatched = $this->query(IEventDispatcher::class); |
|
| 1440 | + $eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class); |
|
| 1441 | + } |
|
| 1442 | + |
|
| 1443 | + /** |
|
| 1444 | + * @return \OCP\Contacts\IManager |
|
| 1445 | + */ |
|
| 1446 | + public function getContactsManager() { |
|
| 1447 | + return $this->query(\OCP\Contacts\IManager::class); |
|
| 1448 | + } |
|
| 1449 | + |
|
| 1450 | + /** |
|
| 1451 | + * @return \OC\Encryption\Manager |
|
| 1452 | + */ |
|
| 1453 | + public function getEncryptionManager() { |
|
| 1454 | + return $this->query(\OCP\Encryption\IManager::class); |
|
| 1455 | + } |
|
| 1456 | + |
|
| 1457 | + /** |
|
| 1458 | + * @return \OC\Encryption\File |
|
| 1459 | + */ |
|
| 1460 | + public function getEncryptionFilesHelper() { |
|
| 1461 | + return $this->query('EncryptionFileHelper'); |
|
| 1462 | + } |
|
| 1463 | + |
|
| 1464 | + /** |
|
| 1465 | + * @return \OCP\Encryption\Keys\IStorage |
|
| 1466 | + */ |
|
| 1467 | + public function getEncryptionKeyStorage() { |
|
| 1468 | + return $this->query('EncryptionKeyStorage'); |
|
| 1469 | + } |
|
| 1470 | + |
|
| 1471 | + /** |
|
| 1472 | + * The current request object holding all information about the request |
|
| 1473 | + * currently being processed is returned from this method. |
|
| 1474 | + * In case the current execution was not initiated by a web request null is returned |
|
| 1475 | + * |
|
| 1476 | + * @return \OCP\IRequest |
|
| 1477 | + */ |
|
| 1478 | + public function getRequest() { |
|
| 1479 | + return $this->query(IRequest::class); |
|
| 1480 | + } |
|
| 1481 | + |
|
| 1482 | + /** |
|
| 1483 | + * Returns the preview manager which can create preview images for a given file |
|
| 1484 | + * |
|
| 1485 | + * @return IPreview |
|
| 1486 | + */ |
|
| 1487 | + public function getPreviewManager() { |
|
| 1488 | + return $this->query(IPreview::class); |
|
| 1489 | + } |
|
| 1490 | + |
|
| 1491 | + /** |
|
| 1492 | + * Returns the tag manager which can get and set tags for different object types |
|
| 1493 | + * |
|
| 1494 | + * @see \OCP\ITagManager::load() |
|
| 1495 | + * @return ITagManager |
|
| 1496 | + */ |
|
| 1497 | + public function getTagManager() { |
|
| 1498 | + return $this->query(ITagManager::class); |
|
| 1499 | + } |
|
| 1500 | + |
|
| 1501 | + /** |
|
| 1502 | + * Returns the system-tag manager |
|
| 1503 | + * |
|
| 1504 | + * @return ISystemTagManager |
|
| 1505 | + * |
|
| 1506 | + * @since 9.0.0 |
|
| 1507 | + */ |
|
| 1508 | + public function getSystemTagManager() { |
|
| 1509 | + return $this->query(ISystemTagManager::class); |
|
| 1510 | + } |
|
| 1511 | + |
|
| 1512 | + /** |
|
| 1513 | + * Returns the system-tag object mapper |
|
| 1514 | + * |
|
| 1515 | + * @return ISystemTagObjectMapper |
|
| 1516 | + * |
|
| 1517 | + * @since 9.0.0 |
|
| 1518 | + */ |
|
| 1519 | + public function getSystemTagObjectMapper() { |
|
| 1520 | + return $this->query(ISystemTagObjectMapper::class); |
|
| 1521 | + } |
|
| 1522 | + |
|
| 1523 | + /** |
|
| 1524 | + * Returns the avatar manager, used for avatar functionality |
|
| 1525 | + * |
|
| 1526 | + * @return IAvatarManager |
|
| 1527 | + */ |
|
| 1528 | + public function getAvatarManager() { |
|
| 1529 | + return $this->query(IAvatarManager::class); |
|
| 1530 | + } |
|
| 1531 | + |
|
| 1532 | + /** |
|
| 1533 | + * Returns the root folder of ownCloud's data directory |
|
| 1534 | + * |
|
| 1535 | + * @return IRootFolder |
|
| 1536 | + */ |
|
| 1537 | + public function getRootFolder() { |
|
| 1538 | + return $this->query(IRootFolder::class); |
|
| 1539 | + } |
|
| 1540 | + |
|
| 1541 | + /** |
|
| 1542 | + * Returns the root folder of ownCloud's data directory |
|
| 1543 | + * This is the lazy variant so this gets only initialized once it |
|
| 1544 | + * is actually used. |
|
| 1545 | + * |
|
| 1546 | + * @return IRootFolder |
|
| 1547 | + */ |
|
| 1548 | + public function getLazyRootFolder() { |
|
| 1549 | + return $this->query(IRootFolder::class); |
|
| 1550 | + } |
|
| 1551 | + |
|
| 1552 | + /** |
|
| 1553 | + * Returns a view to ownCloud's files folder |
|
| 1554 | + * |
|
| 1555 | + * @param string $userId user ID |
|
| 1556 | + * @return \OCP\Files\Folder|null |
|
| 1557 | + */ |
|
| 1558 | + public function getUserFolder($userId = null) { |
|
| 1559 | + if ($userId === null) { |
|
| 1560 | + $user = $this->getUserSession()->getUser(); |
|
| 1561 | + if (!$user) { |
|
| 1562 | + return null; |
|
| 1563 | + } |
|
| 1564 | + $userId = $user->getUID(); |
|
| 1565 | + } |
|
| 1566 | + $root = $this->getRootFolder(); |
|
| 1567 | + return $root->getUserFolder($userId); |
|
| 1568 | + } |
|
| 1569 | + |
|
| 1570 | + /** |
|
| 1571 | + * Returns an app-specific view in ownClouds data directory |
|
| 1572 | + * |
|
| 1573 | + * @return \OCP\Files\Folder |
|
| 1574 | + * @deprecated since 9.2.0 use IAppData |
|
| 1575 | + */ |
|
| 1576 | + public function getAppFolder() { |
|
| 1577 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
| 1578 | + $root = $this->getRootFolder(); |
|
| 1579 | + if (!$root->nodeExists($dir)) { |
|
| 1580 | + $folder = $root->newFolder($dir); |
|
| 1581 | + } else { |
|
| 1582 | + $folder = $root->get($dir); |
|
| 1583 | + } |
|
| 1584 | + return $folder; |
|
| 1585 | + } |
|
| 1586 | + |
|
| 1587 | + /** |
|
| 1588 | + * @return \OC\User\Manager |
|
| 1589 | + */ |
|
| 1590 | + public function getUserManager() { |
|
| 1591 | + return $this->query(IUserManager::class); |
|
| 1592 | + } |
|
| 1593 | + |
|
| 1594 | + /** |
|
| 1595 | + * @return \OC\Group\Manager |
|
| 1596 | + */ |
|
| 1597 | + public function getGroupManager() { |
|
| 1598 | + return $this->query(IGroupManager::class); |
|
| 1599 | + } |
|
| 1600 | + |
|
| 1601 | + /** |
|
| 1602 | + * @return \OC\User\Session |
|
| 1603 | + */ |
|
| 1604 | + public function getUserSession() { |
|
| 1605 | + return $this->query(IUserSession::class); |
|
| 1606 | + } |
|
| 1607 | + |
|
| 1608 | + /** |
|
| 1609 | + * @return \OCP\ISession |
|
| 1610 | + */ |
|
| 1611 | + public function getSession() { |
|
| 1612 | + return $this->getUserSession()->getSession(); |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + /** |
|
| 1616 | + * @param \OCP\ISession $session |
|
| 1617 | + */ |
|
| 1618 | + public function setSession(\OCP\ISession $session) { |
|
| 1619 | + $this->query(SessionStorage::class)->setSession($session); |
|
| 1620 | + $this->getUserSession()->setSession($session); |
|
| 1621 | + $this->query(Store::class)->setSession($session); |
|
| 1622 | + } |
|
| 1623 | + |
|
| 1624 | + /** |
|
| 1625 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
| 1626 | + */ |
|
| 1627 | + public function getTwoFactorAuthManager() { |
|
| 1628 | + return $this->query(\OC\Authentication\TwoFactorAuth\Manager::class); |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + /** |
|
| 1632 | + * @return \OC\NavigationManager |
|
| 1633 | + */ |
|
| 1634 | + public function getNavigationManager() { |
|
| 1635 | + return $this->query(INavigationManager::class); |
|
| 1636 | + } |
|
| 1637 | + |
|
| 1638 | + /** |
|
| 1639 | + * @return \OCP\IConfig |
|
| 1640 | + */ |
|
| 1641 | + public function getConfig() { |
|
| 1642 | + return $this->query(AllConfig::class); |
|
| 1643 | + } |
|
| 1644 | + |
|
| 1645 | + /** |
|
| 1646 | + * @return \OC\SystemConfig |
|
| 1647 | + */ |
|
| 1648 | + public function getSystemConfig() { |
|
| 1649 | + return $this->query(SystemConfig::class); |
|
| 1650 | + } |
|
| 1651 | + |
|
| 1652 | + /** |
|
| 1653 | + * Returns the app config manager |
|
| 1654 | + * |
|
| 1655 | + * @return IAppConfig |
|
| 1656 | + */ |
|
| 1657 | + public function getAppConfig() { |
|
| 1658 | + return $this->query(IAppConfig::class); |
|
| 1659 | + } |
|
| 1660 | + |
|
| 1661 | + /** |
|
| 1662 | + * @return IFactory |
|
| 1663 | + */ |
|
| 1664 | + public function getL10NFactory() { |
|
| 1665 | + return $this->query(IFactory::class); |
|
| 1666 | + } |
|
| 1667 | + |
|
| 1668 | + /** |
|
| 1669 | + * get an L10N instance |
|
| 1670 | + * |
|
| 1671 | + * @param string $app appid |
|
| 1672 | + * @param string $lang |
|
| 1673 | + * @return IL10N |
|
| 1674 | + */ |
|
| 1675 | + public function getL10N($app, $lang = null) { |
|
| 1676 | + return $this->getL10NFactory()->get($app, $lang); |
|
| 1677 | + } |
|
| 1678 | + |
|
| 1679 | + /** |
|
| 1680 | + * @return IURLGenerator |
|
| 1681 | + */ |
|
| 1682 | + public function getURLGenerator() { |
|
| 1683 | + return $this->query(IURLGenerator::class); |
|
| 1684 | + } |
|
| 1685 | + |
|
| 1686 | + /** |
|
| 1687 | + * @return AppFetcher |
|
| 1688 | + */ |
|
| 1689 | + public function getAppFetcher() { |
|
| 1690 | + return $this->query(AppFetcher::class); |
|
| 1691 | + } |
|
| 1692 | + |
|
| 1693 | + /** |
|
| 1694 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
| 1695 | + * getMemCacheFactory() instead. |
|
| 1696 | + * |
|
| 1697 | + * @return ICache |
|
| 1698 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
| 1699 | + */ |
|
| 1700 | + public function getCache() { |
|
| 1701 | + return $this->query(ICache::class); |
|
| 1702 | + } |
|
| 1703 | + |
|
| 1704 | + /** |
|
| 1705 | + * Returns an \OCP\CacheFactory instance |
|
| 1706 | + * |
|
| 1707 | + * @return \OCP\ICacheFactory |
|
| 1708 | + */ |
|
| 1709 | + public function getMemCacheFactory() { |
|
| 1710 | + return $this->query(Factory::class); |
|
| 1711 | + } |
|
| 1712 | + |
|
| 1713 | + /** |
|
| 1714 | + * Returns an \OC\RedisFactory instance |
|
| 1715 | + * |
|
| 1716 | + * @return \OC\RedisFactory |
|
| 1717 | + */ |
|
| 1718 | + public function getGetRedisFactory() { |
|
| 1719 | + return $this->query('RedisFactory'); |
|
| 1720 | + } |
|
| 1721 | + |
|
| 1722 | + |
|
| 1723 | + /** |
|
| 1724 | + * Returns the current session |
|
| 1725 | + * |
|
| 1726 | + * @return \OCP\IDBConnection |
|
| 1727 | + */ |
|
| 1728 | + public function getDatabaseConnection() { |
|
| 1729 | + return $this->query(IDBConnection::class); |
|
| 1730 | + } |
|
| 1731 | + |
|
| 1732 | + /** |
|
| 1733 | + * Returns the activity manager |
|
| 1734 | + * |
|
| 1735 | + * @return \OCP\Activity\IManager |
|
| 1736 | + */ |
|
| 1737 | + public function getActivityManager() { |
|
| 1738 | + return $this->query(\OCP\Activity\IManager::class); |
|
| 1739 | + } |
|
| 1740 | + |
|
| 1741 | + /** |
|
| 1742 | + * Returns an job list for controlling background jobs |
|
| 1743 | + * |
|
| 1744 | + * @return IJobList |
|
| 1745 | + */ |
|
| 1746 | + public function getJobList() { |
|
| 1747 | + return $this->query(IJobList::class); |
|
| 1748 | + } |
|
| 1749 | + |
|
| 1750 | + /** |
|
| 1751 | + * Returns a logger instance |
|
| 1752 | + * |
|
| 1753 | + * @return ILogger |
|
| 1754 | + */ |
|
| 1755 | + public function getLogger() { |
|
| 1756 | + return $this->query(ILogger::class); |
|
| 1757 | + } |
|
| 1758 | + |
|
| 1759 | + /** |
|
| 1760 | + * @return ILogFactory |
|
| 1761 | + * @throws \OCP\AppFramework\QueryException |
|
| 1762 | + */ |
|
| 1763 | + public function getLogFactory() { |
|
| 1764 | + return $this->query(ILogFactory::class); |
|
| 1765 | + } |
|
| 1766 | + |
|
| 1767 | + /** |
|
| 1768 | + * Returns a router for generating and matching urls |
|
| 1769 | + * |
|
| 1770 | + * @return IRouter |
|
| 1771 | + */ |
|
| 1772 | + public function getRouter() { |
|
| 1773 | + return $this->query(IRouter::class); |
|
| 1774 | + } |
|
| 1775 | + |
|
| 1776 | + /** |
|
| 1777 | + * Returns a search instance |
|
| 1778 | + * |
|
| 1779 | + * @return ISearch |
|
| 1780 | + */ |
|
| 1781 | + public function getSearch() { |
|
| 1782 | + return $this->query(ISearch::class); |
|
| 1783 | + } |
|
| 1784 | + |
|
| 1785 | + /** |
|
| 1786 | + * Returns a SecureRandom instance |
|
| 1787 | + * |
|
| 1788 | + * @return \OCP\Security\ISecureRandom |
|
| 1789 | + */ |
|
| 1790 | + public function getSecureRandom() { |
|
| 1791 | + return $this->query(ISecureRandom::class); |
|
| 1792 | + } |
|
| 1793 | + |
|
| 1794 | + /** |
|
| 1795 | + * Returns a Crypto instance |
|
| 1796 | + * |
|
| 1797 | + * @return ICrypto |
|
| 1798 | + */ |
|
| 1799 | + public function getCrypto() { |
|
| 1800 | + return $this->query(ICrypto::class); |
|
| 1801 | + } |
|
| 1802 | + |
|
| 1803 | + /** |
|
| 1804 | + * Returns a Hasher instance |
|
| 1805 | + * |
|
| 1806 | + * @return IHasher |
|
| 1807 | + */ |
|
| 1808 | + public function getHasher() { |
|
| 1809 | + return $this->query(IHasher::class); |
|
| 1810 | + } |
|
| 1811 | + |
|
| 1812 | + /** |
|
| 1813 | + * Returns a CredentialsManager instance |
|
| 1814 | + * |
|
| 1815 | + * @return ICredentialsManager |
|
| 1816 | + */ |
|
| 1817 | + public function getCredentialsManager() { |
|
| 1818 | + return $this->query(ICredentialsManager::class); |
|
| 1819 | + } |
|
| 1820 | + |
|
| 1821 | + /** |
|
| 1822 | + * Get the certificate manager for the user |
|
| 1823 | + * |
|
| 1824 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 1825 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
| 1826 | + */ |
|
| 1827 | + public function getCertificateManager($userId = '') { |
|
| 1828 | + if ($userId === '') { |
|
| 1829 | + $userSession = $this->getUserSession(); |
|
| 1830 | + $user = $userSession->getUser(); |
|
| 1831 | + if (is_null($user)) { |
|
| 1832 | + return null; |
|
| 1833 | + } |
|
| 1834 | + $userId = $user->getUID(); |
|
| 1835 | + } |
|
| 1836 | + return new CertificateManager( |
|
| 1837 | + $userId, |
|
| 1838 | + new View(), |
|
| 1839 | + $this->getConfig(), |
|
| 1840 | + $this->getLogger(), |
|
| 1841 | + $this->getSecureRandom() |
|
| 1842 | + ); |
|
| 1843 | + } |
|
| 1844 | + |
|
| 1845 | + /** |
|
| 1846 | + * Returns an instance of the HTTP client service |
|
| 1847 | + * |
|
| 1848 | + * @return IClientService |
|
| 1849 | + */ |
|
| 1850 | + public function getHTTPClientService() { |
|
| 1851 | + return $this->query(IClientService::class); |
|
| 1852 | + } |
|
| 1853 | + |
|
| 1854 | + /** |
|
| 1855 | + * Create a new event source |
|
| 1856 | + * |
|
| 1857 | + * @return \OCP\IEventSource |
|
| 1858 | + */ |
|
| 1859 | + public function createEventSource() { |
|
| 1860 | + return new \OC_EventSource(); |
|
| 1861 | + } |
|
| 1862 | + |
|
| 1863 | + /** |
|
| 1864 | + * Get the active event logger |
|
| 1865 | + * |
|
| 1866 | + * The returned logger only logs data when debug mode is enabled |
|
| 1867 | + * |
|
| 1868 | + * @return IEventLogger |
|
| 1869 | + */ |
|
| 1870 | + public function getEventLogger() { |
|
| 1871 | + return $this->query(IEventLogger::class); |
|
| 1872 | + } |
|
| 1873 | + |
|
| 1874 | + /** |
|
| 1875 | + * Get the active query logger |
|
| 1876 | + * |
|
| 1877 | + * The returned logger only logs data when debug mode is enabled |
|
| 1878 | + * |
|
| 1879 | + * @return IQueryLogger |
|
| 1880 | + */ |
|
| 1881 | + public function getQueryLogger() { |
|
| 1882 | + return $this->query(IQueryLogger::class); |
|
| 1883 | + } |
|
| 1884 | + |
|
| 1885 | + /** |
|
| 1886 | + * Get the manager for temporary files and folders |
|
| 1887 | + * |
|
| 1888 | + * @return \OCP\ITempManager |
|
| 1889 | + */ |
|
| 1890 | + public function getTempManager() { |
|
| 1891 | + return $this->query(ITempManager::class); |
|
| 1892 | + } |
|
| 1893 | + |
|
| 1894 | + /** |
|
| 1895 | + * Get the app manager |
|
| 1896 | + * |
|
| 1897 | + * @return \OCP\App\IAppManager |
|
| 1898 | + */ |
|
| 1899 | + public function getAppManager() { |
|
| 1900 | + return $this->query(IAppManager::class); |
|
| 1901 | + } |
|
| 1902 | + |
|
| 1903 | + /** |
|
| 1904 | + * Creates a new mailer |
|
| 1905 | + * |
|
| 1906 | + * @return IMailer |
|
| 1907 | + */ |
|
| 1908 | + public function getMailer() { |
|
| 1909 | + return $this->query(IMailer::class); |
|
| 1910 | + } |
|
| 1911 | + |
|
| 1912 | + /** |
|
| 1913 | + * Get the webroot |
|
| 1914 | + * |
|
| 1915 | + * @return string |
|
| 1916 | + */ |
|
| 1917 | + public function getWebRoot() { |
|
| 1918 | + return $this->webRoot; |
|
| 1919 | + } |
|
| 1920 | + |
|
| 1921 | + /** |
|
| 1922 | + * @return \OC\OCSClient |
|
| 1923 | + */ |
|
| 1924 | + public function getOcsClient() { |
|
| 1925 | + return $this->query('OcsClient'); |
|
| 1926 | + } |
|
| 1927 | + |
|
| 1928 | + /** |
|
| 1929 | + * @return IDateTimeZone |
|
| 1930 | + */ |
|
| 1931 | + public function getDateTimeZone() { |
|
| 1932 | + return $this->query(IDateTimeZone::class); |
|
| 1933 | + } |
|
| 1934 | + |
|
| 1935 | + /** |
|
| 1936 | + * @return IDateTimeFormatter |
|
| 1937 | + */ |
|
| 1938 | + public function getDateTimeFormatter() { |
|
| 1939 | + return $this->query(IDateTimeFormatter::class); |
|
| 1940 | + } |
|
| 1941 | + |
|
| 1942 | + /** |
|
| 1943 | + * @return IMountProviderCollection |
|
| 1944 | + */ |
|
| 1945 | + public function getMountProviderCollection() { |
|
| 1946 | + return $this->query(IMountProviderCollection::class); |
|
| 1947 | + } |
|
| 1948 | + |
|
| 1949 | + /** |
|
| 1950 | + * Get the IniWrapper |
|
| 1951 | + * |
|
| 1952 | + * @return IniGetWrapper |
|
| 1953 | + */ |
|
| 1954 | + public function getIniWrapper() { |
|
| 1955 | + return $this->query('IniWrapper'); |
|
| 1956 | + } |
|
| 1957 | + |
|
| 1958 | + /** |
|
| 1959 | + * @return \OCP\Command\IBus |
|
| 1960 | + */ |
|
| 1961 | + public function getCommandBus() { |
|
| 1962 | + return $this->query('AsyncCommandBus'); |
|
| 1963 | + } |
|
| 1964 | + |
|
| 1965 | + /** |
|
| 1966 | + * Get the trusted domain helper |
|
| 1967 | + * |
|
| 1968 | + * @return TrustedDomainHelper |
|
| 1969 | + */ |
|
| 1970 | + public function getTrustedDomainHelper() { |
|
| 1971 | + return $this->query('TrustedDomainHelper'); |
|
| 1972 | + } |
|
| 1973 | + |
|
| 1974 | + /** |
|
| 1975 | + * Get the locking provider |
|
| 1976 | + * |
|
| 1977 | + * @return ILockingProvider |
|
| 1978 | + * @since 8.1.0 |
|
| 1979 | + */ |
|
| 1980 | + public function getLockingProvider() { |
|
| 1981 | + return $this->query(ILockingProvider::class); |
|
| 1982 | + } |
|
| 1983 | + |
|
| 1984 | + /** |
|
| 1985 | + * @return IMountManager |
|
| 1986 | + **/ |
|
| 1987 | + public function getMountManager() { |
|
| 1988 | + return $this->query(IMountManager::class); |
|
| 1989 | + } |
|
| 1990 | + |
|
| 1991 | + /** |
|
| 1992 | + * @return IUserMountCache |
|
| 1993 | + */ |
|
| 1994 | + public function getUserMountCache() { |
|
| 1995 | + return $this->query(IUserMountCache::class); |
|
| 1996 | + } |
|
| 1997 | + |
|
| 1998 | + /** |
|
| 1999 | + * Get the MimeTypeDetector |
|
| 2000 | + * |
|
| 2001 | + * @return IMimeTypeDetector |
|
| 2002 | + */ |
|
| 2003 | + public function getMimeTypeDetector() { |
|
| 2004 | + return $this->query(IMimeTypeDetector::class); |
|
| 2005 | + } |
|
| 2006 | + |
|
| 2007 | + /** |
|
| 2008 | + * Get the MimeTypeLoader |
|
| 2009 | + * |
|
| 2010 | + * @return IMimeTypeLoader |
|
| 2011 | + */ |
|
| 2012 | + public function getMimeTypeLoader() { |
|
| 2013 | + return $this->query(IMimeTypeLoader::class); |
|
| 2014 | + } |
|
| 2015 | + |
|
| 2016 | + /** |
|
| 2017 | + * Get the manager of all the capabilities |
|
| 2018 | + * |
|
| 2019 | + * @return CapabilitiesManager |
|
| 2020 | + */ |
|
| 2021 | + public function getCapabilitiesManager() { |
|
| 2022 | + return $this->query(CapabilitiesManager::class); |
|
| 2023 | + } |
|
| 2024 | + |
|
| 2025 | + /** |
|
| 2026 | + * Get the EventDispatcher |
|
| 2027 | + * |
|
| 2028 | + * @return EventDispatcherInterface |
|
| 2029 | + * @since 8.2.0 |
|
| 2030 | + * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher |
|
| 2031 | + */ |
|
| 2032 | + public function getEventDispatcher() { |
|
| 2033 | + return $this->query(\OC\EventDispatcher\SymfonyAdapter::class); |
|
| 2034 | + } |
|
| 2035 | + |
|
| 2036 | + /** |
|
| 2037 | + * Get the Notification Manager |
|
| 2038 | + * |
|
| 2039 | + * @return \OCP\Notification\IManager |
|
| 2040 | + * @since 8.2.0 |
|
| 2041 | + */ |
|
| 2042 | + public function getNotificationManager() { |
|
| 2043 | + return $this->query(\OCP\Notification\IManager::class); |
|
| 2044 | + } |
|
| 2045 | + |
|
| 2046 | + /** |
|
| 2047 | + * @return ICommentsManager |
|
| 2048 | + */ |
|
| 2049 | + public function getCommentsManager() { |
|
| 2050 | + return $this->query(ICommentsManager::class); |
|
| 2051 | + } |
|
| 2052 | + |
|
| 2053 | + /** |
|
| 2054 | + * @return \OCA\Theming\ThemingDefaults |
|
| 2055 | + */ |
|
| 2056 | + public function getThemingDefaults() { |
|
| 2057 | + return $this->query('ThemingDefaults'); |
|
| 2058 | + } |
|
| 2059 | + |
|
| 2060 | + /** |
|
| 2061 | + * @return \OC\IntegrityCheck\Checker |
|
| 2062 | + */ |
|
| 2063 | + public function getIntegrityCodeChecker() { |
|
| 2064 | + return $this->query('IntegrityCodeChecker'); |
|
| 2065 | + } |
|
| 2066 | + |
|
| 2067 | + /** |
|
| 2068 | + * @return \OC\Session\CryptoWrapper |
|
| 2069 | + */ |
|
| 2070 | + public function getSessionCryptoWrapper() { |
|
| 2071 | + return $this->query('CryptoWrapper'); |
|
| 2072 | + } |
|
| 2073 | + |
|
| 2074 | + /** |
|
| 2075 | + * @return CsrfTokenManager |
|
| 2076 | + */ |
|
| 2077 | + public function getCsrfTokenManager() { |
|
| 2078 | + return $this->query(CsrfTokenManager::class); |
|
| 2079 | + } |
|
| 2080 | + |
|
| 2081 | + /** |
|
| 2082 | + * @return Throttler |
|
| 2083 | + */ |
|
| 2084 | + public function getBruteForceThrottler() { |
|
| 2085 | + return $this->query(Throttler::class); |
|
| 2086 | + } |
|
| 2087 | + |
|
| 2088 | + /** |
|
| 2089 | + * @return IContentSecurityPolicyManager |
|
| 2090 | + */ |
|
| 2091 | + public function getContentSecurityPolicyManager() { |
|
| 2092 | + return $this->query(ContentSecurityPolicyManager::class); |
|
| 2093 | + } |
|
| 2094 | + |
|
| 2095 | + /** |
|
| 2096 | + * @return ContentSecurityPolicyNonceManager |
|
| 2097 | + */ |
|
| 2098 | + public function getContentSecurityPolicyNonceManager() { |
|
| 2099 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
| 2100 | + } |
|
| 2101 | + |
|
| 2102 | + /** |
|
| 2103 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 2104 | + * |
|
| 2105 | + * @return \OCA\Files_External\Service\BackendService |
|
| 2106 | + */ |
|
| 2107 | + public function getStoragesBackendService() { |
|
| 2108 | + return $this->query(BackendService::class); |
|
| 2109 | + } |
|
| 2110 | + |
|
| 2111 | + /** |
|
| 2112 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 2113 | + * |
|
| 2114 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
| 2115 | + */ |
|
| 2116 | + public function getGlobalStoragesService() { |
|
| 2117 | + return $this->query(GlobalStoragesService::class); |
|
| 2118 | + } |
|
| 2119 | + |
|
| 2120 | + /** |
|
| 2121 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 2122 | + * |
|
| 2123 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
| 2124 | + */ |
|
| 2125 | + public function getUserGlobalStoragesService() { |
|
| 2126 | + return $this->query(UserGlobalStoragesService::class); |
|
| 2127 | + } |
|
| 2128 | + |
|
| 2129 | + /** |
|
| 2130 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 2131 | + * |
|
| 2132 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
| 2133 | + */ |
|
| 2134 | + public function getUserStoragesService() { |
|
| 2135 | + return $this->query(UserStoragesService::class); |
|
| 2136 | + } |
|
| 2137 | + |
|
| 2138 | + /** |
|
| 2139 | + * @return \OCP\Share\IManager |
|
| 2140 | + */ |
|
| 2141 | + public function getShareManager() { |
|
| 2142 | + return $this->query(\OCP\Share\IManager::class); |
|
| 2143 | + } |
|
| 2144 | + |
|
| 2145 | + /** |
|
| 2146 | + * @return \OCP\Collaboration\Collaborators\ISearch |
|
| 2147 | + */ |
|
| 2148 | + public function getCollaboratorSearch() { |
|
| 2149 | + return $this->query(\OCP\Collaboration\Collaborators\ISearch::class); |
|
| 2150 | + } |
|
| 2151 | + |
|
| 2152 | + /** |
|
| 2153 | + * @return \OCP\Collaboration\AutoComplete\IManager |
|
| 2154 | + */ |
|
| 2155 | + public function getAutoCompleteManager() { |
|
| 2156 | + return $this->query(IManager::class); |
|
| 2157 | + } |
|
| 2158 | + |
|
| 2159 | + /** |
|
| 2160 | + * Returns the LDAP Provider |
|
| 2161 | + * |
|
| 2162 | + * @return \OCP\LDAP\ILDAPProvider |
|
| 2163 | + */ |
|
| 2164 | + public function getLDAPProvider() { |
|
| 2165 | + return $this->query('LDAPProvider'); |
|
| 2166 | + } |
|
| 2167 | + |
|
| 2168 | + /** |
|
| 2169 | + * @return \OCP\Settings\IManager |
|
| 2170 | + */ |
|
| 2171 | + public function getSettingsManager() { |
|
| 2172 | + return $this->query('SettingsManager'); |
|
| 2173 | + } |
|
| 2174 | + |
|
| 2175 | + /** |
|
| 2176 | + * @return \OCP\Files\IAppData |
|
| 2177 | + */ |
|
| 2178 | + public function getAppDataDir($app) { |
|
| 2179 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
| 2180 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
| 2181 | + return $factory->get($app); |
|
| 2182 | + } |
|
| 2183 | + |
|
| 2184 | + /** |
|
| 2185 | + * @return \OCP\Lockdown\ILockdownManager |
|
| 2186 | + */ |
|
| 2187 | + public function getLockdownManager() { |
|
| 2188 | + return $this->query('LockdownManager'); |
|
| 2189 | + } |
|
| 2190 | + |
|
| 2191 | + /** |
|
| 2192 | + * @return \OCP\Federation\ICloudIdManager |
|
| 2193 | + */ |
|
| 2194 | + public function getCloudIdManager() { |
|
| 2195 | + return $this->query(ICloudIdManager::class); |
|
| 2196 | + } |
|
| 2197 | + |
|
| 2198 | + /** |
|
| 2199 | + * @return \OCP\GlobalScale\IConfig |
|
| 2200 | + */ |
|
| 2201 | + public function getGlobalScaleConfig() { |
|
| 2202 | + return $this->query(IConfig::class); |
|
| 2203 | + } |
|
| 2204 | + |
|
| 2205 | + /** |
|
| 2206 | + * @return \OCP\Federation\ICloudFederationProviderManager |
|
| 2207 | + */ |
|
| 2208 | + public function getCloudFederationProviderManager() { |
|
| 2209 | + return $this->query(ICloudFederationProviderManager::class); |
|
| 2210 | + } |
|
| 2211 | + |
|
| 2212 | + /** |
|
| 2213 | + * @return \OCP\Remote\Api\IApiFactory |
|
| 2214 | + */ |
|
| 2215 | + public function getRemoteApiFactory() { |
|
| 2216 | + return $this->query(IApiFactory::class); |
|
| 2217 | + } |
|
| 2218 | + |
|
| 2219 | + /** |
|
| 2220 | + * @return \OCP\Federation\ICloudFederationFactory |
|
| 2221 | + */ |
|
| 2222 | + public function getCloudFederationFactory() { |
|
| 2223 | + return $this->query(ICloudFederationFactory::class); |
|
| 2224 | + } |
|
| 2225 | + |
|
| 2226 | + /** |
|
| 2227 | + * @return \OCP\Remote\IInstanceFactory |
|
| 2228 | + */ |
|
| 2229 | + public function getRemoteInstanceFactory() { |
|
| 2230 | + return $this->query(IInstanceFactory::class); |
|
| 2231 | + } |
|
| 2232 | + |
|
| 2233 | + /** |
|
| 2234 | + * @return IStorageFactory |
|
| 2235 | + */ |
|
| 2236 | + public function getStorageFactory() { |
|
| 2237 | + return $this->query(IStorageFactory::class); |
|
| 2238 | + } |
|
| 2239 | + |
|
| 2240 | + /** |
|
| 2241 | + * Get the Preview GeneratorHelper |
|
| 2242 | + * |
|
| 2243 | + * @return GeneratorHelper |
|
| 2244 | + * @since 17.0.0 |
|
| 2245 | + */ |
|
| 2246 | + public function getGeneratorHelper() { |
|
| 2247 | + return $this->query(\OC\Preview\GeneratorHelper::class); |
|
| 2248 | + } |
|
| 2249 | + |
|
| 2250 | + private function registerDeprecatedAlias(string $alias, string $target) { |
|
| 2251 | + $this->registerService($alias, function (IContainer $container) use ($target, $alias) { |
|
| 2252 | + try { |
|
| 2253 | + /** @var ILogger $logger */ |
|
| 2254 | + $logger = $container->query(ILogger::class); |
|
| 2255 | + $logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']); |
|
| 2256 | + } catch (QueryException $e) { |
|
| 2257 | + // Could not get logger. Continue |
|
| 2258 | + } |
|
| 2259 | + |
|
| 2260 | + return $container->query($target); |
|
| 2261 | + }, false); |
|
| 2262 | + } |
|
| 2263 | 2263 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | // To find out if we are running from CLI or not |
| 257 | 257 | $this->registerParameter('isCLI', \OC::$CLI); |
| 258 | 258 | |
| 259 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
| 259 | + $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
| 260 | 260 | return $c; |
| 261 | 261 | }); |
| 262 | 262 | |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | $this->registerAlias(IActionFactory::class, ActionFactory::class); |
| 278 | 278 | |
| 279 | 279 | |
| 280 | - $this->registerService(IPreview::class, function (Server $c) { |
|
| 280 | + $this->registerService(IPreview::class, function(Server $c) { |
|
| 281 | 281 | return new PreviewManager( |
| 282 | 282 | $c->getConfig(), |
| 283 | 283 | $c->getRootFolder(), |
@@ -289,13 +289,13 @@ discard block |
||
| 289 | 289 | }); |
| 290 | 290 | $this->registerDeprecatedAlias('PreviewManager', IPreview::class); |
| 291 | 291 | |
| 292 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 292 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
| 293 | 293 | return new \OC\Preview\Watcher( |
| 294 | 294 | new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig(), 'preview') |
| 295 | 295 | ); |
| 296 | 296 | }); |
| 297 | 297 | |
| 298 | - $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { |
|
| 298 | + $this->registerService(\OCP\Encryption\IManager::class, function(Server $c) { |
|
| 299 | 299 | $view = new View(); |
| 300 | 300 | $util = new Encryption\Util( |
| 301 | 301 | $view, |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | }); |
| 315 | 315 | $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class); |
| 316 | 316 | |
| 317 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 317 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
| 318 | 318 | $util = new Encryption\Util( |
| 319 | 319 | new View(), |
| 320 | 320 | $c->getUserManager(), |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | ); |
| 329 | 329 | }); |
| 330 | 330 | |
| 331 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 331 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
| 332 | 332 | $view = new View(); |
| 333 | 333 | $util = new Encryption\Util( |
| 334 | 334 | $view, |
@@ -339,30 +339,30 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | return new Encryption\Keys\Storage($view, $util); |
| 341 | 341 | }); |
| 342 | - $this->registerService('TagMapper', function (Server $c) { |
|
| 342 | + $this->registerService('TagMapper', function(Server $c) { |
|
| 343 | 343 | return new TagMapper($c->getDatabaseConnection()); |
| 344 | 344 | }); |
| 345 | 345 | |
| 346 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
| 346 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
| 347 | 347 | $tagMapper = $c->query('TagMapper'); |
| 348 | 348 | return new TagManager($tagMapper, $c->getUserSession()); |
| 349 | 349 | }); |
| 350 | 350 | $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class); |
| 351 | 351 | |
| 352 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 352 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
| 353 | 353 | $config = $c->getConfig(); |
| 354 | 354 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
| 355 | 355 | return new $factoryClass($this); |
| 356 | 356 | }); |
| 357 | - $this->registerService(ISystemTagManager::class, function (Server $c) { |
|
| 357 | + $this->registerService(ISystemTagManager::class, function(Server $c) { |
|
| 358 | 358 | return $c->query('SystemTagManagerFactory')->getManager(); |
| 359 | 359 | }); |
| 360 | 360 | $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class); |
| 361 | 361 | |
| 362 | - $this->registerService(ISystemTagObjectMapper::class, function (Server $c) { |
|
| 362 | + $this->registerService(ISystemTagObjectMapper::class, function(Server $c) { |
|
| 363 | 363 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
| 364 | 364 | }); |
| 365 | - $this->registerService('RootFolder', function (Server $c) { |
|
| 365 | + $this->registerService('RootFolder', function(Server $c) { |
|
| 366 | 366 | $manager = \OC\Files\Filesystem::getMountManager(null); |
| 367 | 367 | $view = new View(); |
| 368 | 368 | $root = new Root( |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | |
| 380 | 380 | return $root; |
| 381 | 381 | }); |
| 382 | - $this->registerService(HookConnector::class, function (Server $c) { |
|
| 382 | + $this->registerService(HookConnector::class, function(Server $c) { |
|
| 383 | 383 | return new HookConnector( |
| 384 | 384 | $c->query(IRootFolder::class), |
| 385 | 385 | new View(), |
@@ -390,8 +390,8 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class); |
| 392 | 392 | |
| 393 | - $this->registerService(IRootFolder::class, function (Server $c) { |
|
| 394 | - return new LazyRoot(function () use ($c) { |
|
| 393 | + $this->registerService(IRootFolder::class, function(Server $c) { |
|
| 394 | + return new LazyRoot(function() use ($c) { |
|
| 395 | 395 | return $c->query('RootFolder'); |
| 396 | 396 | }); |
| 397 | 397 | }); |
@@ -400,44 +400,44 @@ discard block |
||
| 400 | 400 | $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class); |
| 401 | 401 | $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
| 402 | 402 | |
| 403 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 403 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
| 404 | 404 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); |
| 405 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 405 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
| 406 | 406 | \OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]); |
| 407 | 407 | |
| 408 | 408 | /** @var IEventDispatcher $dispatcher */ |
| 409 | 409 | $dispatcher = $this->query(IEventDispatcher::class); |
| 410 | 410 | $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid)); |
| 411 | 411 | }); |
| 412 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) { |
|
| 412 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $group) { |
|
| 413 | 413 | \OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]); |
| 414 | 414 | |
| 415 | 415 | /** @var IEventDispatcher $dispatcher */ |
| 416 | 416 | $dispatcher = $this->query(IEventDispatcher::class); |
| 417 | 417 | $dispatcher->dispatchTyped(new GroupCreatedEvent($group)); |
| 418 | 418 | }); |
| 419 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 419 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
| 420 | 420 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]); |
| 421 | 421 | |
| 422 | 422 | /** @var IEventDispatcher $dispatcher */ |
| 423 | 423 | $dispatcher = $this->query(IEventDispatcher::class); |
| 424 | 424 | $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group)); |
| 425 | 425 | }); |
| 426 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 426 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
| 427 | 427 | \OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]); |
| 428 | 428 | |
| 429 | 429 | /** @var IEventDispatcher $dispatcher */ |
| 430 | 430 | $dispatcher = $this->query(IEventDispatcher::class); |
| 431 | 431 | $dispatcher->dispatchTyped(new GroupDeletedEvent($group)); |
| 432 | 432 | }); |
| 433 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 433 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 434 | 434 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]); |
| 435 | 435 | |
| 436 | 436 | /** @var IEventDispatcher $dispatcher */ |
| 437 | 437 | $dispatcher = $this->query(IEventDispatcher::class); |
| 438 | 438 | $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user)); |
| 439 | 439 | }); |
| 440 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 440 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 441 | 441 | \OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); |
| 442 | 442 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
| 443 | 443 | \OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]); |
@@ -446,12 +446,12 @@ discard block |
||
| 446 | 446 | $dispatcher = $this->query(IEventDispatcher::class); |
| 447 | 447 | $dispatcher->dispatchTyped(new UserAddedEvent($group, $user)); |
| 448 | 448 | }); |
| 449 | - $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 449 | + $groupManager->listen('\OC\Group', 'preRemoveUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 450 | 450 | /** @var IEventDispatcher $dispatcher */ |
| 451 | 451 | $dispatcher = $this->query(IEventDispatcher::class); |
| 452 | 452 | $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user)); |
| 453 | 453 | }); |
| 454 | - $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 454 | + $groupManager->listen('\OC\Group', 'postRemoveUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 455 | 455 | /** @var IEventDispatcher $dispatcher */ |
| 456 | 456 | $dispatcher = $this->query(IEventDispatcher::class); |
| 457 | 457 | $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user)); |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | }); |
| 461 | 461 | $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class); |
| 462 | 462 | |
| 463 | - $this->registerService(Store::class, function (Server $c) { |
|
| 463 | + $this->registerService(Store::class, function(Server $c) { |
|
| 464 | 464 | $session = $c->getSession(); |
| 465 | 465 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
| 466 | 466 | $tokenProvider = $c->query(IProvider::class); |
@@ -471,13 +471,13 @@ discard block |
||
| 471 | 471 | return new Store($session, $logger, $tokenProvider); |
| 472 | 472 | }); |
| 473 | 473 | $this->registerAlias(IStore::class, Store::class); |
| 474 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
| 474 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function(Server $c) { |
|
| 475 | 475 | $dbConnection = $c->getDatabaseConnection(); |
| 476 | 476 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
| 477 | 477 | }); |
| 478 | 478 | $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
| 479 | 479 | |
| 480 | - $this->registerService(\OC\User\Session::class, function (Server $c) { |
|
| 480 | + $this->registerService(\OC\User\Session::class, function(Server $c) { |
|
| 481 | 481 | $manager = $c->getUserManager(); |
| 482 | 482 | $session = new \OC\Session\Memory(''); |
| 483 | 483 | $timeFactory = new TimeFactory(); |
@@ -502,14 +502,14 @@ discard block |
||
| 502 | 502 | $c->getLogger(), |
| 503 | 503 | $c->query(IEventDispatcher::class) |
| 504 | 504 | ); |
| 505 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 505 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
| 506 | 506 | \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]); |
| 507 | 507 | |
| 508 | 508 | /** @var IEventDispatcher $dispatcher */ |
| 509 | 509 | $dispatcher = $this->query(IEventDispatcher::class); |
| 510 | 510 | $dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password)); |
| 511 | 511 | }); |
| 512 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 512 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
| 513 | 513 | /** @var $user \OC\User\User */ |
| 514 | 514 | \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]); |
| 515 | 515 | |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | $dispatcher = $this->query(IEventDispatcher::class); |
| 518 | 518 | $dispatcher->dispatchTyped(new UserCreatedEvent($user, $password)); |
| 519 | 519 | }); |
| 520 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) { |
|
| 520 | + $userSession->listen('\OC\User', 'preDelete', function($user) use ($legacyDispatcher) { |
|
| 521 | 521 | /** @var $user \OC\User\User */ |
| 522 | 522 | \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]); |
| 523 | 523 | $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | $dispatcher = $this->query(IEventDispatcher::class); |
| 527 | 527 | $dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user)); |
| 528 | 528 | }); |
| 529 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 529 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
| 530 | 530 | /** @var $user \OC\User\User */ |
| 531 | 531 | \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]); |
| 532 | 532 | |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | $dispatcher = $this->query(IEventDispatcher::class); |
| 535 | 535 | $dispatcher->dispatchTyped(new UserDeletedEvent($user)); |
| 536 | 536 | }); |
| 537 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 537 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
| 538 | 538 | /** @var $user \OC\User\User */ |
| 539 | 539 | \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); |
| 540 | 540 | |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | $dispatcher = $this->query(IEventDispatcher::class); |
| 543 | 543 | $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword)); |
| 544 | 544 | }); |
| 545 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 545 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
| 546 | 546 | /** @var $user \OC\User\User */ |
| 547 | 547 | \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]); |
| 548 | 548 | |
@@ -550,14 +550,14 @@ discard block |
||
| 550 | 550 | $dispatcher = $this->query(IEventDispatcher::class); |
| 551 | 551 | $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword)); |
| 552 | 552 | }); |
| 553 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 553 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
| 554 | 554 | \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]); |
| 555 | 555 | |
| 556 | 556 | /** @var IEventDispatcher $dispatcher */ |
| 557 | 557 | $dispatcher = $this->query(IEventDispatcher::class); |
| 558 | 558 | $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password)); |
| 559 | 559 | }); |
| 560 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { |
|
| 560 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password, $isTokenLogin) { |
|
| 561 | 561 | /** @var $user \OC\User\User */ |
| 562 | 562 | \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin]); |
| 563 | 563 | |
@@ -565,12 +565,12 @@ discard block |
||
| 565 | 565 | $dispatcher = $this->query(IEventDispatcher::class); |
| 566 | 566 | $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin)); |
| 567 | 567 | }); |
| 568 | - $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) { |
|
| 568 | + $userSession->listen('\OC\User', 'preRememberedLogin', function($uid) { |
|
| 569 | 569 | /** @var IEventDispatcher $dispatcher */ |
| 570 | 570 | $dispatcher = $this->query(IEventDispatcher::class); |
| 571 | 571 | $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid)); |
| 572 | 572 | }); |
| 573 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
| 573 | + $userSession->listen('\OC\User', 'postRememberedLogin', function($user, $password) { |
|
| 574 | 574 | /** @var $user \OC\User\User */ |
| 575 | 575 | \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]); |
| 576 | 576 | |
@@ -578,19 +578,19 @@ discard block |
||
| 578 | 578 | $dispatcher = $this->query(IEventDispatcher::class); |
| 579 | 579 | $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password)); |
| 580 | 580 | }); |
| 581 | - $userSession->listen('\OC\User', 'logout', function ($user) { |
|
| 581 | + $userSession->listen('\OC\User', 'logout', function($user) { |
|
| 582 | 582 | \OC_Hook::emit('OC_User', 'logout', []); |
| 583 | 583 | |
| 584 | 584 | /** @var IEventDispatcher $dispatcher */ |
| 585 | 585 | $dispatcher = $this->query(IEventDispatcher::class); |
| 586 | 586 | $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user)); |
| 587 | 587 | }); |
| 588 | - $userSession->listen('\OC\User', 'postLogout', function ($user) { |
|
| 588 | + $userSession->listen('\OC\User', 'postLogout', function($user) { |
|
| 589 | 589 | /** @var IEventDispatcher $dispatcher */ |
| 590 | 590 | $dispatcher = $this->query(IEventDispatcher::class); |
| 591 | 591 | $dispatcher->dispatchTyped(new UserLoggedOutEvent($user)); |
| 592 | 592 | }); |
| 593 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
| 593 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) { |
|
| 594 | 594 | /** @var $user \OC\User\User */ |
| 595 | 595 | \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]); |
| 596 | 596 | |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class); |
| 609 | 609 | $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class); |
| 610 | 610 | |
| 611 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
| 611 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
| 612 | 612 | return new \OC\AllConfig( |
| 613 | 613 | $c->getSystemConfig() |
| 614 | 614 | ); |
@@ -616,18 +616,18 @@ discard block |
||
| 616 | 616 | $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class); |
| 617 | 617 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
| 618 | 618 | |
| 619 | - $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) { |
|
| 619 | + $this->registerService(\OC\SystemConfig::class, function($c) use ($config) { |
|
| 620 | 620 | return new \OC\SystemConfig($config); |
| 621 | 621 | }); |
| 622 | 622 | $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class); |
| 623 | 623 | |
| 624 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
| 624 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
| 625 | 625 | return new \OC\AppConfig($c->getDatabaseConnection()); |
| 626 | 626 | }); |
| 627 | 627 | $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class); |
| 628 | 628 | $this->registerAlias(IAppConfig::class, \OC\AppConfig::class); |
| 629 | 629 | |
| 630 | - $this->registerService(IFactory::class, function (Server $c) { |
|
| 630 | + $this->registerService(IFactory::class, function(Server $c) { |
|
| 631 | 631 | return new \OC\L10N\Factory( |
| 632 | 632 | $c->getConfig(), |
| 633 | 633 | $c->getRequest(), |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | }); |
| 638 | 638 | $this->registerDeprecatedAlias('L10NFactory', IFactory::class); |
| 639 | 639 | |
| 640 | - $this->registerService(IURLGenerator::class, function (Server $c) { |
|
| 640 | + $this->registerService(IURLGenerator::class, function(Server $c) { |
|
| 641 | 641 | $config = $c->getConfig(); |
| 642 | 642 | $cacheFactory = $c->getMemCacheFactory(); |
| 643 | 643 | $request = $c->getRequest(); |
@@ -652,12 +652,12 @@ discard block |
||
| 652 | 652 | $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class); |
| 653 | 653 | $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class); |
| 654 | 654 | |
| 655 | - $this->registerService(ICache::class, function ($c) { |
|
| 655 | + $this->registerService(ICache::class, function($c) { |
|
| 656 | 656 | return new Cache\File(); |
| 657 | 657 | }); |
| 658 | 658 | $this->registerDeprecatedAlias('UserCache', ICache::class); |
| 659 | 659 | |
| 660 | - $this->registerService(Factory::class, function (Server $c) { |
|
| 660 | + $this->registerService(Factory::class, function(Server $c) { |
|
| 661 | 661 | $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
| 662 | 662 | ArrayCache::class, |
| 663 | 663 | ArrayCache::class, |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | $version = implode(',', $v); |
| 672 | 672 | $instanceId = \OC_Util::getInstanceId(); |
| 673 | 673 | $path = \OC::$SERVERROOT; |
| 674 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
| 674 | + $prefix = md5($instanceId.'-'.$version.'-'.$path); |
|
| 675 | 675 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
| 676 | 676 | $config->getSystemValue('memcache.local', null), |
| 677 | 677 | $config->getSystemValue('memcache.distributed', null), |
@@ -683,12 +683,12 @@ discard block |
||
| 683 | 683 | $this->registerDeprecatedAlias('MemCacheFactory', Factory::class); |
| 684 | 684 | $this->registerAlias(ICacheFactory::class, Factory::class); |
| 685 | 685 | |
| 686 | - $this->registerService('RedisFactory', function (Server $c) { |
|
| 686 | + $this->registerService('RedisFactory', function(Server $c) { |
|
| 687 | 687 | $systemConfig = $c->getSystemConfig(); |
| 688 | 688 | return new RedisFactory($systemConfig); |
| 689 | 689 | }); |
| 690 | 690 | |
| 691 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 691 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
| 692 | 692 | return new \OC\Activity\Manager( |
| 693 | 693 | $c->getRequest(), |
| 694 | 694 | $c->getUserSession(), |
@@ -698,14 +698,14 @@ discard block |
||
| 698 | 698 | }); |
| 699 | 699 | $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class); |
| 700 | 700 | |
| 701 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 701 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
| 702 | 702 | return new \OC\Activity\EventMerger( |
| 703 | 703 | $c->getL10N('lib') |
| 704 | 704 | ); |
| 705 | 705 | }); |
| 706 | 706 | $this->registerAlias(IValidator::class, Validator::class); |
| 707 | 707 | |
| 708 | - $this->registerService(AvatarManager::class, function (Server $c) { |
|
| 708 | + $this->registerService(AvatarManager::class, function(Server $c) { |
|
| 709 | 709 | return new AvatarManager( |
| 710 | 710 | $c->query(\OC\User\Manager::class), |
| 711 | 711 | $c->getAppDataDir('avatar'), |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
| 721 | 721 | $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class); |
| 722 | 722 | |
| 723 | - $this->registerService(\OC\Log::class, function (Server $c) { |
|
| 723 | + $this->registerService(\OC\Log::class, function(Server $c) { |
|
| 724 | 724 | $logType = $c->query(AllConfig::class)->getSystemValue('log_type', 'file'); |
| 725 | 725 | $factory = new LogFactory($c, $this->getSystemConfig()); |
| 726 | 726 | $logger = $factory->get($logType); |
@@ -733,11 +733,11 @@ discard block |
||
| 733 | 733 | // PSR-3 logger |
| 734 | 734 | $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class); |
| 735 | 735 | |
| 736 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
| 736 | + $this->registerService(ILogFactory::class, function(Server $c) { |
|
| 737 | 737 | return new LogFactory($c, $this->getSystemConfig()); |
| 738 | 738 | }); |
| 739 | 739 | |
| 740 | - $this->registerService(IJobList::class, function (Server $c) { |
|
| 740 | + $this->registerService(IJobList::class, function(Server $c) { |
|
| 741 | 741 | $config = $c->getConfig(); |
| 742 | 742 | return new \OC\BackgroundJob\JobList( |
| 743 | 743 | $c->getDatabaseConnection(), |
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | }); |
| 748 | 748 | $this->registerDeprecatedAlias('JobList', IJobList::class); |
| 749 | 749 | |
| 750 | - $this->registerService(IRouter::class, function (Server $c) { |
|
| 750 | + $this->registerService(IRouter::class, function(Server $c) { |
|
| 751 | 751 | $cacheFactory = $c->getMemCacheFactory(); |
| 752 | 752 | $logger = $c->getLogger(); |
| 753 | 753 | if ($cacheFactory->isLocalCacheAvailable()) { |
@@ -759,39 +759,39 @@ discard block |
||
| 759 | 759 | }); |
| 760 | 760 | $this->registerDeprecatedAlias('Router', IRouter::class); |
| 761 | 761 | |
| 762 | - $this->registerService(ISearch::class, function ($c) { |
|
| 762 | + $this->registerService(ISearch::class, function($c) { |
|
| 763 | 763 | return new Search(); |
| 764 | 764 | }); |
| 765 | 765 | $this->registerDeprecatedAlias('Search', ISearch::class); |
| 766 | 766 | |
| 767 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
| 767 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
| 768 | 768 | return new \OC\Security\RateLimiting\Backend\MemoryCache( |
| 769 | 769 | $this->getMemCacheFactory(), |
| 770 | 770 | new \OC\AppFramework\Utility\TimeFactory() |
| 771 | 771 | ); |
| 772 | 772 | }); |
| 773 | 773 | |
| 774 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
| 774 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
| 775 | 775 | return new SecureRandom(); |
| 776 | 776 | }); |
| 777 | 777 | $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
| 778 | 778 | |
| 779 | - $this->registerService(ICrypto::class, function (Server $c) { |
|
| 779 | + $this->registerService(ICrypto::class, function(Server $c) { |
|
| 780 | 780 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
| 781 | 781 | }); |
| 782 | 782 | $this->registerDeprecatedAlias('Crypto', ICrypto::class); |
| 783 | 783 | |
| 784 | - $this->registerService(IHasher::class, function (Server $c) { |
|
| 784 | + $this->registerService(IHasher::class, function(Server $c) { |
|
| 785 | 785 | return new Hasher($c->getConfig()); |
| 786 | 786 | }); |
| 787 | 787 | $this->registerDeprecatedAlias('Hasher', IHasher::class); |
| 788 | 788 | |
| 789 | - $this->registerService(ICredentialsManager::class, function (Server $c) { |
|
| 789 | + $this->registerService(ICredentialsManager::class, function(Server $c) { |
|
| 790 | 790 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
| 791 | 791 | }); |
| 792 | 792 | $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class); |
| 793 | 793 | |
| 794 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 794 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
| 795 | 795 | $systemConfig = $c->getSystemConfig(); |
| 796 | 796 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
| 797 | 797 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class); |
| 807 | 807 | |
| 808 | 808 | |
| 809 | - $this->registerService(IClientService::class, function (Server $c) { |
|
| 809 | + $this->registerService(IClientService::class, function(Server $c) { |
|
| 810 | 810 | $user = \OC_User::getUser(); |
| 811 | 811 | $uid = $user ? $user : null; |
| 812 | 812 | return new ClientService( |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | ); |
| 823 | 823 | }); |
| 824 | 824 | $this->registerDeprecatedAlias('HttpClientService', IClientService::class); |
| 825 | - $this->registerService(IEventLogger::class, function (Server $c) { |
|
| 825 | + $this->registerService(IEventLogger::class, function(Server $c) { |
|
| 826 | 826 | $eventLogger = new EventLogger(); |
| 827 | 827 | if ($c->getSystemConfig()->getValue('debug', false)) { |
| 828 | 828 | // In debug mode, module is being activated by default |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | }); |
| 833 | 833 | $this->registerDeprecatedAlias('EventLogger', IEventLogger::class); |
| 834 | 834 | |
| 835 | - $this->registerService(IQueryLogger::class, function (Server $c) { |
|
| 835 | + $this->registerService(IQueryLogger::class, function(Server $c) { |
|
| 836 | 836 | $queryLogger = new QueryLogger(); |
| 837 | 837 | if ($c->getSystemConfig()->getValue('debug', false)) { |
| 838 | 838 | // In debug mode, module is being activated by default |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | }); |
| 843 | 843 | $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class); |
| 844 | 844 | |
| 845 | - $this->registerService(TempManager::class, function (Server $c) { |
|
| 845 | + $this->registerService(TempManager::class, function(Server $c) { |
|
| 846 | 846 | return new TempManager( |
| 847 | 847 | $c->getLogger(), |
| 848 | 848 | $c->getConfig() |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | $this->registerDeprecatedAlias('TempManager', TempManager::class); |
| 852 | 852 | $this->registerAlias(ITempManager::class, TempManager::class); |
| 853 | 853 | |
| 854 | - $this->registerService(AppManager::class, function (Server $c) { |
|
| 854 | + $this->registerService(AppManager::class, function(Server $c) { |
|
| 855 | 855 | return new \OC\App\AppManager( |
| 856 | 856 | $c->getUserSession(), |
| 857 | 857 | $c->getConfig(), |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | $this->registerDeprecatedAlias('AppManager', AppManager::class); |
| 866 | 866 | $this->registerAlias(IAppManager::class, AppManager::class); |
| 867 | 867 | |
| 868 | - $this->registerService(IDateTimeZone::class, function (Server $c) { |
|
| 868 | + $this->registerService(IDateTimeZone::class, function(Server $c) { |
|
| 869 | 869 | return new DateTimeZone( |
| 870 | 870 | $c->getConfig(), |
| 871 | 871 | $c->getSession() |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | }); |
| 874 | 874 | $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class); |
| 875 | 875 | |
| 876 | - $this->registerService(IDateTimeFormatter::class, function (Server $c) { |
|
| 876 | + $this->registerService(IDateTimeFormatter::class, function(Server $c) { |
|
| 877 | 877 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
| 878 | 878 | |
| 879 | 879 | return new DateTimeFormatter( |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | }); |
| 884 | 884 | $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class); |
| 885 | 885 | |
| 886 | - $this->registerService(IUserMountCache::class, function (Server $c) { |
|
| 886 | + $this->registerService(IUserMountCache::class, function(Server $c) { |
|
| 887 | 887 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
| 888 | 888 | $listener = new UserMountCacheListener($mountCache); |
| 889 | 889 | $listener->listen($c->getUserManager()); |
@@ -891,7 +891,7 @@ discard block |
||
| 891 | 891 | }); |
| 892 | 892 | $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class); |
| 893 | 893 | |
| 894 | - $this->registerService(IMountProviderCollection::class, function (Server $c) { |
|
| 894 | + $this->registerService(IMountProviderCollection::class, function(Server $c) { |
|
| 895 | 895 | $loader = \OC\Files\Filesystem::getLoader(); |
| 896 | 896 | $mountCache = $c->query(IUserMountCache::class); |
| 897 | 897 | $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
@@ -907,10 +907,10 @@ discard block |
||
| 907 | 907 | }); |
| 908 | 908 | $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class); |
| 909 | 909 | |
| 910 | - $this->registerService('IniWrapper', function ($c) { |
|
| 910 | + $this->registerService('IniWrapper', function($c) { |
|
| 911 | 911 | return new IniGetWrapper(); |
| 912 | 912 | }); |
| 913 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 913 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
| 914 | 914 | $busClass = $c->getConfig()->getSystemValue('commandbus'); |
| 915 | 915 | if ($busClass) { |
| 916 | 916 | list($app, $class) = explode('::', $busClass, 2); |
@@ -925,10 +925,10 @@ discard block |
||
| 925 | 925 | return new CronBus($jobList); |
| 926 | 926 | } |
| 927 | 927 | }); |
| 928 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
| 928 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
| 929 | 929 | return new TrustedDomainHelper($this->getConfig()); |
| 930 | 930 | }); |
| 931 | - $this->registerService(Throttler::class, function (Server $c) { |
|
| 931 | + $this->registerService(Throttler::class, function(Server $c) { |
|
| 932 | 932 | return new Throttler( |
| 933 | 933 | $c->getDatabaseConnection(), |
| 934 | 934 | new TimeFactory(), |
@@ -937,7 +937,7 @@ discard block |
||
| 937 | 937 | ); |
| 938 | 938 | }); |
| 939 | 939 | $this->registerDeprecatedAlias('Throttler', Throttler::class); |
| 940 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 940 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
| 941 | 941 | // IConfig and IAppManager requires a working database. This code |
| 942 | 942 | // might however be called when ownCloud is not yet setup. |
| 943 | 943 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | $c->getMimeTypeDetector() |
| 960 | 960 | ); |
| 961 | 961 | }); |
| 962 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 962 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
| 963 | 963 | if (isset($this['urlParams'])) { |
| 964 | 964 | $urlParams = $this['urlParams']; |
| 965 | 965 | } else { |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | }); |
| 996 | 996 | $this->registerDeprecatedAlias('Request', \OCP\IRequest::class); |
| 997 | 997 | |
| 998 | - $this->registerService(IMailer::class, function (Server $c) { |
|
| 998 | + $this->registerService(IMailer::class, function(Server $c) { |
|
| 999 | 999 | return new Mailer( |
| 1000 | 1000 | $c->getConfig(), |
| 1001 | 1001 | $c->getLogger(), |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | }); |
| 1009 | 1009 | $this->registerDeprecatedAlias('Mailer', IMailer::class); |
| 1010 | 1010 | |
| 1011 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
| 1011 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
| 1012 | 1012 | $config = $c->getConfig(); |
| 1013 | 1013 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
| 1014 | 1014 | if (is_null($factoryClass)) { |
@@ -1018,7 +1018,7 @@ discard block |
||
| 1018 | 1018 | $factory = new $factoryClass($this); |
| 1019 | 1019 | return $factory->getLDAPProvider(); |
| 1020 | 1020 | }); |
| 1021 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
| 1021 | + $this->registerService(ILockingProvider::class, function(Server $c) { |
|
| 1022 | 1022 | $ini = $c->getIniWrapper(); |
| 1023 | 1023 | $config = $c->getConfig(); |
| 1024 | 1024 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -1041,31 +1041,31 @@ discard block |
||
| 1041 | 1041 | }); |
| 1042 | 1042 | $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class); |
| 1043 | 1043 | |
| 1044 | - $this->registerService(IMountManager::class, function () { |
|
| 1044 | + $this->registerService(IMountManager::class, function() { |
|
| 1045 | 1045 | return new \OC\Files\Mount\Manager(); |
| 1046 | 1046 | }); |
| 1047 | 1047 | $this->registerDeprecatedAlias('MountManager', IMountManager::class); |
| 1048 | 1048 | |
| 1049 | - $this->registerService(IMimeTypeDetector::class, function (Server $c) { |
|
| 1049 | + $this->registerService(IMimeTypeDetector::class, function(Server $c) { |
|
| 1050 | 1050 | return new \OC\Files\Type\Detection( |
| 1051 | 1051 | $c->getURLGenerator(), |
| 1052 | 1052 | $c->getLogger(), |
| 1053 | 1053 | \OC::$configDir, |
| 1054 | - \OC::$SERVERROOT . '/resources/config/' |
|
| 1054 | + \OC::$SERVERROOT.'/resources/config/' |
|
| 1055 | 1055 | ); |
| 1056 | 1056 | }); |
| 1057 | 1057 | $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class); |
| 1058 | 1058 | |
| 1059 | - $this->registerService(IMimeTypeLoader::class, function (Server $c) { |
|
| 1059 | + $this->registerService(IMimeTypeLoader::class, function(Server $c) { |
|
| 1060 | 1060 | return new \OC\Files\Type\Loader( |
| 1061 | 1061 | $c->getDatabaseConnection() |
| 1062 | 1062 | ); |
| 1063 | 1063 | }); |
| 1064 | 1064 | $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class); |
| 1065 | - $this->registerService(BundleFetcher::class, function () { |
|
| 1065 | + $this->registerService(BundleFetcher::class, function() { |
|
| 1066 | 1066 | return new BundleFetcher($this->getL10N('lib')); |
| 1067 | 1067 | }); |
| 1068 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
| 1068 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
| 1069 | 1069 | return new Manager( |
| 1070 | 1070 | $c->query(IValidator::class), |
| 1071 | 1071 | $c->getLogger() |
@@ -1073,26 +1073,26 @@ discard block |
||
| 1073 | 1073 | }); |
| 1074 | 1074 | $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class); |
| 1075 | 1075 | |
| 1076 | - $this->registerService(CapabilitiesManager::class, function (Server $c) { |
|
| 1076 | + $this->registerService(CapabilitiesManager::class, function(Server $c) { |
|
| 1077 | 1077 | $manager = new CapabilitiesManager($c->getLogger()); |
| 1078 | - $manager->registerCapability(function () use ($c) { |
|
| 1078 | + $manager->registerCapability(function() use ($c) { |
|
| 1079 | 1079 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
| 1080 | 1080 | }); |
| 1081 | - $manager->registerCapability(function () use ($c) { |
|
| 1081 | + $manager->registerCapability(function() use ($c) { |
|
| 1082 | 1082 | return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
| 1083 | 1083 | }); |
| 1084 | 1084 | return $manager; |
| 1085 | 1085 | }); |
| 1086 | 1086 | $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class); |
| 1087 | 1087 | |
| 1088 | - $this->registerService(ICommentsManager::class, function (Server $c) { |
|
| 1088 | + $this->registerService(ICommentsManager::class, function(Server $c) { |
|
| 1089 | 1089 | $config = $c->getConfig(); |
| 1090 | 1090 | $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
| 1091 | 1091 | /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
| 1092 | 1092 | $factory = new $factoryClass($this); |
| 1093 | 1093 | $manager = $factory->getManager(); |
| 1094 | 1094 | |
| 1095 | - $manager->registerDisplayNameResolver('user', function ($id) use ($c) { |
|
| 1095 | + $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
| 1096 | 1096 | $manager = $c->getUserManager(); |
| 1097 | 1097 | $user = $manager->get($id); |
| 1098 | 1098 | if (is_null($user)) { |
@@ -1108,7 +1108,7 @@ discard block |
||
| 1108 | 1108 | }); |
| 1109 | 1109 | $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class); |
| 1110 | 1110 | |
| 1111 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
| 1111 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
| 1112 | 1112 | /* |
| 1113 | 1113 | * Dark magic for autoloader. |
| 1114 | 1114 | * If we do a class_exists it will try to load the class which will |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | } |
| 1137 | 1137 | return new \OC_Defaults(); |
| 1138 | 1138 | }); |
| 1139 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
| 1139 | + $this->registerService(SCSSCacher::class, function(Server $c) { |
|
| 1140 | 1140 | return new SCSSCacher( |
| 1141 | 1141 | $c->getLogger(), |
| 1142 | 1142 | $c->query(\OC\Files\AppData\Factory::class), |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | new TimeFactory() |
| 1150 | 1150 | ); |
| 1151 | 1151 | }); |
| 1152 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
| 1152 | + $this->registerService(JSCombiner::class, function(Server $c) { |
|
| 1153 | 1153 | return new JSCombiner( |
| 1154 | 1154 | $c->getAppDataDir('js'), |
| 1155 | 1155 | $c->getURLGenerator(), |
@@ -1162,7 +1162,7 @@ discard block |
||
| 1162 | 1162 | $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class); |
| 1163 | 1163 | $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class); |
| 1164 | 1164 | |
| 1165 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 1165 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
| 1166 | 1166 | // FIXME: Instantiiated here due to cyclic dependency |
| 1167 | 1167 | $request = new Request( |
| 1168 | 1168 | [ |
@@ -1187,7 +1187,7 @@ discard block |
||
| 1187 | 1187 | $request |
| 1188 | 1188 | ); |
| 1189 | 1189 | }); |
| 1190 | - $this->registerService(CsrfTokenManager::class, function (Server $c) { |
|
| 1190 | + $this->registerService(CsrfTokenManager::class, function(Server $c) { |
|
| 1191 | 1191 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
| 1192 | 1192 | |
| 1193 | 1193 | return new CsrfTokenManager( |
@@ -1196,20 +1196,20 @@ discard block |
||
| 1196 | 1196 | ); |
| 1197 | 1197 | }); |
| 1198 | 1198 | $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class); |
| 1199 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 1199 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
| 1200 | 1200 | return new SessionStorage($c->getSession()); |
| 1201 | 1201 | }); |
| 1202 | 1202 | $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class); |
| 1203 | 1203 | $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class); |
| 1204 | 1204 | |
| 1205 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
| 1205 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
| 1206 | 1206 | return new ContentSecurityPolicyNonceManager( |
| 1207 | 1207 | $c->getCsrfTokenManager(), |
| 1208 | 1208 | $c->getRequest() |
| 1209 | 1209 | ); |
| 1210 | 1210 | }); |
| 1211 | 1211 | |
| 1212 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
| 1212 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
| 1213 | 1213 | $config = $c->getConfig(); |
| 1214 | 1214 | $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
| 1215 | 1215 | /** @var \OCP\Share\IProviderFactory $factory */ |
@@ -1238,7 +1238,7 @@ discard block |
||
| 1238 | 1238 | }); |
| 1239 | 1239 | $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class); |
| 1240 | 1240 | |
| 1241 | - $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) { |
|
| 1241 | + $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
| 1242 | 1242 | $instance = new Collaboration\Collaborators\Search($c); |
| 1243 | 1243 | |
| 1244 | 1244 | // register default plugins |
@@ -1258,7 +1258,7 @@ discard block |
||
| 1258 | 1258 | $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class); |
| 1259 | 1259 | $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class); |
| 1260 | 1260 | |
| 1261 | - $this->registerService('SettingsManager', function (Server $c) { |
|
| 1261 | + $this->registerService('SettingsManager', function(Server $c) { |
|
| 1262 | 1262 | $manager = new \OC\Settings\Manager( |
| 1263 | 1263 | $c->getLogger(), |
| 1264 | 1264 | $c->getL10NFactory(), |
@@ -1267,34 +1267,34 @@ discard block |
||
| 1267 | 1267 | ); |
| 1268 | 1268 | return $manager; |
| 1269 | 1269 | }); |
| 1270 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 1270 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
| 1271 | 1271 | return new \OC\Files\AppData\Factory( |
| 1272 | 1272 | $c->getRootFolder(), |
| 1273 | 1273 | $c->getSystemConfig() |
| 1274 | 1274 | ); |
| 1275 | 1275 | }); |
| 1276 | 1276 | |
| 1277 | - $this->registerService('LockdownManager', function (Server $c) { |
|
| 1278 | - return new LockdownManager(function () use ($c) { |
|
| 1277 | + $this->registerService('LockdownManager', function(Server $c) { |
|
| 1278 | + return new LockdownManager(function() use ($c) { |
|
| 1279 | 1279 | return $c->getSession(); |
| 1280 | 1280 | }); |
| 1281 | 1281 | }); |
| 1282 | 1282 | |
| 1283 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 1283 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) { |
|
| 1284 | 1284 | return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
| 1285 | 1285 | }); |
| 1286 | 1286 | |
| 1287 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 1287 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
| 1288 | 1288 | return new CloudIdManager(); |
| 1289 | 1289 | }); |
| 1290 | 1290 | |
| 1291 | 1291 | $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class); |
| 1292 | 1292 | |
| 1293 | - $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
| 1293 | + $this->registerService(ICloudFederationProviderManager::class, function(Server $c) { |
|
| 1294 | 1294 | return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
| 1295 | 1295 | }); |
| 1296 | 1296 | |
| 1297 | - $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
| 1297 | + $this->registerService(ICloudFederationFactory::class, function(Server $c) { |
|
| 1298 | 1298 | return new CloudFederationFactory(); |
| 1299 | 1299 | }); |
| 1300 | 1300 | |
@@ -1304,24 +1304,24 @@ discard block |
||
| 1304 | 1304 | $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
| 1305 | 1305 | $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
| 1306 | 1306 | |
| 1307 | - $this->registerService(Defaults::class, function (Server $c) { |
|
| 1307 | + $this->registerService(Defaults::class, function(Server $c) { |
|
| 1308 | 1308 | return new Defaults( |
| 1309 | 1309 | $c->getThemingDefaults() |
| 1310 | 1310 | ); |
| 1311 | 1311 | }); |
| 1312 | 1312 | $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class); |
| 1313 | 1313 | |
| 1314 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
| 1314 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
| 1315 | 1315 | return $c->query(\OCP\IUserSession::class)->getSession(); |
| 1316 | 1316 | }); |
| 1317 | 1317 | |
| 1318 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
| 1318 | + $this->registerService(IShareHelper::class, function(Server $c) { |
|
| 1319 | 1319 | return new ShareHelper( |
| 1320 | 1320 | $c->query(\OCP\Share\IManager::class) |
| 1321 | 1321 | ); |
| 1322 | 1322 | }); |
| 1323 | 1323 | |
| 1324 | - $this->registerService(Installer::class, function (Server $c) { |
|
| 1324 | + $this->registerService(Installer::class, function(Server $c) { |
|
| 1325 | 1325 | return new Installer( |
| 1326 | 1326 | $c->getAppFetcher(), |
| 1327 | 1327 | $c->getHTTPClientService(), |
@@ -1332,16 +1332,16 @@ discard block |
||
| 1332 | 1332 | ); |
| 1333 | 1333 | }); |
| 1334 | 1334 | |
| 1335 | - $this->registerService(IApiFactory::class, function (Server $c) { |
|
| 1335 | + $this->registerService(IApiFactory::class, function(Server $c) { |
|
| 1336 | 1336 | return new ApiFactory($c->getHTTPClientService()); |
| 1337 | 1337 | }); |
| 1338 | 1338 | |
| 1339 | - $this->registerService(IInstanceFactory::class, function (Server $c) { |
|
| 1339 | + $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
| 1340 | 1340 | $memcacheFactory = $c->getMemCacheFactory(); |
| 1341 | 1341 | return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
| 1342 | 1342 | }); |
| 1343 | 1343 | |
| 1344 | - $this->registerService(IContactsStore::class, function (Server $c) { |
|
| 1344 | + $this->registerService(IContactsStore::class, function(Server $c) { |
|
| 1345 | 1345 | return new ContactsStore( |
| 1346 | 1346 | $c->getContactsManager(), |
| 1347 | 1347 | $c->getConfig(), |
@@ -1352,7 +1352,7 @@ discard block |
||
| 1352 | 1352 | $this->registerAlias(IContactsStore::class, ContactsStore::class); |
| 1353 | 1353 | $this->registerAlias(IAccountManager::class, AccountManager::class); |
| 1354 | 1354 | |
| 1355 | - $this->registerService(IStorageFactory::class, function () { |
|
| 1355 | + $this->registerService(IStorageFactory::class, function() { |
|
| 1356 | 1356 | return new StorageFactory(); |
| 1357 | 1357 | }); |
| 1358 | 1358 | |
@@ -1397,7 +1397,7 @@ discard block |
||
| 1397 | 1397 | $dispatcher = $this->getEventDispatcher(); |
| 1398 | 1398 | |
| 1399 | 1399 | // Delete avatar on user deletion |
| 1400 | - $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) { |
|
| 1400 | + $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
| 1401 | 1401 | $logger = $this->getLogger(); |
| 1402 | 1402 | $manager = $this->getAvatarManager(); |
| 1403 | 1403 | /** @var IUser $user */ |
@@ -1410,11 +1410,11 @@ discard block |
||
| 1410 | 1410 | // no avatar to remove |
| 1411 | 1411 | } catch (\Exception $e) { |
| 1412 | 1412 | // Ignore exceptions |
| 1413 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
| 1413 | + $logger->info('Could not cleanup avatar of '.$user->getUID()); |
|
| 1414 | 1414 | } |
| 1415 | 1415 | }); |
| 1416 | 1416 | |
| 1417 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
| 1417 | + $dispatcher->addListener('OCP\IUser::changeUser', function(GenericEvent $e) { |
|
| 1418 | 1418 | $manager = $this->getAvatarManager(); |
| 1419 | 1419 | /** @var IUser $user */ |
| 1420 | 1420 | $user = $e->getSubject(); |
@@ -1574,7 +1574,7 @@ discard block |
||
| 1574 | 1574 | * @deprecated since 9.2.0 use IAppData |
| 1575 | 1575 | */ |
| 1576 | 1576 | public function getAppFolder() { |
| 1577 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
| 1577 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
| 1578 | 1578 | $root = $this->getRootFolder(); |
| 1579 | 1579 | if (!$root->nodeExists($dir)) { |
| 1580 | 1580 | $folder = $root->newFolder($dir); |
@@ -2248,11 +2248,11 @@ discard block |
||
| 2248 | 2248 | } |
| 2249 | 2249 | |
| 2250 | 2250 | private function registerDeprecatedAlias(string $alias, string $target) { |
| 2251 | - $this->registerService($alias, function (IContainer $container) use ($target, $alias) { |
|
| 2251 | + $this->registerService($alias, function(IContainer $container) use ($target, $alias) { |
|
| 2252 | 2252 | try { |
| 2253 | 2253 | /** @var ILogger $logger */ |
| 2254 | 2254 | $logger = $container->query(ILogger::class); |
| 2255 | - $logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']); |
|
| 2255 | + $logger->debug('The requested alias "'.$alias.'" is depreacted. Please request "'.$target.'" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']); |
|
| 2256 | 2256 | } catch (QueryException $e) { |
| 2257 | 2257 | // Could not get logger. Continue |
| 2258 | 2258 | } |