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