| @@ -44,373 +44,373 @@ | ||
| 44 | 44 | |
| 45 | 45 |  class ThemingDefaults extends \OC_Defaults { | 
| 46 | 46 | |
| 47 | - /** @var IConfig */ | |
| 48 | - private $config; | |
| 49 | - /** @var IL10N */ | |
| 50 | - private $l; | |
| 51 | - /** @var ImageManager */ | |
| 52 | - private $imageManager; | |
| 53 | - /** @var IURLGenerator */ | |
| 54 | - private $urlGenerator; | |
| 55 | - /** @var ICacheFactory */ | |
| 56 | - private $cacheFactory; | |
| 57 | - /** @var Util */ | |
| 58 | - private $util; | |
| 59 | - /** @var IAppManager */ | |
| 60 | - private $appManager; | |
| 61 | - /** @var INavigationManager */ | |
| 62 | - private $navigationManager; | |
| 63 | - | |
| 64 | - /** @var string */ | |
| 65 | - private $name; | |
| 66 | - /** @var string */ | |
| 67 | - private $title; | |
| 68 | - /** @var string */ | |
| 69 | - private $entity; | |
| 70 | - /** @var string */ | |
| 71 | - private $url; | |
| 72 | - /** @var string */ | |
| 73 | - private $slogan; | |
| 74 | - /** @var string */ | |
| 75 | - private $color; | |
| 76 | - | |
| 77 | - /** @var string */ | |
| 78 | - private $iTunesAppId; | |
| 79 | - /** @var string */ | |
| 80 | - private $iOSClientUrl; | |
| 81 | - /** @var string */ | |
| 82 | - private $AndroidClientUrl; | |
| 83 | - | |
| 84 | - /** | |
| 85 | - * ThemingDefaults constructor. | |
| 86 | - * | |
| 87 | - * @param IConfig $config | |
| 88 | - * @param IL10N $l | |
| 89 | - * @param ImageManager $imageManager | |
| 90 | - * @param IURLGenerator $urlGenerator | |
| 91 | - * @param ICacheFactory $cacheFactory | |
| 92 | - * @param Util $util | |
| 93 | - * @param IAppManager $appManager | |
| 94 | - */ | |
| 95 | - public function __construct(IConfig $config, | |
| 96 | - IL10N $l, | |
| 97 | - IURLGenerator $urlGenerator, | |
| 98 | - ICacheFactory $cacheFactory, | |
| 99 | - Util $util, | |
| 100 | - ImageManager $imageManager, | |
| 101 | - IAppManager $appManager, | |
| 102 | - INavigationManager $navigationManager | |
| 103 | -	) { | |
| 104 | - parent::__construct(); | |
| 105 | - $this->config = $config; | |
| 106 | - $this->l = $l; | |
| 107 | - $this->imageManager = $imageManager; | |
| 108 | - $this->urlGenerator = $urlGenerator; | |
| 109 | - $this->cacheFactory = $cacheFactory; | |
| 110 | - $this->util = $util; | |
| 111 | - $this->appManager = $appManager; | |
| 112 | - $this->navigationManager = $navigationManager; | |
| 113 | - | |
| 114 | - $this->name = parent::getName(); | |
| 115 | - $this->title = parent::getTitle(); | |
| 116 | - $this->entity = parent::getEntity(); | |
| 117 | - $this->url = parent::getBaseUrl(); | |
| 118 | - $this->slogan = parent::getSlogan(); | |
| 119 | - $this->color = parent::getColorPrimary(); | |
| 120 | - $this->iTunesAppId = parent::getiTunesAppId(); | |
| 121 | - $this->iOSClientUrl = parent::getiOSClientUrl(); | |
| 122 | - $this->AndroidClientUrl = parent::getAndroidClientUrl(); | |
| 123 | - } | |
| 124 | - | |
| 125 | -	public function getName() { | |
| 126 | -		return strip_tags($this->config->getAppValue('theming', 'name', $this->name)); | |
| 127 | - } | |
| 128 | - | |
| 129 | -	public function getHTMLName() { | |
| 130 | -		return $this->config->getAppValue('theming', 'name', $this->name); | |
| 131 | - } | |
| 132 | - | |
| 133 | -	public function getTitle() { | |
| 134 | -		return strip_tags($this->config->getAppValue('theming', 'name', $this->title)); | |
| 135 | - } | |
| 136 | - | |
| 137 | -	public function getEntity() { | |
| 138 | -		return strip_tags($this->config->getAppValue('theming', 'name', $this->entity)); | |
| 139 | - } | |
| 140 | - | |
| 141 | -	public function getBaseUrl() { | |
| 142 | -		return $this->config->getAppValue('theming', 'url', $this->url); | |
| 143 | - } | |
| 144 | - | |
| 145 | -	public function getSlogan() { | |
| 146 | -		return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan)); | |
| 147 | - } | |
| 148 | - | |
| 149 | -	public function getImprintUrl() { | |
| 150 | -		return (string)$this->config->getAppValue('theming', 'imprintUrl', ''); | |
| 151 | - } | |
| 152 | - | |
| 153 | -	public function getPrivacyUrl() { | |
| 154 | -		return (string)$this->config->getAppValue('theming', 'privacyUrl', ''); | |
| 155 | - } | |
| 156 | - | |
| 157 | -	public function getShortFooter() { | |
| 158 | - $slogan = $this->getSlogan(); | |
| 159 | - $baseUrl = $this->getBaseUrl(); | |
| 160 | -		if ($baseUrl !== '') { | |
| 161 | - $footer = '<a href="' . $baseUrl . '" target="_blank"' . | |
| 162 | - ' rel="noreferrer noopener" class="entity-name">' . $this->getEntity() . '</a>'; | |
| 163 | -		} else { | |
| 164 | - $footer = '<span class="entity-name">' .$this->getEntity() . '</span>'; | |
| 165 | - } | |
| 166 | - $footer .= ($slogan !== '' ? ' – ' . $slogan : ''); | |
| 167 | - | |
| 168 | - $links = [ | |
| 169 | - [ | |
| 170 | -				'text' => $this->l->t('Legal notice'), | |
| 171 | - 'url' => (string)$this->getImprintUrl() | |
| 172 | - ], | |
| 173 | - [ | |
| 174 | -				'text' => $this->l->t('Privacy policy'), | |
| 175 | - 'url' => (string)$this->getPrivacyUrl() | |
| 176 | - ], | |
| 177 | - ]; | |
| 178 | - | |
| 179 | - $navigation = $this->navigationManager->getAll(INavigationManager::TYPE_GUEST); | |
| 180 | -		$guestNavigation = array_map(function($nav) { | |
| 181 | - return [ | |
| 182 | - 'text' => $nav['name'], | |
| 183 | - 'url' => $nav['href'] | |
| 184 | - ]; | |
| 185 | - }, $navigation); | |
| 186 | - $links = array_merge($links, $guestNavigation); | |
| 187 | - | |
| 188 | - $legalLinks = ''; $divider = ''; | |
| 189 | -		foreach($links as $link) { | |
| 190 | - if($link['url'] !== '' | |
| 191 | - && filter_var($link['url'], FILTER_VALIDATE_URL) | |
| 192 | -			) { | |
| 193 | - $legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' . | |
| 194 | - ' rel="noreferrer noopener">' . $link['text'] . '</a>'; | |
| 195 | - $divider = ' · '; | |
| 196 | - } | |
| 197 | - } | |
| 198 | -		if($legalLinks !== '' ) { | |
| 199 | - $footer .= '<br/>' . $legalLinks; | |
| 200 | - } | |
| 201 | - | |
| 202 | - return $footer; | |
| 203 | - } | |
| 204 | - | |
| 205 | - /** | |
| 206 | - * Color that is used for the header as well as for mail headers | |
| 207 | - * | |
| 208 | - * @return string | |
| 209 | - */ | |
| 210 | -	public function getColorPrimary() { | |
| 211 | -		return $this->config->getAppValue('theming', 'color', $this->color); | |
| 212 | - } | |
| 213 | - | |
| 214 | - /** | |
| 215 | - * Themed logo url | |
| 216 | - * | |
| 217 | - * @param bool $useSvg Whether to point to the SVG image or a fallback | |
| 218 | - * @return string | |
| 219 | - */ | |
| 220 | -	public function getLogo($useSvg = true): string { | |
| 221 | -		$logo = $this->config->getAppValue('theming', 'logoMime', false); | |
| 222 | - | |
| 223 | - $logoExists = true; | |
| 224 | -		try { | |
| 225 | -			$this->imageManager->getImage('logo', $useSvg); | |
| 226 | -		} catch (\Exception $e) { | |
| 227 | - $logoExists = false; | |
| 228 | - } | |
| 229 | - | |
| 230 | -		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); | |
| 231 | - | |
| 232 | -		if(!$logo || !$logoExists) { | |
| 233 | -			if($useSvg) { | |
| 234 | -				$logo = $this->urlGenerator->imagePath('core', 'logo/logo.svg'); | |
| 235 | -			} else { | |
| 236 | -				$logo = $this->urlGenerator->imagePath('core', 'logo/logo.png'); | |
| 237 | - } | |
| 238 | - return $logo . '?v=' . $cacheBusterCounter; | |
| 239 | - } | |
| 240 | - | |
| 241 | -		return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter ]); | |
| 242 | - } | |
| 243 | - | |
| 244 | - /** | |
| 245 | - * Themed background image url | |
| 246 | - * | |
| 247 | - * @return string | |
| 248 | - */ | |
| 249 | -	public function getBackground(): string { | |
| 250 | -		return $this->imageManager->getImageUrl('background'); | |
| 251 | - } | |
| 252 | - | |
| 253 | - /** | |
| 254 | - * @return string | |
| 255 | - */ | |
| 256 | -	public function getiTunesAppId() { | |
| 257 | -		return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId); | |
| 258 | - } | |
| 259 | - | |
| 260 | - /** | |
| 261 | - * @return string | |
| 262 | - */ | |
| 263 | -	public function getiOSClientUrl() { | |
| 264 | -		return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl); | |
| 265 | - } | |
| 266 | - | |
| 267 | - /** | |
| 268 | - * @return string | |
| 269 | - */ | |
| 270 | -	public function getAndroidClientUrl() { | |
| 271 | -		return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl); | |
| 272 | - } | |
| 273 | - | |
| 274 | - | |
| 275 | - /** | |
| 276 | - * @return array scss variables to overwrite | |
| 277 | - */ | |
| 278 | -	public function getScssVariables() { | |
| 279 | -		$cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl()); | |
| 280 | -		if ($value = $cache->get('getScssVariables')) { | |
| 281 | - return $value; | |
| 282 | - } | |
| 283 | - | |
| 284 | - $variables = [ | |
| 285 | -			'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", | |
| 286 | -			'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'", | |
| 287 | -			'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'", | |
| 288 | -			'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'", | |
| 289 | -			'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'" | |
| 290 | - ]; | |
| 291 | - | |
| 292 | -		$variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')"; | |
| 293 | -		$variables['image-logoheader'] = "'".$this->imageManager->getImageUrl('logoheader')."'"; | |
| 294 | -		$variables['image-favicon'] = "'".$this->imageManager->getImageUrl('favicon')."'"; | |
| 295 | -		$variables['image-login-background'] = "url('".$this->imageManager->getImageUrl('background')."')"; | |
| 296 | - $variables['image-login-plain'] = 'false'; | |
| 297 | - | |
| 298 | -		if ($this->config->getAppValue('theming', 'color', null) !== null) { | |
| 299 | - $variables['color-primary'] = $this->getColorPrimary(); | |
| 300 | - $variables['color-primary-text'] = $this->getTextColorPrimary(); | |
| 301 | - $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary()); | |
| 302 | - } | |
| 303 | - | |
| 304 | -		if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') { | |
| 305 | - $variables['image-login-plain'] = 'true'; | |
| 306 | - } | |
| 307 | - | |
| 308 | - $variables['has-legal-links'] = 'false'; | |
| 309 | -		if($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') { | |
| 310 | - $variables['has-legal-links'] = 'true'; | |
| 311 | - } | |
| 312 | - | |
| 313 | -		$cache->set('getScssVariables', $variables); | |
| 314 | - return $variables; | |
| 315 | - } | |
| 316 | - | |
| 317 | - /** | |
| 318 | - * Check if the image should be replaced by the theming app | |
| 319 | - * and return the new image location then | |
| 320 | - * | |
| 321 | - * @param string $app name of the app | |
| 322 | - * @param string $image filename of the image | |
| 323 | - * @return bool|string false if image should not replaced, otherwise the location of the image | |
| 324 | - */ | |
| 325 | -	public function replaceImagePath($app, $image) { | |
| 326 | -		if ($app === '' || $app === 'files_sharing') { | |
| 327 | - $app = 'core'; | |
| 328 | - } | |
| 329 | -		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); | |
| 330 | - | |
| 331 | -		try { | |
| 332 | -			$customFavicon = $this->imageManager->getImage('favicon'); | |
| 333 | -		} catch (NotFoundException $e) { | |
| 334 | - $customFavicon = null; | |
| 335 | - } | |
| 336 | - | |
| 337 | -		if ($image === 'favicon.ico' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { | |
| 338 | -			return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue; | |
| 339 | - } | |
| 340 | -		if ($image === 'favicon-touch.png' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { | |
| 341 | -			return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue; | |
| 342 | - } | |
| 343 | -		if ($image === 'manifest.json') { | |
| 344 | -			try { | |
| 345 | - $appPath = $this->appManager->getAppPath($app); | |
| 346 | -				if (file_exists($appPath . '/img/manifest.json')) { | |
| 347 | - return false; | |
| 348 | - } | |
| 349 | -			} catch (AppPathNotFoundException $e) {} | |
| 350 | -			return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue; | |
| 351 | - } | |
| 352 | - return false; | |
| 353 | - } | |
| 354 | - | |
| 355 | - /** | |
| 356 | - * Increases the cache buster key | |
| 357 | - */ | |
| 358 | -	private function increaseCacheBuster() { | |
| 359 | -		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); | |
| 360 | -		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); | |
| 361 | -		$this->cacheFactory->createDistributed('theming-')->clear(); | |
| 362 | -		$this->cacheFactory->createDistributed('imagePath')->clear(); | |
| 363 | - | |
| 364 | - } | |
| 365 | - | |
| 366 | - /** | |
| 367 | - * Update setting in the database | |
| 368 | - * | |
| 369 | - * @param string $setting | |
| 370 | - * @param string $value | |
| 371 | - */ | |
| 372 | -	public function set($setting, $value) { | |
| 373 | -		$this->config->setAppValue('theming', $setting, $value); | |
| 374 | - $this->increaseCacheBuster(); | |
| 375 | - } | |
| 376 | - | |
| 377 | - /** | |
| 378 | - * Revert settings to the default value | |
| 379 | - * | |
| 380 | - * @param string $setting setting which should be reverted | |
| 381 | - * @return string default value | |
| 382 | - */ | |
| 383 | -	public function undo($setting) { | |
| 384 | -		$this->config->deleteAppValue('theming', $setting); | |
| 385 | - $this->increaseCacheBuster(); | |
| 386 | - | |
| 387 | -		switch ($setting) { | |
| 388 | - case 'name': | |
| 389 | - $returnValue = $this->getEntity(); | |
| 390 | - break; | |
| 391 | - case 'url': | |
| 392 | - $returnValue = $this->getBaseUrl(); | |
| 393 | - break; | |
| 394 | - case 'slogan': | |
| 395 | - $returnValue = $this->getSlogan(); | |
| 396 | - break; | |
| 397 | - case 'color': | |
| 398 | - $returnValue = $this->getColorPrimary(); | |
| 399 | - break; | |
| 400 | - default: | |
| 401 | - $returnValue = ''; | |
| 402 | - break; | |
| 403 | - } | |
| 404 | - | |
| 405 | - return $returnValue; | |
| 406 | - } | |
| 407 | - | |
| 408 | - /** | |
| 409 | - * Color of text in the header and primary buttons | |
| 410 | - * | |
| 411 | - * @return string | |
| 412 | - */ | |
| 413 | -	public function getTextColorPrimary() { | |
| 414 | - return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#ffffff'; | |
| 415 | - } | |
| 47 | + /** @var IConfig */ | |
| 48 | + private $config; | |
| 49 | + /** @var IL10N */ | |
| 50 | + private $l; | |
| 51 | + /** @var ImageManager */ | |
| 52 | + private $imageManager; | |
| 53 | + /** @var IURLGenerator */ | |
| 54 | + private $urlGenerator; | |
| 55 | + /** @var ICacheFactory */ | |
| 56 | + private $cacheFactory; | |
| 57 | + /** @var Util */ | |
| 58 | + private $util; | |
| 59 | + /** @var IAppManager */ | |
| 60 | + private $appManager; | |
| 61 | + /** @var INavigationManager */ | |
| 62 | + private $navigationManager; | |
| 63 | + | |
| 64 | + /** @var string */ | |
| 65 | + private $name; | |
| 66 | + /** @var string */ | |
| 67 | + private $title; | |
| 68 | + /** @var string */ | |
| 69 | + private $entity; | |
| 70 | + /** @var string */ | |
| 71 | + private $url; | |
| 72 | + /** @var string */ | |
| 73 | + private $slogan; | |
| 74 | + /** @var string */ | |
| 75 | + private $color; | |
| 76 | + | |
| 77 | + /** @var string */ | |
| 78 | + private $iTunesAppId; | |
| 79 | + /** @var string */ | |
| 80 | + private $iOSClientUrl; | |
| 81 | + /** @var string */ | |
| 82 | + private $AndroidClientUrl; | |
| 83 | + | |
| 84 | + /** | |
| 85 | + * ThemingDefaults constructor. | |
| 86 | + * | |
| 87 | + * @param IConfig $config | |
| 88 | + * @param IL10N $l | |
| 89 | + * @param ImageManager $imageManager | |
| 90 | + * @param IURLGenerator $urlGenerator | |
| 91 | + * @param ICacheFactory $cacheFactory | |
| 92 | + * @param Util $util | |
| 93 | + * @param IAppManager $appManager | |
| 94 | + */ | |
| 95 | + public function __construct(IConfig $config, | |
| 96 | + IL10N $l, | |
| 97 | + IURLGenerator $urlGenerator, | |
| 98 | + ICacheFactory $cacheFactory, | |
| 99 | + Util $util, | |
| 100 | + ImageManager $imageManager, | |
| 101 | + IAppManager $appManager, | |
| 102 | + INavigationManager $navigationManager | |
| 103 | +    ) { | |
| 104 | + parent::__construct(); | |
| 105 | + $this->config = $config; | |
| 106 | + $this->l = $l; | |
| 107 | + $this->imageManager = $imageManager; | |
| 108 | + $this->urlGenerator = $urlGenerator; | |
| 109 | + $this->cacheFactory = $cacheFactory; | |
| 110 | + $this->util = $util; | |
| 111 | + $this->appManager = $appManager; | |
| 112 | + $this->navigationManager = $navigationManager; | |
| 113 | + | |
| 114 | + $this->name = parent::getName(); | |
| 115 | + $this->title = parent::getTitle(); | |
| 116 | + $this->entity = parent::getEntity(); | |
| 117 | + $this->url = parent::getBaseUrl(); | |
| 118 | + $this->slogan = parent::getSlogan(); | |
| 119 | + $this->color = parent::getColorPrimary(); | |
| 120 | + $this->iTunesAppId = parent::getiTunesAppId(); | |
| 121 | + $this->iOSClientUrl = parent::getiOSClientUrl(); | |
| 122 | + $this->AndroidClientUrl = parent::getAndroidClientUrl(); | |
| 123 | + } | |
| 124 | + | |
| 125 | +    public function getName() { | |
| 126 | +        return strip_tags($this->config->getAppValue('theming', 'name', $this->name)); | |
| 127 | + } | |
| 128 | + | |
| 129 | +    public function getHTMLName() { | |
| 130 | +        return $this->config->getAppValue('theming', 'name', $this->name); | |
| 131 | + } | |
| 132 | + | |
| 133 | +    public function getTitle() { | |
| 134 | +        return strip_tags($this->config->getAppValue('theming', 'name', $this->title)); | |
| 135 | + } | |
| 136 | + | |
| 137 | +    public function getEntity() { | |
| 138 | +        return strip_tags($this->config->getAppValue('theming', 'name', $this->entity)); | |
| 139 | + } | |
| 140 | + | |
| 141 | +    public function getBaseUrl() { | |
| 142 | +        return $this->config->getAppValue('theming', 'url', $this->url); | |
| 143 | + } | |
| 144 | + | |
| 145 | +    public function getSlogan() { | |
| 146 | +        return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan)); | |
| 147 | + } | |
| 148 | + | |
| 149 | +    public function getImprintUrl() { | |
| 150 | +        return (string)$this->config->getAppValue('theming', 'imprintUrl', ''); | |
| 151 | + } | |
| 152 | + | |
| 153 | +    public function getPrivacyUrl() { | |
| 154 | +        return (string)$this->config->getAppValue('theming', 'privacyUrl', ''); | |
| 155 | + } | |
| 156 | + | |
| 157 | +    public function getShortFooter() { | |
| 158 | + $slogan = $this->getSlogan(); | |
| 159 | + $baseUrl = $this->getBaseUrl(); | |
| 160 | +        if ($baseUrl !== '') { | |
| 161 | + $footer = '<a href="' . $baseUrl . '" target="_blank"' . | |
| 162 | + ' rel="noreferrer noopener" class="entity-name">' . $this->getEntity() . '</a>'; | |
| 163 | +        } else { | |
| 164 | + $footer = '<span class="entity-name">' .$this->getEntity() . '</span>'; | |
| 165 | + } | |
| 166 | + $footer .= ($slogan !== '' ? ' – ' . $slogan : ''); | |
| 167 | + | |
| 168 | + $links = [ | |
| 169 | + [ | |
| 170 | +                'text' => $this->l->t('Legal notice'), | |
| 171 | + 'url' => (string)$this->getImprintUrl() | |
| 172 | + ], | |
| 173 | + [ | |
| 174 | +                'text' => $this->l->t('Privacy policy'), | |
| 175 | + 'url' => (string)$this->getPrivacyUrl() | |
| 176 | + ], | |
| 177 | + ]; | |
| 178 | + | |
| 179 | + $navigation = $this->navigationManager->getAll(INavigationManager::TYPE_GUEST); | |
| 180 | +        $guestNavigation = array_map(function($nav) { | |
| 181 | + return [ | |
| 182 | + 'text' => $nav['name'], | |
| 183 | + 'url' => $nav['href'] | |
| 184 | + ]; | |
| 185 | + }, $navigation); | |
| 186 | + $links = array_merge($links, $guestNavigation); | |
| 187 | + | |
| 188 | + $legalLinks = ''; $divider = ''; | |
| 189 | +        foreach($links as $link) { | |
| 190 | + if($link['url'] !== '' | |
| 191 | + && filter_var($link['url'], FILTER_VALIDATE_URL) | |
| 192 | +            ) { | |
| 193 | + $legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' . | |
| 194 | + ' rel="noreferrer noopener">' . $link['text'] . '</a>'; | |
| 195 | + $divider = ' · '; | |
| 196 | + } | |
| 197 | + } | |
| 198 | +        if($legalLinks !== '' ) { | |
| 199 | + $footer .= '<br/>' . $legalLinks; | |
| 200 | + } | |
| 201 | + | |
| 202 | + return $footer; | |
| 203 | + } | |
| 204 | + | |
| 205 | + /** | |
| 206 | + * Color that is used for the header as well as for mail headers | |
| 207 | + * | |
| 208 | + * @return string | |
| 209 | + */ | |
| 210 | +    public function getColorPrimary() { | |
| 211 | +        return $this->config->getAppValue('theming', 'color', $this->color); | |
| 212 | + } | |
| 213 | + | |
| 214 | + /** | |
| 215 | + * Themed logo url | |
| 216 | + * | |
| 217 | + * @param bool $useSvg Whether to point to the SVG image or a fallback | |
| 218 | + * @return string | |
| 219 | + */ | |
| 220 | +    public function getLogo($useSvg = true): string { | |
| 221 | +        $logo = $this->config->getAppValue('theming', 'logoMime', false); | |
| 222 | + | |
| 223 | + $logoExists = true; | |
| 224 | +        try { | |
| 225 | +            $this->imageManager->getImage('logo', $useSvg); | |
| 226 | +        } catch (\Exception $e) { | |
| 227 | + $logoExists = false; | |
| 228 | + } | |
| 229 | + | |
| 230 | +        $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); | |
| 231 | + | |
| 232 | +        if(!$logo || !$logoExists) { | |
| 233 | +            if($useSvg) { | |
| 234 | +                $logo = $this->urlGenerator->imagePath('core', 'logo/logo.svg'); | |
| 235 | +            } else { | |
| 236 | +                $logo = $this->urlGenerator->imagePath('core', 'logo/logo.png'); | |
| 237 | + } | |
| 238 | + return $logo . '?v=' . $cacheBusterCounter; | |
| 239 | + } | |
| 240 | + | |
| 241 | +        return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter ]); | |
| 242 | + } | |
| 243 | + | |
| 244 | + /** | |
| 245 | + * Themed background image url | |
| 246 | + * | |
| 247 | + * @return string | |
| 248 | + */ | |
| 249 | +    public function getBackground(): string { | |
| 250 | +        return $this->imageManager->getImageUrl('background'); | |
| 251 | + } | |
| 252 | + | |
| 253 | + /** | |
| 254 | + * @return string | |
| 255 | + */ | |
| 256 | +    public function getiTunesAppId() { | |
| 257 | +        return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId); | |
| 258 | + } | |
| 259 | + | |
| 260 | + /** | |
| 261 | + * @return string | |
| 262 | + */ | |
| 263 | +    public function getiOSClientUrl() { | |
| 264 | +        return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl); | |
| 265 | + } | |
| 266 | + | |
| 267 | + /** | |
| 268 | + * @return string | |
| 269 | + */ | |
| 270 | +    public function getAndroidClientUrl() { | |
| 271 | +        return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl); | |
| 272 | + } | |
| 273 | + | |
| 274 | + | |
| 275 | + /** | |
| 276 | + * @return array scss variables to overwrite | |
| 277 | + */ | |
| 278 | +    public function getScssVariables() { | |
| 279 | +        $cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl()); | |
| 280 | +        if ($value = $cache->get('getScssVariables')) { | |
| 281 | + return $value; | |
| 282 | + } | |
| 283 | + | |
| 284 | + $variables = [ | |
| 285 | +            'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", | |
| 286 | +            'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'", | |
| 287 | +            'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'", | |
| 288 | +            'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'", | |
| 289 | +            'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'" | |
| 290 | + ]; | |
| 291 | + | |
| 292 | +        $variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')"; | |
| 293 | +        $variables['image-logoheader'] = "'".$this->imageManager->getImageUrl('logoheader')."'"; | |
| 294 | +        $variables['image-favicon'] = "'".$this->imageManager->getImageUrl('favicon')."'"; | |
| 295 | +        $variables['image-login-background'] = "url('".$this->imageManager->getImageUrl('background')."')"; | |
| 296 | + $variables['image-login-plain'] = 'false'; | |
| 297 | + | |
| 298 | +        if ($this->config->getAppValue('theming', 'color', null) !== null) { | |
| 299 | + $variables['color-primary'] = $this->getColorPrimary(); | |
| 300 | + $variables['color-primary-text'] = $this->getTextColorPrimary(); | |
| 301 | + $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary()); | |
| 302 | + } | |
| 303 | + | |
| 304 | +        if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') { | |
| 305 | + $variables['image-login-plain'] = 'true'; | |
| 306 | + } | |
| 307 | + | |
| 308 | + $variables['has-legal-links'] = 'false'; | |
| 309 | +        if($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') { | |
| 310 | + $variables['has-legal-links'] = 'true'; | |
| 311 | + } | |
| 312 | + | |
| 313 | +        $cache->set('getScssVariables', $variables); | |
| 314 | + return $variables; | |
| 315 | + } | |
| 316 | + | |
| 317 | + /** | |
| 318 | + * Check if the image should be replaced by the theming app | |
| 319 | + * and return the new image location then | |
| 320 | + * | |
| 321 | + * @param string $app name of the app | |
| 322 | + * @param string $image filename of the image | |
| 323 | + * @return bool|string false if image should not replaced, otherwise the location of the image | |
| 324 | + */ | |
| 325 | +    public function replaceImagePath($app, $image) { | |
| 326 | +        if ($app === '' || $app === 'files_sharing') { | |
| 327 | + $app = 'core'; | |
| 328 | + } | |
| 329 | +        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); | |
| 330 | + | |
| 331 | +        try { | |
| 332 | +            $customFavicon = $this->imageManager->getImage('favicon'); | |
| 333 | +        } catch (NotFoundException $e) { | |
| 334 | + $customFavicon = null; | |
| 335 | + } | |
| 336 | + | |
| 337 | +        if ($image === 'favicon.ico' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { | |
| 338 | +            return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue; | |
| 339 | + } | |
| 340 | +        if ($image === 'favicon-touch.png' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { | |
| 341 | +            return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue; | |
| 342 | + } | |
| 343 | +        if ($image === 'manifest.json') { | |
| 344 | +            try { | |
| 345 | + $appPath = $this->appManager->getAppPath($app); | |
| 346 | +                if (file_exists($appPath . '/img/manifest.json')) { | |
| 347 | + return false; | |
| 348 | + } | |
| 349 | +            } catch (AppPathNotFoundException $e) {} | |
| 350 | +            return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue; | |
| 351 | + } | |
| 352 | + return false; | |
| 353 | + } | |
| 354 | + | |
| 355 | + /** | |
| 356 | + * Increases the cache buster key | |
| 357 | + */ | |
| 358 | +    private function increaseCacheBuster() { | |
| 359 | +        $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); | |
| 360 | +        $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); | |
| 361 | +        $this->cacheFactory->createDistributed('theming-')->clear(); | |
| 362 | +        $this->cacheFactory->createDistributed('imagePath')->clear(); | |
| 363 | + | |
| 364 | + } | |
| 365 | + | |
| 366 | + /** | |
| 367 | + * Update setting in the database | |
| 368 | + * | |
| 369 | + * @param string $setting | |
| 370 | + * @param string $value | |
| 371 | + */ | |
| 372 | +    public function set($setting, $value) { | |
| 373 | +        $this->config->setAppValue('theming', $setting, $value); | |
| 374 | + $this->increaseCacheBuster(); | |
| 375 | + } | |
| 376 | + | |
| 377 | + /** | |
| 378 | + * Revert settings to the default value | |
| 379 | + * | |
| 380 | + * @param string $setting setting which should be reverted | |
| 381 | + * @return string default value | |
| 382 | + */ | |
| 383 | +    public function undo($setting) { | |
| 384 | +        $this->config->deleteAppValue('theming', $setting); | |
| 385 | + $this->increaseCacheBuster(); | |
| 386 | + | |
| 387 | +        switch ($setting) { | |
| 388 | + case 'name': | |
| 389 | + $returnValue = $this->getEntity(); | |
| 390 | + break; | |
| 391 | + case 'url': | |
| 392 | + $returnValue = $this->getBaseUrl(); | |
| 393 | + break; | |
| 394 | + case 'slogan': | |
| 395 | + $returnValue = $this->getSlogan(); | |
| 396 | + break; | |
| 397 | + case 'color': | |
| 398 | + $returnValue = $this->getColorPrimary(); | |
| 399 | + break; | |
| 400 | + default: | |
| 401 | + $returnValue = ''; | |
| 402 | + break; | |
| 403 | + } | |
| 404 | + | |
| 405 | + return $returnValue; | |
| 406 | + } | |
| 407 | + | |
| 408 | + /** | |
| 409 | + * Color of text in the header and primary buttons | |
| 410 | + * | |
| 411 | + * @return string | |
| 412 | + */ | |
| 413 | +    public function getTextColorPrimary() { | |
| 414 | + return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#ffffff'; | |
| 415 | + } | |
| 416 | 416 | } | 
| @@ -147,32 +147,32 @@ discard block | ||
| 147 | 147 | } | 
| 148 | 148 | |
| 149 | 149 |  	public function getImprintUrl() { | 
| 150 | -		return (string)$this->config->getAppValue('theming', 'imprintUrl', ''); | |
| 150 | +		return (string) $this->config->getAppValue('theming', 'imprintUrl', ''); | |
| 151 | 151 | } | 
| 152 | 152 | |
| 153 | 153 |  	public function getPrivacyUrl() { | 
| 154 | -		return (string)$this->config->getAppValue('theming', 'privacyUrl', ''); | |
| 154 | +		return (string) $this->config->getAppValue('theming', 'privacyUrl', ''); | |
| 155 | 155 | } | 
| 156 | 156 | |
| 157 | 157 |  	public function getShortFooter() { | 
| 158 | 158 | $slogan = $this->getSlogan(); | 
| 159 | 159 | $baseUrl = $this->getBaseUrl(); | 
| 160 | 160 |  		if ($baseUrl !== '') { | 
| 161 | - $footer = '<a href="' . $baseUrl . '" target="_blank"' . | |
| 162 | - ' rel="noreferrer noopener" class="entity-name">' . $this->getEntity() . '</a>'; | |
| 161 | + $footer = '<a href="'.$baseUrl.'" target="_blank"'. | |
| 162 | + ' rel="noreferrer noopener" class="entity-name">'.$this->getEntity().'</a>'; | |
| 163 | 163 |  		} else { | 
| 164 | - $footer = '<span class="entity-name">' .$this->getEntity() . '</span>'; | |
| 164 | + $footer = '<span class="entity-name">'.$this->getEntity().'</span>'; | |
| 165 | 165 | } | 
| 166 | - $footer .= ($slogan !== '' ? ' – ' . $slogan : ''); | |
| 166 | + $footer .= ($slogan !== '' ? ' – '.$slogan : ''); | |
| 167 | 167 | |
| 168 | 168 | $links = [ | 
| 169 | 169 | [ | 
| 170 | 170 |  				'text' => $this->l->t('Legal notice'), | 
| 171 | - 'url' => (string)$this->getImprintUrl() | |
| 171 | + 'url' => (string) $this->getImprintUrl() | |
| 172 | 172 | ], | 
| 173 | 173 | [ | 
| 174 | 174 |  				'text' => $this->l->t('Privacy policy'), | 
| 175 | - 'url' => (string)$this->getPrivacyUrl() | |
| 175 | + 'url' => (string) $this->getPrivacyUrl() | |
| 176 | 176 | ], | 
| 177 | 177 | ]; | 
| 178 | 178 | |
| @@ -186,17 +186,17 @@ discard block | ||
| 186 | 186 | $links = array_merge($links, $guestNavigation); | 
| 187 | 187 | |
| 188 | 188 | $legalLinks = ''; $divider = ''; | 
| 189 | -		foreach($links as $link) { | |
| 190 | - if($link['url'] !== '' | |
| 189 | +		foreach ($links as $link) { | |
| 190 | + if ($link['url'] !== '' | |
| 191 | 191 | && filter_var($link['url'], FILTER_VALIDATE_URL) | 
| 192 | 192 |  			) { | 
| 193 | - $legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' . | |
| 194 | - ' rel="noreferrer noopener">' . $link['text'] . '</a>'; | |
| 193 | + $legalLinks .= $divider.'<a href="'.$link['url'].'" class="legal" target="_blank"'. | |
| 194 | + ' rel="noreferrer noopener">'.$link['text'].'</a>'; | |
| 195 | 195 | $divider = ' · '; | 
| 196 | 196 | } | 
| 197 | 197 | } | 
| 198 | -		if($legalLinks !== '' ) { | |
| 199 | - $footer .= '<br/>' . $legalLinks; | |
| 198 | +		if ($legalLinks !== '') { | |
| 199 | + $footer .= '<br/>'.$legalLinks; | |
| 200 | 200 | } | 
| 201 | 201 | |
| 202 | 202 | return $footer; | 
| @@ -229,16 +229,16 @@ discard block | ||
| 229 | 229 | |
| 230 | 230 |  		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); | 
| 231 | 231 | |
| 232 | -		if(!$logo || !$logoExists) { | |
| 233 | -			if($useSvg) { | |
| 232 | +		if (!$logo || !$logoExists) { | |
| 233 | +			if ($useSvg) { | |
| 234 | 234 |  				$logo = $this->urlGenerator->imagePath('core', 'logo/logo.svg'); | 
| 235 | 235 |  			} else { | 
| 236 | 236 |  				$logo = $this->urlGenerator->imagePath('core', 'logo/logo.png'); | 
| 237 | 237 | } | 
| 238 | - return $logo . '?v=' . $cacheBusterCounter; | |
| 238 | + return $logo.'?v='.$cacheBusterCounter; | |
| 239 | 239 | } | 
| 240 | 240 | |
| 241 | -		return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter ]); | |
| 241 | +		return $this->urlGenerator->linkToRoute('theming.Theming.getImage', ['key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter]); | |
| 242 | 242 | } | 
| 243 | 243 | |
| 244 | 244 | /** | 
| @@ -276,17 +276,17 @@ discard block | ||
| 276 | 276 | * @return array scss variables to overwrite | 
| 277 | 277 | */ | 
| 278 | 278 |  	public function getScssVariables() { | 
| 279 | -		$cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl()); | |
| 279 | +		$cache = $this->cacheFactory->createDistributed('theming-'.$this->urlGenerator->getBaseUrl()); | |
| 280 | 280 |  		if ($value = $cache->get('getScssVariables')) { | 
| 281 | 281 | return $value; | 
| 282 | 282 | } | 
| 283 | 283 | |
| 284 | 284 | $variables = [ | 
| 285 | -			'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", | |
| 286 | -			'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'", | |
| 287 | -			'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'", | |
| 288 | -			'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'", | |
| 289 | -			'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'" | |
| 285 | +			'theming-cachebuster' => "'".$this->config->getAppValue('theming', 'cachebuster', '0')."'", | |
| 286 | +			'theming-logo-mime' => "'".$this->config->getAppValue('theming', 'logoMime')."'", | |
| 287 | +			'theming-background-mime' => "'".$this->config->getAppValue('theming', 'backgroundMime')."'", | |
| 288 | +			'theming-logoheader-mime' => "'".$this->config->getAppValue('theming', 'logoheaderMime')."'", | |
| 289 | +			'theming-favicon-mime' => "'".$this->config->getAppValue('theming', 'faviconMime')."'" | |
| 290 | 290 | ]; | 
| 291 | 291 | |
| 292 | 292 |  		$variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')"; | 
| @@ -306,7 +306,7 @@ discard block | ||
| 306 | 306 | } | 
| 307 | 307 | |
| 308 | 308 | $variables['has-legal-links'] = 'false'; | 
| 309 | -		if($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') { | |
| 309 | +		if ($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') { | |
| 310 | 310 | $variables['has-legal-links'] = 'true'; | 
| 311 | 311 | } | 
| 312 | 312 | |
| @@ -335,19 +335,19 @@ discard block | ||
| 335 | 335 | } | 
| 336 | 336 | |
| 337 | 337 |  		if ($image === 'favicon.ico' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { | 
| 338 | -			return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue; | |
| 338 | +			return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]).'?v='.$cacheBusterValue; | |
| 339 | 339 | } | 
| 340 | 340 |  		if ($image === 'favicon-touch.png' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { | 
| 341 | -			return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue; | |
| 341 | +			return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]).'?v='.$cacheBusterValue; | |
| 342 | 342 | } | 
| 343 | 343 |  		if ($image === 'manifest.json') { | 
| 344 | 344 |  			try { | 
| 345 | 345 | $appPath = $this->appManager->getAppPath($app); | 
| 346 | -				if (file_exists($appPath . '/img/manifest.json')) { | |
| 346 | +				if (file_exists($appPath.'/img/manifest.json')) { | |
| 347 | 347 | return false; | 
| 348 | 348 | } | 
| 349 | 349 |  			} catch (AppPathNotFoundException $e) {} | 
| 350 | -			return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue; | |
| 350 | +			return $this->urlGenerator->linkToRoute('theming.Theming.getManifest').'?v='.$cacheBusterValue; | |
| 351 | 351 | } | 
| 352 | 352 | return false; | 
| 353 | 353 | } | 
| @@ -357,7 +357,7 @@ discard block | ||
| 357 | 357 | */ | 
| 358 | 358 |  	private function increaseCacheBuster() { | 
| 359 | 359 |  		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); | 
| 360 | -		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); | |
| 360 | +		$this->config->setAppValue('theming', 'cachebuster', (int) $cacheBusterKey + 1); | |
| 361 | 361 |  		$this->cacheFactory->createDistributed('theming-')->clear(); | 
| 362 | 362 |  		$this->cacheFactory->createDistributed('imagePath')->clear(); | 
| 363 | 363 | |
| @@ -170,1898 +170,1898 @@ | ||
| 170 | 170 | * TODO: hookup all manager classes | 
| 171 | 171 | */ | 
| 172 | 172 |  class Server extends ServerContainer implements IServerContainer { | 
| 173 | - /** @var string */ | |
| 174 | - private $webRoot; | |
| 175 | - | |
| 176 | - /** | |
| 177 | - * @param string $webRoot | |
| 178 | - * @param \OC\Config $config | |
| 179 | - */ | |
| 180 | -	public function __construct($webRoot, \OC\Config $config) { | |
| 181 | - parent::__construct(); | |
| 182 | - $this->webRoot = $webRoot; | |
| 183 | - | |
| 184 | - // To find out if we are running from CLI or not | |
| 185 | -		$this->registerParameter('isCLI', \OC::$CLI); | |
| 186 | - | |
| 187 | -		$this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { | |
| 188 | - return $c; | |
| 189 | - }); | |
| 190 | - | |
| 191 | - $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); | |
| 192 | -		$this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); | |
| 193 | - | |
| 194 | - $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); | |
| 195 | -		$this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); | |
| 196 | - | |
| 197 | - $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); | |
| 198 | -		$this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); | |
| 199 | - | |
| 200 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); | |
| 201 | -		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); | |
| 202 | - | |
| 203 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); | |
| 204 | - | |
| 205 | - | |
| 206 | -		$this->registerService(\OCP\IPreview::class, function (Server $c) { | |
| 207 | - return new PreviewManager( | |
| 208 | - $c->getConfig(), | |
| 209 | - $c->getRootFolder(), | |
| 210 | -				$c->getAppDataDir('preview'), | |
| 211 | - $c->getEventDispatcher(), | |
| 212 | -				$c->getSession()->get('user_id') | |
| 213 | - ); | |
| 214 | - }); | |
| 215 | -		$this->registerAlias('PreviewManager', \OCP\IPreview::class); | |
| 216 | - | |
| 217 | -		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) { | |
| 218 | - return new \OC\Preview\Watcher( | |
| 219 | -				$c->getAppDataDir('preview') | |
| 220 | - ); | |
| 221 | - }); | |
| 222 | - | |
| 223 | -		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { | |
| 224 | - $view = new View(); | |
| 225 | - $util = new Encryption\Util( | |
| 226 | - $view, | |
| 227 | - $c->getUserManager(), | |
| 228 | - $c->getGroupManager(), | |
| 229 | - $c->getConfig() | |
| 230 | - ); | |
| 231 | - return new Encryption\Manager( | |
| 232 | - $c->getConfig(), | |
| 233 | - $c->getLogger(), | |
| 234 | -				$c->getL10N('core'), | |
| 235 | - new View(), | |
| 236 | - $util, | |
| 237 | - new ArrayCache() | |
| 238 | - ); | |
| 239 | - }); | |
| 240 | -		$this->registerAlias('EncryptionManager', \OCP\Encryption\IManager::class); | |
| 241 | - | |
| 242 | -		$this->registerService('EncryptionFileHelper', function (Server $c) { | |
| 243 | - $util = new Encryption\Util( | |
| 244 | - new View(), | |
| 245 | - $c->getUserManager(), | |
| 246 | - $c->getGroupManager(), | |
| 247 | - $c->getConfig() | |
| 248 | - ); | |
| 249 | - return new Encryption\File( | |
| 250 | - $util, | |
| 251 | - $c->getRootFolder(), | |
| 252 | - $c->getShareManager() | |
| 253 | - ); | |
| 254 | - }); | |
| 255 | - | |
| 256 | -		$this->registerService('EncryptionKeyStorage', function (Server $c) { | |
| 257 | - $view = new View(); | |
| 258 | - $util = new Encryption\Util( | |
| 259 | - $view, | |
| 260 | - $c->getUserManager(), | |
| 261 | - $c->getGroupManager(), | |
| 262 | - $c->getConfig() | |
| 263 | - ); | |
| 264 | - | |
| 265 | - return new Encryption\Keys\Storage($view, $util); | |
| 266 | - }); | |
| 267 | -		$this->registerService('TagMapper', function (Server $c) { | |
| 268 | - return new TagMapper($c->getDatabaseConnection()); | |
| 269 | - }); | |
| 270 | - | |
| 271 | -		$this->registerService(\OCP\ITagManager::class, function (Server $c) { | |
| 272 | -			$tagMapper = $c->query('TagMapper'); | |
| 273 | - return new TagManager($tagMapper, $c->getUserSession()); | |
| 274 | - }); | |
| 275 | -		$this->registerAlias('TagManager', \OCP\ITagManager::class); | |
| 276 | - | |
| 277 | -		$this->registerService('SystemTagManagerFactory', function (Server $c) { | |
| 278 | - $config = $c->getConfig(); | |
| 279 | -			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); | |
| 280 | - return new $factoryClass($this); | |
| 281 | - }); | |
| 282 | -		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { | |
| 283 | -			return $c->query('SystemTagManagerFactory')->getManager(); | |
| 284 | - }); | |
| 285 | -		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); | |
| 286 | - | |
| 287 | -		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { | |
| 288 | -			return $c->query('SystemTagManagerFactory')->getObjectMapper(); | |
| 289 | - }); | |
| 290 | -		$this->registerService('RootFolder', function (Server $c) { | |
| 291 | - $manager = \OC\Files\Filesystem::getMountManager(null); | |
| 292 | - $view = new View(); | |
| 293 | - $root = new Root( | |
| 294 | - $manager, | |
| 295 | - $view, | |
| 296 | - null, | |
| 297 | - $c->getUserMountCache(), | |
| 298 | - $this->getLogger(), | |
| 299 | - $this->getUserManager() | |
| 300 | - ); | |
| 301 | - $connector = new HookConnector($root, $view); | |
| 302 | - $connector->viewToNode(); | |
| 303 | - | |
| 304 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); | |
| 305 | - $previewConnector->connectWatcher(); | |
| 306 | - | |
| 307 | - return $root; | |
| 308 | - }); | |
| 309 | -		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); | |
| 310 | - | |
| 311 | -		$this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { | |
| 312 | -			return new LazyRoot(function () use ($c) { | |
| 313 | -				return $c->query('RootFolder'); | |
| 314 | - }); | |
| 315 | - }); | |
| 316 | -		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); | |
| 317 | - | |
| 318 | -		$this->registerService(\OC\User\Manager::class, function (Server $c) { | |
| 319 | - $config = $c->getConfig(); | |
| 320 | - return new \OC\User\Manager($config); | |
| 321 | - }); | |
| 322 | -		$this->registerAlias('UserManager', \OC\User\Manager::class); | |
| 323 | - $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); | |
| 324 | - | |
| 325 | -		$this->registerService(\OCP\IGroupManager::class, function (Server $c) { | |
| 326 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); | |
| 327 | -			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) { | |
| 328 | -				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); | |
| 329 | - }); | |
| 330 | -			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { | |
| 331 | -				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); | |
| 332 | - }); | |
| 333 | -			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { | |
| 334 | -				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); | |
| 335 | - }); | |
| 336 | -			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { | |
| 337 | -				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); | |
| 338 | - }); | |
| 339 | -			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { | |
| 340 | -				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); | |
| 341 | - }); | |
| 342 | -			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { | |
| 343 | -				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); | |
| 344 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks | |
| 345 | -				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); | |
| 346 | - }); | |
| 347 | - return $groupManager; | |
| 348 | - }); | |
| 349 | -		$this->registerAlias('GroupManager', \OCP\IGroupManager::class); | |
| 350 | - | |
| 351 | -		$this->registerService(Store::class, function (Server $c) { | |
| 352 | - $session = $c->getSession(); | |
| 353 | -			if (\OC::$server->getSystemConfig()->getValue('installed', false)) { | |
| 354 | - $tokenProvider = $c->query(IProvider::class); | |
| 355 | -			} else { | |
| 356 | - $tokenProvider = null; | |
| 357 | - } | |
| 358 | - $logger = $c->getLogger(); | |
| 359 | - return new Store($session, $logger, $tokenProvider); | |
| 360 | - }); | |
| 361 | - $this->registerAlias(IStore::class, Store::class); | |
| 362 | -		$this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { | |
| 363 | - $dbConnection = $c->getDatabaseConnection(); | |
| 364 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); | |
| 365 | - }); | |
| 366 | - $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); | |
| 367 | - | |
| 368 | -		$this->registerService(\OC\User\Session::class, function (Server $c) { | |
| 369 | - $manager = $c->getUserManager(); | |
| 370 | -			$session = new \OC\Session\Memory(''); | |
| 371 | - $timeFactory = new TimeFactory(); | |
| 372 | - // Token providers might require a working database. This code | |
| 373 | - // might however be called when ownCloud is not yet setup. | |
| 374 | -			if (\OC::$server->getSystemConfig()->getValue('installed', false)) { | |
| 375 | - $defaultTokenProvider = $c->query(IProvider::class); | |
| 376 | -			} else { | |
| 377 | - $defaultTokenProvider = null; | |
| 378 | - } | |
| 379 | - | |
| 380 | - $dispatcher = $c->getEventDispatcher(); | |
| 381 | - | |
| 382 | - $userSession = new \OC\User\Session( | |
| 383 | - $manager, | |
| 384 | - $session, | |
| 385 | - $timeFactory, | |
| 386 | - $defaultTokenProvider, | |
| 387 | - $c->getConfig(), | |
| 388 | - $c->getSecureRandom(), | |
| 389 | - $c->getLockdownManager(), | |
| 390 | - $c->getLogger() | |
| 391 | - ); | |
| 392 | -			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { | |
| 393 | -				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); | |
| 394 | - }); | |
| 395 | -			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { | |
| 396 | - /** @var $user \OC\User\User */ | |
| 397 | -				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); | |
| 398 | - }); | |
| 399 | -			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { | |
| 400 | - /** @var $user \OC\User\User */ | |
| 401 | -				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); | |
| 402 | -				$dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); | |
| 403 | - }); | |
| 404 | -			$userSession->listen('\OC\User', 'postDelete', function ($user) { | |
| 405 | - /** @var $user \OC\User\User */ | |
| 406 | -				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); | |
| 407 | - }); | |
| 408 | -			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { | |
| 409 | - /** @var $user \OC\User\User */ | |
| 410 | -				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); | |
| 411 | - }); | |
| 412 | -			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { | |
| 413 | - /** @var $user \OC\User\User */ | |
| 414 | -				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); | |
| 415 | - }); | |
| 416 | -			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { | |
| 417 | -				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); | |
| 418 | - }); | |
| 419 | -			$userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { | |
| 420 | - /** @var $user \OC\User\User */ | |
| 421 | -				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin)); | |
| 422 | - }); | |
| 423 | -			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { | |
| 424 | - /** @var $user \OC\User\User */ | |
| 425 | -				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); | |
| 426 | - }); | |
| 427 | -			$userSession->listen('\OC\User', 'logout', function () { | |
| 428 | -				\OC_Hook::emit('OC_User', 'logout', array()); | |
| 429 | - }); | |
| 430 | -			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { | |
| 431 | - /** @var $user \OC\User\User */ | |
| 432 | -				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); | |
| 433 | -				$dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); | |
| 434 | - }); | |
| 435 | - return $userSession; | |
| 436 | - }); | |
| 437 | - $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class); | |
| 438 | -		$this->registerAlias('UserSession', \OC\User\Session::class); | |
| 439 | - | |
| 440 | - $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); | |
| 441 | - | |
| 442 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); | |
| 443 | -		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class); | |
| 444 | - | |
| 445 | -		$this->registerService(\OC\AllConfig::class, function (Server $c) { | |
| 446 | - return new \OC\AllConfig( | |
| 447 | - $c->getSystemConfig() | |
| 448 | - ); | |
| 449 | - }); | |
| 450 | -		$this->registerAlias('AllConfig', \OC\AllConfig::class); | |
| 451 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); | |
| 452 | - | |
| 453 | -		$this->registerService('SystemConfig', function ($c) use ($config) { | |
| 454 | - return new \OC\SystemConfig($config); | |
| 455 | - }); | |
| 456 | - | |
| 457 | -		$this->registerService(\OC\AppConfig::class, function (Server $c) { | |
| 458 | - return new \OC\AppConfig($c->getDatabaseConnection()); | |
| 459 | - }); | |
| 460 | -		$this->registerAlias('AppConfig', \OC\AppConfig::class); | |
| 461 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); | |
| 462 | - | |
| 463 | -		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { | |
| 464 | - return new \OC\L10N\Factory( | |
| 465 | - $c->getConfig(), | |
| 466 | - $c->getRequest(), | |
| 467 | - $c->getUserSession(), | |
| 468 | - \OC::$SERVERROOT | |
| 469 | - ); | |
| 470 | - }); | |
| 471 | -		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); | |
| 472 | - | |
| 473 | -		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) { | |
| 474 | - $config = $c->getConfig(); | |
| 475 | - $cacheFactory = $c->getMemCacheFactory(); | |
| 476 | - $request = $c->getRequest(); | |
| 477 | - return new \OC\URLGenerator( | |
| 478 | - $config, | |
| 479 | - $cacheFactory, | |
| 480 | - $request | |
| 481 | - ); | |
| 482 | - }); | |
| 483 | -		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); | |
| 484 | - | |
| 485 | -		$this->registerAlias('AppFetcher', AppFetcher::class); | |
| 486 | -		$this->registerAlias('CategoryFetcher', CategoryFetcher::class); | |
| 487 | - | |
| 488 | -		$this->registerService(\OCP\ICache::class, function ($c) { | |
| 489 | - return new Cache\File(); | |
| 490 | - }); | |
| 491 | -		$this->registerAlias('UserCache', \OCP\ICache::class); | |
| 492 | - | |
| 493 | -		$this->registerService(Factory::class, function (Server $c) { | |
| 494 | - | |
| 495 | -			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), | |
| 496 | - ArrayCache::class, | |
| 497 | - ArrayCache::class, | |
| 498 | - ArrayCache::class | |
| 499 | - ); | |
| 500 | - $config = $c->getConfig(); | |
| 501 | - $request = $c->getRequest(); | |
| 502 | - $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); | |
| 503 | - | |
| 504 | -			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { | |
| 505 | - $v = \OC_App::getAppVersions(); | |
| 506 | -				$v['core'] = implode(',', \OC_Util::getVersion()); | |
| 507 | -				$version = implode(',', $v); | |
| 508 | - $instanceId = \OC_Util::getInstanceId(); | |
| 509 | - $path = \OC::$SERVERROOT; | |
| 510 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); | |
| 511 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), | |
| 512 | -					$config->getSystemValue('memcache.local', null), | |
| 513 | -					$config->getSystemValue('memcache.distributed', null), | |
| 514 | -					$config->getSystemValue('memcache.locking', null) | |
| 515 | - ); | |
| 516 | - } | |
| 517 | - return $arrayCacheFactory; | |
| 518 | - | |
| 519 | - }); | |
| 520 | -		$this->registerAlias('MemCacheFactory', Factory::class); | |
| 521 | - $this->registerAlias(ICacheFactory::class, Factory::class); | |
| 522 | - | |
| 523 | -		$this->registerService('RedisFactory', function (Server $c) { | |
| 524 | - $systemConfig = $c->getSystemConfig(); | |
| 525 | - return new RedisFactory($systemConfig); | |
| 526 | - }); | |
| 527 | - | |
| 528 | -		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) { | |
| 529 | - return new \OC\Activity\Manager( | |
| 530 | - $c->getRequest(), | |
| 531 | - $c->getUserSession(), | |
| 532 | - $c->getConfig(), | |
| 533 | - $c->query(IValidator::class) | |
| 534 | - ); | |
| 535 | - }); | |
| 536 | -		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); | |
| 537 | - | |
| 538 | -		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { | |
| 539 | - return new \OC\Activity\EventMerger( | |
| 540 | -				$c->getL10N('lib') | |
| 541 | - ); | |
| 542 | - }); | |
| 543 | - $this->registerAlias(IValidator::class, Validator::class); | |
| 544 | - | |
| 545 | -		$this->registerService(AvatarManager::class, function(Server $c) { | |
| 546 | - return new AvatarManager( | |
| 547 | - $c->query(\OC\User\Manager::class), | |
| 548 | -				$c->getAppDataDir('avatar'), | |
| 549 | -				$c->getL10N('lib'), | |
| 550 | - $c->getLogger(), | |
| 551 | - $c->getConfig() | |
| 552 | - ); | |
| 553 | - }); | |
| 554 | - $this->registerAlias(\OCP\IAvatarManager::class, AvatarManager::class); | |
| 555 | -		$this->registerAlias('AvatarManager', AvatarManager::class); | |
| 556 | - | |
| 557 | - $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); | |
| 558 | - | |
| 559 | -		$this->registerService(\OC\Log::class, function (Server $c) { | |
| 560 | -			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); | |
| 561 | - $factory = new LogFactory($c, $this->getSystemConfig()); | |
| 562 | - $logger = $factory->get($logType); | |
| 563 | - $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); | |
| 564 | - | |
| 565 | - return new Log($logger, $this->getSystemConfig(), null, $registry); | |
| 566 | - }); | |
| 567 | - $this->registerAlias(\OCP\ILogger::class, \OC\Log::class); | |
| 568 | -		$this->registerAlias('Logger', \OC\Log::class); | |
| 569 | - | |
| 570 | -		$this->registerService(ILogFactory::class, function (Server $c) { | |
| 571 | - return new LogFactory($c, $this->getSystemConfig()); | |
| 572 | - }); | |
| 573 | - | |
| 574 | -		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { | |
| 575 | - $config = $c->getConfig(); | |
| 576 | - return new \OC\BackgroundJob\JobList( | |
| 577 | - $c->getDatabaseConnection(), | |
| 578 | - $config, | |
| 579 | - new TimeFactory() | |
| 580 | - ); | |
| 581 | - }); | |
| 582 | -		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); | |
| 583 | - | |
| 584 | -		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) { | |
| 585 | - $cacheFactory = $c->getMemCacheFactory(); | |
| 586 | - $logger = $c->getLogger(); | |
| 587 | -			if ($cacheFactory->isLocalCacheAvailable()) { | |
| 588 | -				$router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); | |
| 589 | -			} else { | |
| 590 | - $router = new \OC\Route\Router($logger); | |
| 591 | - } | |
| 592 | - return $router; | |
| 593 | - }); | |
| 594 | -		$this->registerAlias('Router', \OCP\Route\IRouter::class); | |
| 595 | - | |
| 596 | -		$this->registerService(\OCP\ISearch::class, function ($c) { | |
| 597 | - return new Search(); | |
| 598 | - }); | |
| 599 | -		$this->registerAlias('Search', \OCP\ISearch::class); | |
| 600 | - | |
| 601 | -		$this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { | |
| 602 | - return new \OC\Security\RateLimiting\Limiter( | |
| 603 | - $this->getUserSession(), | |
| 604 | - $this->getRequest(), | |
| 605 | - new \OC\AppFramework\Utility\TimeFactory(), | |
| 606 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) | |
| 607 | - ); | |
| 608 | - }); | |
| 609 | -		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { | |
| 610 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( | |
| 611 | - $this->getMemCacheFactory(), | |
| 612 | - new \OC\AppFramework\Utility\TimeFactory() | |
| 613 | - ); | |
| 614 | - }); | |
| 615 | - | |
| 616 | -		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { | |
| 617 | - return new SecureRandom(); | |
| 618 | - }); | |
| 619 | -		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); | |
| 620 | - | |
| 621 | -		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { | |
| 622 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); | |
| 623 | - }); | |
| 624 | -		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class); | |
| 625 | - | |
| 626 | -		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) { | |
| 627 | - return new Hasher($c->getConfig()); | |
| 628 | - }); | |
| 629 | -		$this->registerAlias('Hasher', \OCP\Security\IHasher::class); | |
| 630 | - | |
| 631 | -		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { | |
| 632 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); | |
| 633 | - }); | |
| 634 | -		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); | |
| 635 | - | |
| 636 | -		$this->registerService(IDBConnection::class, function (Server $c) { | |
| 637 | - $systemConfig = $c->getSystemConfig(); | |
| 638 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); | |
| 639 | -			$type = $systemConfig->getValue('dbtype', 'sqlite'); | |
| 640 | -			if (!$factory->isValidType($type)) { | |
| 641 | -				throw new \OC\DatabaseException('Invalid database type'); | |
| 642 | - } | |
| 643 | - $connectionParams = $factory->createConnectionParams(); | |
| 644 | - $connection = $factory->getConnection($type, $connectionParams); | |
| 645 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); | |
| 646 | - return $connection; | |
| 647 | - }); | |
| 648 | -		$this->registerAlias('DatabaseConnection', IDBConnection::class); | |
| 649 | - | |
| 650 | - | |
| 651 | -		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { | |
| 652 | - $user = \OC_User::getUser(); | |
| 653 | - $uid = $user ? $user : null; | |
| 654 | - return new ClientService( | |
| 655 | - $c->getConfig(), | |
| 656 | - new \OC\Security\CertificateManager( | |
| 657 | - $uid, | |
| 658 | - new View(), | |
| 659 | - $c->getConfig(), | |
| 660 | - $c->getLogger(), | |
| 661 | - $c->getSecureRandom() | |
| 662 | - ) | |
| 663 | - ); | |
| 664 | - }); | |
| 665 | -		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); | |
| 666 | -		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { | |
| 667 | - $eventLogger = new EventLogger(); | |
| 668 | -			if ($c->getSystemConfig()->getValue('debug', false)) { | |
| 669 | - // In debug mode, module is being activated by default | |
| 670 | - $eventLogger->activate(); | |
| 671 | - } | |
| 672 | - return $eventLogger; | |
| 673 | - }); | |
| 674 | -		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); | |
| 675 | - | |
| 676 | -		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { | |
| 677 | - $queryLogger = new QueryLogger(); | |
| 678 | -			if ($c->getSystemConfig()->getValue('debug', false)) { | |
| 679 | - // In debug mode, module is being activated by default | |
| 680 | - $queryLogger->activate(); | |
| 681 | - } | |
| 682 | - return $queryLogger; | |
| 683 | - }); | |
| 684 | -		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); | |
| 685 | - | |
| 686 | -		$this->registerService(TempManager::class, function (Server $c) { | |
| 687 | - return new TempManager( | |
| 688 | - $c->getLogger(), | |
| 689 | - $c->getConfig() | |
| 690 | - ); | |
| 691 | - }); | |
| 692 | -		$this->registerAlias('TempManager', TempManager::class); | |
| 693 | - $this->registerAlias(ITempManager::class, TempManager::class); | |
| 694 | - | |
| 695 | -		$this->registerService(AppManager::class, function (Server $c) { | |
| 696 | - return new \OC\App\AppManager( | |
| 697 | - $c->getUserSession(), | |
| 698 | - $c->query(\OC\AppConfig::class), | |
| 699 | - $c->getGroupManager(), | |
| 700 | - $c->getMemCacheFactory(), | |
| 701 | - $c->getEventDispatcher() | |
| 702 | - ); | |
| 703 | - }); | |
| 704 | -		$this->registerAlias('AppManager', AppManager::class); | |
| 705 | - $this->registerAlias(IAppManager::class, AppManager::class); | |
| 706 | - | |
| 707 | -		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { | |
| 708 | - return new DateTimeZone( | |
| 709 | - $c->getConfig(), | |
| 710 | - $c->getSession() | |
| 711 | - ); | |
| 712 | - }); | |
| 713 | -		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); | |
| 714 | - | |
| 715 | -		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { | |
| 716 | -			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); | |
| 717 | - | |
| 718 | - return new DateTimeFormatter( | |
| 719 | - $c->getDateTimeZone()->getTimeZone(), | |
| 720 | -				$c->getL10N('lib', $language) | |
| 721 | - ); | |
| 722 | - }); | |
| 723 | -		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); | |
| 724 | - | |
| 725 | -		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { | |
| 726 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); | |
| 727 | - $listener = new UserMountCacheListener($mountCache); | |
| 728 | - $listener->listen($c->getUserManager()); | |
| 729 | - return $mountCache; | |
| 730 | - }); | |
| 731 | -		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); | |
| 732 | - | |
| 733 | -		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { | |
| 734 | - $loader = \OC\Files\Filesystem::getLoader(); | |
| 735 | -			$mountCache = $c->query('UserMountCache'); | |
| 736 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); | |
| 737 | - | |
| 738 | - // builtin providers | |
| 739 | - | |
| 740 | - $config = $c->getConfig(); | |
| 741 | - $manager->registerProvider(new CacheMountProvider($config)); | |
| 742 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); | |
| 743 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); | |
| 744 | - | |
| 745 | - return $manager; | |
| 746 | - }); | |
| 747 | -		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); | |
| 748 | - | |
| 749 | -		$this->registerService('IniWrapper', function ($c) { | |
| 750 | - return new IniGetWrapper(); | |
| 751 | - }); | |
| 752 | -		$this->registerService('AsyncCommandBus', function (Server $c) { | |
| 753 | -			$busClass = $c->getConfig()->getSystemValue('commandbus'); | |
| 754 | -			if ($busClass) { | |
| 755 | -				list($app, $class) = explode('::', $busClass, 2); | |
| 756 | -				if ($c->getAppManager()->isInstalled($app)) { | |
| 757 | - \OC_App::loadApp($app); | |
| 758 | - return $c->query($class); | |
| 759 | -				} else { | |
| 760 | -					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); | |
| 761 | - } | |
| 762 | -			} else { | |
| 763 | - $jobList = $c->getJobList(); | |
| 764 | - return new CronBus($jobList); | |
| 765 | - } | |
| 766 | - }); | |
| 767 | -		$this->registerService('TrustedDomainHelper', function ($c) { | |
| 768 | - return new TrustedDomainHelper($this->getConfig()); | |
| 769 | - }); | |
| 770 | -		$this->registerService(Throttler::class, function (Server $c) { | |
| 771 | - return new Throttler( | |
| 772 | - $c->getDatabaseConnection(), | |
| 773 | - new TimeFactory(), | |
| 774 | - $c->getLogger(), | |
| 775 | - $c->getConfig() | |
| 776 | - ); | |
| 777 | - }); | |
| 778 | -		$this->registerAlias('Throttler', Throttler::class); | |
| 779 | -		$this->registerService('IntegrityCodeChecker', function (Server $c) { | |
| 780 | - // IConfig and IAppManager requires a working database. This code | |
| 781 | - // might however be called when ownCloud is not yet setup. | |
| 782 | -			if (\OC::$server->getSystemConfig()->getValue('installed', false)) { | |
| 783 | - $config = $c->getConfig(); | |
| 784 | - $appManager = $c->getAppManager(); | |
| 785 | -			} else { | |
| 786 | - $config = null; | |
| 787 | - $appManager = null; | |
| 788 | - } | |
| 789 | - | |
| 790 | - return new Checker( | |
| 791 | - new EnvironmentHelper(), | |
| 792 | - new FileAccessHelper(), | |
| 793 | - new AppLocator(), | |
| 794 | - $config, | |
| 795 | - $c->getMemCacheFactory(), | |
| 796 | - $appManager, | |
| 797 | - $c->getTempManager() | |
| 798 | - ); | |
| 799 | - }); | |
| 800 | -		$this->registerService(\OCP\IRequest::class, function ($c) { | |
| 801 | -			if (isset($this['urlParams'])) { | |
| 802 | - $urlParams = $this['urlParams']; | |
| 803 | -			} else { | |
| 804 | - $urlParams = []; | |
| 805 | - } | |
| 806 | - | |
| 807 | -			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN | |
| 808 | -				&& in_array('fakeinput', stream_get_wrappers()) | |
| 809 | -			) { | |
| 810 | - $stream = 'fakeinput://data'; | |
| 811 | -			} else { | |
| 812 | - $stream = 'php://input'; | |
| 813 | - } | |
| 814 | - | |
| 815 | - return new Request( | |
| 816 | - [ | |
| 817 | - 'get' => $_GET, | |
| 818 | - 'post' => $_POST, | |
| 819 | - 'files' => $_FILES, | |
| 820 | - 'server' => $_SERVER, | |
| 821 | - 'env' => $_ENV, | |
| 822 | - 'cookies' => $_COOKIE, | |
| 823 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) | |
| 824 | - ? $_SERVER['REQUEST_METHOD'] | |
| 825 | - : '', | |
| 826 | - 'urlParams' => $urlParams, | |
| 827 | - ], | |
| 828 | - $this->getSecureRandom(), | |
| 829 | - $this->getConfig(), | |
| 830 | - $this->getCsrfTokenManager(), | |
| 831 | - $stream | |
| 832 | - ); | |
| 833 | - }); | |
| 834 | -		$this->registerAlias('Request', \OCP\IRequest::class); | |
| 835 | - | |
| 836 | -		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { | |
| 837 | - return new Mailer( | |
| 838 | - $c->getConfig(), | |
| 839 | - $c->getLogger(), | |
| 840 | - $c->query(Defaults::class), | |
| 841 | - $c->getURLGenerator(), | |
| 842 | -				$c->getL10N('lib') | |
| 843 | - ); | |
| 844 | - }); | |
| 845 | -		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class); | |
| 846 | - | |
| 847 | -		$this->registerService('LDAPProvider', function (Server $c) { | |
| 848 | - $config = $c->getConfig(); | |
| 849 | -			$factoryClass = $config->getSystemValue('ldapProviderFactory', null); | |
| 850 | -			if (is_null($factoryClass)) { | |
| 851 | -				throw new \Exception('ldapProviderFactory not set'); | |
| 852 | - } | |
| 853 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ | |
| 854 | - $factory = new $factoryClass($this); | |
| 855 | - return $factory->getLDAPProvider(); | |
| 856 | - }); | |
| 857 | -		$this->registerService(ILockingProvider::class, function (Server $c) { | |
| 858 | - $ini = $c->getIniWrapper(); | |
| 859 | - $config = $c->getConfig(); | |
| 860 | -			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); | |
| 861 | -			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { | |
| 862 | - /** @var \OC\Memcache\Factory $memcacheFactory */ | |
| 863 | - $memcacheFactory = $c->getMemCacheFactory(); | |
| 864 | -				$memcache = $memcacheFactory->createLocking('lock'); | |
| 865 | -				if (!($memcache instanceof \OC\Memcache\NullCache)) { | |
| 866 | - return new MemcacheLockingProvider($memcache, $ttl); | |
| 867 | - } | |
| 868 | - return new DBLockingProvider( | |
| 869 | - $c->getDatabaseConnection(), | |
| 870 | - $c->getLogger(), | |
| 871 | - new TimeFactory(), | |
| 872 | - $ttl, | |
| 873 | - !\OC::$CLI | |
| 874 | - ); | |
| 875 | - } | |
| 876 | - return new NoopLockingProvider(); | |
| 877 | - }); | |
| 878 | -		$this->registerAlias('LockingProvider', ILockingProvider::class); | |
| 879 | - | |
| 880 | -		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () { | |
| 881 | - return new \OC\Files\Mount\Manager(); | |
| 882 | - }); | |
| 883 | -		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); | |
| 884 | - | |
| 885 | -		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { | |
| 886 | - return new \OC\Files\Type\Detection( | |
| 887 | - $c->getURLGenerator(), | |
| 888 | - \OC::$configDir, | |
| 889 | - \OC::$SERVERROOT . '/resources/config/' | |
| 890 | - ); | |
| 891 | - }); | |
| 892 | -		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); | |
| 893 | - | |
| 894 | -		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { | |
| 895 | - return new \OC\Files\Type\Loader( | |
| 896 | - $c->getDatabaseConnection() | |
| 897 | - ); | |
| 898 | - }); | |
| 899 | -		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); | |
| 900 | -		$this->registerService(BundleFetcher::class, function () { | |
| 901 | -			return new BundleFetcher($this->getL10N('lib')); | |
| 902 | - }); | |
| 903 | -		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) { | |
| 904 | - return new Manager( | |
| 905 | - $c->query(IValidator::class) | |
| 906 | - ); | |
| 907 | - }); | |
| 908 | -		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); | |
| 909 | - | |
| 910 | -		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { | |
| 911 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); | |
| 912 | -			$manager->registerCapability(function () use ($c) { | |
| 913 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); | |
| 914 | - }); | |
| 915 | -			$manager->registerCapability(function () use ($c) { | |
| 916 | - return $c->query(\OC\Security\Bruteforce\Capabilities::class); | |
| 917 | - }); | |
| 918 | - return $manager; | |
| 919 | - }); | |
| 920 | -		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); | |
| 921 | - | |
| 922 | -		$this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { | |
| 923 | - $config = $c->getConfig(); | |
| 924 | -			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); | |
| 925 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ | |
| 926 | - $factory = new $factoryClass($this); | |
| 927 | - $manager = $factory->getManager(); | |
| 928 | - | |
| 929 | -			$manager->registerDisplayNameResolver('user', function($id) use ($c) { | |
| 930 | - $manager = $c->getUserManager(); | |
| 931 | - $user = $manager->get($id); | |
| 932 | -				if(is_null($user)) { | |
| 933 | -					$l = $c->getL10N('core'); | |
| 934 | -					$displayName = $l->t('Unknown user'); | |
| 935 | -				} else { | |
| 936 | - $displayName = $user->getDisplayName(); | |
| 937 | - } | |
| 938 | - return $displayName; | |
| 939 | - }); | |
| 940 | - | |
| 941 | - return $manager; | |
| 942 | - }); | |
| 943 | -		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); | |
| 944 | - | |
| 945 | -		$this->registerService('ThemingDefaults', function (Server $c) { | |
| 946 | - /* | |
| 173 | + /** @var string */ | |
| 174 | + private $webRoot; | |
| 175 | + | |
| 176 | + /** | |
| 177 | + * @param string $webRoot | |
| 178 | + * @param \OC\Config $config | |
| 179 | + */ | |
| 180 | +    public function __construct($webRoot, \OC\Config $config) { | |
| 181 | + parent::__construct(); | |
| 182 | + $this->webRoot = $webRoot; | |
| 183 | + | |
| 184 | + // To find out if we are running from CLI or not | |
| 185 | +        $this->registerParameter('isCLI', \OC::$CLI); | |
| 186 | + | |
| 187 | +        $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { | |
| 188 | + return $c; | |
| 189 | + }); | |
| 190 | + | |
| 191 | + $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); | |
| 192 | +        $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); | |
| 193 | + | |
| 194 | + $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); | |
| 195 | +        $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); | |
| 196 | + | |
| 197 | + $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); | |
| 198 | +        $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); | |
| 199 | + | |
| 200 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); | |
| 201 | +        $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); | |
| 202 | + | |
| 203 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); | |
| 204 | + | |
| 205 | + | |
| 206 | +        $this->registerService(\OCP\IPreview::class, function (Server $c) { | |
| 207 | + return new PreviewManager( | |
| 208 | + $c->getConfig(), | |
| 209 | + $c->getRootFolder(), | |
| 210 | +                $c->getAppDataDir('preview'), | |
| 211 | + $c->getEventDispatcher(), | |
| 212 | +                $c->getSession()->get('user_id') | |
| 213 | + ); | |
| 214 | + }); | |
| 215 | +        $this->registerAlias('PreviewManager', \OCP\IPreview::class); | |
| 216 | + | |
| 217 | +        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { | |
| 218 | + return new \OC\Preview\Watcher( | |
| 219 | +                $c->getAppDataDir('preview') | |
| 220 | + ); | |
| 221 | + }); | |
| 222 | + | |
| 223 | +        $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { | |
| 224 | + $view = new View(); | |
| 225 | + $util = new Encryption\Util( | |
| 226 | + $view, | |
| 227 | + $c->getUserManager(), | |
| 228 | + $c->getGroupManager(), | |
| 229 | + $c->getConfig() | |
| 230 | + ); | |
| 231 | + return new Encryption\Manager( | |
| 232 | + $c->getConfig(), | |
| 233 | + $c->getLogger(), | |
| 234 | +                $c->getL10N('core'), | |
| 235 | + new View(), | |
| 236 | + $util, | |
| 237 | + new ArrayCache() | |
| 238 | + ); | |
| 239 | + }); | |
| 240 | +        $this->registerAlias('EncryptionManager', \OCP\Encryption\IManager::class); | |
| 241 | + | |
| 242 | +        $this->registerService('EncryptionFileHelper', function (Server $c) { | |
| 243 | + $util = new Encryption\Util( | |
| 244 | + new View(), | |
| 245 | + $c->getUserManager(), | |
| 246 | + $c->getGroupManager(), | |
| 247 | + $c->getConfig() | |
| 248 | + ); | |
| 249 | + return new Encryption\File( | |
| 250 | + $util, | |
| 251 | + $c->getRootFolder(), | |
| 252 | + $c->getShareManager() | |
| 253 | + ); | |
| 254 | + }); | |
| 255 | + | |
| 256 | +        $this->registerService('EncryptionKeyStorage', function (Server $c) { | |
| 257 | + $view = new View(); | |
| 258 | + $util = new Encryption\Util( | |
| 259 | + $view, | |
| 260 | + $c->getUserManager(), | |
| 261 | + $c->getGroupManager(), | |
| 262 | + $c->getConfig() | |
| 263 | + ); | |
| 264 | + | |
| 265 | + return new Encryption\Keys\Storage($view, $util); | |
| 266 | + }); | |
| 267 | +        $this->registerService('TagMapper', function (Server $c) { | |
| 268 | + return new TagMapper($c->getDatabaseConnection()); | |
| 269 | + }); | |
| 270 | + | |
| 271 | +        $this->registerService(\OCP\ITagManager::class, function (Server $c) { | |
| 272 | +            $tagMapper = $c->query('TagMapper'); | |
| 273 | + return new TagManager($tagMapper, $c->getUserSession()); | |
| 274 | + }); | |
| 275 | +        $this->registerAlias('TagManager', \OCP\ITagManager::class); | |
| 276 | + | |
| 277 | +        $this->registerService('SystemTagManagerFactory', function (Server $c) { | |
| 278 | + $config = $c->getConfig(); | |
| 279 | +            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); | |
| 280 | + return new $factoryClass($this); | |
| 281 | + }); | |
| 282 | +        $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { | |
| 283 | +            return $c->query('SystemTagManagerFactory')->getManager(); | |
| 284 | + }); | |
| 285 | +        $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); | |
| 286 | + | |
| 287 | +        $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { | |
| 288 | +            return $c->query('SystemTagManagerFactory')->getObjectMapper(); | |
| 289 | + }); | |
| 290 | +        $this->registerService('RootFolder', function (Server $c) { | |
| 291 | + $manager = \OC\Files\Filesystem::getMountManager(null); | |
| 292 | + $view = new View(); | |
| 293 | + $root = new Root( | |
| 294 | + $manager, | |
| 295 | + $view, | |
| 296 | + null, | |
| 297 | + $c->getUserMountCache(), | |
| 298 | + $this->getLogger(), | |
| 299 | + $this->getUserManager() | |
| 300 | + ); | |
| 301 | + $connector = new HookConnector($root, $view); | |
| 302 | + $connector->viewToNode(); | |
| 303 | + | |
| 304 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); | |
| 305 | + $previewConnector->connectWatcher(); | |
| 306 | + | |
| 307 | + return $root; | |
| 308 | + }); | |
| 309 | +        $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); | |
| 310 | + | |
| 311 | +        $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { | |
| 312 | +            return new LazyRoot(function () use ($c) { | |
| 313 | +                return $c->query('RootFolder'); | |
| 314 | + }); | |
| 315 | + }); | |
| 316 | +        $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); | |
| 317 | + | |
| 318 | +        $this->registerService(\OC\User\Manager::class, function (Server $c) { | |
| 319 | + $config = $c->getConfig(); | |
| 320 | + return new \OC\User\Manager($config); | |
| 321 | + }); | |
| 322 | +        $this->registerAlias('UserManager', \OC\User\Manager::class); | |
| 323 | + $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); | |
| 324 | + | |
| 325 | +        $this->registerService(\OCP\IGroupManager::class, function (Server $c) { | |
| 326 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); | |
| 327 | +            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { | |
| 328 | +                \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); | |
| 329 | + }); | |
| 330 | +            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { | |
| 331 | +                \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); | |
| 332 | + }); | |
| 333 | +            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { | |
| 334 | +                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); | |
| 335 | + }); | |
| 336 | +            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { | |
| 337 | +                \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); | |
| 338 | + }); | |
| 339 | +            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { | |
| 340 | +                \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); | |
| 341 | + }); | |
| 342 | +            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { | |
| 343 | +                \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); | |
| 344 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks | |
| 345 | +                \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); | |
| 346 | + }); | |
| 347 | + return $groupManager; | |
| 348 | + }); | |
| 349 | +        $this->registerAlias('GroupManager', \OCP\IGroupManager::class); | |
| 350 | + | |
| 351 | +        $this->registerService(Store::class, function (Server $c) { | |
| 352 | + $session = $c->getSession(); | |
| 353 | +            if (\OC::$server->getSystemConfig()->getValue('installed', false)) { | |
| 354 | + $tokenProvider = $c->query(IProvider::class); | |
| 355 | +            } else { | |
| 356 | + $tokenProvider = null; | |
| 357 | + } | |
| 358 | + $logger = $c->getLogger(); | |
| 359 | + return new Store($session, $logger, $tokenProvider); | |
| 360 | + }); | |
| 361 | + $this->registerAlias(IStore::class, Store::class); | |
| 362 | +        $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { | |
| 363 | + $dbConnection = $c->getDatabaseConnection(); | |
| 364 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); | |
| 365 | + }); | |
| 366 | + $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); | |
| 367 | + | |
| 368 | +        $this->registerService(\OC\User\Session::class, function (Server $c) { | |
| 369 | + $manager = $c->getUserManager(); | |
| 370 | +            $session = new \OC\Session\Memory(''); | |
| 371 | + $timeFactory = new TimeFactory(); | |
| 372 | + // Token providers might require a working database. This code | |
| 373 | + // might however be called when ownCloud is not yet setup. | |
| 374 | +            if (\OC::$server->getSystemConfig()->getValue('installed', false)) { | |
| 375 | + $defaultTokenProvider = $c->query(IProvider::class); | |
| 376 | +            } else { | |
| 377 | + $defaultTokenProvider = null; | |
| 378 | + } | |
| 379 | + | |
| 380 | + $dispatcher = $c->getEventDispatcher(); | |
| 381 | + | |
| 382 | + $userSession = new \OC\User\Session( | |
| 383 | + $manager, | |
| 384 | + $session, | |
| 385 | + $timeFactory, | |
| 386 | + $defaultTokenProvider, | |
| 387 | + $c->getConfig(), | |
| 388 | + $c->getSecureRandom(), | |
| 389 | + $c->getLockdownManager(), | |
| 390 | + $c->getLogger() | |
| 391 | + ); | |
| 392 | +            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { | |
| 393 | +                \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); | |
| 394 | + }); | |
| 395 | +            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { | |
| 396 | + /** @var $user \OC\User\User */ | |
| 397 | +                \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); | |
| 398 | + }); | |
| 399 | +            $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { | |
| 400 | + /** @var $user \OC\User\User */ | |
| 401 | +                \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); | |
| 402 | +                $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); | |
| 403 | + }); | |
| 404 | +            $userSession->listen('\OC\User', 'postDelete', function ($user) { | |
| 405 | + /** @var $user \OC\User\User */ | |
| 406 | +                \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); | |
| 407 | + }); | |
| 408 | +            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { | |
| 409 | + /** @var $user \OC\User\User */ | |
| 410 | +                \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); | |
| 411 | + }); | |
| 412 | +            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { | |
| 413 | + /** @var $user \OC\User\User */ | |
| 414 | +                \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); | |
| 415 | + }); | |
| 416 | +            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { | |
| 417 | +                \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); | |
| 418 | + }); | |
| 419 | +            $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { | |
| 420 | + /** @var $user \OC\User\User */ | |
| 421 | +                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin)); | |
| 422 | + }); | |
| 423 | +            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { | |
| 424 | + /** @var $user \OC\User\User */ | |
| 425 | +                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); | |
| 426 | + }); | |
| 427 | +            $userSession->listen('\OC\User', 'logout', function () { | |
| 428 | +                \OC_Hook::emit('OC_User', 'logout', array()); | |
| 429 | + }); | |
| 430 | +            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { | |
| 431 | + /** @var $user \OC\User\User */ | |
| 432 | +                \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); | |
| 433 | +                $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); | |
| 434 | + }); | |
| 435 | + return $userSession; | |
| 436 | + }); | |
| 437 | + $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class); | |
| 438 | +        $this->registerAlias('UserSession', \OC\User\Session::class); | |
| 439 | + | |
| 440 | + $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); | |
| 441 | + | |
| 442 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); | |
| 443 | +        $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); | |
| 444 | + | |
| 445 | +        $this->registerService(\OC\AllConfig::class, function (Server $c) { | |
| 446 | + return new \OC\AllConfig( | |
| 447 | + $c->getSystemConfig() | |
| 448 | + ); | |
| 449 | + }); | |
| 450 | +        $this->registerAlias('AllConfig', \OC\AllConfig::class); | |
| 451 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); | |
| 452 | + | |
| 453 | +        $this->registerService('SystemConfig', function ($c) use ($config) { | |
| 454 | + return new \OC\SystemConfig($config); | |
| 455 | + }); | |
| 456 | + | |
| 457 | +        $this->registerService(\OC\AppConfig::class, function (Server $c) { | |
| 458 | + return new \OC\AppConfig($c->getDatabaseConnection()); | |
| 459 | + }); | |
| 460 | +        $this->registerAlias('AppConfig', \OC\AppConfig::class); | |
| 461 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); | |
| 462 | + | |
| 463 | +        $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { | |
| 464 | + return new \OC\L10N\Factory( | |
| 465 | + $c->getConfig(), | |
| 466 | + $c->getRequest(), | |
| 467 | + $c->getUserSession(), | |
| 468 | + \OC::$SERVERROOT | |
| 469 | + ); | |
| 470 | + }); | |
| 471 | +        $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); | |
| 472 | + | |
| 473 | +        $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { | |
| 474 | + $config = $c->getConfig(); | |
| 475 | + $cacheFactory = $c->getMemCacheFactory(); | |
| 476 | + $request = $c->getRequest(); | |
| 477 | + return new \OC\URLGenerator( | |
| 478 | + $config, | |
| 479 | + $cacheFactory, | |
| 480 | + $request | |
| 481 | + ); | |
| 482 | + }); | |
| 483 | +        $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); | |
| 484 | + | |
| 485 | +        $this->registerAlias('AppFetcher', AppFetcher::class); | |
| 486 | +        $this->registerAlias('CategoryFetcher', CategoryFetcher::class); | |
| 487 | + | |
| 488 | +        $this->registerService(\OCP\ICache::class, function ($c) { | |
| 489 | + return new Cache\File(); | |
| 490 | + }); | |
| 491 | +        $this->registerAlias('UserCache', \OCP\ICache::class); | |
| 492 | + | |
| 493 | +        $this->registerService(Factory::class, function (Server $c) { | |
| 494 | + | |
| 495 | +            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), | |
| 496 | + ArrayCache::class, | |
| 497 | + ArrayCache::class, | |
| 498 | + ArrayCache::class | |
| 499 | + ); | |
| 500 | + $config = $c->getConfig(); | |
| 501 | + $request = $c->getRequest(); | |
| 502 | + $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); | |
| 503 | + | |
| 504 | +            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { | |
| 505 | + $v = \OC_App::getAppVersions(); | |
| 506 | +                $v['core'] = implode(',', \OC_Util::getVersion()); | |
| 507 | +                $version = implode(',', $v); | |
| 508 | + $instanceId = \OC_Util::getInstanceId(); | |
| 509 | + $path = \OC::$SERVERROOT; | |
| 510 | + $prefix = md5($instanceId . '-' . $version . '-' . $path); | |
| 511 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), | |
| 512 | +                    $config->getSystemValue('memcache.local', null), | |
| 513 | +                    $config->getSystemValue('memcache.distributed', null), | |
| 514 | +                    $config->getSystemValue('memcache.locking', null) | |
| 515 | + ); | |
| 516 | + } | |
| 517 | + return $arrayCacheFactory; | |
| 518 | + | |
| 519 | + }); | |
| 520 | +        $this->registerAlias('MemCacheFactory', Factory::class); | |
| 521 | + $this->registerAlias(ICacheFactory::class, Factory::class); | |
| 522 | + | |
| 523 | +        $this->registerService('RedisFactory', function (Server $c) { | |
| 524 | + $systemConfig = $c->getSystemConfig(); | |
| 525 | + return new RedisFactory($systemConfig); | |
| 526 | + }); | |
| 527 | + | |
| 528 | +        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { | |
| 529 | + return new \OC\Activity\Manager( | |
| 530 | + $c->getRequest(), | |
| 531 | + $c->getUserSession(), | |
| 532 | + $c->getConfig(), | |
| 533 | + $c->query(IValidator::class) | |
| 534 | + ); | |
| 535 | + }); | |
| 536 | +        $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); | |
| 537 | + | |
| 538 | +        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { | |
| 539 | + return new \OC\Activity\EventMerger( | |
| 540 | +                $c->getL10N('lib') | |
| 541 | + ); | |
| 542 | + }); | |
| 543 | + $this->registerAlias(IValidator::class, Validator::class); | |
| 544 | + | |
| 545 | +        $this->registerService(AvatarManager::class, function(Server $c) { | |
| 546 | + return new AvatarManager( | |
| 547 | + $c->query(\OC\User\Manager::class), | |
| 548 | +                $c->getAppDataDir('avatar'), | |
| 549 | +                $c->getL10N('lib'), | |
| 550 | + $c->getLogger(), | |
| 551 | + $c->getConfig() | |
| 552 | + ); | |
| 553 | + }); | |
| 554 | + $this->registerAlias(\OCP\IAvatarManager::class, AvatarManager::class); | |
| 555 | +        $this->registerAlias('AvatarManager', AvatarManager::class); | |
| 556 | + | |
| 557 | + $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); | |
| 558 | + | |
| 559 | +        $this->registerService(\OC\Log::class, function (Server $c) { | |
| 560 | +            $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); | |
| 561 | + $factory = new LogFactory($c, $this->getSystemConfig()); | |
| 562 | + $logger = $factory->get($logType); | |
| 563 | + $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); | |
| 564 | + | |
| 565 | + return new Log($logger, $this->getSystemConfig(), null, $registry); | |
| 566 | + }); | |
| 567 | + $this->registerAlias(\OCP\ILogger::class, \OC\Log::class); | |
| 568 | +        $this->registerAlias('Logger', \OC\Log::class); | |
| 569 | + | |
| 570 | +        $this->registerService(ILogFactory::class, function (Server $c) { | |
| 571 | + return new LogFactory($c, $this->getSystemConfig()); | |
| 572 | + }); | |
| 573 | + | |
| 574 | +        $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { | |
| 575 | + $config = $c->getConfig(); | |
| 576 | + return new \OC\BackgroundJob\JobList( | |
| 577 | + $c->getDatabaseConnection(), | |
| 578 | + $config, | |
| 579 | + new TimeFactory() | |
| 580 | + ); | |
| 581 | + }); | |
| 582 | +        $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); | |
| 583 | + | |
| 584 | +        $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { | |
| 585 | + $cacheFactory = $c->getMemCacheFactory(); | |
| 586 | + $logger = $c->getLogger(); | |
| 587 | +            if ($cacheFactory->isLocalCacheAvailable()) { | |
| 588 | +                $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); | |
| 589 | +            } else { | |
| 590 | + $router = new \OC\Route\Router($logger); | |
| 591 | + } | |
| 592 | + return $router; | |
| 593 | + }); | |
| 594 | +        $this->registerAlias('Router', \OCP\Route\IRouter::class); | |
| 595 | + | |
| 596 | +        $this->registerService(\OCP\ISearch::class, function ($c) { | |
| 597 | + return new Search(); | |
| 598 | + }); | |
| 599 | +        $this->registerAlias('Search', \OCP\ISearch::class); | |
| 600 | + | |
| 601 | +        $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { | |
| 602 | + return new \OC\Security\RateLimiting\Limiter( | |
| 603 | + $this->getUserSession(), | |
| 604 | + $this->getRequest(), | |
| 605 | + new \OC\AppFramework\Utility\TimeFactory(), | |
| 606 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) | |
| 607 | + ); | |
| 608 | + }); | |
| 609 | +        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { | |
| 610 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( | |
| 611 | + $this->getMemCacheFactory(), | |
| 612 | + new \OC\AppFramework\Utility\TimeFactory() | |
| 613 | + ); | |
| 614 | + }); | |
| 615 | + | |
| 616 | +        $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { | |
| 617 | + return new SecureRandom(); | |
| 618 | + }); | |
| 619 | +        $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); | |
| 620 | + | |
| 621 | +        $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { | |
| 622 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); | |
| 623 | + }); | |
| 624 | +        $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); | |
| 625 | + | |
| 626 | +        $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { | |
| 627 | + return new Hasher($c->getConfig()); | |
| 628 | + }); | |
| 629 | +        $this->registerAlias('Hasher', \OCP\Security\IHasher::class); | |
| 630 | + | |
| 631 | +        $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { | |
| 632 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); | |
| 633 | + }); | |
| 634 | +        $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); | |
| 635 | + | |
| 636 | +        $this->registerService(IDBConnection::class, function (Server $c) { | |
| 637 | + $systemConfig = $c->getSystemConfig(); | |
| 638 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); | |
| 639 | +            $type = $systemConfig->getValue('dbtype', 'sqlite'); | |
| 640 | +            if (!$factory->isValidType($type)) { | |
| 641 | +                throw new \OC\DatabaseException('Invalid database type'); | |
| 642 | + } | |
| 643 | + $connectionParams = $factory->createConnectionParams(); | |
| 644 | + $connection = $factory->getConnection($type, $connectionParams); | |
| 645 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); | |
| 646 | + return $connection; | |
| 647 | + }); | |
| 648 | +        $this->registerAlias('DatabaseConnection', IDBConnection::class); | |
| 649 | + | |
| 650 | + | |
| 651 | +        $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { | |
| 652 | + $user = \OC_User::getUser(); | |
| 653 | + $uid = $user ? $user : null; | |
| 654 | + return new ClientService( | |
| 655 | + $c->getConfig(), | |
| 656 | + new \OC\Security\CertificateManager( | |
| 657 | + $uid, | |
| 658 | + new View(), | |
| 659 | + $c->getConfig(), | |
| 660 | + $c->getLogger(), | |
| 661 | + $c->getSecureRandom() | |
| 662 | + ) | |
| 663 | + ); | |
| 664 | + }); | |
| 665 | +        $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); | |
| 666 | +        $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { | |
| 667 | + $eventLogger = new EventLogger(); | |
| 668 | +            if ($c->getSystemConfig()->getValue('debug', false)) { | |
| 669 | + // In debug mode, module is being activated by default | |
| 670 | + $eventLogger->activate(); | |
| 671 | + } | |
| 672 | + return $eventLogger; | |
| 673 | + }); | |
| 674 | +        $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); | |
| 675 | + | |
| 676 | +        $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { | |
| 677 | + $queryLogger = new QueryLogger(); | |
| 678 | +            if ($c->getSystemConfig()->getValue('debug', false)) { | |
| 679 | + // In debug mode, module is being activated by default | |
| 680 | + $queryLogger->activate(); | |
| 681 | + } | |
| 682 | + return $queryLogger; | |
| 683 | + }); | |
| 684 | +        $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); | |
| 685 | + | |
| 686 | +        $this->registerService(TempManager::class, function (Server $c) { | |
| 687 | + return new TempManager( | |
| 688 | + $c->getLogger(), | |
| 689 | + $c->getConfig() | |
| 690 | + ); | |
| 691 | + }); | |
| 692 | +        $this->registerAlias('TempManager', TempManager::class); | |
| 693 | + $this->registerAlias(ITempManager::class, TempManager::class); | |
| 694 | + | |
| 695 | +        $this->registerService(AppManager::class, function (Server $c) { | |
| 696 | + return new \OC\App\AppManager( | |
| 697 | + $c->getUserSession(), | |
| 698 | + $c->query(\OC\AppConfig::class), | |
| 699 | + $c->getGroupManager(), | |
| 700 | + $c->getMemCacheFactory(), | |
| 701 | + $c->getEventDispatcher() | |
| 702 | + ); | |
| 703 | + }); | |
| 704 | +        $this->registerAlias('AppManager', AppManager::class); | |
| 705 | + $this->registerAlias(IAppManager::class, AppManager::class); | |
| 706 | + | |
| 707 | +        $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { | |
| 708 | + return new DateTimeZone( | |
| 709 | + $c->getConfig(), | |
| 710 | + $c->getSession() | |
| 711 | + ); | |
| 712 | + }); | |
| 713 | +        $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); | |
| 714 | + | |
| 715 | +        $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { | |
| 716 | +            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); | |
| 717 | + | |
| 718 | + return new DateTimeFormatter( | |
| 719 | + $c->getDateTimeZone()->getTimeZone(), | |
| 720 | +                $c->getL10N('lib', $language) | |
| 721 | + ); | |
| 722 | + }); | |
| 723 | +        $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); | |
| 724 | + | |
| 725 | +        $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { | |
| 726 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); | |
| 727 | + $listener = new UserMountCacheListener($mountCache); | |
| 728 | + $listener->listen($c->getUserManager()); | |
| 729 | + return $mountCache; | |
| 730 | + }); | |
| 731 | +        $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); | |
| 732 | + | |
| 733 | +        $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { | |
| 734 | + $loader = \OC\Files\Filesystem::getLoader(); | |
| 735 | +            $mountCache = $c->query('UserMountCache'); | |
| 736 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); | |
| 737 | + | |
| 738 | + // builtin providers | |
| 739 | + | |
| 740 | + $config = $c->getConfig(); | |
| 741 | + $manager->registerProvider(new CacheMountProvider($config)); | |
| 742 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); | |
| 743 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); | |
| 744 | + | |
| 745 | + return $manager; | |
| 746 | + }); | |
| 747 | +        $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); | |
| 748 | + | |
| 749 | +        $this->registerService('IniWrapper', function ($c) { | |
| 750 | + return new IniGetWrapper(); | |
| 751 | + }); | |
| 752 | +        $this->registerService('AsyncCommandBus', function (Server $c) { | |
| 753 | +            $busClass = $c->getConfig()->getSystemValue('commandbus'); | |
| 754 | +            if ($busClass) { | |
| 755 | +                list($app, $class) = explode('::', $busClass, 2); | |
| 756 | +                if ($c->getAppManager()->isInstalled($app)) { | |
| 757 | + \OC_App::loadApp($app); | |
| 758 | + return $c->query($class); | |
| 759 | +                } else { | |
| 760 | +                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); | |
| 761 | + } | |
| 762 | +            } else { | |
| 763 | + $jobList = $c->getJobList(); | |
| 764 | + return new CronBus($jobList); | |
| 765 | + } | |
| 766 | + }); | |
| 767 | +        $this->registerService('TrustedDomainHelper', function ($c) { | |
| 768 | + return new TrustedDomainHelper($this->getConfig()); | |
| 769 | + }); | |
| 770 | +        $this->registerService(Throttler::class, function (Server $c) { | |
| 771 | + return new Throttler( | |
| 772 | + $c->getDatabaseConnection(), | |
| 773 | + new TimeFactory(), | |
| 774 | + $c->getLogger(), | |
| 775 | + $c->getConfig() | |
| 776 | + ); | |
| 777 | + }); | |
| 778 | +        $this->registerAlias('Throttler', Throttler::class); | |
| 779 | +        $this->registerService('IntegrityCodeChecker', function (Server $c) { | |
| 780 | + // IConfig and IAppManager requires a working database. This code | |
| 781 | + // might however be called when ownCloud is not yet setup. | |
| 782 | +            if (\OC::$server->getSystemConfig()->getValue('installed', false)) { | |
| 783 | + $config = $c->getConfig(); | |
| 784 | + $appManager = $c->getAppManager(); | |
| 785 | +            } else { | |
| 786 | + $config = null; | |
| 787 | + $appManager = null; | |
| 788 | + } | |
| 789 | + | |
| 790 | + return new Checker( | |
| 791 | + new EnvironmentHelper(), | |
| 792 | + new FileAccessHelper(), | |
| 793 | + new AppLocator(), | |
| 794 | + $config, | |
| 795 | + $c->getMemCacheFactory(), | |
| 796 | + $appManager, | |
| 797 | + $c->getTempManager() | |
| 798 | + ); | |
| 799 | + }); | |
| 800 | +        $this->registerService(\OCP\IRequest::class, function ($c) { | |
| 801 | +            if (isset($this['urlParams'])) { | |
| 802 | + $urlParams = $this['urlParams']; | |
| 803 | +            } else { | |
| 804 | + $urlParams = []; | |
| 805 | + } | |
| 806 | + | |
| 807 | +            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN | |
| 808 | +                && in_array('fakeinput', stream_get_wrappers()) | |
| 809 | +            ) { | |
| 810 | + $stream = 'fakeinput://data'; | |
| 811 | +            } else { | |
| 812 | + $stream = 'php://input'; | |
| 813 | + } | |
| 814 | + | |
| 815 | + return new Request( | |
| 816 | + [ | |
| 817 | + 'get' => $_GET, | |
| 818 | + 'post' => $_POST, | |
| 819 | + 'files' => $_FILES, | |
| 820 | + 'server' => $_SERVER, | |
| 821 | + 'env' => $_ENV, | |
| 822 | + 'cookies' => $_COOKIE, | |
| 823 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) | |
| 824 | + ? $_SERVER['REQUEST_METHOD'] | |
| 825 | + : '', | |
| 826 | + 'urlParams' => $urlParams, | |
| 827 | + ], | |
| 828 | + $this->getSecureRandom(), | |
| 829 | + $this->getConfig(), | |
| 830 | + $this->getCsrfTokenManager(), | |
| 831 | + $stream | |
| 832 | + ); | |
| 833 | + }); | |
| 834 | +        $this->registerAlias('Request', \OCP\IRequest::class); | |
| 835 | + | |
| 836 | +        $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { | |
| 837 | + return new Mailer( | |
| 838 | + $c->getConfig(), | |
| 839 | + $c->getLogger(), | |
| 840 | + $c->query(Defaults::class), | |
| 841 | + $c->getURLGenerator(), | |
| 842 | +                $c->getL10N('lib') | |
| 843 | + ); | |
| 844 | + }); | |
| 845 | +        $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); | |
| 846 | + | |
| 847 | +        $this->registerService('LDAPProvider', function (Server $c) { | |
| 848 | + $config = $c->getConfig(); | |
| 849 | +            $factoryClass = $config->getSystemValue('ldapProviderFactory', null); | |
| 850 | +            if (is_null($factoryClass)) { | |
| 851 | +                throw new \Exception('ldapProviderFactory not set'); | |
| 852 | + } | |
| 853 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ | |
| 854 | + $factory = new $factoryClass($this); | |
| 855 | + return $factory->getLDAPProvider(); | |
| 856 | + }); | |
| 857 | +        $this->registerService(ILockingProvider::class, function (Server $c) { | |
| 858 | + $ini = $c->getIniWrapper(); | |
| 859 | + $config = $c->getConfig(); | |
| 860 | +            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); | |
| 861 | +            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { | |
| 862 | + /** @var \OC\Memcache\Factory $memcacheFactory */ | |
| 863 | + $memcacheFactory = $c->getMemCacheFactory(); | |
| 864 | +                $memcache = $memcacheFactory->createLocking('lock'); | |
| 865 | +                if (!($memcache instanceof \OC\Memcache\NullCache)) { | |
| 866 | + return new MemcacheLockingProvider($memcache, $ttl); | |
| 867 | + } | |
| 868 | + return new DBLockingProvider( | |
| 869 | + $c->getDatabaseConnection(), | |
| 870 | + $c->getLogger(), | |
| 871 | + new TimeFactory(), | |
| 872 | + $ttl, | |
| 873 | + !\OC::$CLI | |
| 874 | + ); | |
| 875 | + } | |
| 876 | + return new NoopLockingProvider(); | |
| 877 | + }); | |
| 878 | +        $this->registerAlias('LockingProvider', ILockingProvider::class); | |
| 879 | + | |
| 880 | +        $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { | |
| 881 | + return new \OC\Files\Mount\Manager(); | |
| 882 | + }); | |
| 883 | +        $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); | |
| 884 | + | |
| 885 | +        $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { | |
| 886 | + return new \OC\Files\Type\Detection( | |
| 887 | + $c->getURLGenerator(), | |
| 888 | + \OC::$configDir, | |
| 889 | + \OC::$SERVERROOT . '/resources/config/' | |
| 890 | + ); | |
| 891 | + }); | |
| 892 | +        $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); | |
| 893 | + | |
| 894 | +        $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { | |
| 895 | + return new \OC\Files\Type\Loader( | |
| 896 | + $c->getDatabaseConnection() | |
| 897 | + ); | |
| 898 | + }); | |
| 899 | +        $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); | |
| 900 | +        $this->registerService(BundleFetcher::class, function () { | |
| 901 | +            return new BundleFetcher($this->getL10N('lib')); | |
| 902 | + }); | |
| 903 | +        $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { | |
| 904 | + return new Manager( | |
| 905 | + $c->query(IValidator::class) | |
| 906 | + ); | |
| 907 | + }); | |
| 908 | +        $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); | |
| 909 | + | |
| 910 | +        $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { | |
| 911 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); | |
| 912 | +            $manager->registerCapability(function () use ($c) { | |
| 913 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); | |
| 914 | + }); | |
| 915 | +            $manager->registerCapability(function () use ($c) { | |
| 916 | + return $c->query(\OC\Security\Bruteforce\Capabilities::class); | |
| 917 | + }); | |
| 918 | + return $manager; | |
| 919 | + }); | |
| 920 | +        $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); | |
| 921 | + | |
| 922 | +        $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { | |
| 923 | + $config = $c->getConfig(); | |
| 924 | +            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); | |
| 925 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ | |
| 926 | + $factory = new $factoryClass($this); | |
| 927 | + $manager = $factory->getManager(); | |
| 928 | + | |
| 929 | +            $manager->registerDisplayNameResolver('user', function($id) use ($c) { | |
| 930 | + $manager = $c->getUserManager(); | |
| 931 | + $user = $manager->get($id); | |
| 932 | +                if(is_null($user)) { | |
| 933 | +                    $l = $c->getL10N('core'); | |
| 934 | +                    $displayName = $l->t('Unknown user'); | |
| 935 | +                } else { | |
| 936 | + $displayName = $user->getDisplayName(); | |
| 937 | + } | |
| 938 | + return $displayName; | |
| 939 | + }); | |
| 940 | + | |
| 941 | + return $manager; | |
| 942 | + }); | |
| 943 | +        $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); | |
| 944 | + | |
| 945 | +        $this->registerService('ThemingDefaults', function (Server $c) { | |
| 946 | + /* | |
| 947 | 947 | * Dark magic for autoloader. | 
| 948 | 948 | * If we do a class_exists it will try to load the class which will | 
| 949 | 949 | * make composer cache the result. Resulting in errors when enabling | 
| 950 | 950 | * the theming app. | 
| 951 | 951 | */ | 
| 952 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); | |
| 953 | -			if (isset($prefixes['OCA\\Theming\\'])) { | |
| 954 | - $classExists = true; | |
| 955 | -			} else { | |
| 956 | - $classExists = false; | |
| 957 | - } | |
| 958 | - | |
| 959 | -			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { | |
| 960 | - return new ThemingDefaults( | |
| 961 | - $c->getConfig(), | |
| 962 | -					$c->getL10N('theming'), | |
| 963 | - $c->getURLGenerator(), | |
| 964 | - $c->getMemCacheFactory(), | |
| 965 | -					new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), | |
| 966 | -					new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), | |
| 967 | - $c->getAppManager(), | |
| 968 | - $c->getNavigationManager() | |
| 969 | - ); | |
| 970 | - } | |
| 971 | - return new \OC_Defaults(); | |
| 972 | - }); | |
| 973 | -		$this->registerService(SCSSCacher::class, function (Server $c) { | |
| 974 | - /** @var Factory $cacheFactory */ | |
| 975 | - $cacheFactory = $c->query(Factory::class); | |
| 976 | - return new SCSSCacher( | |
| 977 | - $c->getLogger(), | |
| 978 | - $c->query(\OC\Files\AppData\Factory::class), | |
| 979 | - $c->getURLGenerator(), | |
| 980 | - $c->getConfig(), | |
| 981 | - $c->getThemingDefaults(), | |
| 982 | - \OC::$SERVERROOT, | |
| 983 | - $this->getMemCacheFactory(), | |
| 984 | - $c->query(IconsCacher::class), | |
| 985 | - new TimeFactory() | |
| 986 | - ); | |
| 987 | - }); | |
| 988 | -		$this->registerService(JSCombiner::class, function (Server $c) { | |
| 989 | - /** @var Factory $cacheFactory */ | |
| 990 | - $cacheFactory = $c->query(Factory::class); | |
| 991 | - return new JSCombiner( | |
| 992 | -				$c->getAppDataDir('js'), | |
| 993 | - $c->getURLGenerator(), | |
| 994 | - $this->getMemCacheFactory(), | |
| 995 | - $c->getSystemConfig(), | |
| 996 | - $c->getLogger() | |
| 997 | - ); | |
| 998 | - }); | |
| 999 | -		$this->registerService(EventDispatcher::class, function () { | |
| 1000 | - return new EventDispatcher(); | |
| 1001 | - }); | |
| 1002 | -		$this->registerAlias('EventDispatcher', EventDispatcher::class); | |
| 1003 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); | |
| 1004 | - | |
| 1005 | -		$this->registerService('CryptoWrapper', function (Server $c) { | |
| 1006 | - // FIXME: Instantiiated here due to cyclic dependency | |
| 1007 | - $request = new Request( | |
| 1008 | - [ | |
| 1009 | - 'get' => $_GET, | |
| 1010 | - 'post' => $_POST, | |
| 1011 | - 'files' => $_FILES, | |
| 1012 | - 'server' => $_SERVER, | |
| 1013 | - 'env' => $_ENV, | |
| 1014 | - 'cookies' => $_COOKIE, | |
| 1015 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) | |
| 1016 | - ? $_SERVER['REQUEST_METHOD'] | |
| 1017 | - : null, | |
| 1018 | - ], | |
| 1019 | - $c->getSecureRandom(), | |
| 1020 | - $c->getConfig() | |
| 1021 | - ); | |
| 1022 | - | |
| 1023 | - return new CryptoWrapper( | |
| 1024 | - $c->getConfig(), | |
| 1025 | - $c->getCrypto(), | |
| 1026 | - $c->getSecureRandom(), | |
| 1027 | - $request | |
| 1028 | - ); | |
| 1029 | - }); | |
| 1030 | -		$this->registerService('CsrfTokenManager', function (Server $c) { | |
| 1031 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); | |
| 1032 | - | |
| 1033 | - return new CsrfTokenManager( | |
| 1034 | - $tokenGenerator, | |
| 1035 | - $c->query(SessionStorage::class) | |
| 1036 | - ); | |
| 1037 | - }); | |
| 1038 | -		$this->registerService(SessionStorage::class, function (Server $c) { | |
| 1039 | - return new SessionStorage($c->getSession()); | |
| 1040 | - }); | |
| 1041 | -		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { | |
| 1042 | - return new ContentSecurityPolicyManager(); | |
| 1043 | - }); | |
| 1044 | -		$this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); | |
| 1045 | - | |
| 1046 | -		$this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { | |
| 1047 | - return new ContentSecurityPolicyNonceManager( | |
| 1048 | - $c->getCsrfTokenManager(), | |
| 1049 | - $c->getRequest() | |
| 1050 | - ); | |
| 1051 | - }); | |
| 1052 | - | |
| 1053 | -		$this->registerService(\OCP\Share\IManager::class, function (Server $c) { | |
| 1054 | - $config = $c->getConfig(); | |
| 1055 | -			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); | |
| 1056 | - /** @var \OCP\Share\IProviderFactory $factory */ | |
| 1057 | - $factory = new $factoryClass($this); | |
| 1058 | - | |
| 1059 | - $manager = new \OC\Share20\Manager( | |
| 1060 | - $c->getLogger(), | |
| 1061 | - $c->getConfig(), | |
| 1062 | - $c->getSecureRandom(), | |
| 1063 | - $c->getHasher(), | |
| 1064 | - $c->getMountManager(), | |
| 1065 | - $c->getGroupManager(), | |
| 1066 | -				$c->getL10N('lib'), | |
| 1067 | - $c->getL10NFactory(), | |
| 1068 | - $factory, | |
| 1069 | - $c->getUserManager(), | |
| 1070 | - $c->getLazyRootFolder(), | |
| 1071 | - $c->getEventDispatcher(), | |
| 1072 | - $c->getMailer(), | |
| 1073 | - $c->getURLGenerator(), | |
| 1074 | - $c->getThemingDefaults() | |
| 1075 | - ); | |
| 1076 | - | |
| 1077 | - return $manager; | |
| 1078 | - }); | |
| 1079 | -		$this->registerAlias('ShareManager', \OCP\Share\IManager::class); | |
| 1080 | - | |
| 1081 | -		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { | |
| 1082 | - $instance = new Collaboration\Collaborators\Search($c); | |
| 1083 | - | |
| 1084 | - // register default plugins | |
| 1085 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); | |
| 1086 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); | |
| 1087 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); | |
| 1088 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); | |
| 1089 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]); | |
| 1090 | - | |
| 1091 | - return $instance; | |
| 1092 | - }); | |
| 1093 | -		$this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); | |
| 1094 | - $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class); | |
| 1095 | - | |
| 1096 | - $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); | |
| 1097 | - | |
| 1098 | -		$this->registerService('SettingsManager', function (Server $c) { | |
| 1099 | - $manager = new \OC\Settings\Manager( | |
| 1100 | - $c->getLogger(), | |
| 1101 | -				$c->getL10N('lib'), | |
| 1102 | - $c->getURLGenerator(), | |
| 1103 | - $c | |
| 1104 | - ); | |
| 1105 | - return $manager; | |
| 1106 | - }); | |
| 1107 | -		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { | |
| 1108 | - return new \OC\Files\AppData\Factory( | |
| 1109 | - $c->getRootFolder(), | |
| 1110 | - $c->getSystemConfig() | |
| 1111 | - ); | |
| 1112 | - }); | |
| 1113 | - | |
| 1114 | -		$this->registerService('LockdownManager', function (Server $c) { | |
| 1115 | -			return new LockdownManager(function () use ($c) { | |
| 1116 | - return $c->getSession(); | |
| 1117 | - }); | |
| 1118 | - }); | |
| 1119 | - | |
| 1120 | -		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { | |
| 1121 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); | |
| 1122 | - }); | |
| 1123 | - | |
| 1124 | -		$this->registerService(ICloudIdManager::class, function (Server $c) { | |
| 1125 | - return new CloudIdManager(); | |
| 1126 | - }); | |
| 1127 | - | |
| 1128 | -		$this->registerService(IConfig::class, function (Server $c) { | |
| 1129 | - return new GlobalScale\Config($c->getConfig()); | |
| 1130 | - }); | |
| 1131 | - | |
| 1132 | -		$this->registerService(ICloudFederationProviderManager::class, function (Server $c) { | |
| 1133 | - return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); | |
| 1134 | - }); | |
| 1135 | - | |
| 1136 | -		$this->registerService(ICloudFederationFactory::class, function (Server $c) { | |
| 1137 | - return new CloudFederationFactory(); | |
| 1138 | - }); | |
| 1139 | - | |
| 1140 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); | |
| 1141 | -		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); | |
| 1142 | - | |
| 1143 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); | |
| 1144 | -		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); | |
| 1145 | - | |
| 1146 | -		$this->registerService(Defaults::class, function (Server $c) { | |
| 1147 | - return new Defaults( | |
| 1148 | - $c->getThemingDefaults() | |
| 1149 | - ); | |
| 1150 | - }); | |
| 1151 | -		$this->registerAlias('Defaults', \OCP\Defaults::class); | |
| 1152 | - | |
| 1153 | -		$this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { | |
| 1154 | - return $c->query(\OCP\IUserSession::class)->getSession(); | |
| 1155 | - }); | |
| 1156 | - | |
| 1157 | -		$this->registerService(IShareHelper::class, function (Server $c) { | |
| 1158 | - return new ShareHelper( | |
| 1159 | - $c->query(\OCP\Share\IManager::class) | |
| 1160 | - ); | |
| 1161 | - }); | |
| 1162 | - | |
| 1163 | -		$this->registerService(Installer::class, function(Server $c) { | |
| 1164 | - return new Installer( | |
| 1165 | - $c->getAppFetcher(), | |
| 1166 | - $c->getHTTPClientService(), | |
| 1167 | - $c->getTempManager(), | |
| 1168 | - $c->getLogger(), | |
| 1169 | - $c->getConfig() | |
| 1170 | - ); | |
| 1171 | - }); | |
| 1172 | - | |
| 1173 | -		$this->registerService(IApiFactory::class, function(Server $c) { | |
| 1174 | - return new ApiFactory($c->getHTTPClientService()); | |
| 1175 | - }); | |
| 1176 | - | |
| 1177 | -		$this->registerService(IInstanceFactory::class, function(Server $c) { | |
| 1178 | - $memcacheFactory = $c->getMemCacheFactory(); | |
| 1179 | -			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); | |
| 1180 | - }); | |
| 1181 | - | |
| 1182 | -		$this->registerService(IContactsStore::class, function(Server $c) { | |
| 1183 | - return new ContactsStore( | |
| 1184 | - $c->getContactsManager(), | |
| 1185 | - $c->getConfig(), | |
| 1186 | - $c->getUserManager(), | |
| 1187 | - $c->getGroupManager() | |
| 1188 | - ); | |
| 1189 | - }); | |
| 1190 | - $this->registerAlias(IContactsStore::class, ContactsStore::class); | |
| 1191 | - $this->registerAlias(IAccountManager::class, AccountManager::class); | |
| 1192 | - | |
| 1193 | -		$this->registerService(IStorageFactory::class, function() { | |
| 1194 | - return new StorageFactory(); | |
| 1195 | - }); | |
| 1196 | - | |
| 1197 | - $this->registerAlias(IDashboardManager::class, DashboardManager::class); | |
| 1198 | - $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); | |
| 1199 | - | |
| 1200 | -		$this->registerService(\OC\Security\IdentityProof\Manager::class, function (Server $c) { | |
| 1201 | - return new \OC\Security\IdentityProof\Manager( | |
| 1202 | - $c->query(\OC\Files\AppData\Factory::class), | |
| 1203 | - $c->getCrypto(), | |
| 1204 | - $c->getConfig() | |
| 1205 | - ); | |
| 1206 | - }); | |
| 1207 | - | |
| 1208 | - $this->registerAlias(ISubAdmin::class, SubAdmin::class); | |
| 1209 | - | |
| 1210 | - $this->registerAlias(IInitialStateService::class, InitialStateService::class); | |
| 1211 | - | |
| 1212 | - $this->connectDispatcher(); | |
| 1213 | - } | |
| 1214 | - | |
| 1215 | - /** | |
| 1216 | - * @return \OCP\Calendar\IManager | |
| 1217 | - */ | |
| 1218 | -	public function getCalendarManager() { | |
| 1219 | -		return $this->query('CalendarManager'); | |
| 1220 | - } | |
| 1221 | - | |
| 1222 | - /** | |
| 1223 | - * @return \OCP\Calendar\Resource\IManager | |
| 1224 | - */ | |
| 1225 | -	public function getCalendarResourceBackendManager() { | |
| 1226 | -		return $this->query('CalendarResourceBackendManager'); | |
| 1227 | - } | |
| 1228 | - | |
| 1229 | - /** | |
| 1230 | - * @return \OCP\Calendar\Room\IManager | |
| 1231 | - */ | |
| 1232 | -	public function getCalendarRoomBackendManager() { | |
| 1233 | -		return $this->query('CalendarRoomBackendManager'); | |
| 1234 | - } | |
| 1235 | - | |
| 1236 | -	private function connectDispatcher() { | |
| 1237 | - $dispatcher = $this->getEventDispatcher(); | |
| 1238 | - | |
| 1239 | - // Delete avatar on user deletion | |
| 1240 | -		$dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { | |
| 1241 | - $logger = $this->getLogger(); | |
| 1242 | - $manager = $this->getAvatarManager(); | |
| 1243 | - /** @var IUser $user */ | |
| 1244 | - $user = $e->getSubject(); | |
| 1245 | - | |
| 1246 | -			try { | |
| 1247 | - $avatar = $manager->getAvatar($user->getUID()); | |
| 1248 | - $avatar->remove(); | |
| 1249 | -			} catch (NotFoundException $e) { | |
| 1250 | - // no avatar to remove | |
| 1251 | -			} catch (\Exception $e) { | |
| 1252 | - // Ignore exceptions | |
| 1253 | -				$logger->info('Could not cleanup avatar of ' . $user->getUID()); | |
| 1254 | - } | |
| 1255 | - }); | |
| 1256 | - | |
| 1257 | -		$dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { | |
| 1258 | - $manager = $this->getAvatarManager(); | |
| 1259 | - /** @var IUser $user */ | |
| 1260 | - $user = $e->getSubject(); | |
| 1261 | -			$feature = $e->getArgument('feature'); | |
| 1262 | -			$oldValue = $e->getArgument('oldValue'); | |
| 1263 | -			$value = $e->getArgument('value'); | |
| 1264 | - | |
| 1265 | -			try { | |
| 1266 | - $avatar = $manager->getAvatar($user->getUID()); | |
| 1267 | - $avatar->userChanged($feature, $oldValue, $value); | |
| 1268 | -			} catch (NotFoundException $e) { | |
| 1269 | - // no avatar to remove | |
| 1270 | - } | |
| 1271 | - }); | |
| 1272 | - } | |
| 1273 | - | |
| 1274 | - /** | |
| 1275 | - * @return \OCP\Contacts\IManager | |
| 1276 | - */ | |
| 1277 | -	public function getContactsManager() { | |
| 1278 | -		return $this->query('ContactsManager'); | |
| 1279 | - } | |
| 1280 | - | |
| 1281 | - /** | |
| 1282 | - * @return \OC\Encryption\Manager | |
| 1283 | - */ | |
| 1284 | -	public function getEncryptionManager() { | |
| 1285 | -		return $this->query('EncryptionManager'); | |
| 1286 | - } | |
| 1287 | - | |
| 1288 | - /** | |
| 1289 | - * @return \OC\Encryption\File | |
| 1290 | - */ | |
| 1291 | -	public function getEncryptionFilesHelper() { | |
| 1292 | -		return $this->query('EncryptionFileHelper'); | |
| 1293 | - } | |
| 1294 | - | |
| 1295 | - /** | |
| 1296 | - * @return \OCP\Encryption\Keys\IStorage | |
| 1297 | - */ | |
| 1298 | -	public function getEncryptionKeyStorage() { | |
| 1299 | -		return $this->query('EncryptionKeyStorage'); | |
| 1300 | - } | |
| 1301 | - | |
| 1302 | - /** | |
| 1303 | - * The current request object holding all information about the request | |
| 1304 | - * currently being processed is returned from this method. | |
| 1305 | - * In case the current execution was not initiated by a web request null is returned | |
| 1306 | - * | |
| 1307 | - * @return \OCP\IRequest | |
| 1308 | - */ | |
| 1309 | -	public function getRequest() { | |
| 1310 | -		return $this->query('Request'); | |
| 1311 | - } | |
| 1312 | - | |
| 1313 | - /** | |
| 1314 | - * Returns the preview manager which can create preview images for a given file | |
| 1315 | - * | |
| 1316 | - * @return \OCP\IPreview | |
| 1317 | - */ | |
| 1318 | -	public function getPreviewManager() { | |
| 1319 | -		return $this->query('PreviewManager'); | |
| 1320 | - } | |
| 1321 | - | |
| 1322 | - /** | |
| 1323 | - * Returns the tag manager which can get and set tags for different object types | |
| 1324 | - * | |
| 1325 | - * @see \OCP\ITagManager::load() | |
| 1326 | - * @return \OCP\ITagManager | |
| 1327 | - */ | |
| 1328 | -	public function getTagManager() { | |
| 1329 | -		return $this->query('TagManager'); | |
| 1330 | - } | |
| 1331 | - | |
| 1332 | - /** | |
| 1333 | - * Returns the system-tag manager | |
| 1334 | - * | |
| 1335 | - * @return \OCP\SystemTag\ISystemTagManager | |
| 1336 | - * | |
| 1337 | - * @since 9.0.0 | |
| 1338 | - */ | |
| 1339 | -	public function getSystemTagManager() { | |
| 1340 | -		return $this->query('SystemTagManager'); | |
| 1341 | - } | |
| 1342 | - | |
| 1343 | - /** | |
| 1344 | - * Returns the system-tag object mapper | |
| 1345 | - * | |
| 1346 | - * @return \OCP\SystemTag\ISystemTagObjectMapper | |
| 1347 | - * | |
| 1348 | - * @since 9.0.0 | |
| 1349 | - */ | |
| 1350 | -	public function getSystemTagObjectMapper() { | |
| 1351 | -		return $this->query('SystemTagObjectMapper'); | |
| 1352 | - } | |
| 1353 | - | |
| 1354 | - /** | |
| 1355 | - * Returns the avatar manager, used for avatar functionality | |
| 1356 | - * | |
| 1357 | - * @return \OCP\IAvatarManager | |
| 1358 | - */ | |
| 1359 | -	public function getAvatarManager() { | |
| 1360 | -		return $this->query('AvatarManager'); | |
| 1361 | - } | |
| 1362 | - | |
| 1363 | - /** | |
| 1364 | - * Returns the root folder of ownCloud's data directory | |
| 1365 | - * | |
| 1366 | - * @return \OCP\Files\IRootFolder | |
| 1367 | - */ | |
| 1368 | -	public function getRootFolder() { | |
| 1369 | -		return $this->query('LazyRootFolder'); | |
| 1370 | - } | |
| 1371 | - | |
| 1372 | - /** | |
| 1373 | - * Returns the root folder of ownCloud's data directory | |
| 1374 | - * This is the lazy variant so this gets only initialized once it | |
| 1375 | - * is actually used. | |
| 1376 | - * | |
| 1377 | - * @return \OCP\Files\IRootFolder | |
| 1378 | - */ | |
| 1379 | -	public function getLazyRootFolder() { | |
| 1380 | -		return $this->query('LazyRootFolder'); | |
| 1381 | - } | |
| 1382 | - | |
| 1383 | - /** | |
| 1384 | - * Returns a view to ownCloud's files folder | |
| 1385 | - * | |
| 1386 | - * @param string $userId user ID | |
| 1387 | - * @return \OCP\Files\Folder|null | |
| 1388 | - */ | |
| 1389 | -	public function getUserFolder($userId = null) { | |
| 1390 | -		if ($userId === null) { | |
| 1391 | - $user = $this->getUserSession()->getUser(); | |
| 1392 | -			if (!$user) { | |
| 1393 | - return null; | |
| 1394 | - } | |
| 1395 | - $userId = $user->getUID(); | |
| 1396 | - } | |
| 1397 | - $root = $this->getRootFolder(); | |
| 1398 | - return $root->getUserFolder($userId); | |
| 1399 | - } | |
| 1400 | - | |
| 1401 | - /** | |
| 1402 | - * Returns an app-specific view in ownClouds data directory | |
| 1403 | - * | |
| 1404 | - * @return \OCP\Files\Folder | |
| 1405 | - * @deprecated since 9.2.0 use IAppData | |
| 1406 | - */ | |
| 1407 | -	public function getAppFolder() { | |
| 1408 | - $dir = '/' . \OC_App::getCurrentApp(); | |
| 1409 | - $root = $this->getRootFolder(); | |
| 1410 | -		if (!$root->nodeExists($dir)) { | |
| 1411 | - $folder = $root->newFolder($dir); | |
| 1412 | -		} else { | |
| 1413 | - $folder = $root->get($dir); | |
| 1414 | - } | |
| 1415 | - return $folder; | |
| 1416 | - } | |
| 1417 | - | |
| 1418 | - /** | |
| 1419 | - * @return \OC\User\Manager | |
| 1420 | - */ | |
| 1421 | -	public function getUserManager() { | |
| 1422 | -		return $this->query('UserManager'); | |
| 1423 | - } | |
| 1424 | - | |
| 1425 | - /** | |
| 1426 | - * @return \OC\Group\Manager | |
| 1427 | - */ | |
| 1428 | -	public function getGroupManager() { | |
| 1429 | -		return $this->query('GroupManager'); | |
| 1430 | - } | |
| 1431 | - | |
| 1432 | - /** | |
| 1433 | - * @return \OC\User\Session | |
| 1434 | - */ | |
| 1435 | -	public function getUserSession() { | |
| 1436 | -		return $this->query('UserSession'); | |
| 1437 | - } | |
| 1438 | - | |
| 1439 | - /** | |
| 1440 | - * @return \OCP\ISession | |
| 1441 | - */ | |
| 1442 | -	public function getSession() { | |
| 1443 | -		return $this->query('UserSession')->getSession(); | |
| 1444 | - } | |
| 1445 | - | |
| 1446 | - /** | |
| 1447 | - * @param \OCP\ISession $session | |
| 1448 | - */ | |
| 1449 | -	public function setSession(\OCP\ISession $session) { | |
| 1450 | - $this->query(SessionStorage::class)->setSession($session); | |
| 1451 | -		$this->query('UserSession')->setSession($session); | |
| 1452 | - $this->query(Store::class)->setSession($session); | |
| 1453 | - } | |
| 1454 | - | |
| 1455 | - /** | |
| 1456 | - * @return \OC\Authentication\TwoFactorAuth\Manager | |
| 1457 | - */ | |
| 1458 | -	public function getTwoFactorAuthManager() { | |
| 1459 | -		return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); | |
| 1460 | - } | |
| 1461 | - | |
| 1462 | - /** | |
| 1463 | - * @return \OC\NavigationManager | |
| 1464 | - */ | |
| 1465 | -	public function getNavigationManager() { | |
| 1466 | -		return $this->query('NavigationManager'); | |
| 1467 | - } | |
| 1468 | - | |
| 1469 | - /** | |
| 1470 | - * @return \OCP\IConfig | |
| 1471 | - */ | |
| 1472 | -	public function getConfig() { | |
| 1473 | -		return $this->query('AllConfig'); | |
| 1474 | - } | |
| 1475 | - | |
| 1476 | - /** | |
| 1477 | - * @return \OC\SystemConfig | |
| 1478 | - */ | |
| 1479 | -	public function getSystemConfig() { | |
| 1480 | -		return $this->query('SystemConfig'); | |
| 1481 | - } | |
| 1482 | - | |
| 1483 | - /** | |
| 1484 | - * Returns the app config manager | |
| 1485 | - * | |
| 1486 | - * @return \OCP\IAppConfig | |
| 1487 | - */ | |
| 1488 | -	public function getAppConfig() { | |
| 1489 | -		return $this->query('AppConfig'); | |
| 1490 | - } | |
| 1491 | - | |
| 1492 | - /** | |
| 1493 | - * @return \OCP\L10N\IFactory | |
| 1494 | - */ | |
| 1495 | -	public function getL10NFactory() { | |
| 1496 | -		return $this->query('L10NFactory'); | |
| 1497 | - } | |
| 1498 | - | |
| 1499 | - /** | |
| 1500 | - * get an L10N instance | |
| 1501 | - * | |
| 1502 | - * @param string $app appid | |
| 1503 | - * @param string $lang | |
| 1504 | - * @return IL10N | |
| 1505 | - */ | |
| 1506 | -	public function getL10N($app, $lang = null) { | |
| 1507 | - return $this->getL10NFactory()->get($app, $lang); | |
| 1508 | - } | |
| 1509 | - | |
| 1510 | - /** | |
| 1511 | - * @return \OCP\IURLGenerator | |
| 1512 | - */ | |
| 1513 | -	public function getURLGenerator() { | |
| 1514 | -		return $this->query('URLGenerator'); | |
| 1515 | - } | |
| 1516 | - | |
| 1517 | - /** | |
| 1518 | - * @return AppFetcher | |
| 1519 | - */ | |
| 1520 | -	public function getAppFetcher() { | |
| 1521 | - return $this->query(AppFetcher::class); | |
| 1522 | - } | |
| 1523 | - | |
| 1524 | - /** | |
| 1525 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use | |
| 1526 | - * getMemCacheFactory() instead. | |
| 1527 | - * | |
| 1528 | - * @return \OCP\ICache | |
| 1529 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache | |
| 1530 | - */ | |
| 1531 | -	public function getCache() { | |
| 1532 | -		return $this->query('UserCache'); | |
| 1533 | - } | |
| 1534 | - | |
| 1535 | - /** | |
| 1536 | - * Returns an \OCP\CacheFactory instance | |
| 1537 | - * | |
| 1538 | - * @return \OCP\ICacheFactory | |
| 1539 | - */ | |
| 1540 | -	public function getMemCacheFactory() { | |
| 1541 | -		return $this->query('MemCacheFactory'); | |
| 1542 | - } | |
| 1543 | - | |
| 1544 | - /** | |
| 1545 | - * Returns an \OC\RedisFactory instance | |
| 1546 | - * | |
| 1547 | - * @return \OC\RedisFactory | |
| 1548 | - */ | |
| 1549 | -	public function getGetRedisFactory() { | |
| 1550 | -		return $this->query('RedisFactory'); | |
| 1551 | - } | |
| 1552 | - | |
| 1553 | - | |
| 1554 | - /** | |
| 1555 | - * Returns the current session | |
| 1556 | - * | |
| 1557 | - * @return \OCP\IDBConnection | |
| 1558 | - */ | |
| 1559 | -	public function getDatabaseConnection() { | |
| 1560 | -		return $this->query('DatabaseConnection'); | |
| 1561 | - } | |
| 1562 | - | |
| 1563 | - /** | |
| 1564 | - * Returns the activity manager | |
| 1565 | - * | |
| 1566 | - * @return \OCP\Activity\IManager | |
| 1567 | - */ | |
| 1568 | -	public function getActivityManager() { | |
| 1569 | -		return $this->query('ActivityManager'); | |
| 1570 | - } | |
| 1571 | - | |
| 1572 | - /** | |
| 1573 | - * Returns an job list for controlling background jobs | |
| 1574 | - * | |
| 1575 | - * @return \OCP\BackgroundJob\IJobList | |
| 1576 | - */ | |
| 1577 | -	public function getJobList() { | |
| 1578 | -		return $this->query('JobList'); | |
| 1579 | - } | |
| 1580 | - | |
| 1581 | - /** | |
| 1582 | - * Returns a logger instance | |
| 1583 | - * | |
| 1584 | - * @return \OCP\ILogger | |
| 1585 | - */ | |
| 1586 | -	public function getLogger() { | |
| 1587 | -		return $this->query('Logger'); | |
| 1588 | - } | |
| 1589 | - | |
| 1590 | - /** | |
| 1591 | - * @return ILogFactory | |
| 1592 | - * @throws \OCP\AppFramework\QueryException | |
| 1593 | - */ | |
| 1594 | -	public function getLogFactory() { | |
| 1595 | - return $this->query(ILogFactory::class); | |
| 1596 | - } | |
| 1597 | - | |
| 1598 | - /** | |
| 1599 | - * Returns a router for generating and matching urls | |
| 1600 | - * | |
| 1601 | - * @return \OCP\Route\IRouter | |
| 1602 | - */ | |
| 1603 | -	public function getRouter() { | |
| 1604 | -		return $this->query('Router'); | |
| 1605 | - } | |
| 1606 | - | |
| 1607 | - /** | |
| 1608 | - * Returns a search instance | |
| 1609 | - * | |
| 1610 | - * @return \OCP\ISearch | |
| 1611 | - */ | |
| 1612 | -	public function getSearch() { | |
| 1613 | -		return $this->query('Search'); | |
| 1614 | - } | |
| 1615 | - | |
| 1616 | - /** | |
| 1617 | - * Returns a SecureRandom instance | |
| 1618 | - * | |
| 1619 | - * @return \OCP\Security\ISecureRandom | |
| 1620 | - */ | |
| 1621 | -	public function getSecureRandom() { | |
| 1622 | -		return $this->query('SecureRandom'); | |
| 1623 | - } | |
| 1624 | - | |
| 1625 | - /** | |
| 1626 | - * Returns a Crypto instance | |
| 1627 | - * | |
| 1628 | - * @return \OCP\Security\ICrypto | |
| 1629 | - */ | |
| 1630 | -	public function getCrypto() { | |
| 1631 | -		return $this->query('Crypto'); | |
| 1632 | - } | |
| 1633 | - | |
| 1634 | - /** | |
| 1635 | - * Returns a Hasher instance | |
| 1636 | - * | |
| 1637 | - * @return \OCP\Security\IHasher | |
| 1638 | - */ | |
| 1639 | -	public function getHasher() { | |
| 1640 | -		return $this->query('Hasher'); | |
| 1641 | - } | |
| 1642 | - | |
| 1643 | - /** | |
| 1644 | - * Returns a CredentialsManager instance | |
| 1645 | - * | |
| 1646 | - * @return \OCP\Security\ICredentialsManager | |
| 1647 | - */ | |
| 1648 | -	public function getCredentialsManager() { | |
| 1649 | -		return $this->query('CredentialsManager'); | |
| 1650 | - } | |
| 1651 | - | |
| 1652 | - /** | |
| 1653 | - * Get the certificate manager for the user | |
| 1654 | - * | |
| 1655 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager | |
| 1656 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in | |
| 1657 | - */ | |
| 1658 | -	public function getCertificateManager($userId = '') { | |
| 1659 | -		if ($userId === '') { | |
| 1660 | - $userSession = $this->getUserSession(); | |
| 1661 | - $user = $userSession->getUser(); | |
| 1662 | -			if (is_null($user)) { | |
| 1663 | - return null; | |
| 1664 | - } | |
| 1665 | - $userId = $user->getUID(); | |
| 1666 | - } | |
| 1667 | - return new CertificateManager( | |
| 1668 | - $userId, | |
| 1669 | - new View(), | |
| 1670 | - $this->getConfig(), | |
| 1671 | - $this->getLogger(), | |
| 1672 | - $this->getSecureRandom() | |
| 1673 | - ); | |
| 1674 | - } | |
| 1675 | - | |
| 1676 | - /** | |
| 1677 | - * Returns an instance of the HTTP client service | |
| 1678 | - * | |
| 1679 | - * @return \OCP\Http\Client\IClientService | |
| 1680 | - */ | |
| 1681 | -	public function getHTTPClientService() { | |
| 1682 | -		return $this->query('HttpClientService'); | |
| 1683 | - } | |
| 1684 | - | |
| 1685 | - /** | |
| 1686 | - * Create a new event source | |
| 1687 | - * | |
| 1688 | - * @return \OCP\IEventSource | |
| 1689 | - */ | |
| 1690 | -	public function createEventSource() { | |
| 1691 | - return new \OC_EventSource(); | |
| 1692 | - } | |
| 1693 | - | |
| 1694 | - /** | |
| 1695 | - * Get the active event logger | |
| 1696 | - * | |
| 1697 | - * The returned logger only logs data when debug mode is enabled | |
| 1698 | - * | |
| 1699 | - * @return \OCP\Diagnostics\IEventLogger | |
| 1700 | - */ | |
| 1701 | -	public function getEventLogger() { | |
| 1702 | -		return $this->query('EventLogger'); | |
| 1703 | - } | |
| 1704 | - | |
| 1705 | - /** | |
| 1706 | - * Get the active query logger | |
| 1707 | - * | |
| 1708 | - * The returned logger only logs data when debug mode is enabled | |
| 1709 | - * | |
| 1710 | - * @return \OCP\Diagnostics\IQueryLogger | |
| 1711 | - */ | |
| 1712 | -	public function getQueryLogger() { | |
| 1713 | -		return $this->query('QueryLogger'); | |
| 1714 | - } | |
| 1715 | - | |
| 1716 | - /** | |
| 1717 | - * Get the manager for temporary files and folders | |
| 1718 | - * | |
| 1719 | - * @return \OCP\ITempManager | |
| 1720 | - */ | |
| 1721 | -	public function getTempManager() { | |
| 1722 | -		return $this->query('TempManager'); | |
| 1723 | - } | |
| 1724 | - | |
| 1725 | - /** | |
| 1726 | - * Get the app manager | |
| 1727 | - * | |
| 1728 | - * @return \OCP\App\IAppManager | |
| 1729 | - */ | |
| 1730 | -	public function getAppManager() { | |
| 1731 | -		return $this->query('AppManager'); | |
| 1732 | - } | |
| 1733 | - | |
| 1734 | - /** | |
| 1735 | - * Creates a new mailer | |
| 1736 | - * | |
| 1737 | - * @return \OCP\Mail\IMailer | |
| 1738 | - */ | |
| 1739 | -	public function getMailer() { | |
| 1740 | -		return $this->query('Mailer'); | |
| 1741 | - } | |
| 1742 | - | |
| 1743 | - /** | |
| 1744 | - * Get the webroot | |
| 1745 | - * | |
| 1746 | - * @return string | |
| 1747 | - */ | |
| 1748 | -	public function getWebRoot() { | |
| 1749 | - return $this->webRoot; | |
| 1750 | - } | |
| 1751 | - | |
| 1752 | - /** | |
| 1753 | - * @return \OC\OCSClient | |
| 1754 | - */ | |
| 1755 | -	public function getOcsClient() { | |
| 1756 | -		return $this->query('OcsClient'); | |
| 1757 | - } | |
| 1758 | - | |
| 1759 | - /** | |
| 1760 | - * @return \OCP\IDateTimeZone | |
| 1761 | - */ | |
| 1762 | -	public function getDateTimeZone() { | |
| 1763 | -		return $this->query('DateTimeZone'); | |
| 1764 | - } | |
| 1765 | - | |
| 1766 | - /** | |
| 1767 | - * @return \OCP\IDateTimeFormatter | |
| 1768 | - */ | |
| 1769 | -	public function getDateTimeFormatter() { | |
| 1770 | -		return $this->query('DateTimeFormatter'); | |
| 1771 | - } | |
| 1772 | - | |
| 1773 | - /** | |
| 1774 | - * @return \OCP\Files\Config\IMountProviderCollection | |
| 1775 | - */ | |
| 1776 | -	public function getMountProviderCollection() { | |
| 1777 | -		return $this->query('MountConfigManager'); | |
| 1778 | - } | |
| 1779 | - | |
| 1780 | - /** | |
| 1781 | - * Get the IniWrapper | |
| 1782 | - * | |
| 1783 | - * @return IniGetWrapper | |
| 1784 | - */ | |
| 1785 | -	public function getIniWrapper() { | |
| 1786 | -		return $this->query('IniWrapper'); | |
| 1787 | - } | |
| 1788 | - | |
| 1789 | - /** | |
| 1790 | - * @return \OCP\Command\IBus | |
| 1791 | - */ | |
| 1792 | -	public function getCommandBus() { | |
| 1793 | -		return $this->query('AsyncCommandBus'); | |
| 1794 | - } | |
| 1795 | - | |
| 1796 | - /** | |
| 1797 | - * Get the trusted domain helper | |
| 1798 | - * | |
| 1799 | - * @return TrustedDomainHelper | |
| 1800 | - */ | |
| 1801 | -	public function getTrustedDomainHelper() { | |
| 1802 | -		return $this->query('TrustedDomainHelper'); | |
| 1803 | - } | |
| 1804 | - | |
| 1805 | - /** | |
| 1806 | - * Get the locking provider | |
| 1807 | - * | |
| 1808 | - * @return \OCP\Lock\ILockingProvider | |
| 1809 | - * @since 8.1.0 | |
| 1810 | - */ | |
| 1811 | -	public function getLockingProvider() { | |
| 1812 | -		return $this->query('LockingProvider'); | |
| 1813 | - } | |
| 1814 | - | |
| 1815 | - /** | |
| 1816 | - * @return \OCP\Files\Mount\IMountManager | |
| 1817 | - **/ | |
| 1818 | -	function getMountManager() { | |
| 1819 | -		return $this->query('MountManager'); | |
| 1820 | - } | |
| 1821 | - | |
| 1822 | - /** @return \OCP\Files\Config\IUserMountCache */ | |
| 1823 | -	function getUserMountCache() { | |
| 1824 | -		return $this->query('UserMountCache'); | |
| 1825 | - } | |
| 1826 | - | |
| 1827 | - /** | |
| 1828 | - * Get the MimeTypeDetector | |
| 1829 | - * | |
| 1830 | - * @return \OCP\Files\IMimeTypeDetector | |
| 1831 | - */ | |
| 1832 | -	public function getMimeTypeDetector() { | |
| 1833 | -		return $this->query('MimeTypeDetector'); | |
| 1834 | - } | |
| 1835 | - | |
| 1836 | - /** | |
| 1837 | - * Get the MimeTypeLoader | |
| 1838 | - * | |
| 1839 | - * @return \OCP\Files\IMimeTypeLoader | |
| 1840 | - */ | |
| 1841 | -	public function getMimeTypeLoader() { | |
| 1842 | -		return $this->query('MimeTypeLoader'); | |
| 1843 | - } | |
| 1844 | - | |
| 1845 | - /** | |
| 1846 | - * Get the manager of all the capabilities | |
| 1847 | - * | |
| 1848 | - * @return \OC\CapabilitiesManager | |
| 1849 | - */ | |
| 1850 | -	public function getCapabilitiesManager() { | |
| 1851 | -		return $this->query('CapabilitiesManager'); | |
| 1852 | - } | |
| 1853 | - | |
| 1854 | - /** | |
| 1855 | - * Get the EventDispatcher | |
| 1856 | - * | |
| 1857 | - * @return EventDispatcherInterface | |
| 1858 | - * @since 8.2.0 | |
| 1859 | - */ | |
| 1860 | -	public function getEventDispatcher() { | |
| 1861 | -		return $this->query('EventDispatcher'); | |
| 1862 | - } | |
| 1863 | - | |
| 1864 | - /** | |
| 1865 | - * Get the Notification Manager | |
| 1866 | - * | |
| 1867 | - * @return \OCP\Notification\IManager | |
| 1868 | - * @since 8.2.0 | |
| 1869 | - */ | |
| 1870 | -	public function getNotificationManager() { | |
| 1871 | -		return $this->query('NotificationManager'); | |
| 1872 | - } | |
| 1873 | - | |
| 1874 | - /** | |
| 1875 | - * @return \OCP\Comments\ICommentsManager | |
| 1876 | - */ | |
| 1877 | -	public function getCommentsManager() { | |
| 1878 | -		return $this->query('CommentsManager'); | |
| 1879 | - } | |
| 1880 | - | |
| 1881 | - /** | |
| 1882 | - * @return \OCA\Theming\ThemingDefaults | |
| 1883 | - */ | |
| 1884 | -	public function getThemingDefaults() { | |
| 1885 | -		return $this->query('ThemingDefaults'); | |
| 1886 | - } | |
| 1887 | - | |
| 1888 | - /** | |
| 1889 | - * @return \OC\IntegrityCheck\Checker | |
| 1890 | - */ | |
| 1891 | -	public function getIntegrityCodeChecker() { | |
| 1892 | -		return $this->query('IntegrityCodeChecker'); | |
| 1893 | - } | |
| 1894 | - | |
| 1895 | - /** | |
| 1896 | - * @return \OC\Session\CryptoWrapper | |
| 1897 | - */ | |
| 1898 | -	public function getSessionCryptoWrapper() { | |
| 1899 | -		return $this->query('CryptoWrapper'); | |
| 1900 | - } | |
| 1901 | - | |
| 1902 | - /** | |
| 1903 | - * @return CsrfTokenManager | |
| 1904 | - */ | |
| 1905 | -	public function getCsrfTokenManager() { | |
| 1906 | -		return $this->query('CsrfTokenManager'); | |
| 1907 | - } | |
| 1908 | - | |
| 1909 | - /** | |
| 1910 | - * @return Throttler | |
| 1911 | - */ | |
| 1912 | -	public function getBruteForceThrottler() { | |
| 1913 | -		return $this->query('Throttler'); | |
| 1914 | - } | |
| 1915 | - | |
| 1916 | - /** | |
| 1917 | - * @return IContentSecurityPolicyManager | |
| 1918 | - */ | |
| 1919 | -	public function getContentSecurityPolicyManager() { | |
| 1920 | -		return $this->query('ContentSecurityPolicyManager'); | |
| 1921 | - } | |
| 1922 | - | |
| 1923 | - /** | |
| 1924 | - * @return ContentSecurityPolicyNonceManager | |
| 1925 | - */ | |
| 1926 | -	public function getContentSecurityPolicyNonceManager() { | |
| 1927 | -		return $this->query('ContentSecurityPolicyNonceManager'); | |
| 1928 | - } | |
| 1929 | - | |
| 1930 | - /** | |
| 1931 | - * Not a public API as of 8.2, wait for 9.0 | |
| 1932 | - * | |
| 1933 | - * @return \OCA\Files_External\Service\BackendService | |
| 1934 | - */ | |
| 1935 | -	public function getStoragesBackendService() { | |
| 1936 | -		return $this->query('OCA\\Files_External\\Service\\BackendService'); | |
| 1937 | - } | |
| 1938 | - | |
| 1939 | - /** | |
| 1940 | - * Not a public API as of 8.2, wait for 9.0 | |
| 1941 | - * | |
| 1942 | - * @return \OCA\Files_External\Service\GlobalStoragesService | |
| 1943 | - */ | |
| 1944 | -	public function getGlobalStoragesService() { | |
| 1945 | -		return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); | |
| 1946 | - } | |
| 1947 | - | |
| 1948 | - /** | |
| 1949 | - * Not a public API as of 8.2, wait for 9.0 | |
| 1950 | - * | |
| 1951 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService | |
| 1952 | - */ | |
| 1953 | -	public function getUserGlobalStoragesService() { | |
| 1954 | -		return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); | |
| 1955 | - } | |
| 1956 | - | |
| 1957 | - /** | |
| 1958 | - * Not a public API as of 8.2, wait for 9.0 | |
| 1959 | - * | |
| 1960 | - * @return \OCA\Files_External\Service\UserStoragesService | |
| 1961 | - */ | |
| 1962 | -	public function getUserStoragesService() { | |
| 1963 | -		return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); | |
| 1964 | - } | |
| 1965 | - | |
| 1966 | - /** | |
| 1967 | - * @return \OCP\Share\IManager | |
| 1968 | - */ | |
| 1969 | -	public function getShareManager() { | |
| 1970 | -		return $this->query('ShareManager'); | |
| 1971 | - } | |
| 1972 | - | |
| 1973 | - /** | |
| 1974 | - * @return \OCP\Collaboration\Collaborators\ISearch | |
| 1975 | - */ | |
| 1976 | -	public function getCollaboratorSearch() { | |
| 1977 | -		return $this->query('CollaboratorSearch'); | |
| 1978 | - } | |
| 1979 | - | |
| 1980 | - /** | |
| 1981 | - * @return \OCP\Collaboration\AutoComplete\IManager | |
| 1982 | - */ | |
| 1983 | -	public function getAutoCompleteManager(){ | |
| 1984 | - return $this->query(IManager::class); | |
| 1985 | - } | |
| 1986 | - | |
| 1987 | - /** | |
| 1988 | - * Returns the LDAP Provider | |
| 1989 | - * | |
| 1990 | - * @return \OCP\LDAP\ILDAPProvider | |
| 1991 | - */ | |
| 1992 | -	public function getLDAPProvider() { | |
| 1993 | -		return $this->query('LDAPProvider'); | |
| 1994 | - } | |
| 1995 | - | |
| 1996 | - /** | |
| 1997 | - * @return \OCP\Settings\IManager | |
| 1998 | - */ | |
| 1999 | -	public function getSettingsManager() { | |
| 2000 | -		return $this->query('SettingsManager'); | |
| 2001 | - } | |
| 2002 | - | |
| 2003 | - /** | |
| 2004 | - * @return \OCP\Files\IAppData | |
| 2005 | - */ | |
| 2006 | -	public function getAppDataDir($app) { | |
| 2007 | - /** @var \OC\Files\AppData\Factory $factory */ | |
| 2008 | - $factory = $this->query(\OC\Files\AppData\Factory::class); | |
| 2009 | - return $factory->get($app); | |
| 2010 | - } | |
| 2011 | - | |
| 2012 | - /** | |
| 2013 | - * @return \OCP\Lockdown\ILockdownManager | |
| 2014 | - */ | |
| 2015 | -	public function getLockdownManager() { | |
| 2016 | -		return $this->query('LockdownManager'); | |
| 2017 | - } | |
| 2018 | - | |
| 2019 | - /** | |
| 2020 | - * @return \OCP\Federation\ICloudIdManager | |
| 2021 | - */ | |
| 2022 | -	public function getCloudIdManager() { | |
| 2023 | - return $this->query(ICloudIdManager::class); | |
| 2024 | - } | |
| 2025 | - | |
| 2026 | - /** | |
| 2027 | - * @return \OCP\GlobalScale\IConfig | |
| 2028 | - */ | |
| 2029 | -	public function getGlobalScaleConfig() { | |
| 2030 | - return $this->query(IConfig::class); | |
| 2031 | - } | |
| 2032 | - | |
| 2033 | - /** | |
| 2034 | - * @return \OCP\Federation\ICloudFederationProviderManager | |
| 2035 | - */ | |
| 2036 | -	public function getCloudFederationProviderManager() { | |
| 2037 | - return $this->query(ICloudFederationProviderManager::class); | |
| 2038 | - } | |
| 2039 | - | |
| 2040 | - /** | |
| 2041 | - * @return \OCP\Remote\Api\IApiFactory | |
| 2042 | - */ | |
| 2043 | -	public function getRemoteApiFactory() { | |
| 2044 | - return $this->query(IApiFactory::class); | |
| 2045 | - } | |
| 2046 | - | |
| 2047 | - /** | |
| 2048 | - * @return \OCP\Federation\ICloudFederationFactory | |
| 2049 | - */ | |
| 2050 | -	public function getCloudFederationFactory() { | |
| 2051 | - return $this->query(ICloudFederationFactory::class); | |
| 2052 | - } | |
| 2053 | - | |
| 2054 | - /** | |
| 2055 | - * @return \OCP\Remote\IInstanceFactory | |
| 2056 | - */ | |
| 2057 | -	public function getRemoteInstanceFactory() { | |
| 2058 | - return $this->query(IInstanceFactory::class); | |
| 2059 | - } | |
| 2060 | - | |
| 2061 | - /** | |
| 2062 | - * @return IStorageFactory | |
| 2063 | - */ | |
| 2064 | -	public function getStorageFactory() { | |
| 2065 | - return $this->query(IStorageFactory::class); | |
| 2066 | - } | |
| 952 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); | |
| 953 | +            if (isset($prefixes['OCA\\Theming\\'])) { | |
| 954 | + $classExists = true; | |
| 955 | +            } else { | |
| 956 | + $classExists = false; | |
| 957 | + } | |
| 958 | + | |
| 959 | +            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { | |
| 960 | + return new ThemingDefaults( | |
| 961 | + $c->getConfig(), | |
| 962 | +                    $c->getL10N('theming'), | |
| 963 | + $c->getURLGenerator(), | |
| 964 | + $c->getMemCacheFactory(), | |
| 965 | +                    new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), | |
| 966 | +                    new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), | |
| 967 | + $c->getAppManager(), | |
| 968 | + $c->getNavigationManager() | |
| 969 | + ); | |
| 970 | + } | |
| 971 | + return new \OC_Defaults(); | |
| 972 | + }); | |
| 973 | +        $this->registerService(SCSSCacher::class, function (Server $c) { | |
| 974 | + /** @var Factory $cacheFactory */ | |
| 975 | + $cacheFactory = $c->query(Factory::class); | |
| 976 | + return new SCSSCacher( | |
| 977 | + $c->getLogger(), | |
| 978 | + $c->query(\OC\Files\AppData\Factory::class), | |
| 979 | + $c->getURLGenerator(), | |
| 980 | + $c->getConfig(), | |
| 981 | + $c->getThemingDefaults(), | |
| 982 | + \OC::$SERVERROOT, | |
| 983 | + $this->getMemCacheFactory(), | |
| 984 | + $c->query(IconsCacher::class), | |
| 985 | + new TimeFactory() | |
| 986 | + ); | |
| 987 | + }); | |
| 988 | +        $this->registerService(JSCombiner::class, function (Server $c) { | |
| 989 | + /** @var Factory $cacheFactory */ | |
| 990 | + $cacheFactory = $c->query(Factory::class); | |
| 991 | + return new JSCombiner( | |
| 992 | +                $c->getAppDataDir('js'), | |
| 993 | + $c->getURLGenerator(), | |
| 994 | + $this->getMemCacheFactory(), | |
| 995 | + $c->getSystemConfig(), | |
| 996 | + $c->getLogger() | |
| 997 | + ); | |
| 998 | + }); | |
| 999 | +        $this->registerService(EventDispatcher::class, function () { | |
| 1000 | + return new EventDispatcher(); | |
| 1001 | + }); | |
| 1002 | +        $this->registerAlias('EventDispatcher', EventDispatcher::class); | |
| 1003 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); | |
| 1004 | + | |
| 1005 | +        $this->registerService('CryptoWrapper', function (Server $c) { | |
| 1006 | + // FIXME: Instantiiated here due to cyclic dependency | |
| 1007 | + $request = new Request( | |
| 1008 | + [ | |
| 1009 | + 'get' => $_GET, | |
| 1010 | + 'post' => $_POST, | |
| 1011 | + 'files' => $_FILES, | |
| 1012 | + 'server' => $_SERVER, | |
| 1013 | + 'env' => $_ENV, | |
| 1014 | + 'cookies' => $_COOKIE, | |
| 1015 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) | |
| 1016 | + ? $_SERVER['REQUEST_METHOD'] | |
| 1017 | + : null, | |
| 1018 | + ], | |
| 1019 | + $c->getSecureRandom(), | |
| 1020 | + $c->getConfig() | |
| 1021 | + ); | |
| 1022 | + | |
| 1023 | + return new CryptoWrapper( | |
| 1024 | + $c->getConfig(), | |
| 1025 | + $c->getCrypto(), | |
| 1026 | + $c->getSecureRandom(), | |
| 1027 | + $request | |
| 1028 | + ); | |
| 1029 | + }); | |
| 1030 | +        $this->registerService('CsrfTokenManager', function (Server $c) { | |
| 1031 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); | |
| 1032 | + | |
| 1033 | + return new CsrfTokenManager( | |
| 1034 | + $tokenGenerator, | |
| 1035 | + $c->query(SessionStorage::class) | |
| 1036 | + ); | |
| 1037 | + }); | |
| 1038 | +        $this->registerService(SessionStorage::class, function (Server $c) { | |
| 1039 | + return new SessionStorage($c->getSession()); | |
| 1040 | + }); | |
| 1041 | +        $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { | |
| 1042 | + return new ContentSecurityPolicyManager(); | |
| 1043 | + }); | |
| 1044 | +        $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); | |
| 1045 | + | |
| 1046 | +        $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { | |
| 1047 | + return new ContentSecurityPolicyNonceManager( | |
| 1048 | + $c->getCsrfTokenManager(), | |
| 1049 | + $c->getRequest() | |
| 1050 | + ); | |
| 1051 | + }); | |
| 1052 | + | |
| 1053 | +        $this->registerService(\OCP\Share\IManager::class, function (Server $c) { | |
| 1054 | + $config = $c->getConfig(); | |
| 1055 | +            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); | |
| 1056 | + /** @var \OCP\Share\IProviderFactory $factory */ | |
| 1057 | + $factory = new $factoryClass($this); | |
| 1058 | + | |
| 1059 | + $manager = new \OC\Share20\Manager( | |
| 1060 | + $c->getLogger(), | |
| 1061 | + $c->getConfig(), | |
| 1062 | + $c->getSecureRandom(), | |
| 1063 | + $c->getHasher(), | |
| 1064 | + $c->getMountManager(), | |
| 1065 | + $c->getGroupManager(), | |
| 1066 | +                $c->getL10N('lib'), | |
| 1067 | + $c->getL10NFactory(), | |
| 1068 | + $factory, | |
| 1069 | + $c->getUserManager(), | |
| 1070 | + $c->getLazyRootFolder(), | |
| 1071 | + $c->getEventDispatcher(), | |
| 1072 | + $c->getMailer(), | |
| 1073 | + $c->getURLGenerator(), | |
| 1074 | + $c->getThemingDefaults() | |
| 1075 | + ); | |
| 1076 | + | |
| 1077 | + return $manager; | |
| 1078 | + }); | |
| 1079 | +        $this->registerAlias('ShareManager', \OCP\Share\IManager::class); | |
| 1080 | + | |
| 1081 | +        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { | |
| 1082 | + $instance = new Collaboration\Collaborators\Search($c); | |
| 1083 | + | |
| 1084 | + // register default plugins | |
| 1085 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); | |
| 1086 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); | |
| 1087 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); | |
| 1088 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); | |
| 1089 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]); | |
| 1090 | + | |
| 1091 | + return $instance; | |
| 1092 | + }); | |
| 1093 | +        $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); | |
| 1094 | + $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class); | |
| 1095 | + | |
| 1096 | + $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); | |
| 1097 | + | |
| 1098 | +        $this->registerService('SettingsManager', function (Server $c) { | |
| 1099 | + $manager = new \OC\Settings\Manager( | |
| 1100 | + $c->getLogger(), | |
| 1101 | +                $c->getL10N('lib'), | |
| 1102 | + $c->getURLGenerator(), | |
| 1103 | + $c | |
| 1104 | + ); | |
| 1105 | + return $manager; | |
| 1106 | + }); | |
| 1107 | +        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { | |
| 1108 | + return new \OC\Files\AppData\Factory( | |
| 1109 | + $c->getRootFolder(), | |
| 1110 | + $c->getSystemConfig() | |
| 1111 | + ); | |
| 1112 | + }); | |
| 1113 | + | |
| 1114 | +        $this->registerService('LockdownManager', function (Server $c) { | |
| 1115 | +            return new LockdownManager(function () use ($c) { | |
| 1116 | + return $c->getSession(); | |
| 1117 | + }); | |
| 1118 | + }); | |
| 1119 | + | |
| 1120 | +        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { | |
| 1121 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); | |
| 1122 | + }); | |
| 1123 | + | |
| 1124 | +        $this->registerService(ICloudIdManager::class, function (Server $c) { | |
| 1125 | + return new CloudIdManager(); | |
| 1126 | + }); | |
| 1127 | + | |
| 1128 | +        $this->registerService(IConfig::class, function (Server $c) { | |
| 1129 | + return new GlobalScale\Config($c->getConfig()); | |
| 1130 | + }); | |
| 1131 | + | |
| 1132 | +        $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { | |
| 1133 | + return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); | |
| 1134 | + }); | |
| 1135 | + | |
| 1136 | +        $this->registerService(ICloudFederationFactory::class, function (Server $c) { | |
| 1137 | + return new CloudFederationFactory(); | |
| 1138 | + }); | |
| 1139 | + | |
| 1140 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); | |
| 1141 | +        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); | |
| 1142 | + | |
| 1143 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); | |
| 1144 | +        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); | |
| 1145 | + | |
| 1146 | +        $this->registerService(Defaults::class, function (Server $c) { | |
| 1147 | + return new Defaults( | |
| 1148 | + $c->getThemingDefaults() | |
| 1149 | + ); | |
| 1150 | + }); | |
| 1151 | +        $this->registerAlias('Defaults', \OCP\Defaults::class); | |
| 1152 | + | |
| 1153 | +        $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { | |
| 1154 | + return $c->query(\OCP\IUserSession::class)->getSession(); | |
| 1155 | + }); | |
| 1156 | + | |
| 1157 | +        $this->registerService(IShareHelper::class, function (Server $c) { | |
| 1158 | + return new ShareHelper( | |
| 1159 | + $c->query(\OCP\Share\IManager::class) | |
| 1160 | + ); | |
| 1161 | + }); | |
| 1162 | + | |
| 1163 | +        $this->registerService(Installer::class, function(Server $c) { | |
| 1164 | + return new Installer( | |
| 1165 | + $c->getAppFetcher(), | |
| 1166 | + $c->getHTTPClientService(), | |
| 1167 | + $c->getTempManager(), | |
| 1168 | + $c->getLogger(), | |
| 1169 | + $c->getConfig() | |
| 1170 | + ); | |
| 1171 | + }); | |
| 1172 | + | |
| 1173 | +        $this->registerService(IApiFactory::class, function(Server $c) { | |
| 1174 | + return new ApiFactory($c->getHTTPClientService()); | |
| 1175 | + }); | |
| 1176 | + | |
| 1177 | +        $this->registerService(IInstanceFactory::class, function(Server $c) { | |
| 1178 | + $memcacheFactory = $c->getMemCacheFactory(); | |
| 1179 | +            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); | |
| 1180 | + }); | |
| 1181 | + | |
| 1182 | +        $this->registerService(IContactsStore::class, function(Server $c) { | |
| 1183 | + return new ContactsStore( | |
| 1184 | + $c->getContactsManager(), | |
| 1185 | + $c->getConfig(), | |
| 1186 | + $c->getUserManager(), | |
| 1187 | + $c->getGroupManager() | |
| 1188 | + ); | |
| 1189 | + }); | |
| 1190 | + $this->registerAlias(IContactsStore::class, ContactsStore::class); | |
| 1191 | + $this->registerAlias(IAccountManager::class, AccountManager::class); | |
| 1192 | + | |
| 1193 | +        $this->registerService(IStorageFactory::class, function() { | |
| 1194 | + return new StorageFactory(); | |
| 1195 | + }); | |
| 1196 | + | |
| 1197 | + $this->registerAlias(IDashboardManager::class, DashboardManager::class); | |
| 1198 | + $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); | |
| 1199 | + | |
| 1200 | +        $this->registerService(\OC\Security\IdentityProof\Manager::class, function (Server $c) { | |
| 1201 | + return new \OC\Security\IdentityProof\Manager( | |
| 1202 | + $c->query(\OC\Files\AppData\Factory::class), | |
| 1203 | + $c->getCrypto(), | |
| 1204 | + $c->getConfig() | |
| 1205 | + ); | |
| 1206 | + }); | |
| 1207 | + | |
| 1208 | + $this->registerAlias(ISubAdmin::class, SubAdmin::class); | |
| 1209 | + | |
| 1210 | + $this->registerAlias(IInitialStateService::class, InitialStateService::class); | |
| 1211 | + | |
| 1212 | + $this->connectDispatcher(); | |
| 1213 | + } | |
| 1214 | + | |
| 1215 | + /** | |
| 1216 | + * @return \OCP\Calendar\IManager | |
| 1217 | + */ | |
| 1218 | +    public function getCalendarManager() { | |
| 1219 | +        return $this->query('CalendarManager'); | |
| 1220 | + } | |
| 1221 | + | |
| 1222 | + /** | |
| 1223 | + * @return \OCP\Calendar\Resource\IManager | |
| 1224 | + */ | |
| 1225 | +    public function getCalendarResourceBackendManager() { | |
| 1226 | +        return $this->query('CalendarResourceBackendManager'); | |
| 1227 | + } | |
| 1228 | + | |
| 1229 | + /** | |
| 1230 | + * @return \OCP\Calendar\Room\IManager | |
| 1231 | + */ | |
| 1232 | +    public function getCalendarRoomBackendManager() { | |
| 1233 | +        return $this->query('CalendarRoomBackendManager'); | |
| 1234 | + } | |
| 1235 | + | |
| 1236 | +    private function connectDispatcher() { | |
| 1237 | + $dispatcher = $this->getEventDispatcher(); | |
| 1238 | + | |
| 1239 | + // Delete avatar on user deletion | |
| 1240 | +        $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { | |
| 1241 | + $logger = $this->getLogger(); | |
| 1242 | + $manager = $this->getAvatarManager(); | |
| 1243 | + /** @var IUser $user */ | |
| 1244 | + $user = $e->getSubject(); | |
| 1245 | + | |
| 1246 | +            try { | |
| 1247 | + $avatar = $manager->getAvatar($user->getUID()); | |
| 1248 | + $avatar->remove(); | |
| 1249 | +            } catch (NotFoundException $e) { | |
| 1250 | + // no avatar to remove | |
| 1251 | +            } catch (\Exception $e) { | |
| 1252 | + // Ignore exceptions | |
| 1253 | +                $logger->info('Could not cleanup avatar of ' . $user->getUID()); | |
| 1254 | + } | |
| 1255 | + }); | |
| 1256 | + | |
| 1257 | +        $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { | |
| 1258 | + $manager = $this->getAvatarManager(); | |
| 1259 | + /** @var IUser $user */ | |
| 1260 | + $user = $e->getSubject(); | |
| 1261 | +            $feature = $e->getArgument('feature'); | |
| 1262 | +            $oldValue = $e->getArgument('oldValue'); | |
| 1263 | +            $value = $e->getArgument('value'); | |
| 1264 | + | |
| 1265 | +            try { | |
| 1266 | + $avatar = $manager->getAvatar($user->getUID()); | |
| 1267 | + $avatar->userChanged($feature, $oldValue, $value); | |
| 1268 | +            } catch (NotFoundException $e) { | |
| 1269 | + // no avatar to remove | |
| 1270 | + } | |
| 1271 | + }); | |
| 1272 | + } | |
| 1273 | + | |
| 1274 | + /** | |
| 1275 | + * @return \OCP\Contacts\IManager | |
| 1276 | + */ | |
| 1277 | +    public function getContactsManager() { | |
| 1278 | +        return $this->query('ContactsManager'); | |
| 1279 | + } | |
| 1280 | + | |
| 1281 | + /** | |
| 1282 | + * @return \OC\Encryption\Manager | |
| 1283 | + */ | |
| 1284 | +    public function getEncryptionManager() { | |
| 1285 | +        return $this->query('EncryptionManager'); | |
| 1286 | + } | |
| 1287 | + | |
| 1288 | + /** | |
| 1289 | + * @return \OC\Encryption\File | |
| 1290 | + */ | |
| 1291 | +    public function getEncryptionFilesHelper() { | |
| 1292 | +        return $this->query('EncryptionFileHelper'); | |
| 1293 | + } | |
| 1294 | + | |
| 1295 | + /** | |
| 1296 | + * @return \OCP\Encryption\Keys\IStorage | |
| 1297 | + */ | |
| 1298 | +    public function getEncryptionKeyStorage() { | |
| 1299 | +        return $this->query('EncryptionKeyStorage'); | |
| 1300 | + } | |
| 1301 | + | |
| 1302 | + /** | |
| 1303 | + * The current request object holding all information about the request | |
| 1304 | + * currently being processed is returned from this method. | |
| 1305 | + * In case the current execution was not initiated by a web request null is returned | |
| 1306 | + * | |
| 1307 | + * @return \OCP\IRequest | |
| 1308 | + */ | |
| 1309 | +    public function getRequest() { | |
| 1310 | +        return $this->query('Request'); | |
| 1311 | + } | |
| 1312 | + | |
| 1313 | + /** | |
| 1314 | + * Returns the preview manager which can create preview images for a given file | |
| 1315 | + * | |
| 1316 | + * @return \OCP\IPreview | |
| 1317 | + */ | |
| 1318 | +    public function getPreviewManager() { | |
| 1319 | +        return $this->query('PreviewManager'); | |
| 1320 | + } | |
| 1321 | + | |
| 1322 | + /** | |
| 1323 | + * Returns the tag manager which can get and set tags for different object types | |
| 1324 | + * | |
| 1325 | + * @see \OCP\ITagManager::load() | |
| 1326 | + * @return \OCP\ITagManager | |
| 1327 | + */ | |
| 1328 | +    public function getTagManager() { | |
| 1329 | +        return $this->query('TagManager'); | |
| 1330 | + } | |
| 1331 | + | |
| 1332 | + /** | |
| 1333 | + * Returns the system-tag manager | |
| 1334 | + * | |
| 1335 | + * @return \OCP\SystemTag\ISystemTagManager | |
| 1336 | + * | |
| 1337 | + * @since 9.0.0 | |
| 1338 | + */ | |
| 1339 | +    public function getSystemTagManager() { | |
| 1340 | +        return $this->query('SystemTagManager'); | |
| 1341 | + } | |
| 1342 | + | |
| 1343 | + /** | |
| 1344 | + * Returns the system-tag object mapper | |
| 1345 | + * | |
| 1346 | + * @return \OCP\SystemTag\ISystemTagObjectMapper | |
| 1347 | + * | |
| 1348 | + * @since 9.0.0 | |
| 1349 | + */ | |
| 1350 | +    public function getSystemTagObjectMapper() { | |
| 1351 | +        return $this->query('SystemTagObjectMapper'); | |
| 1352 | + } | |
| 1353 | + | |
| 1354 | + /** | |
| 1355 | + * Returns the avatar manager, used for avatar functionality | |
| 1356 | + * | |
| 1357 | + * @return \OCP\IAvatarManager | |
| 1358 | + */ | |
| 1359 | +    public function getAvatarManager() { | |
| 1360 | +        return $this->query('AvatarManager'); | |
| 1361 | + } | |
| 1362 | + | |
| 1363 | + /** | |
| 1364 | + * Returns the root folder of ownCloud's data directory | |
| 1365 | + * | |
| 1366 | + * @return \OCP\Files\IRootFolder | |
| 1367 | + */ | |
| 1368 | +    public function getRootFolder() { | |
| 1369 | +        return $this->query('LazyRootFolder'); | |
| 1370 | + } | |
| 1371 | + | |
| 1372 | + /** | |
| 1373 | + * Returns the root folder of ownCloud's data directory | |
| 1374 | + * This is the lazy variant so this gets only initialized once it | |
| 1375 | + * is actually used. | |
| 1376 | + * | |
| 1377 | + * @return \OCP\Files\IRootFolder | |
| 1378 | + */ | |
| 1379 | +    public function getLazyRootFolder() { | |
| 1380 | +        return $this->query('LazyRootFolder'); | |
| 1381 | + } | |
| 1382 | + | |
| 1383 | + /** | |
| 1384 | + * Returns a view to ownCloud's files folder | |
| 1385 | + * | |
| 1386 | + * @param string $userId user ID | |
| 1387 | + * @return \OCP\Files\Folder|null | |
| 1388 | + */ | |
| 1389 | +    public function getUserFolder($userId = null) { | |
| 1390 | +        if ($userId === null) { | |
| 1391 | + $user = $this->getUserSession()->getUser(); | |
| 1392 | +            if (!$user) { | |
| 1393 | + return null; | |
| 1394 | + } | |
| 1395 | + $userId = $user->getUID(); | |
| 1396 | + } | |
| 1397 | + $root = $this->getRootFolder(); | |
| 1398 | + return $root->getUserFolder($userId); | |
| 1399 | + } | |
| 1400 | + | |
| 1401 | + /** | |
| 1402 | + * Returns an app-specific view in ownClouds data directory | |
| 1403 | + * | |
| 1404 | + * @return \OCP\Files\Folder | |
| 1405 | + * @deprecated since 9.2.0 use IAppData | |
| 1406 | + */ | |
| 1407 | +    public function getAppFolder() { | |
| 1408 | + $dir = '/' . \OC_App::getCurrentApp(); | |
| 1409 | + $root = $this->getRootFolder(); | |
| 1410 | +        if (!$root->nodeExists($dir)) { | |
| 1411 | + $folder = $root->newFolder($dir); | |
| 1412 | +        } else { | |
| 1413 | + $folder = $root->get($dir); | |
| 1414 | + } | |
| 1415 | + return $folder; | |
| 1416 | + } | |
| 1417 | + | |
| 1418 | + /** | |
| 1419 | + * @return \OC\User\Manager | |
| 1420 | + */ | |
| 1421 | +    public function getUserManager() { | |
| 1422 | +        return $this->query('UserManager'); | |
| 1423 | + } | |
| 1424 | + | |
| 1425 | + /** | |
| 1426 | + * @return \OC\Group\Manager | |
| 1427 | + */ | |
| 1428 | +    public function getGroupManager() { | |
| 1429 | +        return $this->query('GroupManager'); | |
| 1430 | + } | |
| 1431 | + | |
| 1432 | + /** | |
| 1433 | + * @return \OC\User\Session | |
| 1434 | + */ | |
| 1435 | +    public function getUserSession() { | |
| 1436 | +        return $this->query('UserSession'); | |
| 1437 | + } | |
| 1438 | + | |
| 1439 | + /** | |
| 1440 | + * @return \OCP\ISession | |
| 1441 | + */ | |
| 1442 | +    public function getSession() { | |
| 1443 | +        return $this->query('UserSession')->getSession(); | |
| 1444 | + } | |
| 1445 | + | |
| 1446 | + /** | |
| 1447 | + * @param \OCP\ISession $session | |
| 1448 | + */ | |
| 1449 | +    public function setSession(\OCP\ISession $session) { | |
| 1450 | + $this->query(SessionStorage::class)->setSession($session); | |
| 1451 | +        $this->query('UserSession')->setSession($session); | |
| 1452 | + $this->query(Store::class)->setSession($session); | |
| 1453 | + } | |
| 1454 | + | |
| 1455 | + /** | |
| 1456 | + * @return \OC\Authentication\TwoFactorAuth\Manager | |
| 1457 | + */ | |
| 1458 | +    public function getTwoFactorAuthManager() { | |
| 1459 | +        return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); | |
| 1460 | + } | |
| 1461 | + | |
| 1462 | + /** | |
| 1463 | + * @return \OC\NavigationManager | |
| 1464 | + */ | |
| 1465 | +    public function getNavigationManager() { | |
| 1466 | +        return $this->query('NavigationManager'); | |
| 1467 | + } | |
| 1468 | + | |
| 1469 | + /** | |
| 1470 | + * @return \OCP\IConfig | |
| 1471 | + */ | |
| 1472 | +    public function getConfig() { | |
| 1473 | +        return $this->query('AllConfig'); | |
| 1474 | + } | |
| 1475 | + | |
| 1476 | + /** | |
| 1477 | + * @return \OC\SystemConfig | |
| 1478 | + */ | |
| 1479 | +    public function getSystemConfig() { | |
| 1480 | +        return $this->query('SystemConfig'); | |
| 1481 | + } | |
| 1482 | + | |
| 1483 | + /** | |
| 1484 | + * Returns the app config manager | |
| 1485 | + * | |
| 1486 | + * @return \OCP\IAppConfig | |
| 1487 | + */ | |
| 1488 | +    public function getAppConfig() { | |
| 1489 | +        return $this->query('AppConfig'); | |
| 1490 | + } | |
| 1491 | + | |
| 1492 | + /** | |
| 1493 | + * @return \OCP\L10N\IFactory | |
| 1494 | + */ | |
| 1495 | +    public function getL10NFactory() { | |
| 1496 | +        return $this->query('L10NFactory'); | |
| 1497 | + } | |
| 1498 | + | |
| 1499 | + /** | |
| 1500 | + * get an L10N instance | |
| 1501 | + * | |
| 1502 | + * @param string $app appid | |
| 1503 | + * @param string $lang | |
| 1504 | + * @return IL10N | |
| 1505 | + */ | |
| 1506 | +    public function getL10N($app, $lang = null) { | |
| 1507 | + return $this->getL10NFactory()->get($app, $lang); | |
| 1508 | + } | |
| 1509 | + | |
| 1510 | + /** | |
| 1511 | + * @return \OCP\IURLGenerator | |
| 1512 | + */ | |
| 1513 | +    public function getURLGenerator() { | |
| 1514 | +        return $this->query('URLGenerator'); | |
| 1515 | + } | |
| 1516 | + | |
| 1517 | + /** | |
| 1518 | + * @return AppFetcher | |
| 1519 | + */ | |
| 1520 | +    public function getAppFetcher() { | |
| 1521 | + return $this->query(AppFetcher::class); | |
| 1522 | + } | |
| 1523 | + | |
| 1524 | + /** | |
| 1525 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use | |
| 1526 | + * getMemCacheFactory() instead. | |
| 1527 | + * | |
| 1528 | + * @return \OCP\ICache | |
| 1529 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache | |
| 1530 | + */ | |
| 1531 | +    public function getCache() { | |
| 1532 | +        return $this->query('UserCache'); | |
| 1533 | + } | |
| 1534 | + | |
| 1535 | + /** | |
| 1536 | + * Returns an \OCP\CacheFactory instance | |
| 1537 | + * | |
| 1538 | + * @return \OCP\ICacheFactory | |
| 1539 | + */ | |
| 1540 | +    public function getMemCacheFactory() { | |
| 1541 | +        return $this->query('MemCacheFactory'); | |
| 1542 | + } | |
| 1543 | + | |
| 1544 | + /** | |
| 1545 | + * Returns an \OC\RedisFactory instance | |
| 1546 | + * | |
| 1547 | + * @return \OC\RedisFactory | |
| 1548 | + */ | |
| 1549 | +    public function getGetRedisFactory() { | |
| 1550 | +        return $this->query('RedisFactory'); | |
| 1551 | + } | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + /** | |
| 1555 | + * Returns the current session | |
| 1556 | + * | |
| 1557 | + * @return \OCP\IDBConnection | |
| 1558 | + */ | |
| 1559 | +    public function getDatabaseConnection() { | |
| 1560 | +        return $this->query('DatabaseConnection'); | |
| 1561 | + } | |
| 1562 | + | |
| 1563 | + /** | |
| 1564 | + * Returns the activity manager | |
| 1565 | + * | |
| 1566 | + * @return \OCP\Activity\IManager | |
| 1567 | + */ | |
| 1568 | +    public function getActivityManager() { | |
| 1569 | +        return $this->query('ActivityManager'); | |
| 1570 | + } | |
| 1571 | + | |
| 1572 | + /** | |
| 1573 | + * Returns an job list for controlling background jobs | |
| 1574 | + * | |
| 1575 | + * @return \OCP\BackgroundJob\IJobList | |
| 1576 | + */ | |
| 1577 | +    public function getJobList() { | |
| 1578 | +        return $this->query('JobList'); | |
| 1579 | + } | |
| 1580 | + | |
| 1581 | + /** | |
| 1582 | + * Returns a logger instance | |
| 1583 | + * | |
| 1584 | + * @return \OCP\ILogger | |
| 1585 | + */ | |
| 1586 | +    public function getLogger() { | |
| 1587 | +        return $this->query('Logger'); | |
| 1588 | + } | |
| 1589 | + | |
| 1590 | + /** | |
| 1591 | + * @return ILogFactory | |
| 1592 | + * @throws \OCP\AppFramework\QueryException | |
| 1593 | + */ | |
| 1594 | +    public function getLogFactory() { | |
| 1595 | + return $this->query(ILogFactory::class); | |
| 1596 | + } | |
| 1597 | + | |
| 1598 | + /** | |
| 1599 | + * Returns a router for generating and matching urls | |
| 1600 | + * | |
| 1601 | + * @return \OCP\Route\IRouter | |
| 1602 | + */ | |
| 1603 | +    public function getRouter() { | |
| 1604 | +        return $this->query('Router'); | |
| 1605 | + } | |
| 1606 | + | |
| 1607 | + /** | |
| 1608 | + * Returns a search instance | |
| 1609 | + * | |
| 1610 | + * @return \OCP\ISearch | |
| 1611 | + */ | |
| 1612 | +    public function getSearch() { | |
| 1613 | +        return $this->query('Search'); | |
| 1614 | + } | |
| 1615 | + | |
| 1616 | + /** | |
| 1617 | + * Returns a SecureRandom instance | |
| 1618 | + * | |
| 1619 | + * @return \OCP\Security\ISecureRandom | |
| 1620 | + */ | |
| 1621 | +    public function getSecureRandom() { | |
| 1622 | +        return $this->query('SecureRandom'); | |
| 1623 | + } | |
| 1624 | + | |
| 1625 | + /** | |
| 1626 | + * Returns a Crypto instance | |
| 1627 | + * | |
| 1628 | + * @return \OCP\Security\ICrypto | |
| 1629 | + */ | |
| 1630 | +    public function getCrypto() { | |
| 1631 | +        return $this->query('Crypto'); | |
| 1632 | + } | |
| 1633 | + | |
| 1634 | + /** | |
| 1635 | + * Returns a Hasher instance | |
| 1636 | + * | |
| 1637 | + * @return \OCP\Security\IHasher | |
| 1638 | + */ | |
| 1639 | +    public function getHasher() { | |
| 1640 | +        return $this->query('Hasher'); | |
| 1641 | + } | |
| 1642 | + | |
| 1643 | + /** | |
| 1644 | + * Returns a CredentialsManager instance | |
| 1645 | + * | |
| 1646 | + * @return \OCP\Security\ICredentialsManager | |
| 1647 | + */ | |
| 1648 | +    public function getCredentialsManager() { | |
| 1649 | +        return $this->query('CredentialsManager'); | |
| 1650 | + } | |
| 1651 | + | |
| 1652 | + /** | |
| 1653 | + * Get the certificate manager for the user | |
| 1654 | + * | |
| 1655 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager | |
| 1656 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in | |
| 1657 | + */ | |
| 1658 | +    public function getCertificateManager($userId = '') { | |
| 1659 | +        if ($userId === '') { | |
| 1660 | + $userSession = $this->getUserSession(); | |
| 1661 | + $user = $userSession->getUser(); | |
| 1662 | +            if (is_null($user)) { | |
| 1663 | + return null; | |
| 1664 | + } | |
| 1665 | + $userId = $user->getUID(); | |
| 1666 | + } | |
| 1667 | + return new CertificateManager( | |
| 1668 | + $userId, | |
| 1669 | + new View(), | |
| 1670 | + $this->getConfig(), | |
| 1671 | + $this->getLogger(), | |
| 1672 | + $this->getSecureRandom() | |
| 1673 | + ); | |
| 1674 | + } | |
| 1675 | + | |
| 1676 | + /** | |
| 1677 | + * Returns an instance of the HTTP client service | |
| 1678 | + * | |
| 1679 | + * @return \OCP\Http\Client\IClientService | |
| 1680 | + */ | |
| 1681 | +    public function getHTTPClientService() { | |
| 1682 | +        return $this->query('HttpClientService'); | |
| 1683 | + } | |
| 1684 | + | |
| 1685 | + /** | |
| 1686 | + * Create a new event source | |
| 1687 | + * | |
| 1688 | + * @return \OCP\IEventSource | |
| 1689 | + */ | |
| 1690 | +    public function createEventSource() { | |
| 1691 | + return new \OC_EventSource(); | |
| 1692 | + } | |
| 1693 | + | |
| 1694 | + /** | |
| 1695 | + * Get the active event logger | |
| 1696 | + * | |
| 1697 | + * The returned logger only logs data when debug mode is enabled | |
| 1698 | + * | |
| 1699 | + * @return \OCP\Diagnostics\IEventLogger | |
| 1700 | + */ | |
| 1701 | +    public function getEventLogger() { | |
| 1702 | +        return $this->query('EventLogger'); | |
| 1703 | + } | |
| 1704 | + | |
| 1705 | + /** | |
| 1706 | + * Get the active query logger | |
| 1707 | + * | |
| 1708 | + * The returned logger only logs data when debug mode is enabled | |
| 1709 | + * | |
| 1710 | + * @return \OCP\Diagnostics\IQueryLogger | |
| 1711 | + */ | |
| 1712 | +    public function getQueryLogger() { | |
| 1713 | +        return $this->query('QueryLogger'); | |
| 1714 | + } | |
| 1715 | + | |
| 1716 | + /** | |
| 1717 | + * Get the manager for temporary files and folders | |
| 1718 | + * | |
| 1719 | + * @return \OCP\ITempManager | |
| 1720 | + */ | |
| 1721 | +    public function getTempManager() { | |
| 1722 | +        return $this->query('TempManager'); | |
| 1723 | + } | |
| 1724 | + | |
| 1725 | + /** | |
| 1726 | + * Get the app manager | |
| 1727 | + * | |
| 1728 | + * @return \OCP\App\IAppManager | |
| 1729 | + */ | |
| 1730 | +    public function getAppManager() { | |
| 1731 | +        return $this->query('AppManager'); | |
| 1732 | + } | |
| 1733 | + | |
| 1734 | + /** | |
| 1735 | + * Creates a new mailer | |
| 1736 | + * | |
| 1737 | + * @return \OCP\Mail\IMailer | |
| 1738 | + */ | |
| 1739 | +    public function getMailer() { | |
| 1740 | +        return $this->query('Mailer'); | |
| 1741 | + } | |
| 1742 | + | |
| 1743 | + /** | |
| 1744 | + * Get the webroot | |
| 1745 | + * | |
| 1746 | + * @return string | |
| 1747 | + */ | |
| 1748 | +    public function getWebRoot() { | |
| 1749 | + return $this->webRoot; | |
| 1750 | + } | |
| 1751 | + | |
| 1752 | + /** | |
| 1753 | + * @return \OC\OCSClient | |
| 1754 | + */ | |
| 1755 | +    public function getOcsClient() { | |
| 1756 | +        return $this->query('OcsClient'); | |
| 1757 | + } | |
| 1758 | + | |
| 1759 | + /** | |
| 1760 | + * @return \OCP\IDateTimeZone | |
| 1761 | + */ | |
| 1762 | +    public function getDateTimeZone() { | |
| 1763 | +        return $this->query('DateTimeZone'); | |
| 1764 | + } | |
| 1765 | + | |
| 1766 | + /** | |
| 1767 | + * @return \OCP\IDateTimeFormatter | |
| 1768 | + */ | |
| 1769 | +    public function getDateTimeFormatter() { | |
| 1770 | +        return $this->query('DateTimeFormatter'); | |
| 1771 | + } | |
| 1772 | + | |
| 1773 | + /** | |
| 1774 | + * @return \OCP\Files\Config\IMountProviderCollection | |
| 1775 | + */ | |
| 1776 | +    public function getMountProviderCollection() { | |
| 1777 | +        return $this->query('MountConfigManager'); | |
| 1778 | + } | |
| 1779 | + | |
| 1780 | + /** | |
| 1781 | + * Get the IniWrapper | |
| 1782 | + * | |
| 1783 | + * @return IniGetWrapper | |
| 1784 | + */ | |
| 1785 | +    public function getIniWrapper() { | |
| 1786 | +        return $this->query('IniWrapper'); | |
| 1787 | + } | |
| 1788 | + | |
| 1789 | + /** | |
| 1790 | + * @return \OCP\Command\IBus | |
| 1791 | + */ | |
| 1792 | +    public function getCommandBus() { | |
| 1793 | +        return $this->query('AsyncCommandBus'); | |
| 1794 | + } | |
| 1795 | + | |
| 1796 | + /** | |
| 1797 | + * Get the trusted domain helper | |
| 1798 | + * | |
| 1799 | + * @return TrustedDomainHelper | |
| 1800 | + */ | |
| 1801 | +    public function getTrustedDomainHelper() { | |
| 1802 | +        return $this->query('TrustedDomainHelper'); | |
| 1803 | + } | |
| 1804 | + | |
| 1805 | + /** | |
| 1806 | + * Get the locking provider | |
| 1807 | + * | |
| 1808 | + * @return \OCP\Lock\ILockingProvider | |
| 1809 | + * @since 8.1.0 | |
| 1810 | + */ | |
| 1811 | +    public function getLockingProvider() { | |
| 1812 | +        return $this->query('LockingProvider'); | |
| 1813 | + } | |
| 1814 | + | |
| 1815 | + /** | |
| 1816 | + * @return \OCP\Files\Mount\IMountManager | |
| 1817 | + **/ | |
| 1818 | +    function getMountManager() { | |
| 1819 | +        return $this->query('MountManager'); | |
| 1820 | + } | |
| 1821 | + | |
| 1822 | + /** @return \OCP\Files\Config\IUserMountCache */ | |
| 1823 | +    function getUserMountCache() { | |
| 1824 | +        return $this->query('UserMountCache'); | |
| 1825 | + } | |
| 1826 | + | |
| 1827 | + /** | |
| 1828 | + * Get the MimeTypeDetector | |
| 1829 | + * | |
| 1830 | + * @return \OCP\Files\IMimeTypeDetector | |
| 1831 | + */ | |
| 1832 | +    public function getMimeTypeDetector() { | |
| 1833 | +        return $this->query('MimeTypeDetector'); | |
| 1834 | + } | |
| 1835 | + | |
| 1836 | + /** | |
| 1837 | + * Get the MimeTypeLoader | |
| 1838 | + * | |
| 1839 | + * @return \OCP\Files\IMimeTypeLoader | |
| 1840 | + */ | |
| 1841 | +    public function getMimeTypeLoader() { | |
| 1842 | +        return $this->query('MimeTypeLoader'); | |
| 1843 | + } | |
| 1844 | + | |
| 1845 | + /** | |
| 1846 | + * Get the manager of all the capabilities | |
| 1847 | + * | |
| 1848 | + * @return \OC\CapabilitiesManager | |
| 1849 | + */ | |
| 1850 | +    public function getCapabilitiesManager() { | |
| 1851 | +        return $this->query('CapabilitiesManager'); | |
| 1852 | + } | |
| 1853 | + | |
| 1854 | + /** | |
| 1855 | + * Get the EventDispatcher | |
| 1856 | + * | |
| 1857 | + * @return EventDispatcherInterface | |
| 1858 | + * @since 8.2.0 | |
| 1859 | + */ | |
| 1860 | +    public function getEventDispatcher() { | |
| 1861 | +        return $this->query('EventDispatcher'); | |
| 1862 | + } | |
| 1863 | + | |
| 1864 | + /** | |
| 1865 | + * Get the Notification Manager | |
| 1866 | + * | |
| 1867 | + * @return \OCP\Notification\IManager | |
| 1868 | + * @since 8.2.0 | |
| 1869 | + */ | |
| 1870 | +    public function getNotificationManager() { | |
| 1871 | +        return $this->query('NotificationManager'); | |
| 1872 | + } | |
| 1873 | + | |
| 1874 | + /** | |
| 1875 | + * @return \OCP\Comments\ICommentsManager | |
| 1876 | + */ | |
| 1877 | +    public function getCommentsManager() { | |
| 1878 | +        return $this->query('CommentsManager'); | |
| 1879 | + } | |
| 1880 | + | |
| 1881 | + /** | |
| 1882 | + * @return \OCA\Theming\ThemingDefaults | |
| 1883 | + */ | |
| 1884 | +    public function getThemingDefaults() { | |
| 1885 | +        return $this->query('ThemingDefaults'); | |
| 1886 | + } | |
| 1887 | + | |
| 1888 | + /** | |
| 1889 | + * @return \OC\IntegrityCheck\Checker | |
| 1890 | + */ | |
| 1891 | +    public function getIntegrityCodeChecker() { | |
| 1892 | +        return $this->query('IntegrityCodeChecker'); | |
| 1893 | + } | |
| 1894 | + | |
| 1895 | + /** | |
| 1896 | + * @return \OC\Session\CryptoWrapper | |
| 1897 | + */ | |
| 1898 | +    public function getSessionCryptoWrapper() { | |
| 1899 | +        return $this->query('CryptoWrapper'); | |
| 1900 | + } | |
| 1901 | + | |
| 1902 | + /** | |
| 1903 | + * @return CsrfTokenManager | |
| 1904 | + */ | |
| 1905 | +    public function getCsrfTokenManager() { | |
| 1906 | +        return $this->query('CsrfTokenManager'); | |
| 1907 | + } | |
| 1908 | + | |
| 1909 | + /** | |
| 1910 | + * @return Throttler | |
| 1911 | + */ | |
| 1912 | +    public function getBruteForceThrottler() { | |
| 1913 | +        return $this->query('Throttler'); | |
| 1914 | + } | |
| 1915 | + | |
| 1916 | + /** | |
| 1917 | + * @return IContentSecurityPolicyManager | |
| 1918 | + */ | |
| 1919 | +    public function getContentSecurityPolicyManager() { | |
| 1920 | +        return $this->query('ContentSecurityPolicyManager'); | |
| 1921 | + } | |
| 1922 | + | |
| 1923 | + /** | |
| 1924 | + * @return ContentSecurityPolicyNonceManager | |
| 1925 | + */ | |
| 1926 | +    public function getContentSecurityPolicyNonceManager() { | |
| 1927 | +        return $this->query('ContentSecurityPolicyNonceManager'); | |
| 1928 | + } | |
| 1929 | + | |
| 1930 | + /** | |
| 1931 | + * Not a public API as of 8.2, wait for 9.0 | |
| 1932 | + * | |
| 1933 | + * @return \OCA\Files_External\Service\BackendService | |
| 1934 | + */ | |
| 1935 | +    public function getStoragesBackendService() { | |
| 1936 | +        return $this->query('OCA\\Files_External\\Service\\BackendService'); | |
| 1937 | + } | |
| 1938 | + | |
| 1939 | + /** | |
| 1940 | + * Not a public API as of 8.2, wait for 9.0 | |
| 1941 | + * | |
| 1942 | + * @return \OCA\Files_External\Service\GlobalStoragesService | |
| 1943 | + */ | |
| 1944 | +    public function getGlobalStoragesService() { | |
| 1945 | +        return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); | |
| 1946 | + } | |
| 1947 | + | |
| 1948 | + /** | |
| 1949 | + * Not a public API as of 8.2, wait for 9.0 | |
| 1950 | + * | |
| 1951 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService | |
| 1952 | + */ | |
| 1953 | +    public function getUserGlobalStoragesService() { | |
| 1954 | +        return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); | |
| 1955 | + } | |
| 1956 | + | |
| 1957 | + /** | |
| 1958 | + * Not a public API as of 8.2, wait for 9.0 | |
| 1959 | + * | |
| 1960 | + * @return \OCA\Files_External\Service\UserStoragesService | |
| 1961 | + */ | |
| 1962 | +    public function getUserStoragesService() { | |
| 1963 | +        return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); | |
| 1964 | + } | |
| 1965 | + | |
| 1966 | + /** | |
| 1967 | + * @return \OCP\Share\IManager | |
| 1968 | + */ | |
| 1969 | +    public function getShareManager() { | |
| 1970 | +        return $this->query('ShareManager'); | |
| 1971 | + } | |
| 1972 | + | |
| 1973 | + /** | |
| 1974 | + * @return \OCP\Collaboration\Collaborators\ISearch | |
| 1975 | + */ | |
| 1976 | +    public function getCollaboratorSearch() { | |
| 1977 | +        return $this->query('CollaboratorSearch'); | |
| 1978 | + } | |
| 1979 | + | |
| 1980 | + /** | |
| 1981 | + * @return \OCP\Collaboration\AutoComplete\IManager | |
| 1982 | + */ | |
| 1983 | +    public function getAutoCompleteManager(){ | |
| 1984 | + return $this->query(IManager::class); | |
| 1985 | + } | |
| 1986 | + | |
| 1987 | + /** | |
| 1988 | + * Returns the LDAP Provider | |
| 1989 | + * | |
| 1990 | + * @return \OCP\LDAP\ILDAPProvider | |
| 1991 | + */ | |
| 1992 | +    public function getLDAPProvider() { | |
| 1993 | +        return $this->query('LDAPProvider'); | |
| 1994 | + } | |
| 1995 | + | |
| 1996 | + /** | |
| 1997 | + * @return \OCP\Settings\IManager | |
| 1998 | + */ | |
| 1999 | +    public function getSettingsManager() { | |
| 2000 | +        return $this->query('SettingsManager'); | |
| 2001 | + } | |
| 2002 | + | |
| 2003 | + /** | |
| 2004 | + * @return \OCP\Files\IAppData | |
| 2005 | + */ | |
| 2006 | +    public function getAppDataDir($app) { | |
| 2007 | + /** @var \OC\Files\AppData\Factory $factory */ | |
| 2008 | + $factory = $this->query(\OC\Files\AppData\Factory::class); | |
| 2009 | + return $factory->get($app); | |
| 2010 | + } | |
| 2011 | + | |
| 2012 | + /** | |
| 2013 | + * @return \OCP\Lockdown\ILockdownManager | |
| 2014 | + */ | |
| 2015 | +    public function getLockdownManager() { | |
| 2016 | +        return $this->query('LockdownManager'); | |
| 2017 | + } | |
| 2018 | + | |
| 2019 | + /** | |
| 2020 | + * @return \OCP\Federation\ICloudIdManager | |
| 2021 | + */ | |
| 2022 | +    public function getCloudIdManager() { | |
| 2023 | + return $this->query(ICloudIdManager::class); | |
| 2024 | + } | |
| 2025 | + | |
| 2026 | + /** | |
| 2027 | + * @return \OCP\GlobalScale\IConfig | |
| 2028 | + */ | |
| 2029 | +    public function getGlobalScaleConfig() { | |
| 2030 | + return $this->query(IConfig::class); | |
| 2031 | + } | |
| 2032 | + | |
| 2033 | + /** | |
| 2034 | + * @return \OCP\Federation\ICloudFederationProviderManager | |
| 2035 | + */ | |
| 2036 | +    public function getCloudFederationProviderManager() { | |
| 2037 | + return $this->query(ICloudFederationProviderManager::class); | |
| 2038 | + } | |
| 2039 | + | |
| 2040 | + /** | |
| 2041 | + * @return \OCP\Remote\Api\IApiFactory | |
| 2042 | + */ | |
| 2043 | +    public function getRemoteApiFactory() { | |
| 2044 | + return $this->query(IApiFactory::class); | |
| 2045 | + } | |
| 2046 | + | |
| 2047 | + /** | |
| 2048 | + * @return \OCP\Federation\ICloudFederationFactory | |
| 2049 | + */ | |
| 2050 | +    public function getCloudFederationFactory() { | |
| 2051 | + return $this->query(ICloudFederationFactory::class); | |
| 2052 | + } | |
| 2053 | + | |
| 2054 | + /** | |
| 2055 | + * @return \OCP\Remote\IInstanceFactory | |
| 2056 | + */ | |
| 2057 | +    public function getRemoteInstanceFactory() { | |
| 2058 | + return $this->query(IInstanceFactory::class); | |
| 2059 | + } | |
| 2060 | + | |
| 2061 | + /** | |
| 2062 | + * @return IStorageFactory | |
| 2063 | + */ | |
| 2064 | +    public function getStorageFactory() { | |
| 2065 | + return $this->query(IStorageFactory::class); | |
| 2066 | + } | |
| 2067 | 2067 | } | 
| @@ -40,49 +40,49 @@ | ||
| 40 | 40 | */ | 
| 41 | 41 |  interface INavigationManager { | 
| 42 | 42 | |
| 43 | - /** | |
| 44 | - * Navigation entries of the app navigation | |
| 45 | - * @since 16.0.0 | |
| 46 | - */ | |
| 47 | - const TYPE_APPS = 'link'; | |
| 43 | + /** | |
| 44 | + * Navigation entries of the app navigation | |
| 45 | + * @since 16.0.0 | |
| 46 | + */ | |
| 47 | + const TYPE_APPS = 'link'; | |
| 48 | 48 | |
| 49 | - /** | |
| 50 | - * Navigation entries of the settings navigation | |
| 51 | - * @since 16.0.0 | |
| 52 | - */ | |
| 53 | - const TYPE_SETTINGS = 'settings'; | |
| 49 | + /** | |
| 50 | + * Navigation entries of the settings navigation | |
| 51 | + * @since 16.0.0 | |
| 52 | + */ | |
| 53 | + const TYPE_SETTINGS = 'settings'; | |
| 54 | 54 | |
| 55 | - /** | |
| 56 | - * Navigation entries for public page footer navigation | |
| 57 | - * @since 16.0.0 | |
| 58 | - */ | |
| 59 | - const TYPE_GUEST = 'guest'; | |
| 55 | + /** | |
| 56 | + * Navigation entries for public page footer navigation | |
| 57 | + * @since 16.0.0 | |
| 58 | + */ | |
| 59 | + const TYPE_GUEST = 'guest'; | |
| 60 | 60 | |
| 61 | - /** | |
| 62 | - * Creates a new navigation entry | |
| 63 | - * | |
| 64 | - * @param array|\Closure $entry Array containing: id, name, order, icon and href key | |
| 65 | - * The use of a closure is preferred, because it will avoid | |
| 66 | - * loading the routing of your app, unless required. | |
| 67 | - * @return void | |
| 68 | - * @since 6.0.0 | |
| 69 | - */ | |
| 70 | - public function add($entry); | |
| 61 | + /** | |
| 62 | + * Creates a new navigation entry | |
| 63 | + * | |
| 64 | + * @param array|\Closure $entry Array containing: id, name, order, icon and href key | |
| 65 | + * The use of a closure is preferred, because it will avoid | |
| 66 | + * loading the routing of your app, unless required. | |
| 67 | + * @return void | |
| 68 | + * @since 6.0.0 | |
| 69 | + */ | |
| 70 | + public function add($entry); | |
| 71 | 71 | |
| 72 | - /** | |
| 73 | - * Sets the current navigation entry of the currently running app | |
| 74 | - * @param string $appId id of the app entry to activate (from added $entry) | |
| 75 | - * @return void | |
| 76 | - * @since 6.0.0 | |
| 77 | - */ | |
| 78 | - public function setActiveEntry($appId); | |
| 72 | + /** | |
| 73 | + * Sets the current navigation entry of the currently running app | |
| 74 | + * @param string $appId id of the app entry to activate (from added $entry) | |
| 75 | + * @return void | |
| 76 | + * @since 6.0.0 | |
| 77 | + */ | |
| 78 | + public function setActiveEntry($appId); | |
| 79 | 79 | |
| 80 | - /** | |
| 81 | - * Get a list of navigation entries | |
| 82 | - * | |
| 83 | - * @param string $type type of the navigation entries | |
| 84 | - * @return array | |
| 85 | - * @since 14.0.0 | |
| 86 | - */ | |
| 87 | - public function getAll(string $type = self::TYPE_APPS): array; | |
| 80 | + /** | |
| 81 | + * Get a list of navigation entries | |
| 82 | + * | |
| 83 | + * @param string $type type of the navigation entries | |
| 84 | + * @return array | |
| 85 | + * @since 14.0.0 | |
| 86 | + */ | |
| 87 | + public function getAll(string $type = self::TYPE_APPS): array; | |
| 88 | 88 | } |