@@ -32,58 +32,58 @@ |
||
32 | 32 | |
33 | 33 | class Admin implements ISettings { |
34 | 34 | |
35 | - /** @var FederatedShareProvider */ |
|
36 | - private $fedShareProvider; |
|
35 | + /** @var FederatedShareProvider */ |
|
36 | + private $fedShareProvider; |
|
37 | 37 | |
38 | - /** @var IConfig */ |
|
39 | - private $gsConfig; |
|
38 | + /** @var IConfig */ |
|
39 | + private $gsConfig; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Admin constructor. |
|
43 | - * |
|
44 | - * @param FederatedShareProvider $fedShareProvider |
|
45 | - * @param IConfig $globalScaleConfig |
|
46 | - */ |
|
47 | - public function __construct(FederatedShareProvider $fedShareProvider, IConfig $globalScaleConfig) { |
|
48 | - $this->fedShareProvider = $fedShareProvider; |
|
49 | - $this->gsConfig = $globalScaleConfig; |
|
50 | - } |
|
41 | + /** |
|
42 | + * Admin constructor. |
|
43 | + * |
|
44 | + * @param FederatedShareProvider $fedShareProvider |
|
45 | + * @param IConfig $globalScaleConfig |
|
46 | + */ |
|
47 | + public function __construct(FederatedShareProvider $fedShareProvider, IConfig $globalScaleConfig) { |
|
48 | + $this->fedShareProvider = $fedShareProvider; |
|
49 | + $this->gsConfig = $globalScaleConfig; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return TemplateResponse |
|
54 | - */ |
|
55 | - public function getForm() { |
|
52 | + /** |
|
53 | + * @return TemplateResponse |
|
54 | + */ |
|
55 | + public function getForm() { |
|
56 | 56 | |
57 | - $parameters = [ |
|
58 | - 'internalOnly' => $this->gsConfig->onlyInternalFederation(), |
|
59 | - 'outgoingServer2serverShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverShareEnabled(), |
|
60 | - 'incomingServer2serverShareEnabled' => $this->fedShareProvider->isIncomingServer2serverShareEnabled(), |
|
61 | - 'federatedGroupSharingSupported' => $this->fedShareProvider->isFederatedGroupSharingSupported(), |
|
62 | - 'outgoingServer2serverGroupShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverGroupShareEnabled(), |
|
63 | - 'incomingServer2serverGroupShareEnabled' => $this->fedShareProvider->isIncomingServer2serverGroupShareEnabled(), |
|
64 | - 'lookupServerEnabled' => $this->fedShareProvider->isLookupServerQueriesEnabled(), |
|
65 | - 'lookupServerUploadEnabled' => $this->fedShareProvider->isLookupServerUploadEnabled(), |
|
66 | - ]; |
|
57 | + $parameters = [ |
|
58 | + 'internalOnly' => $this->gsConfig->onlyInternalFederation(), |
|
59 | + 'outgoingServer2serverShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverShareEnabled(), |
|
60 | + 'incomingServer2serverShareEnabled' => $this->fedShareProvider->isIncomingServer2serverShareEnabled(), |
|
61 | + 'federatedGroupSharingSupported' => $this->fedShareProvider->isFederatedGroupSharingSupported(), |
|
62 | + 'outgoingServer2serverGroupShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverGroupShareEnabled(), |
|
63 | + 'incomingServer2serverGroupShareEnabled' => $this->fedShareProvider->isIncomingServer2serverGroupShareEnabled(), |
|
64 | + 'lookupServerEnabled' => $this->fedShareProvider->isLookupServerQueriesEnabled(), |
|
65 | + 'lookupServerUploadEnabled' => $this->fedShareProvider->isLookupServerUploadEnabled(), |
|
66 | + ]; |
|
67 | 67 | |
68 | - return new TemplateResponse('federatedfilesharing', 'settings-admin', $parameters, ''); |
|
69 | - } |
|
68 | + return new TemplateResponse('federatedfilesharing', 'settings-admin', $parameters, ''); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return string the section ID, e.g. 'sharing' |
|
73 | - */ |
|
74 | - public function getSection() { |
|
75 | - return 'sharing'; |
|
76 | - } |
|
71 | + /** |
|
72 | + * @return string the section ID, e.g. 'sharing' |
|
73 | + */ |
|
74 | + public function getSection() { |
|
75 | + return 'sharing'; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @return int whether the form should be rather on the top or bottom of |
|
80 | - * the admin section. The forms are arranged in ascending order of the |
|
81 | - * priority values. It is required to return a value between 0 and 100. |
|
82 | - * |
|
83 | - * E.g.: 70 |
|
84 | - */ |
|
85 | - public function getPriority() { |
|
86 | - return 20; |
|
87 | - } |
|
78 | + /** |
|
79 | + * @return int whether the form should be rather on the top or bottom of |
|
80 | + * the admin section. The forms are arranged in ascending order of the |
|
81 | + * priority values. It is required to return a value between 0 and 100. |
|
82 | + * |
|
83 | + * E.g.: 70 |
|
84 | + */ |
|
85 | + public function getPriority() { |
|
86 | + return 20; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | } |
@@ -39,51 +39,51 @@ |
||
39 | 39 | |
40 | 40 | interface ICloudFederationProvider { |
41 | 41 | |
42 | - /** |
|
43 | - * get the name of the share type, handled by this provider |
|
44 | - * |
|
45 | - * @return string |
|
46 | - * |
|
47 | - * @since 14.0.0 |
|
48 | - */ |
|
49 | - public function getShareType(); |
|
42 | + /** |
|
43 | + * get the name of the share type, handled by this provider |
|
44 | + * |
|
45 | + * @return string |
|
46 | + * |
|
47 | + * @since 14.0.0 |
|
48 | + */ |
|
49 | + public function getShareType(); |
|
50 | 50 | |
51 | - /** |
|
52 | - * share received from another server |
|
53 | - * |
|
54 | - * @param ICloudFederationShare $share |
|
55 | - * @return string provider specific unique ID of the share |
|
56 | - * |
|
57 | - * @throws ProviderCouldNotAddShareException |
|
58 | - * |
|
59 | - * @since 14.0.0 |
|
60 | - */ |
|
61 | - public function shareReceived(ICloudFederationShare $share); |
|
51 | + /** |
|
52 | + * share received from another server |
|
53 | + * |
|
54 | + * @param ICloudFederationShare $share |
|
55 | + * @return string provider specific unique ID of the share |
|
56 | + * |
|
57 | + * @throws ProviderCouldNotAddShareException |
|
58 | + * |
|
59 | + * @since 14.0.0 |
|
60 | + */ |
|
61 | + public function shareReceived(ICloudFederationShare $share); |
|
62 | 62 | |
63 | - /** |
|
64 | - * notification received from another server |
|
65 | - * |
|
66 | - * @param string $notificationType (e.g SHARE_ACCEPTED) |
|
67 | - * @param string $providerId share ID |
|
68 | - * @param array $notification provider specific notification |
|
69 | - * @return array $data send back to sender |
|
70 | - * |
|
71 | - * @throws ShareNotFound |
|
72 | - * @throws ActionNotSupportedException |
|
73 | - * @throws BadRequestException |
|
74 | - * @throws AuthenticationFailedException |
|
75 | - * |
|
76 | - * @since 14.0.0 |
|
77 | - */ |
|
78 | - public function notificationReceived($notificationType, $providerId, array $notification); |
|
63 | + /** |
|
64 | + * notification received from another server |
|
65 | + * |
|
66 | + * @param string $notificationType (e.g SHARE_ACCEPTED) |
|
67 | + * @param string $providerId share ID |
|
68 | + * @param array $notification provider specific notification |
|
69 | + * @return array $data send back to sender |
|
70 | + * |
|
71 | + * @throws ShareNotFound |
|
72 | + * @throws ActionNotSupportedException |
|
73 | + * @throws BadRequestException |
|
74 | + * @throws AuthenticationFailedException |
|
75 | + * |
|
76 | + * @since 14.0.0 |
|
77 | + */ |
|
78 | + public function notificationReceived($notificationType, $providerId, array $notification); |
|
79 | 79 | |
80 | - /** |
|
81 | - * get the supported share types, e.g. "user", "group", etc. |
|
82 | - * |
|
83 | - * @return array |
|
84 | - * |
|
85 | - * @since 14.0.0 |
|
86 | - */ |
|
87 | - public function getSupportedShareTypes(); |
|
80 | + /** |
|
81 | + * get the supported share types, e.g. "user", "group", etc. |
|
82 | + * |
|
83 | + * @return array |
|
84 | + * |
|
85 | + * @since 14.0.0 |
|
86 | + */ |
|
87 | + public function getSupportedShareTypes(); |
|
88 | 88 | |
89 | 89 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | // To find out if we are running from CLI or not |
173 | 173 | $this->registerParameter('isCLI', \OC::$CLI); |
174 | 174 | |
175 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
175 | + $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
176 | 176 | return $c; |
177 | 177 | }); |
178 | 178 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $this->registerAlias(IActionFactory::class, ActionFactory::class); |
186 | 186 | |
187 | 187 | |
188 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
188 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
189 | 189 | return new PreviewManager( |
190 | 190 | $c->getConfig(), |
191 | 191 | $c->getRootFolder(), |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | }); |
197 | 197 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
198 | 198 | |
199 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
199 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
200 | 200 | return new \OC\Preview\Watcher( |
201 | 201 | $c->getAppDataDir('preview') |
202 | 202 | ); |
203 | 203 | }); |
204 | 204 | |
205 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
205 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
206 | 206 | $view = new View(); |
207 | 207 | $util = new Encryption\Util( |
208 | 208 | $view, |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | ); |
221 | 221 | }); |
222 | 222 | |
223 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
223 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
224 | 224 | $util = new Encryption\Util( |
225 | 225 | new View(), |
226 | 226 | $c->getUserManager(), |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | ); |
235 | 235 | }); |
236 | 236 | |
237 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
237 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
238 | 238 | $view = new View(); |
239 | 239 | $util = new Encryption\Util( |
240 | 240 | $view, |
@@ -245,30 +245,30 @@ discard block |
||
245 | 245 | |
246 | 246 | return new Encryption\Keys\Storage($view, $util); |
247 | 247 | }); |
248 | - $this->registerService('TagMapper', function (Server $c) { |
|
248 | + $this->registerService('TagMapper', function(Server $c) { |
|
249 | 249 | return new TagMapper($c->getDatabaseConnection()); |
250 | 250 | }); |
251 | 251 | |
252 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
252 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
253 | 253 | $tagMapper = $c->query('TagMapper'); |
254 | 254 | return new TagManager($tagMapper, $c->getUserSession()); |
255 | 255 | }); |
256 | 256 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
257 | 257 | |
258 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
258 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
259 | 259 | $config = $c->getConfig(); |
260 | 260 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
261 | 261 | return new $factoryClass($this); |
262 | 262 | }); |
263 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
263 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
264 | 264 | return $c->query('SystemTagManagerFactory')->getManager(); |
265 | 265 | }); |
266 | 266 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
267 | 267 | |
268 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
268 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
269 | 269 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
270 | 270 | }); |
271 | - $this->registerService('RootFolder', function (Server $c) { |
|
271 | + $this->registerService('RootFolder', function(Server $c) { |
|
272 | 272 | $manager = \OC\Files\Filesystem::getMountManager(null); |
273 | 273 | $view = new View(); |
274 | 274 | $root = new Root( |
@@ -289,38 +289,38 @@ discard block |
||
289 | 289 | }); |
290 | 290 | $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
291 | 291 | |
292 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
293 | - return new LazyRoot(function () use ($c) { |
|
292 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
293 | + return new LazyRoot(function() use ($c) { |
|
294 | 294 | return $c->query('RootFolder'); |
295 | 295 | }); |
296 | 296 | }); |
297 | 297 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
298 | 298 | |
299 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
299 | + $this->registerService(\OC\User\Manager::class, function(Server $c) { |
|
300 | 300 | $config = $c->getConfig(); |
301 | 301 | return new \OC\User\Manager($config); |
302 | 302 | }); |
303 | 303 | $this->registerAlias('UserManager', \OC\User\Manager::class); |
304 | 304 | $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
305 | 305 | |
306 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
306 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
307 | 307 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
308 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
308 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
309 | 309 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
310 | 310 | }); |
311 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
311 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
312 | 312 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
313 | 313 | }); |
314 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
314 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
315 | 315 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
316 | 316 | }); |
317 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
317 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
318 | 318 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
319 | 319 | }); |
320 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
320 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
321 | 321 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
322 | 322 | }); |
323 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
323 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
324 | 324 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
325 | 325 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
326 | 326 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | }); |
330 | 330 | $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
331 | 331 | |
332 | - $this->registerService(Store::class, function (Server $c) { |
|
332 | + $this->registerService(Store::class, function(Server $c) { |
|
333 | 333 | $session = $c->getSession(); |
334 | 334 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
335 | 335 | $tokenProvider = $c->query(IProvider::class); |
@@ -340,13 +340,13 @@ discard block |
||
340 | 340 | return new Store($session, $logger, $tokenProvider); |
341 | 341 | }); |
342 | 342 | $this->registerAlias(IStore::class, Store::class); |
343 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
343 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function(Server $c) { |
|
344 | 344 | $dbConnection = $c->getDatabaseConnection(); |
345 | 345 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
346 | 346 | }); |
347 | 347 | $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
348 | 348 | |
349 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
349 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
350 | 350 | $manager = $c->getUserManager(); |
351 | 351 | $session = new \OC\Session\Memory(''); |
352 | 352 | $timeFactory = new TimeFactory(); |
@@ -370,45 +370,45 @@ discard block |
||
370 | 370 | $c->getLockdownManager(), |
371 | 371 | $c->getLogger() |
372 | 372 | ); |
373 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
373 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
374 | 374 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
375 | 375 | }); |
376 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
376 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
377 | 377 | /** @var $user \OC\User\User */ |
378 | 378 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
379 | 379 | }); |
380 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
380 | + $userSession->listen('\OC\User', 'preDelete', function($user) use ($dispatcher) { |
|
381 | 381 | /** @var $user \OC\User\User */ |
382 | 382 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
383 | 383 | $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
384 | 384 | }); |
385 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
385 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
386 | 386 | /** @var $user \OC\User\User */ |
387 | 387 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
388 | 388 | }); |
389 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
389 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
390 | 390 | /** @var $user \OC\User\User */ |
391 | 391 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
392 | 392 | }); |
393 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
393 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
394 | 394 | /** @var $user \OC\User\User */ |
395 | 395 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
396 | 396 | }); |
397 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
397 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
398 | 398 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
399 | 399 | }); |
400 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
400 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
401 | 401 | /** @var $user \OC\User\User */ |
402 | 402 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
403 | 403 | }); |
404 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
404 | + $userSession->listen('\OC\User', 'postRememberedLogin', function($user, $password) { |
|
405 | 405 | /** @var $user \OC\User\User */ |
406 | 406 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
407 | 407 | }); |
408 | - $userSession->listen('\OC\User', 'logout', function () { |
|
408 | + $userSession->listen('\OC\User', 'logout', function() { |
|
409 | 409 | \OC_Hook::emit('OC_User', 'logout', array()); |
410 | 410 | }); |
411 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
411 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
412 | 412 | /** @var $user \OC\User\User */ |
413 | 413 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
414 | 414 | $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
423 | 423 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
424 | 424 | |
425 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
425 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
426 | 426 | return new \OC\AllConfig( |
427 | 427 | $c->getSystemConfig() |
428 | 428 | ); |
@@ -430,17 +430,17 @@ discard block |
||
430 | 430 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
431 | 431 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
432 | 432 | |
433 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
433 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
434 | 434 | return new \OC\SystemConfig($config); |
435 | 435 | }); |
436 | 436 | |
437 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
437 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
438 | 438 | return new \OC\AppConfig($c->getDatabaseConnection()); |
439 | 439 | }); |
440 | 440 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
441 | 441 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
442 | 442 | |
443 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
443 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
444 | 444 | return new \OC\L10N\Factory( |
445 | 445 | $c->getConfig(), |
446 | 446 | $c->getRequest(), |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | }); |
451 | 451 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
452 | 452 | |
453 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
453 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
454 | 454 | $config = $c->getConfig(); |
455 | 455 | $cacheFactory = $c->getMemCacheFactory(); |
456 | 456 | $request = $c->getRequest(); |
@@ -465,12 +465,12 @@ discard block |
||
465 | 465 | $this->registerAlias('AppFetcher', AppFetcher::class); |
466 | 466 | $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
467 | 467 | |
468 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
468 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
469 | 469 | return new Cache\File(); |
470 | 470 | }); |
471 | 471 | $this->registerAlias('UserCache', \OCP\ICache::class); |
472 | 472 | |
473 | - $this->registerService(Factory::class, function (Server $c) { |
|
473 | + $this->registerService(Factory::class, function(Server $c) { |
|
474 | 474 | |
475 | 475 | $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
476 | 476 | ArrayCache::class, |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | $version = implode(',', $v); |
488 | 488 | $instanceId = \OC_Util::getInstanceId(); |
489 | 489 | $path = \OC::$SERVERROOT; |
490 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
490 | + $prefix = md5($instanceId.'-'.$version.'-'.$path); |
|
491 | 491 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
492 | 492 | $config->getSystemValue('memcache.local', null), |
493 | 493 | $config->getSystemValue('memcache.distributed', null), |
@@ -500,12 +500,12 @@ discard block |
||
500 | 500 | $this->registerAlias('MemCacheFactory', Factory::class); |
501 | 501 | $this->registerAlias(ICacheFactory::class, Factory::class); |
502 | 502 | |
503 | - $this->registerService('RedisFactory', function (Server $c) { |
|
503 | + $this->registerService('RedisFactory', function(Server $c) { |
|
504 | 504 | $systemConfig = $c->getSystemConfig(); |
505 | 505 | return new RedisFactory($systemConfig); |
506 | 506 | }); |
507 | 507 | |
508 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
508 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
509 | 509 | return new \OC\Activity\Manager( |
510 | 510 | $c->getRequest(), |
511 | 511 | $c->getUserSession(), |
@@ -515,14 +515,14 @@ discard block |
||
515 | 515 | }); |
516 | 516 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
517 | 517 | |
518 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
518 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
519 | 519 | return new \OC\Activity\EventMerger( |
520 | 520 | $c->getL10N('lib') |
521 | 521 | ); |
522 | 522 | }); |
523 | 523 | $this->registerAlias(IValidator::class, Validator::class); |
524 | 524 | |
525 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
525 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
526 | 526 | return new AvatarManager( |
527 | 527 | $c->query(\OC\User\Manager::class), |
528 | 528 | $c->getAppDataDir('avatar'), |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | |
536 | 536 | $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
537 | 537 | |
538 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
538 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
539 | 539 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
540 | 540 | $factory = new LogFactory($c, $this->getSystemConfig()); |
541 | 541 | $logger = $factory->get($logType); |
@@ -545,11 +545,11 @@ discard block |
||
545 | 545 | }); |
546 | 546 | $this->registerAlias('Logger', \OCP\ILogger::class); |
547 | 547 | |
548 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
548 | + $this->registerService(ILogFactory::class, function(Server $c) { |
|
549 | 549 | return new LogFactory($c, $this->getSystemConfig()); |
550 | 550 | }); |
551 | 551 | |
552 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
552 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
553 | 553 | $config = $c->getConfig(); |
554 | 554 | return new \OC\BackgroundJob\JobList( |
555 | 555 | $c->getDatabaseConnection(), |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | }); |
560 | 560 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
561 | 561 | |
562 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
562 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
563 | 563 | $cacheFactory = $c->getMemCacheFactory(); |
564 | 564 | $logger = $c->getLogger(); |
565 | 565 | if ($cacheFactory->isLocalCacheAvailable()) { |
@@ -571,12 +571,12 @@ discard block |
||
571 | 571 | }); |
572 | 572 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
573 | 573 | |
574 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
574 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
575 | 575 | return new Search(); |
576 | 576 | }); |
577 | 577 | $this->registerAlias('Search', \OCP\ISearch::class); |
578 | 578 | |
579 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
579 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function(Server $c) { |
|
580 | 580 | return new \OC\Security\RateLimiting\Limiter( |
581 | 581 | $this->getUserSession(), |
582 | 582 | $this->getRequest(), |
@@ -584,34 +584,34 @@ discard block |
||
584 | 584 | $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
585 | 585 | ); |
586 | 586 | }); |
587 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
587 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
588 | 588 | return new \OC\Security\RateLimiting\Backend\MemoryCache( |
589 | 589 | $this->getMemCacheFactory(), |
590 | 590 | new \OC\AppFramework\Utility\TimeFactory() |
591 | 591 | ); |
592 | 592 | }); |
593 | 593 | |
594 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
594 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
595 | 595 | return new SecureRandom(); |
596 | 596 | }); |
597 | 597 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
598 | 598 | |
599 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
599 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
600 | 600 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
601 | 601 | }); |
602 | 602 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
603 | 603 | |
604 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
604 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
605 | 605 | return new Hasher($c->getConfig()); |
606 | 606 | }); |
607 | 607 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
608 | 608 | |
609 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
609 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
610 | 610 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
611 | 611 | }); |
612 | 612 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
613 | 613 | |
614 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
614 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
615 | 615 | $systemConfig = $c->getSystemConfig(); |
616 | 616 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
617 | 617 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
627 | 627 | |
628 | 628 | |
629 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
629 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
630 | 630 | $user = \OC_User::getUser(); |
631 | 631 | $uid = $user ? $user : null; |
632 | 632 | return new ClientService( |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | ); |
642 | 642 | }); |
643 | 643 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
644 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
644 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
645 | 645 | $eventLogger = new EventLogger(); |
646 | 646 | if ($c->getSystemConfig()->getValue('debug', false)) { |
647 | 647 | // In debug mode, module is being activated by default |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | }); |
652 | 652 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
653 | 653 | |
654 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
654 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
655 | 655 | $queryLogger = new QueryLogger(); |
656 | 656 | if ($c->getSystemConfig()->getValue('debug', false)) { |
657 | 657 | // In debug mode, module is being activated by default |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | }); |
662 | 662 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
663 | 663 | |
664 | - $this->registerService(TempManager::class, function (Server $c) { |
|
664 | + $this->registerService(TempManager::class, function(Server $c) { |
|
665 | 665 | return new TempManager( |
666 | 666 | $c->getLogger(), |
667 | 667 | $c->getConfig() |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | $this->registerAlias('TempManager', TempManager::class); |
671 | 671 | $this->registerAlias(ITempManager::class, TempManager::class); |
672 | 672 | |
673 | - $this->registerService(AppManager::class, function (Server $c) { |
|
673 | + $this->registerService(AppManager::class, function(Server $c) { |
|
674 | 674 | return new \OC\App\AppManager( |
675 | 675 | $c->getUserSession(), |
676 | 676 | $c->query(\OC\AppConfig::class), |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | $this->registerAlias('AppManager', AppManager::class); |
683 | 683 | $this->registerAlias(IAppManager::class, AppManager::class); |
684 | 684 | |
685 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
685 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
686 | 686 | return new DateTimeZone( |
687 | 687 | $c->getConfig(), |
688 | 688 | $c->getSession() |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | }); |
691 | 691 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
692 | 692 | |
693 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
693 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
694 | 694 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
695 | 695 | |
696 | 696 | return new DateTimeFormatter( |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | }); |
701 | 701 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
702 | 702 | |
703 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
703 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
704 | 704 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
705 | 705 | $listener = new UserMountCacheListener($mountCache); |
706 | 706 | $listener->listen($c->getUserManager()); |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | }); |
709 | 709 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
710 | 710 | |
711 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
711 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
712 | 712 | $loader = \OC\Files\Filesystem::getLoader(); |
713 | 713 | $mountCache = $c->query('UserMountCache'); |
714 | 714 | $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
@@ -724,10 +724,10 @@ discard block |
||
724 | 724 | }); |
725 | 725 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
726 | 726 | |
727 | - $this->registerService('IniWrapper', function ($c) { |
|
727 | + $this->registerService('IniWrapper', function($c) { |
|
728 | 728 | return new IniGetWrapper(); |
729 | 729 | }); |
730 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
730 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
731 | 731 | $busClass = $c->getConfig()->getSystemValue('commandbus'); |
732 | 732 | if ($busClass) { |
733 | 733 | list($app, $class) = explode('::', $busClass, 2); |
@@ -742,10 +742,10 @@ discard block |
||
742 | 742 | return new CronBus($jobList); |
743 | 743 | } |
744 | 744 | }); |
745 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
745 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
746 | 746 | return new TrustedDomainHelper($this->getConfig()); |
747 | 747 | }); |
748 | - $this->registerService('Throttler', function (Server $c) { |
|
748 | + $this->registerService('Throttler', function(Server $c) { |
|
749 | 749 | return new Throttler( |
750 | 750 | $c->getDatabaseConnection(), |
751 | 751 | new TimeFactory(), |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | $c->getConfig() |
754 | 754 | ); |
755 | 755 | }); |
756 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
756 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
757 | 757 | // IConfig and IAppManager requires a working database. This code |
758 | 758 | // might however be called when ownCloud is not yet setup. |
759 | 759 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | $c->getTempManager() |
775 | 775 | ); |
776 | 776 | }); |
777 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
777 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
778 | 778 | if (isset($this['urlParams'])) { |
779 | 779 | $urlParams = $this['urlParams']; |
780 | 780 | } else { |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | }); |
811 | 811 | $this->registerAlias('Request', \OCP\IRequest::class); |
812 | 812 | |
813 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
813 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
814 | 814 | return new Mailer( |
815 | 815 | $c->getConfig(), |
816 | 816 | $c->getLogger(), |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | }); |
822 | 822 | $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
823 | 823 | |
824 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
824 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
825 | 825 | $config = $c->getConfig(); |
826 | 826 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
827 | 827 | if (is_null($factoryClass)) { |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | $factory = new $factoryClass($this); |
832 | 832 | return $factory->getLDAPProvider(); |
833 | 833 | }); |
834 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
834 | + $this->registerService(ILockingProvider::class, function(Server $c) { |
|
835 | 835 | $ini = $c->getIniWrapper(); |
836 | 836 | $config = $c->getConfig(); |
837 | 837 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -854,49 +854,49 @@ discard block |
||
854 | 854 | }); |
855 | 855 | $this->registerAlias('LockingProvider', ILockingProvider::class); |
856 | 856 | |
857 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
857 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
858 | 858 | return new \OC\Files\Mount\Manager(); |
859 | 859 | }); |
860 | 860 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
861 | 861 | |
862 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
862 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
863 | 863 | return new \OC\Files\Type\Detection( |
864 | 864 | $c->getURLGenerator(), |
865 | 865 | \OC::$configDir, |
866 | - \OC::$SERVERROOT . '/resources/config/' |
|
866 | + \OC::$SERVERROOT.'/resources/config/' |
|
867 | 867 | ); |
868 | 868 | }); |
869 | 869 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
870 | 870 | |
871 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
871 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
872 | 872 | return new \OC\Files\Type\Loader( |
873 | 873 | $c->getDatabaseConnection() |
874 | 874 | ); |
875 | 875 | }); |
876 | 876 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
877 | - $this->registerService(BundleFetcher::class, function () { |
|
877 | + $this->registerService(BundleFetcher::class, function() { |
|
878 | 878 | return new BundleFetcher($this->getL10N('lib')); |
879 | 879 | }); |
880 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
880 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
881 | 881 | return new Manager( |
882 | 882 | $c->query(IValidator::class) |
883 | 883 | ); |
884 | 884 | }); |
885 | 885 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
886 | 886 | |
887 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
887 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
888 | 888 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
889 | - $manager->registerCapability(function () use ($c) { |
|
889 | + $manager->registerCapability(function() use ($c) { |
|
890 | 890 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
891 | 891 | }); |
892 | - $manager->registerCapability(function () use ($c) { |
|
892 | + $manager->registerCapability(function() use ($c) { |
|
893 | 893 | return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
894 | 894 | }); |
895 | 895 | return $manager; |
896 | 896 | }); |
897 | 897 | $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
898 | 898 | |
899 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
899 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
900 | 900 | $config = $c->getConfig(); |
901 | 901 | $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
902 | 902 | /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
907 | 907 | $manager = $c->getUserManager(); |
908 | 908 | $user = $manager->get($id); |
909 | - if(is_null($user)) { |
|
909 | + if (is_null($user)) { |
|
910 | 910 | $l = $c->getL10N('core'); |
911 | 911 | $displayName = $l->t('Unknown user'); |
912 | 912 | } else { |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | }); |
920 | 920 | $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
921 | 921 | |
922 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
922 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
923 | 923 | /* |
924 | 924 | * Dark magic for autoloader. |
925 | 925 | * If we do a class_exists it will try to load the class which will |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | } |
947 | 947 | return new \OC_Defaults(); |
948 | 948 | }); |
949 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
949 | + $this->registerService(SCSSCacher::class, function(Server $c) { |
|
950 | 950 | /** @var Factory $cacheFactory */ |
951 | 951 | $cacheFactory = $c->query(Factory::class); |
952 | 952 | return new SCSSCacher( |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | $this->getMemCacheFactory() |
960 | 960 | ); |
961 | 961 | }); |
962 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
962 | + $this->registerService(JSCombiner::class, function(Server $c) { |
|
963 | 963 | /** @var Factory $cacheFactory */ |
964 | 964 | $cacheFactory = $c->query(Factory::class); |
965 | 965 | return new JSCombiner( |
@@ -970,13 +970,13 @@ discard block |
||
970 | 970 | $c->getLogger() |
971 | 971 | ); |
972 | 972 | }); |
973 | - $this->registerService(EventDispatcher::class, function () { |
|
973 | + $this->registerService(EventDispatcher::class, function() { |
|
974 | 974 | return new EventDispatcher(); |
975 | 975 | }); |
976 | 976 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
977 | 977 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
978 | 978 | |
979 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
979 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
980 | 980 | // FIXME: Instantiiated here due to cyclic dependency |
981 | 981 | $request = new Request( |
982 | 982 | [ |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | $request |
1002 | 1002 | ); |
1003 | 1003 | }); |
1004 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1004 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
1005 | 1005 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
1006 | 1006 | |
1007 | 1007 | return new CsrfTokenManager( |
@@ -1009,22 +1009,22 @@ discard block |
||
1009 | 1009 | $c->query(SessionStorage::class) |
1010 | 1010 | ); |
1011 | 1011 | }); |
1012 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
1012 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
1013 | 1013 | return new SessionStorage($c->getSession()); |
1014 | 1014 | }); |
1015 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1015 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
1016 | 1016 | return new ContentSecurityPolicyManager(); |
1017 | 1017 | }); |
1018 | 1018 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
1019 | 1019 | |
1020 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1020 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
1021 | 1021 | return new ContentSecurityPolicyNonceManager( |
1022 | 1022 | $c->getCsrfTokenManager(), |
1023 | 1023 | $c->getRequest() |
1024 | 1024 | ); |
1025 | 1025 | }); |
1026 | 1026 | |
1027 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1027 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
1028 | 1028 | $config = $c->getConfig(); |
1029 | 1029 | $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
1030 | 1030 | /** @var \OCP\Share\IProviderFactory $factory */ |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | |
1068 | 1068 | $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
1069 | 1069 | |
1070 | - $this->registerService('SettingsManager', function (Server $c) { |
|
1070 | + $this->registerService('SettingsManager', function(Server $c) { |
|
1071 | 1071 | $manager = new \OC\Settings\Manager( |
1072 | 1072 | $c->getLogger(), |
1073 | 1073 | $c->getDatabaseConnection(), |
@@ -1085,36 +1085,36 @@ discard block |
||
1085 | 1085 | ); |
1086 | 1086 | return $manager; |
1087 | 1087 | }); |
1088 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1088 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
1089 | 1089 | return new \OC\Files\AppData\Factory( |
1090 | 1090 | $c->getRootFolder(), |
1091 | 1091 | $c->getSystemConfig() |
1092 | 1092 | ); |
1093 | 1093 | }); |
1094 | 1094 | |
1095 | - $this->registerService('LockdownManager', function (Server $c) { |
|
1096 | - return new LockdownManager(function () use ($c) { |
|
1095 | + $this->registerService('LockdownManager', function(Server $c) { |
|
1096 | + return new LockdownManager(function() use ($c) { |
|
1097 | 1097 | return $c->getSession(); |
1098 | 1098 | }); |
1099 | 1099 | }); |
1100 | 1100 | |
1101 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1101 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) { |
|
1102 | 1102 | return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
1103 | 1103 | }); |
1104 | 1104 | |
1105 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1105 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
1106 | 1106 | return new CloudIdManager(); |
1107 | 1107 | }); |
1108 | 1108 | |
1109 | - $this->registerService(IConfig::class, function (Server $c) { |
|
1109 | + $this->registerService(IConfig::class, function(Server $c) { |
|
1110 | 1110 | return new GlobalScale\Config($c->getConfig()); |
1111 | 1111 | }); |
1112 | 1112 | |
1113 | - $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
1113 | + $this->registerService(ICloudFederationProviderManager::class, function(Server $c) { |
|
1114 | 1114 | return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
1115 | 1115 | }); |
1116 | 1116 | |
1117 | - $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
1117 | + $this->registerService(ICloudFederationFactory::class, function(Server $c) { |
|
1118 | 1118 | return new CloudFederationFactory(); |
1119 | 1119 | }); |
1120 | 1120 | |
@@ -1124,18 +1124,18 @@ discard block |
||
1124 | 1124 | $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
1125 | 1125 | $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
1126 | 1126 | |
1127 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1127 | + $this->registerService(Defaults::class, function(Server $c) { |
|
1128 | 1128 | return new Defaults( |
1129 | 1129 | $c->getThemingDefaults() |
1130 | 1130 | ); |
1131 | 1131 | }); |
1132 | 1132 | $this->registerAlias('Defaults', \OCP\Defaults::class); |
1133 | 1133 | |
1134 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1134 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
1135 | 1135 | return $c->query(\OCP\IUserSession::class)->getSession(); |
1136 | 1136 | }); |
1137 | 1137 | |
1138 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
1138 | + $this->registerService(IShareHelper::class, function(Server $c) { |
|
1139 | 1139 | return new ShareHelper( |
1140 | 1140 | $c->query(\OCP\Share\IManager::class) |
1141 | 1141 | ); |
@@ -1197,11 +1197,11 @@ discard block |
||
1197 | 1197 | // no avatar to remove |
1198 | 1198 | } catch (\Exception $e) { |
1199 | 1199 | // Ignore exceptions |
1200 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1200 | + $logger->info('Could not cleanup avatar of '.$user->getUID()); |
|
1201 | 1201 | } |
1202 | 1202 | }); |
1203 | 1203 | |
1204 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1204 | + $dispatcher->addListener('OCP\IUser::changeUser', function(GenericEvent $e) { |
|
1205 | 1205 | $manager = $this->getAvatarManager(); |
1206 | 1206 | /** @var IUser $user */ |
1207 | 1207 | $user = $e->getSubject(); |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | * @deprecated since 9.2.0 use IAppData |
1353 | 1353 | */ |
1354 | 1354 | public function getAppFolder() { |
1355 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1355 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
1356 | 1356 | $root = $this->getRootFolder(); |
1357 | 1357 | if (!$root->nodeExists($dir)) { |
1358 | 1358 | $folder = $root->newFolder($dir); |
@@ -1927,7 +1927,7 @@ discard block |
||
1927 | 1927 | /** |
1928 | 1928 | * @return \OCP\Collaboration\AutoComplete\IManager |
1929 | 1929 | */ |
1930 | - public function getAutoCompleteManager(){ |
|
1930 | + public function getAutoCompleteManager() { |
|
1931 | 1931 | return $this->query(IManager::class); |
1932 | 1932 | } |
1933 | 1933 |
@@ -158,1870 +158,1870 @@ |
||
158 | 158 | * TODO: hookup all manager classes |
159 | 159 | */ |
160 | 160 | class Server extends ServerContainer implements IServerContainer { |
161 | - /** @var string */ |
|
162 | - private $webRoot; |
|
163 | - |
|
164 | - /** |
|
165 | - * @param string $webRoot |
|
166 | - * @param \OC\Config $config |
|
167 | - */ |
|
168 | - public function __construct($webRoot, \OC\Config $config) { |
|
169 | - parent::__construct(); |
|
170 | - $this->webRoot = $webRoot; |
|
171 | - |
|
172 | - // To find out if we are running from CLI or not |
|
173 | - $this->registerParameter('isCLI', \OC::$CLI); |
|
174 | - |
|
175 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
176 | - return $c; |
|
177 | - }); |
|
178 | - |
|
179 | - $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
180 | - $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
181 | - |
|
182 | - $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
183 | - $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
184 | - |
|
185 | - $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
186 | - $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
187 | - |
|
188 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
189 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
190 | - |
|
191 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
192 | - |
|
193 | - |
|
194 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
195 | - return new PreviewManager( |
|
196 | - $c->getConfig(), |
|
197 | - $c->getRootFolder(), |
|
198 | - $c->getAppDataDir('preview'), |
|
199 | - $c->getEventDispatcher(), |
|
200 | - $c->getSession()->get('user_id') |
|
201 | - ); |
|
202 | - }); |
|
203 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
204 | - |
|
205 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
206 | - return new \OC\Preview\Watcher( |
|
207 | - $c->getAppDataDir('preview') |
|
208 | - ); |
|
209 | - }); |
|
210 | - |
|
211 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
212 | - $view = new View(); |
|
213 | - $util = new Encryption\Util( |
|
214 | - $view, |
|
215 | - $c->getUserManager(), |
|
216 | - $c->getGroupManager(), |
|
217 | - $c->getConfig() |
|
218 | - ); |
|
219 | - return new Encryption\Manager( |
|
220 | - $c->getConfig(), |
|
221 | - $c->getLogger(), |
|
222 | - $c->getL10N('core'), |
|
223 | - new View(), |
|
224 | - $util, |
|
225 | - new ArrayCache() |
|
226 | - ); |
|
227 | - }); |
|
228 | - |
|
229 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
230 | - $util = new Encryption\Util( |
|
231 | - new View(), |
|
232 | - $c->getUserManager(), |
|
233 | - $c->getGroupManager(), |
|
234 | - $c->getConfig() |
|
235 | - ); |
|
236 | - return new Encryption\File( |
|
237 | - $util, |
|
238 | - $c->getRootFolder(), |
|
239 | - $c->getShareManager() |
|
240 | - ); |
|
241 | - }); |
|
242 | - |
|
243 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
244 | - $view = new View(); |
|
245 | - $util = new Encryption\Util( |
|
246 | - $view, |
|
247 | - $c->getUserManager(), |
|
248 | - $c->getGroupManager(), |
|
249 | - $c->getConfig() |
|
250 | - ); |
|
251 | - |
|
252 | - return new Encryption\Keys\Storage($view, $util); |
|
253 | - }); |
|
254 | - $this->registerService('TagMapper', function (Server $c) { |
|
255 | - return new TagMapper($c->getDatabaseConnection()); |
|
256 | - }); |
|
257 | - |
|
258 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
259 | - $tagMapper = $c->query('TagMapper'); |
|
260 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
261 | - }); |
|
262 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
263 | - |
|
264 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
265 | - $config = $c->getConfig(); |
|
266 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
267 | - return new $factoryClass($this); |
|
268 | - }); |
|
269 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
270 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
271 | - }); |
|
272 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
273 | - |
|
274 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
275 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
276 | - }); |
|
277 | - $this->registerService('RootFolder', function (Server $c) { |
|
278 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
279 | - $view = new View(); |
|
280 | - $root = new Root( |
|
281 | - $manager, |
|
282 | - $view, |
|
283 | - null, |
|
284 | - $c->getUserMountCache(), |
|
285 | - $this->getLogger(), |
|
286 | - $this->getUserManager() |
|
287 | - ); |
|
288 | - $connector = new HookConnector($root, $view); |
|
289 | - $connector->viewToNode(); |
|
290 | - |
|
291 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
292 | - $previewConnector->connectWatcher(); |
|
293 | - |
|
294 | - return $root; |
|
295 | - }); |
|
296 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
297 | - |
|
298 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
299 | - return new LazyRoot(function () use ($c) { |
|
300 | - return $c->query('RootFolder'); |
|
301 | - }); |
|
302 | - }); |
|
303 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
304 | - |
|
305 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
306 | - $config = $c->getConfig(); |
|
307 | - return new \OC\User\Manager($config); |
|
308 | - }); |
|
309 | - $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
310 | - $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
311 | - |
|
312 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
313 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
314 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
315 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
316 | - }); |
|
317 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
318 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
319 | - }); |
|
320 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
321 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
322 | - }); |
|
323 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
324 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
325 | - }); |
|
326 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
327 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
328 | - }); |
|
329 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
330 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
331 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
332 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
333 | - }); |
|
334 | - return $groupManager; |
|
335 | - }); |
|
336 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
337 | - |
|
338 | - $this->registerService(Store::class, function (Server $c) { |
|
339 | - $session = $c->getSession(); |
|
340 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
341 | - $tokenProvider = $c->query(IProvider::class); |
|
342 | - } else { |
|
343 | - $tokenProvider = null; |
|
344 | - } |
|
345 | - $logger = $c->getLogger(); |
|
346 | - return new Store($session, $logger, $tokenProvider); |
|
347 | - }); |
|
348 | - $this->registerAlias(IStore::class, Store::class); |
|
349 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
350 | - $dbConnection = $c->getDatabaseConnection(); |
|
351 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
352 | - }); |
|
353 | - $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
|
354 | - |
|
355 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
356 | - $manager = $c->getUserManager(); |
|
357 | - $session = new \OC\Session\Memory(''); |
|
358 | - $timeFactory = new TimeFactory(); |
|
359 | - // Token providers might require a working database. This code |
|
360 | - // might however be called when ownCloud is not yet setup. |
|
361 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
362 | - $defaultTokenProvider = $c->query(IProvider::class); |
|
363 | - } else { |
|
364 | - $defaultTokenProvider = null; |
|
365 | - } |
|
366 | - |
|
367 | - $dispatcher = $c->getEventDispatcher(); |
|
368 | - |
|
369 | - $userSession = new \OC\User\Session( |
|
370 | - $manager, |
|
371 | - $session, |
|
372 | - $timeFactory, |
|
373 | - $defaultTokenProvider, |
|
374 | - $c->getConfig(), |
|
375 | - $c->getSecureRandom(), |
|
376 | - $c->getLockdownManager(), |
|
377 | - $c->getLogger() |
|
378 | - ); |
|
379 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
380 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
381 | - }); |
|
382 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
383 | - /** @var $user \OC\User\User */ |
|
384 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
385 | - }); |
|
386 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
387 | - /** @var $user \OC\User\User */ |
|
388 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
389 | - $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
390 | - }); |
|
391 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
392 | - /** @var $user \OC\User\User */ |
|
393 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
394 | - }); |
|
395 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
396 | - /** @var $user \OC\User\User */ |
|
397 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
398 | - }); |
|
399 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
400 | - /** @var $user \OC\User\User */ |
|
401 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
402 | - }); |
|
403 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
404 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
405 | - }); |
|
406 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
407 | - /** @var $user \OC\User\User */ |
|
408 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
409 | - }); |
|
410 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
411 | - /** @var $user \OC\User\User */ |
|
412 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
413 | - }); |
|
414 | - $userSession->listen('\OC\User', 'logout', function () { |
|
415 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
416 | - }); |
|
417 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
418 | - /** @var $user \OC\User\User */ |
|
419 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
420 | - $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
421 | - }); |
|
422 | - return $userSession; |
|
423 | - }); |
|
424 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
425 | - |
|
426 | - $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); |
|
427 | - |
|
428 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
429 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
430 | - |
|
431 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
432 | - return new \OC\AllConfig( |
|
433 | - $c->getSystemConfig() |
|
434 | - ); |
|
435 | - }); |
|
436 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
437 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
438 | - |
|
439 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
440 | - return new \OC\SystemConfig($config); |
|
441 | - }); |
|
442 | - |
|
443 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
444 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
445 | - }); |
|
446 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
447 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
448 | - |
|
449 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
450 | - return new \OC\L10N\Factory( |
|
451 | - $c->getConfig(), |
|
452 | - $c->getRequest(), |
|
453 | - $c->getUserSession(), |
|
454 | - \OC::$SERVERROOT |
|
455 | - ); |
|
456 | - }); |
|
457 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
458 | - |
|
459 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
460 | - $config = $c->getConfig(); |
|
461 | - $cacheFactory = $c->getMemCacheFactory(); |
|
462 | - $request = $c->getRequest(); |
|
463 | - return new \OC\URLGenerator( |
|
464 | - $config, |
|
465 | - $cacheFactory, |
|
466 | - $request |
|
467 | - ); |
|
468 | - }); |
|
469 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
470 | - |
|
471 | - $this->registerAlias('AppFetcher', AppFetcher::class); |
|
472 | - $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
473 | - |
|
474 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
475 | - return new Cache\File(); |
|
476 | - }); |
|
477 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
478 | - |
|
479 | - $this->registerService(Factory::class, function (Server $c) { |
|
480 | - |
|
481 | - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
482 | - ArrayCache::class, |
|
483 | - ArrayCache::class, |
|
484 | - ArrayCache::class |
|
485 | - ); |
|
486 | - $config = $c->getConfig(); |
|
487 | - $request = $c->getRequest(); |
|
488 | - $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
489 | - |
|
490 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
491 | - $v = \OC_App::getAppVersions(); |
|
492 | - $v['core'] = implode(',', \OC_Util::getVersion()); |
|
493 | - $version = implode(',', $v); |
|
494 | - $instanceId = \OC_Util::getInstanceId(); |
|
495 | - $path = \OC::$SERVERROOT; |
|
496 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
497 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
498 | - $config->getSystemValue('memcache.local', null), |
|
499 | - $config->getSystemValue('memcache.distributed', null), |
|
500 | - $config->getSystemValue('memcache.locking', null) |
|
501 | - ); |
|
502 | - } |
|
503 | - return $arrayCacheFactory; |
|
504 | - |
|
505 | - }); |
|
506 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
507 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
508 | - |
|
509 | - $this->registerService('RedisFactory', function (Server $c) { |
|
510 | - $systemConfig = $c->getSystemConfig(); |
|
511 | - return new RedisFactory($systemConfig); |
|
512 | - }); |
|
513 | - |
|
514 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
515 | - return new \OC\Activity\Manager( |
|
516 | - $c->getRequest(), |
|
517 | - $c->getUserSession(), |
|
518 | - $c->getConfig(), |
|
519 | - $c->query(IValidator::class) |
|
520 | - ); |
|
521 | - }); |
|
522 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
523 | - |
|
524 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
525 | - return new \OC\Activity\EventMerger( |
|
526 | - $c->getL10N('lib') |
|
527 | - ); |
|
528 | - }); |
|
529 | - $this->registerAlias(IValidator::class, Validator::class); |
|
530 | - |
|
531 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
532 | - return new AvatarManager( |
|
533 | - $c->query(\OC\User\Manager::class), |
|
534 | - $c->getAppDataDir('avatar'), |
|
535 | - $c->getL10N('lib'), |
|
536 | - $c->getLogger(), |
|
537 | - $c->getConfig() |
|
538 | - ); |
|
539 | - }); |
|
540 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
541 | - |
|
542 | - $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
543 | - |
|
544 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
545 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
546 | - $factory = new LogFactory($c, $this->getSystemConfig()); |
|
547 | - $logger = $factory->get($logType); |
|
548 | - $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
549 | - |
|
550 | - return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
551 | - }); |
|
552 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
553 | - |
|
554 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
555 | - return new LogFactory($c, $this->getSystemConfig()); |
|
556 | - }); |
|
557 | - |
|
558 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
559 | - $config = $c->getConfig(); |
|
560 | - return new \OC\BackgroundJob\JobList( |
|
561 | - $c->getDatabaseConnection(), |
|
562 | - $config, |
|
563 | - new TimeFactory() |
|
564 | - ); |
|
565 | - }); |
|
566 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
567 | - |
|
568 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
569 | - $cacheFactory = $c->getMemCacheFactory(); |
|
570 | - $logger = $c->getLogger(); |
|
571 | - if ($cacheFactory->isLocalCacheAvailable()) { |
|
572 | - $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
573 | - } else { |
|
574 | - $router = new \OC\Route\Router($logger); |
|
575 | - } |
|
576 | - return $router; |
|
577 | - }); |
|
578 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
579 | - |
|
580 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
581 | - return new Search(); |
|
582 | - }); |
|
583 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
584 | - |
|
585 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
586 | - return new \OC\Security\RateLimiting\Limiter( |
|
587 | - $this->getUserSession(), |
|
588 | - $this->getRequest(), |
|
589 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
590 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
591 | - ); |
|
592 | - }); |
|
593 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
594 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
595 | - $this->getMemCacheFactory(), |
|
596 | - new \OC\AppFramework\Utility\TimeFactory() |
|
597 | - ); |
|
598 | - }); |
|
599 | - |
|
600 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
601 | - return new SecureRandom(); |
|
602 | - }); |
|
603 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
604 | - |
|
605 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
606 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
607 | - }); |
|
608 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
609 | - |
|
610 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
611 | - return new Hasher($c->getConfig()); |
|
612 | - }); |
|
613 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
614 | - |
|
615 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
616 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
617 | - }); |
|
618 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
619 | - |
|
620 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
621 | - $systemConfig = $c->getSystemConfig(); |
|
622 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
623 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
624 | - if (!$factory->isValidType($type)) { |
|
625 | - throw new \OC\DatabaseException('Invalid database type'); |
|
626 | - } |
|
627 | - $connectionParams = $factory->createConnectionParams(); |
|
628 | - $connection = $factory->getConnection($type, $connectionParams); |
|
629 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
630 | - return $connection; |
|
631 | - }); |
|
632 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
633 | - |
|
634 | - |
|
635 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
636 | - $user = \OC_User::getUser(); |
|
637 | - $uid = $user ? $user : null; |
|
638 | - return new ClientService( |
|
639 | - $c->getConfig(), |
|
640 | - new \OC\Security\CertificateManager( |
|
641 | - $uid, |
|
642 | - new View(), |
|
643 | - $c->getConfig(), |
|
644 | - $c->getLogger(), |
|
645 | - $c->getSecureRandom() |
|
646 | - ) |
|
647 | - ); |
|
648 | - }); |
|
649 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
650 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
651 | - $eventLogger = new EventLogger(); |
|
652 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
653 | - // In debug mode, module is being activated by default |
|
654 | - $eventLogger->activate(); |
|
655 | - } |
|
656 | - return $eventLogger; |
|
657 | - }); |
|
658 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
659 | - |
|
660 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
661 | - $queryLogger = new QueryLogger(); |
|
662 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
663 | - // In debug mode, module is being activated by default |
|
664 | - $queryLogger->activate(); |
|
665 | - } |
|
666 | - return $queryLogger; |
|
667 | - }); |
|
668 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
669 | - |
|
670 | - $this->registerService(TempManager::class, function (Server $c) { |
|
671 | - return new TempManager( |
|
672 | - $c->getLogger(), |
|
673 | - $c->getConfig() |
|
674 | - ); |
|
675 | - }); |
|
676 | - $this->registerAlias('TempManager', TempManager::class); |
|
677 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
678 | - |
|
679 | - $this->registerService(AppManager::class, function (Server $c) { |
|
680 | - return new \OC\App\AppManager( |
|
681 | - $c->getUserSession(), |
|
682 | - $c->query(\OC\AppConfig::class), |
|
683 | - $c->getGroupManager(), |
|
684 | - $c->getMemCacheFactory(), |
|
685 | - $c->getEventDispatcher() |
|
686 | - ); |
|
687 | - }); |
|
688 | - $this->registerAlias('AppManager', AppManager::class); |
|
689 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
690 | - |
|
691 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
692 | - return new DateTimeZone( |
|
693 | - $c->getConfig(), |
|
694 | - $c->getSession() |
|
695 | - ); |
|
696 | - }); |
|
697 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
698 | - |
|
699 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
700 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
701 | - |
|
702 | - return new DateTimeFormatter( |
|
703 | - $c->getDateTimeZone()->getTimeZone(), |
|
704 | - $c->getL10N('lib', $language) |
|
705 | - ); |
|
706 | - }); |
|
707 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
708 | - |
|
709 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
710 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
711 | - $listener = new UserMountCacheListener($mountCache); |
|
712 | - $listener->listen($c->getUserManager()); |
|
713 | - return $mountCache; |
|
714 | - }); |
|
715 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
716 | - |
|
717 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
718 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
719 | - $mountCache = $c->query('UserMountCache'); |
|
720 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
721 | - |
|
722 | - // builtin providers |
|
723 | - |
|
724 | - $config = $c->getConfig(); |
|
725 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
726 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
727 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
728 | - |
|
729 | - return $manager; |
|
730 | - }); |
|
731 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
732 | - |
|
733 | - $this->registerService('IniWrapper', function ($c) { |
|
734 | - return new IniGetWrapper(); |
|
735 | - }); |
|
736 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
737 | - $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
738 | - if ($busClass) { |
|
739 | - list($app, $class) = explode('::', $busClass, 2); |
|
740 | - if ($c->getAppManager()->isInstalled($app)) { |
|
741 | - \OC_App::loadApp($app); |
|
742 | - return $c->query($class); |
|
743 | - } else { |
|
744 | - throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
745 | - } |
|
746 | - } else { |
|
747 | - $jobList = $c->getJobList(); |
|
748 | - return new CronBus($jobList); |
|
749 | - } |
|
750 | - }); |
|
751 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
752 | - return new TrustedDomainHelper($this->getConfig()); |
|
753 | - }); |
|
754 | - $this->registerService('Throttler', function (Server $c) { |
|
755 | - return new Throttler( |
|
756 | - $c->getDatabaseConnection(), |
|
757 | - new TimeFactory(), |
|
758 | - $c->getLogger(), |
|
759 | - $c->getConfig() |
|
760 | - ); |
|
761 | - }); |
|
762 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
763 | - // IConfig and IAppManager requires a working database. This code |
|
764 | - // might however be called when ownCloud is not yet setup. |
|
765 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
766 | - $config = $c->getConfig(); |
|
767 | - $appManager = $c->getAppManager(); |
|
768 | - } else { |
|
769 | - $config = null; |
|
770 | - $appManager = null; |
|
771 | - } |
|
772 | - |
|
773 | - return new Checker( |
|
774 | - new EnvironmentHelper(), |
|
775 | - new FileAccessHelper(), |
|
776 | - new AppLocator(), |
|
777 | - $config, |
|
778 | - $c->getMemCacheFactory(), |
|
779 | - $appManager, |
|
780 | - $c->getTempManager() |
|
781 | - ); |
|
782 | - }); |
|
783 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
784 | - if (isset($this['urlParams'])) { |
|
785 | - $urlParams = $this['urlParams']; |
|
786 | - } else { |
|
787 | - $urlParams = []; |
|
788 | - } |
|
789 | - |
|
790 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
791 | - && in_array('fakeinput', stream_get_wrappers()) |
|
792 | - ) { |
|
793 | - $stream = 'fakeinput://data'; |
|
794 | - } else { |
|
795 | - $stream = 'php://input'; |
|
796 | - } |
|
797 | - |
|
798 | - return new Request( |
|
799 | - [ |
|
800 | - 'get' => $_GET, |
|
801 | - 'post' => $_POST, |
|
802 | - 'files' => $_FILES, |
|
803 | - 'server' => $_SERVER, |
|
804 | - 'env' => $_ENV, |
|
805 | - 'cookies' => $_COOKIE, |
|
806 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
807 | - ? $_SERVER['REQUEST_METHOD'] |
|
808 | - : '', |
|
809 | - 'urlParams' => $urlParams, |
|
810 | - ], |
|
811 | - $this->getSecureRandom(), |
|
812 | - $this->getConfig(), |
|
813 | - $this->getCsrfTokenManager(), |
|
814 | - $stream |
|
815 | - ); |
|
816 | - }); |
|
817 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
818 | - |
|
819 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
820 | - return new Mailer( |
|
821 | - $c->getConfig(), |
|
822 | - $c->getLogger(), |
|
823 | - $c->query(Defaults::class), |
|
824 | - $c->getURLGenerator(), |
|
825 | - $c->getL10N('lib') |
|
826 | - ); |
|
827 | - }); |
|
828 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
829 | - |
|
830 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
831 | - $config = $c->getConfig(); |
|
832 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
833 | - if (is_null($factoryClass)) { |
|
834 | - throw new \Exception('ldapProviderFactory not set'); |
|
835 | - } |
|
836 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
837 | - $factory = new $factoryClass($this); |
|
838 | - return $factory->getLDAPProvider(); |
|
839 | - }); |
|
840 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
841 | - $ini = $c->getIniWrapper(); |
|
842 | - $config = $c->getConfig(); |
|
843 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
844 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
845 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
846 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
847 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
848 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
849 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
850 | - } |
|
851 | - return new DBLockingProvider( |
|
852 | - $c->getDatabaseConnection(), |
|
853 | - $c->getLogger(), |
|
854 | - new TimeFactory(), |
|
855 | - $ttl, |
|
856 | - !\OC::$CLI |
|
857 | - ); |
|
858 | - } |
|
859 | - return new NoopLockingProvider(); |
|
860 | - }); |
|
861 | - $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
862 | - |
|
863 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
864 | - return new \OC\Files\Mount\Manager(); |
|
865 | - }); |
|
866 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
867 | - |
|
868 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
869 | - return new \OC\Files\Type\Detection( |
|
870 | - $c->getURLGenerator(), |
|
871 | - \OC::$configDir, |
|
872 | - \OC::$SERVERROOT . '/resources/config/' |
|
873 | - ); |
|
874 | - }); |
|
875 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
876 | - |
|
877 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
878 | - return new \OC\Files\Type\Loader( |
|
879 | - $c->getDatabaseConnection() |
|
880 | - ); |
|
881 | - }); |
|
882 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
883 | - $this->registerService(BundleFetcher::class, function () { |
|
884 | - return new BundleFetcher($this->getL10N('lib')); |
|
885 | - }); |
|
886 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
887 | - return new Manager( |
|
888 | - $c->query(IValidator::class) |
|
889 | - ); |
|
890 | - }); |
|
891 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
892 | - |
|
893 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
894 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
895 | - $manager->registerCapability(function () use ($c) { |
|
896 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
897 | - }); |
|
898 | - $manager->registerCapability(function () use ($c) { |
|
899 | - return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
900 | - }); |
|
901 | - return $manager; |
|
902 | - }); |
|
903 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
904 | - |
|
905 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
906 | - $config = $c->getConfig(); |
|
907 | - $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
908 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
909 | - $factory = new $factoryClass($this); |
|
910 | - $manager = $factory->getManager(); |
|
911 | - |
|
912 | - $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
913 | - $manager = $c->getUserManager(); |
|
914 | - $user = $manager->get($id); |
|
915 | - if(is_null($user)) { |
|
916 | - $l = $c->getL10N('core'); |
|
917 | - $displayName = $l->t('Unknown user'); |
|
918 | - } else { |
|
919 | - $displayName = $user->getDisplayName(); |
|
920 | - } |
|
921 | - return $displayName; |
|
922 | - }); |
|
923 | - |
|
924 | - return $manager; |
|
925 | - }); |
|
926 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
927 | - |
|
928 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
929 | - /* |
|
161 | + /** @var string */ |
|
162 | + private $webRoot; |
|
163 | + |
|
164 | + /** |
|
165 | + * @param string $webRoot |
|
166 | + * @param \OC\Config $config |
|
167 | + */ |
|
168 | + public function __construct($webRoot, \OC\Config $config) { |
|
169 | + parent::__construct(); |
|
170 | + $this->webRoot = $webRoot; |
|
171 | + |
|
172 | + // To find out if we are running from CLI or not |
|
173 | + $this->registerParameter('isCLI', \OC::$CLI); |
|
174 | + |
|
175 | + $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
176 | + return $c; |
|
177 | + }); |
|
178 | + |
|
179 | + $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
180 | + $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
181 | + |
|
182 | + $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
183 | + $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
184 | + |
|
185 | + $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
186 | + $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
187 | + |
|
188 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
189 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
190 | + |
|
191 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
192 | + |
|
193 | + |
|
194 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
195 | + return new PreviewManager( |
|
196 | + $c->getConfig(), |
|
197 | + $c->getRootFolder(), |
|
198 | + $c->getAppDataDir('preview'), |
|
199 | + $c->getEventDispatcher(), |
|
200 | + $c->getSession()->get('user_id') |
|
201 | + ); |
|
202 | + }); |
|
203 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
204 | + |
|
205 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
206 | + return new \OC\Preview\Watcher( |
|
207 | + $c->getAppDataDir('preview') |
|
208 | + ); |
|
209 | + }); |
|
210 | + |
|
211 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
212 | + $view = new View(); |
|
213 | + $util = new Encryption\Util( |
|
214 | + $view, |
|
215 | + $c->getUserManager(), |
|
216 | + $c->getGroupManager(), |
|
217 | + $c->getConfig() |
|
218 | + ); |
|
219 | + return new Encryption\Manager( |
|
220 | + $c->getConfig(), |
|
221 | + $c->getLogger(), |
|
222 | + $c->getL10N('core'), |
|
223 | + new View(), |
|
224 | + $util, |
|
225 | + new ArrayCache() |
|
226 | + ); |
|
227 | + }); |
|
228 | + |
|
229 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
230 | + $util = new Encryption\Util( |
|
231 | + new View(), |
|
232 | + $c->getUserManager(), |
|
233 | + $c->getGroupManager(), |
|
234 | + $c->getConfig() |
|
235 | + ); |
|
236 | + return new Encryption\File( |
|
237 | + $util, |
|
238 | + $c->getRootFolder(), |
|
239 | + $c->getShareManager() |
|
240 | + ); |
|
241 | + }); |
|
242 | + |
|
243 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
244 | + $view = new View(); |
|
245 | + $util = new Encryption\Util( |
|
246 | + $view, |
|
247 | + $c->getUserManager(), |
|
248 | + $c->getGroupManager(), |
|
249 | + $c->getConfig() |
|
250 | + ); |
|
251 | + |
|
252 | + return new Encryption\Keys\Storage($view, $util); |
|
253 | + }); |
|
254 | + $this->registerService('TagMapper', function (Server $c) { |
|
255 | + return new TagMapper($c->getDatabaseConnection()); |
|
256 | + }); |
|
257 | + |
|
258 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
259 | + $tagMapper = $c->query('TagMapper'); |
|
260 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
261 | + }); |
|
262 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
263 | + |
|
264 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
265 | + $config = $c->getConfig(); |
|
266 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
267 | + return new $factoryClass($this); |
|
268 | + }); |
|
269 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
270 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
271 | + }); |
|
272 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
273 | + |
|
274 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
275 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
276 | + }); |
|
277 | + $this->registerService('RootFolder', function (Server $c) { |
|
278 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
279 | + $view = new View(); |
|
280 | + $root = new Root( |
|
281 | + $manager, |
|
282 | + $view, |
|
283 | + null, |
|
284 | + $c->getUserMountCache(), |
|
285 | + $this->getLogger(), |
|
286 | + $this->getUserManager() |
|
287 | + ); |
|
288 | + $connector = new HookConnector($root, $view); |
|
289 | + $connector->viewToNode(); |
|
290 | + |
|
291 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
292 | + $previewConnector->connectWatcher(); |
|
293 | + |
|
294 | + return $root; |
|
295 | + }); |
|
296 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
297 | + |
|
298 | + $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
299 | + return new LazyRoot(function () use ($c) { |
|
300 | + return $c->query('RootFolder'); |
|
301 | + }); |
|
302 | + }); |
|
303 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
304 | + |
|
305 | + $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
306 | + $config = $c->getConfig(); |
|
307 | + return new \OC\User\Manager($config); |
|
308 | + }); |
|
309 | + $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
310 | + $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
311 | + |
|
312 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
313 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
314 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
315 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
316 | + }); |
|
317 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
318 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
319 | + }); |
|
320 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
321 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
322 | + }); |
|
323 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
324 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
325 | + }); |
|
326 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
327 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
328 | + }); |
|
329 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
330 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
331 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
332 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
333 | + }); |
|
334 | + return $groupManager; |
|
335 | + }); |
|
336 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
337 | + |
|
338 | + $this->registerService(Store::class, function (Server $c) { |
|
339 | + $session = $c->getSession(); |
|
340 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
341 | + $tokenProvider = $c->query(IProvider::class); |
|
342 | + } else { |
|
343 | + $tokenProvider = null; |
|
344 | + } |
|
345 | + $logger = $c->getLogger(); |
|
346 | + return new Store($session, $logger, $tokenProvider); |
|
347 | + }); |
|
348 | + $this->registerAlias(IStore::class, Store::class); |
|
349 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
350 | + $dbConnection = $c->getDatabaseConnection(); |
|
351 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
352 | + }); |
|
353 | + $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
|
354 | + |
|
355 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
356 | + $manager = $c->getUserManager(); |
|
357 | + $session = new \OC\Session\Memory(''); |
|
358 | + $timeFactory = new TimeFactory(); |
|
359 | + // Token providers might require a working database. This code |
|
360 | + // might however be called when ownCloud is not yet setup. |
|
361 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
362 | + $defaultTokenProvider = $c->query(IProvider::class); |
|
363 | + } else { |
|
364 | + $defaultTokenProvider = null; |
|
365 | + } |
|
366 | + |
|
367 | + $dispatcher = $c->getEventDispatcher(); |
|
368 | + |
|
369 | + $userSession = new \OC\User\Session( |
|
370 | + $manager, |
|
371 | + $session, |
|
372 | + $timeFactory, |
|
373 | + $defaultTokenProvider, |
|
374 | + $c->getConfig(), |
|
375 | + $c->getSecureRandom(), |
|
376 | + $c->getLockdownManager(), |
|
377 | + $c->getLogger() |
|
378 | + ); |
|
379 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
380 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
381 | + }); |
|
382 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
383 | + /** @var $user \OC\User\User */ |
|
384 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
385 | + }); |
|
386 | + $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
387 | + /** @var $user \OC\User\User */ |
|
388 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
389 | + $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
390 | + }); |
|
391 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
392 | + /** @var $user \OC\User\User */ |
|
393 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
394 | + }); |
|
395 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
396 | + /** @var $user \OC\User\User */ |
|
397 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
398 | + }); |
|
399 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
400 | + /** @var $user \OC\User\User */ |
|
401 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
402 | + }); |
|
403 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
404 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
405 | + }); |
|
406 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
407 | + /** @var $user \OC\User\User */ |
|
408 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
409 | + }); |
|
410 | + $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
411 | + /** @var $user \OC\User\User */ |
|
412 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
413 | + }); |
|
414 | + $userSession->listen('\OC\User', 'logout', function () { |
|
415 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
416 | + }); |
|
417 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
418 | + /** @var $user \OC\User\User */ |
|
419 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
420 | + $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
421 | + }); |
|
422 | + return $userSession; |
|
423 | + }); |
|
424 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
425 | + |
|
426 | + $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); |
|
427 | + |
|
428 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
429 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
430 | + |
|
431 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
432 | + return new \OC\AllConfig( |
|
433 | + $c->getSystemConfig() |
|
434 | + ); |
|
435 | + }); |
|
436 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
437 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
438 | + |
|
439 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
440 | + return new \OC\SystemConfig($config); |
|
441 | + }); |
|
442 | + |
|
443 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
444 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
445 | + }); |
|
446 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
447 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
448 | + |
|
449 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
450 | + return new \OC\L10N\Factory( |
|
451 | + $c->getConfig(), |
|
452 | + $c->getRequest(), |
|
453 | + $c->getUserSession(), |
|
454 | + \OC::$SERVERROOT |
|
455 | + ); |
|
456 | + }); |
|
457 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
458 | + |
|
459 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
460 | + $config = $c->getConfig(); |
|
461 | + $cacheFactory = $c->getMemCacheFactory(); |
|
462 | + $request = $c->getRequest(); |
|
463 | + return new \OC\URLGenerator( |
|
464 | + $config, |
|
465 | + $cacheFactory, |
|
466 | + $request |
|
467 | + ); |
|
468 | + }); |
|
469 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
470 | + |
|
471 | + $this->registerAlias('AppFetcher', AppFetcher::class); |
|
472 | + $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
473 | + |
|
474 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
475 | + return new Cache\File(); |
|
476 | + }); |
|
477 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
478 | + |
|
479 | + $this->registerService(Factory::class, function (Server $c) { |
|
480 | + |
|
481 | + $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
482 | + ArrayCache::class, |
|
483 | + ArrayCache::class, |
|
484 | + ArrayCache::class |
|
485 | + ); |
|
486 | + $config = $c->getConfig(); |
|
487 | + $request = $c->getRequest(); |
|
488 | + $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
489 | + |
|
490 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
491 | + $v = \OC_App::getAppVersions(); |
|
492 | + $v['core'] = implode(',', \OC_Util::getVersion()); |
|
493 | + $version = implode(',', $v); |
|
494 | + $instanceId = \OC_Util::getInstanceId(); |
|
495 | + $path = \OC::$SERVERROOT; |
|
496 | + $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
497 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
498 | + $config->getSystemValue('memcache.local', null), |
|
499 | + $config->getSystemValue('memcache.distributed', null), |
|
500 | + $config->getSystemValue('memcache.locking', null) |
|
501 | + ); |
|
502 | + } |
|
503 | + return $arrayCacheFactory; |
|
504 | + |
|
505 | + }); |
|
506 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
507 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
508 | + |
|
509 | + $this->registerService('RedisFactory', function (Server $c) { |
|
510 | + $systemConfig = $c->getSystemConfig(); |
|
511 | + return new RedisFactory($systemConfig); |
|
512 | + }); |
|
513 | + |
|
514 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
515 | + return new \OC\Activity\Manager( |
|
516 | + $c->getRequest(), |
|
517 | + $c->getUserSession(), |
|
518 | + $c->getConfig(), |
|
519 | + $c->query(IValidator::class) |
|
520 | + ); |
|
521 | + }); |
|
522 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
523 | + |
|
524 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
525 | + return new \OC\Activity\EventMerger( |
|
526 | + $c->getL10N('lib') |
|
527 | + ); |
|
528 | + }); |
|
529 | + $this->registerAlias(IValidator::class, Validator::class); |
|
530 | + |
|
531 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
532 | + return new AvatarManager( |
|
533 | + $c->query(\OC\User\Manager::class), |
|
534 | + $c->getAppDataDir('avatar'), |
|
535 | + $c->getL10N('lib'), |
|
536 | + $c->getLogger(), |
|
537 | + $c->getConfig() |
|
538 | + ); |
|
539 | + }); |
|
540 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
541 | + |
|
542 | + $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
543 | + |
|
544 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
545 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
546 | + $factory = new LogFactory($c, $this->getSystemConfig()); |
|
547 | + $logger = $factory->get($logType); |
|
548 | + $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
549 | + |
|
550 | + return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
551 | + }); |
|
552 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
553 | + |
|
554 | + $this->registerService(ILogFactory::class, function (Server $c) { |
|
555 | + return new LogFactory($c, $this->getSystemConfig()); |
|
556 | + }); |
|
557 | + |
|
558 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
559 | + $config = $c->getConfig(); |
|
560 | + return new \OC\BackgroundJob\JobList( |
|
561 | + $c->getDatabaseConnection(), |
|
562 | + $config, |
|
563 | + new TimeFactory() |
|
564 | + ); |
|
565 | + }); |
|
566 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
567 | + |
|
568 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
569 | + $cacheFactory = $c->getMemCacheFactory(); |
|
570 | + $logger = $c->getLogger(); |
|
571 | + if ($cacheFactory->isLocalCacheAvailable()) { |
|
572 | + $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
573 | + } else { |
|
574 | + $router = new \OC\Route\Router($logger); |
|
575 | + } |
|
576 | + return $router; |
|
577 | + }); |
|
578 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
579 | + |
|
580 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
581 | + return new Search(); |
|
582 | + }); |
|
583 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
584 | + |
|
585 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
586 | + return new \OC\Security\RateLimiting\Limiter( |
|
587 | + $this->getUserSession(), |
|
588 | + $this->getRequest(), |
|
589 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
590 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
591 | + ); |
|
592 | + }); |
|
593 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
594 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
595 | + $this->getMemCacheFactory(), |
|
596 | + new \OC\AppFramework\Utility\TimeFactory() |
|
597 | + ); |
|
598 | + }); |
|
599 | + |
|
600 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
601 | + return new SecureRandom(); |
|
602 | + }); |
|
603 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
604 | + |
|
605 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
606 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
607 | + }); |
|
608 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
609 | + |
|
610 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
611 | + return new Hasher($c->getConfig()); |
|
612 | + }); |
|
613 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
614 | + |
|
615 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
616 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
617 | + }); |
|
618 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
619 | + |
|
620 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
621 | + $systemConfig = $c->getSystemConfig(); |
|
622 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
623 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
624 | + if (!$factory->isValidType($type)) { |
|
625 | + throw new \OC\DatabaseException('Invalid database type'); |
|
626 | + } |
|
627 | + $connectionParams = $factory->createConnectionParams(); |
|
628 | + $connection = $factory->getConnection($type, $connectionParams); |
|
629 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
630 | + return $connection; |
|
631 | + }); |
|
632 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
633 | + |
|
634 | + |
|
635 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
636 | + $user = \OC_User::getUser(); |
|
637 | + $uid = $user ? $user : null; |
|
638 | + return new ClientService( |
|
639 | + $c->getConfig(), |
|
640 | + new \OC\Security\CertificateManager( |
|
641 | + $uid, |
|
642 | + new View(), |
|
643 | + $c->getConfig(), |
|
644 | + $c->getLogger(), |
|
645 | + $c->getSecureRandom() |
|
646 | + ) |
|
647 | + ); |
|
648 | + }); |
|
649 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
650 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
651 | + $eventLogger = new EventLogger(); |
|
652 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
653 | + // In debug mode, module is being activated by default |
|
654 | + $eventLogger->activate(); |
|
655 | + } |
|
656 | + return $eventLogger; |
|
657 | + }); |
|
658 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
659 | + |
|
660 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
661 | + $queryLogger = new QueryLogger(); |
|
662 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
663 | + // In debug mode, module is being activated by default |
|
664 | + $queryLogger->activate(); |
|
665 | + } |
|
666 | + return $queryLogger; |
|
667 | + }); |
|
668 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
669 | + |
|
670 | + $this->registerService(TempManager::class, function (Server $c) { |
|
671 | + return new TempManager( |
|
672 | + $c->getLogger(), |
|
673 | + $c->getConfig() |
|
674 | + ); |
|
675 | + }); |
|
676 | + $this->registerAlias('TempManager', TempManager::class); |
|
677 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
678 | + |
|
679 | + $this->registerService(AppManager::class, function (Server $c) { |
|
680 | + return new \OC\App\AppManager( |
|
681 | + $c->getUserSession(), |
|
682 | + $c->query(\OC\AppConfig::class), |
|
683 | + $c->getGroupManager(), |
|
684 | + $c->getMemCacheFactory(), |
|
685 | + $c->getEventDispatcher() |
|
686 | + ); |
|
687 | + }); |
|
688 | + $this->registerAlias('AppManager', AppManager::class); |
|
689 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
690 | + |
|
691 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
692 | + return new DateTimeZone( |
|
693 | + $c->getConfig(), |
|
694 | + $c->getSession() |
|
695 | + ); |
|
696 | + }); |
|
697 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
698 | + |
|
699 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
700 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
701 | + |
|
702 | + return new DateTimeFormatter( |
|
703 | + $c->getDateTimeZone()->getTimeZone(), |
|
704 | + $c->getL10N('lib', $language) |
|
705 | + ); |
|
706 | + }); |
|
707 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
708 | + |
|
709 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
710 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
711 | + $listener = new UserMountCacheListener($mountCache); |
|
712 | + $listener->listen($c->getUserManager()); |
|
713 | + return $mountCache; |
|
714 | + }); |
|
715 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
716 | + |
|
717 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
718 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
719 | + $mountCache = $c->query('UserMountCache'); |
|
720 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
721 | + |
|
722 | + // builtin providers |
|
723 | + |
|
724 | + $config = $c->getConfig(); |
|
725 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
726 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
727 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
728 | + |
|
729 | + return $manager; |
|
730 | + }); |
|
731 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
732 | + |
|
733 | + $this->registerService('IniWrapper', function ($c) { |
|
734 | + return new IniGetWrapper(); |
|
735 | + }); |
|
736 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
737 | + $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
738 | + if ($busClass) { |
|
739 | + list($app, $class) = explode('::', $busClass, 2); |
|
740 | + if ($c->getAppManager()->isInstalled($app)) { |
|
741 | + \OC_App::loadApp($app); |
|
742 | + return $c->query($class); |
|
743 | + } else { |
|
744 | + throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
745 | + } |
|
746 | + } else { |
|
747 | + $jobList = $c->getJobList(); |
|
748 | + return new CronBus($jobList); |
|
749 | + } |
|
750 | + }); |
|
751 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
752 | + return new TrustedDomainHelper($this->getConfig()); |
|
753 | + }); |
|
754 | + $this->registerService('Throttler', function (Server $c) { |
|
755 | + return new Throttler( |
|
756 | + $c->getDatabaseConnection(), |
|
757 | + new TimeFactory(), |
|
758 | + $c->getLogger(), |
|
759 | + $c->getConfig() |
|
760 | + ); |
|
761 | + }); |
|
762 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
763 | + // IConfig and IAppManager requires a working database. This code |
|
764 | + // might however be called when ownCloud is not yet setup. |
|
765 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
766 | + $config = $c->getConfig(); |
|
767 | + $appManager = $c->getAppManager(); |
|
768 | + } else { |
|
769 | + $config = null; |
|
770 | + $appManager = null; |
|
771 | + } |
|
772 | + |
|
773 | + return new Checker( |
|
774 | + new EnvironmentHelper(), |
|
775 | + new FileAccessHelper(), |
|
776 | + new AppLocator(), |
|
777 | + $config, |
|
778 | + $c->getMemCacheFactory(), |
|
779 | + $appManager, |
|
780 | + $c->getTempManager() |
|
781 | + ); |
|
782 | + }); |
|
783 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
784 | + if (isset($this['urlParams'])) { |
|
785 | + $urlParams = $this['urlParams']; |
|
786 | + } else { |
|
787 | + $urlParams = []; |
|
788 | + } |
|
789 | + |
|
790 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
791 | + && in_array('fakeinput', stream_get_wrappers()) |
|
792 | + ) { |
|
793 | + $stream = 'fakeinput://data'; |
|
794 | + } else { |
|
795 | + $stream = 'php://input'; |
|
796 | + } |
|
797 | + |
|
798 | + return new Request( |
|
799 | + [ |
|
800 | + 'get' => $_GET, |
|
801 | + 'post' => $_POST, |
|
802 | + 'files' => $_FILES, |
|
803 | + 'server' => $_SERVER, |
|
804 | + 'env' => $_ENV, |
|
805 | + 'cookies' => $_COOKIE, |
|
806 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
807 | + ? $_SERVER['REQUEST_METHOD'] |
|
808 | + : '', |
|
809 | + 'urlParams' => $urlParams, |
|
810 | + ], |
|
811 | + $this->getSecureRandom(), |
|
812 | + $this->getConfig(), |
|
813 | + $this->getCsrfTokenManager(), |
|
814 | + $stream |
|
815 | + ); |
|
816 | + }); |
|
817 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
818 | + |
|
819 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
820 | + return new Mailer( |
|
821 | + $c->getConfig(), |
|
822 | + $c->getLogger(), |
|
823 | + $c->query(Defaults::class), |
|
824 | + $c->getURLGenerator(), |
|
825 | + $c->getL10N('lib') |
|
826 | + ); |
|
827 | + }); |
|
828 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
829 | + |
|
830 | + $this->registerService('LDAPProvider', function (Server $c) { |
|
831 | + $config = $c->getConfig(); |
|
832 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
833 | + if (is_null($factoryClass)) { |
|
834 | + throw new \Exception('ldapProviderFactory not set'); |
|
835 | + } |
|
836 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
837 | + $factory = new $factoryClass($this); |
|
838 | + return $factory->getLDAPProvider(); |
|
839 | + }); |
|
840 | + $this->registerService(ILockingProvider::class, function (Server $c) { |
|
841 | + $ini = $c->getIniWrapper(); |
|
842 | + $config = $c->getConfig(); |
|
843 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
844 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
845 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
846 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
847 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
848 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
849 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
850 | + } |
|
851 | + return new DBLockingProvider( |
|
852 | + $c->getDatabaseConnection(), |
|
853 | + $c->getLogger(), |
|
854 | + new TimeFactory(), |
|
855 | + $ttl, |
|
856 | + !\OC::$CLI |
|
857 | + ); |
|
858 | + } |
|
859 | + return new NoopLockingProvider(); |
|
860 | + }); |
|
861 | + $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
862 | + |
|
863 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
864 | + return new \OC\Files\Mount\Manager(); |
|
865 | + }); |
|
866 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
867 | + |
|
868 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
869 | + return new \OC\Files\Type\Detection( |
|
870 | + $c->getURLGenerator(), |
|
871 | + \OC::$configDir, |
|
872 | + \OC::$SERVERROOT . '/resources/config/' |
|
873 | + ); |
|
874 | + }); |
|
875 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
876 | + |
|
877 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
878 | + return new \OC\Files\Type\Loader( |
|
879 | + $c->getDatabaseConnection() |
|
880 | + ); |
|
881 | + }); |
|
882 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
883 | + $this->registerService(BundleFetcher::class, function () { |
|
884 | + return new BundleFetcher($this->getL10N('lib')); |
|
885 | + }); |
|
886 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
887 | + return new Manager( |
|
888 | + $c->query(IValidator::class) |
|
889 | + ); |
|
890 | + }); |
|
891 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
892 | + |
|
893 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
894 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
895 | + $manager->registerCapability(function () use ($c) { |
|
896 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
897 | + }); |
|
898 | + $manager->registerCapability(function () use ($c) { |
|
899 | + return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
900 | + }); |
|
901 | + return $manager; |
|
902 | + }); |
|
903 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
904 | + |
|
905 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
906 | + $config = $c->getConfig(); |
|
907 | + $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
908 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
909 | + $factory = new $factoryClass($this); |
|
910 | + $manager = $factory->getManager(); |
|
911 | + |
|
912 | + $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
913 | + $manager = $c->getUserManager(); |
|
914 | + $user = $manager->get($id); |
|
915 | + if(is_null($user)) { |
|
916 | + $l = $c->getL10N('core'); |
|
917 | + $displayName = $l->t('Unknown user'); |
|
918 | + } else { |
|
919 | + $displayName = $user->getDisplayName(); |
|
920 | + } |
|
921 | + return $displayName; |
|
922 | + }); |
|
923 | + |
|
924 | + return $manager; |
|
925 | + }); |
|
926 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
927 | + |
|
928 | + $this->registerService('ThemingDefaults', function (Server $c) { |
|
929 | + /* |
|
930 | 930 | * Dark magic for autoloader. |
931 | 931 | * If we do a class_exists it will try to load the class which will |
932 | 932 | * make composer cache the result. Resulting in errors when enabling |
933 | 933 | * the theming app. |
934 | 934 | */ |
935 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
936 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
937 | - $classExists = true; |
|
938 | - } else { |
|
939 | - $classExists = false; |
|
940 | - } |
|
941 | - |
|
942 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
943 | - return new ThemingDefaults( |
|
944 | - $c->getConfig(), |
|
945 | - $c->getL10N('theming'), |
|
946 | - $c->getURLGenerator(), |
|
947 | - $c->getMemCacheFactory(), |
|
948 | - new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
949 | - new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
950 | - $c->getAppManager() |
|
951 | - ); |
|
952 | - } |
|
953 | - return new \OC_Defaults(); |
|
954 | - }); |
|
955 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
956 | - /** @var Factory $cacheFactory */ |
|
957 | - $cacheFactory = $c->query(Factory::class); |
|
958 | - return new SCSSCacher( |
|
959 | - $c->getLogger(), |
|
960 | - $c->query(\OC\Files\AppData\Factory::class), |
|
961 | - $c->getURLGenerator(), |
|
962 | - $c->getConfig(), |
|
963 | - $c->getThemingDefaults(), |
|
964 | - \OC::$SERVERROOT, |
|
965 | - $this->getMemCacheFactory() |
|
966 | - ); |
|
967 | - }); |
|
968 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
969 | - /** @var Factory $cacheFactory */ |
|
970 | - $cacheFactory = $c->query(Factory::class); |
|
971 | - return new JSCombiner( |
|
972 | - $c->getAppDataDir('js'), |
|
973 | - $c->getURLGenerator(), |
|
974 | - $this->getMemCacheFactory(), |
|
975 | - $c->getSystemConfig(), |
|
976 | - $c->getLogger() |
|
977 | - ); |
|
978 | - }); |
|
979 | - $this->registerService(EventDispatcher::class, function () { |
|
980 | - return new EventDispatcher(); |
|
981 | - }); |
|
982 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
983 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
984 | - |
|
985 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
986 | - // FIXME: Instantiiated here due to cyclic dependency |
|
987 | - $request = new Request( |
|
988 | - [ |
|
989 | - 'get' => $_GET, |
|
990 | - 'post' => $_POST, |
|
991 | - 'files' => $_FILES, |
|
992 | - 'server' => $_SERVER, |
|
993 | - 'env' => $_ENV, |
|
994 | - 'cookies' => $_COOKIE, |
|
995 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
996 | - ? $_SERVER['REQUEST_METHOD'] |
|
997 | - : null, |
|
998 | - ], |
|
999 | - $c->getSecureRandom(), |
|
1000 | - $c->getConfig() |
|
1001 | - ); |
|
1002 | - |
|
1003 | - return new CryptoWrapper( |
|
1004 | - $c->getConfig(), |
|
1005 | - $c->getCrypto(), |
|
1006 | - $c->getSecureRandom(), |
|
1007 | - $request |
|
1008 | - ); |
|
1009 | - }); |
|
1010 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1011 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
1012 | - |
|
1013 | - return new CsrfTokenManager( |
|
1014 | - $tokenGenerator, |
|
1015 | - $c->query(SessionStorage::class) |
|
1016 | - ); |
|
1017 | - }); |
|
1018 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
1019 | - return new SessionStorage($c->getSession()); |
|
1020 | - }); |
|
1021 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1022 | - return new ContentSecurityPolicyManager(); |
|
1023 | - }); |
|
1024 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
1025 | - |
|
1026 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1027 | - return new ContentSecurityPolicyNonceManager( |
|
1028 | - $c->getCsrfTokenManager(), |
|
1029 | - $c->getRequest() |
|
1030 | - ); |
|
1031 | - }); |
|
1032 | - |
|
1033 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1034 | - $config = $c->getConfig(); |
|
1035 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
1036 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
1037 | - $factory = new $factoryClass($this); |
|
1038 | - |
|
1039 | - $manager = new \OC\Share20\Manager( |
|
1040 | - $c->getLogger(), |
|
1041 | - $c->getConfig(), |
|
1042 | - $c->getSecureRandom(), |
|
1043 | - $c->getHasher(), |
|
1044 | - $c->getMountManager(), |
|
1045 | - $c->getGroupManager(), |
|
1046 | - $c->getL10N('lib'), |
|
1047 | - $c->getL10NFactory(), |
|
1048 | - $factory, |
|
1049 | - $c->getUserManager(), |
|
1050 | - $c->getLazyRootFolder(), |
|
1051 | - $c->getEventDispatcher(), |
|
1052 | - $c->getMailer(), |
|
1053 | - $c->getURLGenerator(), |
|
1054 | - $c->getThemingDefaults() |
|
1055 | - ); |
|
1056 | - |
|
1057 | - return $manager; |
|
1058 | - }); |
|
1059 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
1060 | - |
|
1061 | - $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
1062 | - $instance = new Collaboration\Collaborators\Search($c); |
|
1063 | - |
|
1064 | - // register default plugins |
|
1065 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
1066 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
1067 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
1068 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
1069 | - |
|
1070 | - return $instance; |
|
1071 | - }); |
|
1072 | - $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
1073 | - |
|
1074 | - $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
1075 | - |
|
1076 | - $this->registerService('SettingsManager', function (Server $c) { |
|
1077 | - $manager = new \OC\Settings\Manager( |
|
1078 | - $c->getLogger(), |
|
1079 | - $c->getDatabaseConnection(), |
|
1080 | - $c->getL10N('lib'), |
|
1081 | - $c->getConfig(), |
|
1082 | - $c->getEncryptionManager(), |
|
1083 | - $c->getUserManager(), |
|
1084 | - $c->getLockingProvider(), |
|
1085 | - $c->getRequest(), |
|
1086 | - $c->getURLGenerator(), |
|
1087 | - $c->query(AccountManager::class), |
|
1088 | - $c->getGroupManager(), |
|
1089 | - $c->getL10NFactory(), |
|
1090 | - $c->getAppManager() |
|
1091 | - ); |
|
1092 | - return $manager; |
|
1093 | - }); |
|
1094 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1095 | - return new \OC\Files\AppData\Factory( |
|
1096 | - $c->getRootFolder(), |
|
1097 | - $c->getSystemConfig() |
|
1098 | - ); |
|
1099 | - }); |
|
1100 | - |
|
1101 | - $this->registerService('LockdownManager', function (Server $c) { |
|
1102 | - return new LockdownManager(function () use ($c) { |
|
1103 | - return $c->getSession(); |
|
1104 | - }); |
|
1105 | - }); |
|
1106 | - |
|
1107 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1108 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
1109 | - }); |
|
1110 | - |
|
1111 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1112 | - return new CloudIdManager(); |
|
1113 | - }); |
|
1114 | - |
|
1115 | - $this->registerService(IConfig::class, function (Server $c) { |
|
1116 | - return new GlobalScale\Config($c->getConfig()); |
|
1117 | - }); |
|
1118 | - |
|
1119 | - $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
1120 | - return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
|
1121 | - }); |
|
1122 | - |
|
1123 | - $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
1124 | - return new CloudFederationFactory(); |
|
1125 | - }); |
|
1126 | - |
|
1127 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1128 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1129 | - |
|
1130 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1131 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1132 | - |
|
1133 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1134 | - return new Defaults( |
|
1135 | - $c->getThemingDefaults() |
|
1136 | - ); |
|
1137 | - }); |
|
1138 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1139 | - |
|
1140 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1141 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1142 | - }); |
|
1143 | - |
|
1144 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
1145 | - return new ShareHelper( |
|
1146 | - $c->query(\OCP\Share\IManager::class) |
|
1147 | - ); |
|
1148 | - }); |
|
1149 | - |
|
1150 | - $this->registerService(Installer::class, function(Server $c) { |
|
1151 | - return new Installer( |
|
1152 | - $c->getAppFetcher(), |
|
1153 | - $c->getHTTPClientService(), |
|
1154 | - $c->getTempManager(), |
|
1155 | - $c->getLogger(), |
|
1156 | - $c->getConfig() |
|
1157 | - ); |
|
1158 | - }); |
|
1159 | - |
|
1160 | - $this->registerService(IApiFactory::class, function(Server $c) { |
|
1161 | - return new ApiFactory($c->getHTTPClientService()); |
|
1162 | - }); |
|
1163 | - |
|
1164 | - $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
1165 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
1166 | - return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
1167 | - }); |
|
1168 | - |
|
1169 | - $this->registerService(IContactsStore::class, function(Server $c) { |
|
1170 | - return new ContactsStore( |
|
1171 | - $c->getContactsManager(), |
|
1172 | - $c->getConfig(), |
|
1173 | - $c->getUserManager(), |
|
1174 | - $c->getGroupManager() |
|
1175 | - ); |
|
1176 | - }); |
|
1177 | - $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
1178 | - |
|
1179 | - $this->connectDispatcher(); |
|
1180 | - } |
|
1181 | - |
|
1182 | - /** |
|
1183 | - * @return \OCP\Calendar\IManager |
|
1184 | - */ |
|
1185 | - public function getCalendarManager() { |
|
1186 | - return $this->query('CalendarManager'); |
|
1187 | - } |
|
1188 | - |
|
1189 | - /** |
|
1190 | - * @return \OCP\Calendar\Resource\IManager |
|
1191 | - */ |
|
1192 | - public function getCalendarResourceBackendManager() { |
|
1193 | - return $this->query('CalendarResourceBackendManager'); |
|
1194 | - } |
|
1195 | - |
|
1196 | - /** |
|
1197 | - * @return \OCP\Calendar\Room\IManager |
|
1198 | - */ |
|
1199 | - public function getCalendarRoomBackendManager() { |
|
1200 | - return $this->query('CalendarRoomBackendManager'); |
|
1201 | - } |
|
1202 | - |
|
1203 | - private function connectDispatcher() { |
|
1204 | - $dispatcher = $this->getEventDispatcher(); |
|
1205 | - |
|
1206 | - // Delete avatar on user deletion |
|
1207 | - $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
1208 | - $logger = $this->getLogger(); |
|
1209 | - $manager = $this->getAvatarManager(); |
|
1210 | - /** @var IUser $user */ |
|
1211 | - $user = $e->getSubject(); |
|
1212 | - |
|
1213 | - try { |
|
1214 | - $avatar = $manager->getAvatar($user->getUID()); |
|
1215 | - $avatar->remove(); |
|
1216 | - } catch (NotFoundException $e) { |
|
1217 | - // no avatar to remove |
|
1218 | - } catch (\Exception $e) { |
|
1219 | - // Ignore exceptions |
|
1220 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1221 | - } |
|
1222 | - }); |
|
1223 | - |
|
1224 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1225 | - $manager = $this->getAvatarManager(); |
|
1226 | - /** @var IUser $user */ |
|
1227 | - $user = $e->getSubject(); |
|
1228 | - $feature = $e->getArgument('feature'); |
|
1229 | - $oldValue = $e->getArgument('oldValue'); |
|
1230 | - $value = $e->getArgument('value'); |
|
1231 | - |
|
1232 | - try { |
|
1233 | - $avatar = $manager->getAvatar($user->getUID()); |
|
1234 | - $avatar->userChanged($feature, $oldValue, $value); |
|
1235 | - } catch (NotFoundException $e) { |
|
1236 | - // no avatar to remove |
|
1237 | - } |
|
1238 | - }); |
|
1239 | - } |
|
1240 | - |
|
1241 | - /** |
|
1242 | - * @return \OCP\Contacts\IManager |
|
1243 | - */ |
|
1244 | - public function getContactsManager() { |
|
1245 | - return $this->query('ContactsManager'); |
|
1246 | - } |
|
1247 | - |
|
1248 | - /** |
|
1249 | - * @return \OC\Encryption\Manager |
|
1250 | - */ |
|
1251 | - public function getEncryptionManager() { |
|
1252 | - return $this->query('EncryptionManager'); |
|
1253 | - } |
|
1254 | - |
|
1255 | - /** |
|
1256 | - * @return \OC\Encryption\File |
|
1257 | - */ |
|
1258 | - public function getEncryptionFilesHelper() { |
|
1259 | - return $this->query('EncryptionFileHelper'); |
|
1260 | - } |
|
1261 | - |
|
1262 | - /** |
|
1263 | - * @return \OCP\Encryption\Keys\IStorage |
|
1264 | - */ |
|
1265 | - public function getEncryptionKeyStorage() { |
|
1266 | - return $this->query('EncryptionKeyStorage'); |
|
1267 | - } |
|
1268 | - |
|
1269 | - /** |
|
1270 | - * The current request object holding all information about the request |
|
1271 | - * currently being processed is returned from this method. |
|
1272 | - * In case the current execution was not initiated by a web request null is returned |
|
1273 | - * |
|
1274 | - * @return \OCP\IRequest |
|
1275 | - */ |
|
1276 | - public function getRequest() { |
|
1277 | - return $this->query('Request'); |
|
1278 | - } |
|
1279 | - |
|
1280 | - /** |
|
1281 | - * Returns the preview manager which can create preview images for a given file |
|
1282 | - * |
|
1283 | - * @return \OCP\IPreview |
|
1284 | - */ |
|
1285 | - public function getPreviewManager() { |
|
1286 | - return $this->query('PreviewManager'); |
|
1287 | - } |
|
1288 | - |
|
1289 | - /** |
|
1290 | - * Returns the tag manager which can get and set tags for different object types |
|
1291 | - * |
|
1292 | - * @see \OCP\ITagManager::load() |
|
1293 | - * @return \OCP\ITagManager |
|
1294 | - */ |
|
1295 | - public function getTagManager() { |
|
1296 | - return $this->query('TagManager'); |
|
1297 | - } |
|
1298 | - |
|
1299 | - /** |
|
1300 | - * Returns the system-tag manager |
|
1301 | - * |
|
1302 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1303 | - * |
|
1304 | - * @since 9.0.0 |
|
1305 | - */ |
|
1306 | - public function getSystemTagManager() { |
|
1307 | - return $this->query('SystemTagManager'); |
|
1308 | - } |
|
1309 | - |
|
1310 | - /** |
|
1311 | - * Returns the system-tag object mapper |
|
1312 | - * |
|
1313 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1314 | - * |
|
1315 | - * @since 9.0.0 |
|
1316 | - */ |
|
1317 | - public function getSystemTagObjectMapper() { |
|
1318 | - return $this->query('SystemTagObjectMapper'); |
|
1319 | - } |
|
1320 | - |
|
1321 | - /** |
|
1322 | - * Returns the avatar manager, used for avatar functionality |
|
1323 | - * |
|
1324 | - * @return \OCP\IAvatarManager |
|
1325 | - */ |
|
1326 | - public function getAvatarManager() { |
|
1327 | - return $this->query('AvatarManager'); |
|
1328 | - } |
|
1329 | - |
|
1330 | - /** |
|
1331 | - * Returns the root folder of ownCloud's data directory |
|
1332 | - * |
|
1333 | - * @return \OCP\Files\IRootFolder |
|
1334 | - */ |
|
1335 | - public function getRootFolder() { |
|
1336 | - return $this->query('LazyRootFolder'); |
|
1337 | - } |
|
1338 | - |
|
1339 | - /** |
|
1340 | - * Returns the root folder of ownCloud's data directory |
|
1341 | - * This is the lazy variant so this gets only initialized once it |
|
1342 | - * is actually used. |
|
1343 | - * |
|
1344 | - * @return \OCP\Files\IRootFolder |
|
1345 | - */ |
|
1346 | - public function getLazyRootFolder() { |
|
1347 | - return $this->query('LazyRootFolder'); |
|
1348 | - } |
|
1349 | - |
|
1350 | - /** |
|
1351 | - * Returns a view to ownCloud's files folder |
|
1352 | - * |
|
1353 | - * @param string $userId user ID |
|
1354 | - * @return \OCP\Files\Folder|null |
|
1355 | - */ |
|
1356 | - public function getUserFolder($userId = null) { |
|
1357 | - if ($userId === null) { |
|
1358 | - $user = $this->getUserSession()->getUser(); |
|
1359 | - if (!$user) { |
|
1360 | - return null; |
|
1361 | - } |
|
1362 | - $userId = $user->getUID(); |
|
1363 | - } |
|
1364 | - $root = $this->getRootFolder(); |
|
1365 | - return $root->getUserFolder($userId); |
|
1366 | - } |
|
1367 | - |
|
1368 | - /** |
|
1369 | - * Returns an app-specific view in ownClouds data directory |
|
1370 | - * |
|
1371 | - * @return \OCP\Files\Folder |
|
1372 | - * @deprecated since 9.2.0 use IAppData |
|
1373 | - */ |
|
1374 | - public function getAppFolder() { |
|
1375 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1376 | - $root = $this->getRootFolder(); |
|
1377 | - if (!$root->nodeExists($dir)) { |
|
1378 | - $folder = $root->newFolder($dir); |
|
1379 | - } else { |
|
1380 | - $folder = $root->get($dir); |
|
1381 | - } |
|
1382 | - return $folder; |
|
1383 | - } |
|
1384 | - |
|
1385 | - /** |
|
1386 | - * @return \OC\User\Manager |
|
1387 | - */ |
|
1388 | - public function getUserManager() { |
|
1389 | - return $this->query('UserManager'); |
|
1390 | - } |
|
1391 | - |
|
1392 | - /** |
|
1393 | - * @return \OC\Group\Manager |
|
1394 | - */ |
|
1395 | - public function getGroupManager() { |
|
1396 | - return $this->query('GroupManager'); |
|
1397 | - } |
|
1398 | - |
|
1399 | - /** |
|
1400 | - * @return \OC\User\Session |
|
1401 | - */ |
|
1402 | - public function getUserSession() { |
|
1403 | - return $this->query('UserSession'); |
|
1404 | - } |
|
1405 | - |
|
1406 | - /** |
|
1407 | - * @return \OCP\ISession |
|
1408 | - */ |
|
1409 | - public function getSession() { |
|
1410 | - return $this->query('UserSession')->getSession(); |
|
1411 | - } |
|
1412 | - |
|
1413 | - /** |
|
1414 | - * @param \OCP\ISession $session |
|
1415 | - */ |
|
1416 | - public function setSession(\OCP\ISession $session) { |
|
1417 | - $this->query(SessionStorage::class)->setSession($session); |
|
1418 | - $this->query('UserSession')->setSession($session); |
|
1419 | - $this->query(Store::class)->setSession($session); |
|
1420 | - } |
|
1421 | - |
|
1422 | - /** |
|
1423 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1424 | - */ |
|
1425 | - public function getTwoFactorAuthManager() { |
|
1426 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1427 | - } |
|
1428 | - |
|
1429 | - /** |
|
1430 | - * @return \OC\NavigationManager |
|
1431 | - */ |
|
1432 | - public function getNavigationManager() { |
|
1433 | - return $this->query('NavigationManager'); |
|
1434 | - } |
|
1435 | - |
|
1436 | - /** |
|
1437 | - * @return \OCP\IConfig |
|
1438 | - */ |
|
1439 | - public function getConfig() { |
|
1440 | - return $this->query('AllConfig'); |
|
1441 | - } |
|
1442 | - |
|
1443 | - /** |
|
1444 | - * @return \OC\SystemConfig |
|
1445 | - */ |
|
1446 | - public function getSystemConfig() { |
|
1447 | - return $this->query('SystemConfig'); |
|
1448 | - } |
|
1449 | - |
|
1450 | - /** |
|
1451 | - * Returns the app config manager |
|
1452 | - * |
|
1453 | - * @return \OCP\IAppConfig |
|
1454 | - */ |
|
1455 | - public function getAppConfig() { |
|
1456 | - return $this->query('AppConfig'); |
|
1457 | - } |
|
1458 | - |
|
1459 | - /** |
|
1460 | - * @return \OCP\L10N\IFactory |
|
1461 | - */ |
|
1462 | - public function getL10NFactory() { |
|
1463 | - return $this->query('L10NFactory'); |
|
1464 | - } |
|
1465 | - |
|
1466 | - /** |
|
1467 | - * get an L10N instance |
|
1468 | - * |
|
1469 | - * @param string $app appid |
|
1470 | - * @param string $lang |
|
1471 | - * @return IL10N |
|
1472 | - */ |
|
1473 | - public function getL10N($app, $lang = null) { |
|
1474 | - return $this->getL10NFactory()->get($app, $lang); |
|
1475 | - } |
|
1476 | - |
|
1477 | - /** |
|
1478 | - * @return \OCP\IURLGenerator |
|
1479 | - */ |
|
1480 | - public function getURLGenerator() { |
|
1481 | - return $this->query('URLGenerator'); |
|
1482 | - } |
|
1483 | - |
|
1484 | - /** |
|
1485 | - * @return AppFetcher |
|
1486 | - */ |
|
1487 | - public function getAppFetcher() { |
|
1488 | - return $this->query(AppFetcher::class); |
|
1489 | - } |
|
1490 | - |
|
1491 | - /** |
|
1492 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1493 | - * getMemCacheFactory() instead. |
|
1494 | - * |
|
1495 | - * @return \OCP\ICache |
|
1496 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1497 | - */ |
|
1498 | - public function getCache() { |
|
1499 | - return $this->query('UserCache'); |
|
1500 | - } |
|
1501 | - |
|
1502 | - /** |
|
1503 | - * Returns an \OCP\CacheFactory instance |
|
1504 | - * |
|
1505 | - * @return \OCP\ICacheFactory |
|
1506 | - */ |
|
1507 | - public function getMemCacheFactory() { |
|
1508 | - return $this->query('MemCacheFactory'); |
|
1509 | - } |
|
1510 | - |
|
1511 | - /** |
|
1512 | - * Returns an \OC\RedisFactory instance |
|
1513 | - * |
|
1514 | - * @return \OC\RedisFactory |
|
1515 | - */ |
|
1516 | - public function getGetRedisFactory() { |
|
1517 | - return $this->query('RedisFactory'); |
|
1518 | - } |
|
1519 | - |
|
1520 | - |
|
1521 | - /** |
|
1522 | - * Returns the current session |
|
1523 | - * |
|
1524 | - * @return \OCP\IDBConnection |
|
1525 | - */ |
|
1526 | - public function getDatabaseConnection() { |
|
1527 | - return $this->query('DatabaseConnection'); |
|
1528 | - } |
|
1529 | - |
|
1530 | - /** |
|
1531 | - * Returns the activity manager |
|
1532 | - * |
|
1533 | - * @return \OCP\Activity\IManager |
|
1534 | - */ |
|
1535 | - public function getActivityManager() { |
|
1536 | - return $this->query('ActivityManager'); |
|
1537 | - } |
|
1538 | - |
|
1539 | - /** |
|
1540 | - * Returns an job list for controlling background jobs |
|
1541 | - * |
|
1542 | - * @return \OCP\BackgroundJob\IJobList |
|
1543 | - */ |
|
1544 | - public function getJobList() { |
|
1545 | - return $this->query('JobList'); |
|
1546 | - } |
|
1547 | - |
|
1548 | - /** |
|
1549 | - * Returns a logger instance |
|
1550 | - * |
|
1551 | - * @return \OCP\ILogger |
|
1552 | - */ |
|
1553 | - public function getLogger() { |
|
1554 | - return $this->query('Logger'); |
|
1555 | - } |
|
1556 | - |
|
1557 | - /** |
|
1558 | - * @return ILogFactory |
|
1559 | - * @throws \OCP\AppFramework\QueryException |
|
1560 | - */ |
|
1561 | - public function getLogFactory() { |
|
1562 | - return $this->query(ILogFactory::class); |
|
1563 | - } |
|
1564 | - |
|
1565 | - /** |
|
1566 | - * Returns a router for generating and matching urls |
|
1567 | - * |
|
1568 | - * @return \OCP\Route\IRouter |
|
1569 | - */ |
|
1570 | - public function getRouter() { |
|
1571 | - return $this->query('Router'); |
|
1572 | - } |
|
1573 | - |
|
1574 | - /** |
|
1575 | - * Returns a search instance |
|
1576 | - * |
|
1577 | - * @return \OCP\ISearch |
|
1578 | - */ |
|
1579 | - public function getSearch() { |
|
1580 | - return $this->query('Search'); |
|
1581 | - } |
|
1582 | - |
|
1583 | - /** |
|
1584 | - * Returns a SecureRandom instance |
|
1585 | - * |
|
1586 | - * @return \OCP\Security\ISecureRandom |
|
1587 | - */ |
|
1588 | - public function getSecureRandom() { |
|
1589 | - return $this->query('SecureRandom'); |
|
1590 | - } |
|
1591 | - |
|
1592 | - /** |
|
1593 | - * Returns a Crypto instance |
|
1594 | - * |
|
1595 | - * @return \OCP\Security\ICrypto |
|
1596 | - */ |
|
1597 | - public function getCrypto() { |
|
1598 | - return $this->query('Crypto'); |
|
1599 | - } |
|
1600 | - |
|
1601 | - /** |
|
1602 | - * Returns a Hasher instance |
|
1603 | - * |
|
1604 | - * @return \OCP\Security\IHasher |
|
1605 | - */ |
|
1606 | - public function getHasher() { |
|
1607 | - return $this->query('Hasher'); |
|
1608 | - } |
|
1609 | - |
|
1610 | - /** |
|
1611 | - * Returns a CredentialsManager instance |
|
1612 | - * |
|
1613 | - * @return \OCP\Security\ICredentialsManager |
|
1614 | - */ |
|
1615 | - public function getCredentialsManager() { |
|
1616 | - return $this->query('CredentialsManager'); |
|
1617 | - } |
|
1618 | - |
|
1619 | - /** |
|
1620 | - * Get the certificate manager for the user |
|
1621 | - * |
|
1622 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1623 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1624 | - */ |
|
1625 | - public function getCertificateManager($userId = '') { |
|
1626 | - if ($userId === '') { |
|
1627 | - $userSession = $this->getUserSession(); |
|
1628 | - $user = $userSession->getUser(); |
|
1629 | - if (is_null($user)) { |
|
1630 | - return null; |
|
1631 | - } |
|
1632 | - $userId = $user->getUID(); |
|
1633 | - } |
|
1634 | - return new CertificateManager( |
|
1635 | - $userId, |
|
1636 | - new View(), |
|
1637 | - $this->getConfig(), |
|
1638 | - $this->getLogger(), |
|
1639 | - $this->getSecureRandom() |
|
1640 | - ); |
|
1641 | - } |
|
1642 | - |
|
1643 | - /** |
|
1644 | - * Returns an instance of the HTTP client service |
|
1645 | - * |
|
1646 | - * @return \OCP\Http\Client\IClientService |
|
1647 | - */ |
|
1648 | - public function getHTTPClientService() { |
|
1649 | - return $this->query('HttpClientService'); |
|
1650 | - } |
|
1651 | - |
|
1652 | - /** |
|
1653 | - * Create a new event source |
|
1654 | - * |
|
1655 | - * @return \OCP\IEventSource |
|
1656 | - */ |
|
1657 | - public function createEventSource() { |
|
1658 | - return new \OC_EventSource(); |
|
1659 | - } |
|
1660 | - |
|
1661 | - /** |
|
1662 | - * Get the active event logger |
|
1663 | - * |
|
1664 | - * The returned logger only logs data when debug mode is enabled |
|
1665 | - * |
|
1666 | - * @return \OCP\Diagnostics\IEventLogger |
|
1667 | - */ |
|
1668 | - public function getEventLogger() { |
|
1669 | - return $this->query('EventLogger'); |
|
1670 | - } |
|
1671 | - |
|
1672 | - /** |
|
1673 | - * Get the active query logger |
|
1674 | - * |
|
1675 | - * The returned logger only logs data when debug mode is enabled |
|
1676 | - * |
|
1677 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1678 | - */ |
|
1679 | - public function getQueryLogger() { |
|
1680 | - return $this->query('QueryLogger'); |
|
1681 | - } |
|
1682 | - |
|
1683 | - /** |
|
1684 | - * Get the manager for temporary files and folders |
|
1685 | - * |
|
1686 | - * @return \OCP\ITempManager |
|
1687 | - */ |
|
1688 | - public function getTempManager() { |
|
1689 | - return $this->query('TempManager'); |
|
1690 | - } |
|
1691 | - |
|
1692 | - /** |
|
1693 | - * Get the app manager |
|
1694 | - * |
|
1695 | - * @return \OCP\App\IAppManager |
|
1696 | - */ |
|
1697 | - public function getAppManager() { |
|
1698 | - return $this->query('AppManager'); |
|
1699 | - } |
|
1700 | - |
|
1701 | - /** |
|
1702 | - * Creates a new mailer |
|
1703 | - * |
|
1704 | - * @return \OCP\Mail\IMailer |
|
1705 | - */ |
|
1706 | - public function getMailer() { |
|
1707 | - return $this->query('Mailer'); |
|
1708 | - } |
|
1709 | - |
|
1710 | - /** |
|
1711 | - * Get the webroot |
|
1712 | - * |
|
1713 | - * @return string |
|
1714 | - */ |
|
1715 | - public function getWebRoot() { |
|
1716 | - return $this->webRoot; |
|
1717 | - } |
|
1718 | - |
|
1719 | - /** |
|
1720 | - * @return \OC\OCSClient |
|
1721 | - */ |
|
1722 | - public function getOcsClient() { |
|
1723 | - return $this->query('OcsClient'); |
|
1724 | - } |
|
1725 | - |
|
1726 | - /** |
|
1727 | - * @return \OCP\IDateTimeZone |
|
1728 | - */ |
|
1729 | - public function getDateTimeZone() { |
|
1730 | - return $this->query('DateTimeZone'); |
|
1731 | - } |
|
1732 | - |
|
1733 | - /** |
|
1734 | - * @return \OCP\IDateTimeFormatter |
|
1735 | - */ |
|
1736 | - public function getDateTimeFormatter() { |
|
1737 | - return $this->query('DateTimeFormatter'); |
|
1738 | - } |
|
1739 | - |
|
1740 | - /** |
|
1741 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1742 | - */ |
|
1743 | - public function getMountProviderCollection() { |
|
1744 | - return $this->query('MountConfigManager'); |
|
1745 | - } |
|
1746 | - |
|
1747 | - /** |
|
1748 | - * Get the IniWrapper |
|
1749 | - * |
|
1750 | - * @return IniGetWrapper |
|
1751 | - */ |
|
1752 | - public function getIniWrapper() { |
|
1753 | - return $this->query('IniWrapper'); |
|
1754 | - } |
|
1755 | - |
|
1756 | - /** |
|
1757 | - * @return \OCP\Command\IBus |
|
1758 | - */ |
|
1759 | - public function getCommandBus() { |
|
1760 | - return $this->query('AsyncCommandBus'); |
|
1761 | - } |
|
1762 | - |
|
1763 | - /** |
|
1764 | - * Get the trusted domain helper |
|
1765 | - * |
|
1766 | - * @return TrustedDomainHelper |
|
1767 | - */ |
|
1768 | - public function getTrustedDomainHelper() { |
|
1769 | - return $this->query('TrustedDomainHelper'); |
|
1770 | - } |
|
1771 | - |
|
1772 | - /** |
|
1773 | - * Get the locking provider |
|
1774 | - * |
|
1775 | - * @return \OCP\Lock\ILockingProvider |
|
1776 | - * @since 8.1.0 |
|
1777 | - */ |
|
1778 | - public function getLockingProvider() { |
|
1779 | - return $this->query('LockingProvider'); |
|
1780 | - } |
|
1781 | - |
|
1782 | - /** |
|
1783 | - * @return \OCP\Files\Mount\IMountManager |
|
1784 | - **/ |
|
1785 | - function getMountManager() { |
|
1786 | - return $this->query('MountManager'); |
|
1787 | - } |
|
1788 | - |
|
1789 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1790 | - function getUserMountCache() { |
|
1791 | - return $this->query('UserMountCache'); |
|
1792 | - } |
|
1793 | - |
|
1794 | - /** |
|
1795 | - * Get the MimeTypeDetector |
|
1796 | - * |
|
1797 | - * @return \OCP\Files\IMimeTypeDetector |
|
1798 | - */ |
|
1799 | - public function getMimeTypeDetector() { |
|
1800 | - return $this->query('MimeTypeDetector'); |
|
1801 | - } |
|
1802 | - |
|
1803 | - /** |
|
1804 | - * Get the MimeTypeLoader |
|
1805 | - * |
|
1806 | - * @return \OCP\Files\IMimeTypeLoader |
|
1807 | - */ |
|
1808 | - public function getMimeTypeLoader() { |
|
1809 | - return $this->query('MimeTypeLoader'); |
|
1810 | - } |
|
1811 | - |
|
1812 | - /** |
|
1813 | - * Get the manager of all the capabilities |
|
1814 | - * |
|
1815 | - * @return \OC\CapabilitiesManager |
|
1816 | - */ |
|
1817 | - public function getCapabilitiesManager() { |
|
1818 | - return $this->query('CapabilitiesManager'); |
|
1819 | - } |
|
1820 | - |
|
1821 | - /** |
|
1822 | - * Get the EventDispatcher |
|
1823 | - * |
|
1824 | - * @return EventDispatcherInterface |
|
1825 | - * @since 8.2.0 |
|
1826 | - */ |
|
1827 | - public function getEventDispatcher() { |
|
1828 | - return $this->query('EventDispatcher'); |
|
1829 | - } |
|
1830 | - |
|
1831 | - /** |
|
1832 | - * Get the Notification Manager |
|
1833 | - * |
|
1834 | - * @return \OCP\Notification\IManager |
|
1835 | - * @since 8.2.0 |
|
1836 | - */ |
|
1837 | - public function getNotificationManager() { |
|
1838 | - return $this->query('NotificationManager'); |
|
1839 | - } |
|
1840 | - |
|
1841 | - /** |
|
1842 | - * @return \OCP\Comments\ICommentsManager |
|
1843 | - */ |
|
1844 | - public function getCommentsManager() { |
|
1845 | - return $this->query('CommentsManager'); |
|
1846 | - } |
|
1847 | - |
|
1848 | - /** |
|
1849 | - * @return \OCA\Theming\ThemingDefaults |
|
1850 | - */ |
|
1851 | - public function getThemingDefaults() { |
|
1852 | - return $this->query('ThemingDefaults'); |
|
1853 | - } |
|
1854 | - |
|
1855 | - /** |
|
1856 | - * @return \OC\IntegrityCheck\Checker |
|
1857 | - */ |
|
1858 | - public function getIntegrityCodeChecker() { |
|
1859 | - return $this->query('IntegrityCodeChecker'); |
|
1860 | - } |
|
1861 | - |
|
1862 | - /** |
|
1863 | - * @return \OC\Session\CryptoWrapper |
|
1864 | - */ |
|
1865 | - public function getSessionCryptoWrapper() { |
|
1866 | - return $this->query('CryptoWrapper'); |
|
1867 | - } |
|
1868 | - |
|
1869 | - /** |
|
1870 | - * @return CsrfTokenManager |
|
1871 | - */ |
|
1872 | - public function getCsrfTokenManager() { |
|
1873 | - return $this->query('CsrfTokenManager'); |
|
1874 | - } |
|
1875 | - |
|
1876 | - /** |
|
1877 | - * @return Throttler |
|
1878 | - */ |
|
1879 | - public function getBruteForceThrottler() { |
|
1880 | - return $this->query('Throttler'); |
|
1881 | - } |
|
1882 | - |
|
1883 | - /** |
|
1884 | - * @return IContentSecurityPolicyManager |
|
1885 | - */ |
|
1886 | - public function getContentSecurityPolicyManager() { |
|
1887 | - return $this->query('ContentSecurityPolicyManager'); |
|
1888 | - } |
|
1889 | - |
|
1890 | - /** |
|
1891 | - * @return ContentSecurityPolicyNonceManager |
|
1892 | - */ |
|
1893 | - public function getContentSecurityPolicyNonceManager() { |
|
1894 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1895 | - } |
|
1896 | - |
|
1897 | - /** |
|
1898 | - * Not a public API as of 8.2, wait for 9.0 |
|
1899 | - * |
|
1900 | - * @return \OCA\Files_External\Service\BackendService |
|
1901 | - */ |
|
1902 | - public function getStoragesBackendService() { |
|
1903 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1904 | - } |
|
1905 | - |
|
1906 | - /** |
|
1907 | - * Not a public API as of 8.2, wait for 9.0 |
|
1908 | - * |
|
1909 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1910 | - */ |
|
1911 | - public function getGlobalStoragesService() { |
|
1912 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1913 | - } |
|
1914 | - |
|
1915 | - /** |
|
1916 | - * Not a public API as of 8.2, wait for 9.0 |
|
1917 | - * |
|
1918 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1919 | - */ |
|
1920 | - public function getUserGlobalStoragesService() { |
|
1921 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1922 | - } |
|
1923 | - |
|
1924 | - /** |
|
1925 | - * Not a public API as of 8.2, wait for 9.0 |
|
1926 | - * |
|
1927 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1928 | - */ |
|
1929 | - public function getUserStoragesService() { |
|
1930 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1931 | - } |
|
1932 | - |
|
1933 | - /** |
|
1934 | - * @return \OCP\Share\IManager |
|
1935 | - */ |
|
1936 | - public function getShareManager() { |
|
1937 | - return $this->query('ShareManager'); |
|
1938 | - } |
|
1939 | - |
|
1940 | - /** |
|
1941 | - * @return \OCP\Collaboration\Collaborators\ISearch |
|
1942 | - */ |
|
1943 | - public function getCollaboratorSearch() { |
|
1944 | - return $this->query('CollaboratorSearch'); |
|
1945 | - } |
|
1946 | - |
|
1947 | - /** |
|
1948 | - * @return \OCP\Collaboration\AutoComplete\IManager |
|
1949 | - */ |
|
1950 | - public function getAutoCompleteManager(){ |
|
1951 | - return $this->query(IManager::class); |
|
1952 | - } |
|
1953 | - |
|
1954 | - /** |
|
1955 | - * Returns the LDAP Provider |
|
1956 | - * |
|
1957 | - * @return \OCP\LDAP\ILDAPProvider |
|
1958 | - */ |
|
1959 | - public function getLDAPProvider() { |
|
1960 | - return $this->query('LDAPProvider'); |
|
1961 | - } |
|
1962 | - |
|
1963 | - /** |
|
1964 | - * @return \OCP\Settings\IManager |
|
1965 | - */ |
|
1966 | - public function getSettingsManager() { |
|
1967 | - return $this->query('SettingsManager'); |
|
1968 | - } |
|
1969 | - |
|
1970 | - /** |
|
1971 | - * @return \OCP\Files\IAppData |
|
1972 | - */ |
|
1973 | - public function getAppDataDir($app) { |
|
1974 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1975 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1976 | - return $factory->get($app); |
|
1977 | - } |
|
1978 | - |
|
1979 | - /** |
|
1980 | - * @return \OCP\Lockdown\ILockdownManager |
|
1981 | - */ |
|
1982 | - public function getLockdownManager() { |
|
1983 | - return $this->query('LockdownManager'); |
|
1984 | - } |
|
1985 | - |
|
1986 | - /** |
|
1987 | - * @return \OCP\Federation\ICloudIdManager |
|
1988 | - */ |
|
1989 | - public function getCloudIdManager() { |
|
1990 | - return $this->query(ICloudIdManager::class); |
|
1991 | - } |
|
1992 | - |
|
1993 | - /** |
|
1994 | - * @return \OCP\GlobalScale\IConfig |
|
1995 | - */ |
|
1996 | - public function getGlobalScaleConfig() { |
|
1997 | - return $this->query(IConfig::class); |
|
1998 | - } |
|
1999 | - |
|
2000 | - /** |
|
2001 | - * @return \OCP\Federation\ICloudFederationProviderManager |
|
2002 | - */ |
|
2003 | - public function getCloudFederationProviderManager() { |
|
2004 | - return $this->query(ICloudFederationProviderManager::class); |
|
2005 | - } |
|
2006 | - |
|
2007 | - /** |
|
2008 | - * @return \OCP\Remote\Api\IApiFactory |
|
2009 | - */ |
|
2010 | - public function getRemoteApiFactory() { |
|
2011 | - return $this->query(IApiFactory::class); |
|
2012 | - } |
|
2013 | - |
|
2014 | - /** |
|
2015 | - * @return \OCP\Federation\ICloudFederationFactory |
|
2016 | - */ |
|
2017 | - public function getCloudFederationFactory() { |
|
2018 | - return $this->query(ICloudFederationFactory::class); |
|
2019 | - } |
|
2020 | - |
|
2021 | - /** |
|
2022 | - * @return \OCP\Remote\IInstanceFactory |
|
2023 | - */ |
|
2024 | - public function getRemoteInstanceFactory() { |
|
2025 | - return $this->query(IInstanceFactory::class); |
|
2026 | - } |
|
935 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
936 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
937 | + $classExists = true; |
|
938 | + } else { |
|
939 | + $classExists = false; |
|
940 | + } |
|
941 | + |
|
942 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
943 | + return new ThemingDefaults( |
|
944 | + $c->getConfig(), |
|
945 | + $c->getL10N('theming'), |
|
946 | + $c->getURLGenerator(), |
|
947 | + $c->getMemCacheFactory(), |
|
948 | + new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
949 | + new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
950 | + $c->getAppManager() |
|
951 | + ); |
|
952 | + } |
|
953 | + return new \OC_Defaults(); |
|
954 | + }); |
|
955 | + $this->registerService(SCSSCacher::class, function (Server $c) { |
|
956 | + /** @var Factory $cacheFactory */ |
|
957 | + $cacheFactory = $c->query(Factory::class); |
|
958 | + return new SCSSCacher( |
|
959 | + $c->getLogger(), |
|
960 | + $c->query(\OC\Files\AppData\Factory::class), |
|
961 | + $c->getURLGenerator(), |
|
962 | + $c->getConfig(), |
|
963 | + $c->getThemingDefaults(), |
|
964 | + \OC::$SERVERROOT, |
|
965 | + $this->getMemCacheFactory() |
|
966 | + ); |
|
967 | + }); |
|
968 | + $this->registerService(JSCombiner::class, function (Server $c) { |
|
969 | + /** @var Factory $cacheFactory */ |
|
970 | + $cacheFactory = $c->query(Factory::class); |
|
971 | + return new JSCombiner( |
|
972 | + $c->getAppDataDir('js'), |
|
973 | + $c->getURLGenerator(), |
|
974 | + $this->getMemCacheFactory(), |
|
975 | + $c->getSystemConfig(), |
|
976 | + $c->getLogger() |
|
977 | + ); |
|
978 | + }); |
|
979 | + $this->registerService(EventDispatcher::class, function () { |
|
980 | + return new EventDispatcher(); |
|
981 | + }); |
|
982 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
983 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
984 | + |
|
985 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
986 | + // FIXME: Instantiiated here due to cyclic dependency |
|
987 | + $request = new Request( |
|
988 | + [ |
|
989 | + 'get' => $_GET, |
|
990 | + 'post' => $_POST, |
|
991 | + 'files' => $_FILES, |
|
992 | + 'server' => $_SERVER, |
|
993 | + 'env' => $_ENV, |
|
994 | + 'cookies' => $_COOKIE, |
|
995 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
996 | + ? $_SERVER['REQUEST_METHOD'] |
|
997 | + : null, |
|
998 | + ], |
|
999 | + $c->getSecureRandom(), |
|
1000 | + $c->getConfig() |
|
1001 | + ); |
|
1002 | + |
|
1003 | + return new CryptoWrapper( |
|
1004 | + $c->getConfig(), |
|
1005 | + $c->getCrypto(), |
|
1006 | + $c->getSecureRandom(), |
|
1007 | + $request |
|
1008 | + ); |
|
1009 | + }); |
|
1010 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1011 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
1012 | + |
|
1013 | + return new CsrfTokenManager( |
|
1014 | + $tokenGenerator, |
|
1015 | + $c->query(SessionStorage::class) |
|
1016 | + ); |
|
1017 | + }); |
|
1018 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
1019 | + return new SessionStorage($c->getSession()); |
|
1020 | + }); |
|
1021 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1022 | + return new ContentSecurityPolicyManager(); |
|
1023 | + }); |
|
1024 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
1025 | + |
|
1026 | + $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1027 | + return new ContentSecurityPolicyNonceManager( |
|
1028 | + $c->getCsrfTokenManager(), |
|
1029 | + $c->getRequest() |
|
1030 | + ); |
|
1031 | + }); |
|
1032 | + |
|
1033 | + $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1034 | + $config = $c->getConfig(); |
|
1035 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
1036 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
1037 | + $factory = new $factoryClass($this); |
|
1038 | + |
|
1039 | + $manager = new \OC\Share20\Manager( |
|
1040 | + $c->getLogger(), |
|
1041 | + $c->getConfig(), |
|
1042 | + $c->getSecureRandom(), |
|
1043 | + $c->getHasher(), |
|
1044 | + $c->getMountManager(), |
|
1045 | + $c->getGroupManager(), |
|
1046 | + $c->getL10N('lib'), |
|
1047 | + $c->getL10NFactory(), |
|
1048 | + $factory, |
|
1049 | + $c->getUserManager(), |
|
1050 | + $c->getLazyRootFolder(), |
|
1051 | + $c->getEventDispatcher(), |
|
1052 | + $c->getMailer(), |
|
1053 | + $c->getURLGenerator(), |
|
1054 | + $c->getThemingDefaults() |
|
1055 | + ); |
|
1056 | + |
|
1057 | + return $manager; |
|
1058 | + }); |
|
1059 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
1060 | + |
|
1061 | + $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
1062 | + $instance = new Collaboration\Collaborators\Search($c); |
|
1063 | + |
|
1064 | + // register default plugins |
|
1065 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
1066 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
1067 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
1068 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
1069 | + |
|
1070 | + return $instance; |
|
1071 | + }); |
|
1072 | + $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
1073 | + |
|
1074 | + $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
1075 | + |
|
1076 | + $this->registerService('SettingsManager', function (Server $c) { |
|
1077 | + $manager = new \OC\Settings\Manager( |
|
1078 | + $c->getLogger(), |
|
1079 | + $c->getDatabaseConnection(), |
|
1080 | + $c->getL10N('lib'), |
|
1081 | + $c->getConfig(), |
|
1082 | + $c->getEncryptionManager(), |
|
1083 | + $c->getUserManager(), |
|
1084 | + $c->getLockingProvider(), |
|
1085 | + $c->getRequest(), |
|
1086 | + $c->getURLGenerator(), |
|
1087 | + $c->query(AccountManager::class), |
|
1088 | + $c->getGroupManager(), |
|
1089 | + $c->getL10NFactory(), |
|
1090 | + $c->getAppManager() |
|
1091 | + ); |
|
1092 | + return $manager; |
|
1093 | + }); |
|
1094 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1095 | + return new \OC\Files\AppData\Factory( |
|
1096 | + $c->getRootFolder(), |
|
1097 | + $c->getSystemConfig() |
|
1098 | + ); |
|
1099 | + }); |
|
1100 | + |
|
1101 | + $this->registerService('LockdownManager', function (Server $c) { |
|
1102 | + return new LockdownManager(function () use ($c) { |
|
1103 | + return $c->getSession(); |
|
1104 | + }); |
|
1105 | + }); |
|
1106 | + |
|
1107 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1108 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
1109 | + }); |
|
1110 | + |
|
1111 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1112 | + return new CloudIdManager(); |
|
1113 | + }); |
|
1114 | + |
|
1115 | + $this->registerService(IConfig::class, function (Server $c) { |
|
1116 | + return new GlobalScale\Config($c->getConfig()); |
|
1117 | + }); |
|
1118 | + |
|
1119 | + $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
1120 | + return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
|
1121 | + }); |
|
1122 | + |
|
1123 | + $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
1124 | + return new CloudFederationFactory(); |
|
1125 | + }); |
|
1126 | + |
|
1127 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1128 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1129 | + |
|
1130 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1131 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1132 | + |
|
1133 | + $this->registerService(Defaults::class, function (Server $c) { |
|
1134 | + return new Defaults( |
|
1135 | + $c->getThemingDefaults() |
|
1136 | + ); |
|
1137 | + }); |
|
1138 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1139 | + |
|
1140 | + $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1141 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1142 | + }); |
|
1143 | + |
|
1144 | + $this->registerService(IShareHelper::class, function (Server $c) { |
|
1145 | + return new ShareHelper( |
|
1146 | + $c->query(\OCP\Share\IManager::class) |
|
1147 | + ); |
|
1148 | + }); |
|
1149 | + |
|
1150 | + $this->registerService(Installer::class, function(Server $c) { |
|
1151 | + return new Installer( |
|
1152 | + $c->getAppFetcher(), |
|
1153 | + $c->getHTTPClientService(), |
|
1154 | + $c->getTempManager(), |
|
1155 | + $c->getLogger(), |
|
1156 | + $c->getConfig() |
|
1157 | + ); |
|
1158 | + }); |
|
1159 | + |
|
1160 | + $this->registerService(IApiFactory::class, function(Server $c) { |
|
1161 | + return new ApiFactory($c->getHTTPClientService()); |
|
1162 | + }); |
|
1163 | + |
|
1164 | + $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
1165 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
1166 | + return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
1167 | + }); |
|
1168 | + |
|
1169 | + $this->registerService(IContactsStore::class, function(Server $c) { |
|
1170 | + return new ContactsStore( |
|
1171 | + $c->getContactsManager(), |
|
1172 | + $c->getConfig(), |
|
1173 | + $c->getUserManager(), |
|
1174 | + $c->getGroupManager() |
|
1175 | + ); |
|
1176 | + }); |
|
1177 | + $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
1178 | + |
|
1179 | + $this->connectDispatcher(); |
|
1180 | + } |
|
1181 | + |
|
1182 | + /** |
|
1183 | + * @return \OCP\Calendar\IManager |
|
1184 | + */ |
|
1185 | + public function getCalendarManager() { |
|
1186 | + return $this->query('CalendarManager'); |
|
1187 | + } |
|
1188 | + |
|
1189 | + /** |
|
1190 | + * @return \OCP\Calendar\Resource\IManager |
|
1191 | + */ |
|
1192 | + public function getCalendarResourceBackendManager() { |
|
1193 | + return $this->query('CalendarResourceBackendManager'); |
|
1194 | + } |
|
1195 | + |
|
1196 | + /** |
|
1197 | + * @return \OCP\Calendar\Room\IManager |
|
1198 | + */ |
|
1199 | + public function getCalendarRoomBackendManager() { |
|
1200 | + return $this->query('CalendarRoomBackendManager'); |
|
1201 | + } |
|
1202 | + |
|
1203 | + private function connectDispatcher() { |
|
1204 | + $dispatcher = $this->getEventDispatcher(); |
|
1205 | + |
|
1206 | + // Delete avatar on user deletion |
|
1207 | + $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
1208 | + $logger = $this->getLogger(); |
|
1209 | + $manager = $this->getAvatarManager(); |
|
1210 | + /** @var IUser $user */ |
|
1211 | + $user = $e->getSubject(); |
|
1212 | + |
|
1213 | + try { |
|
1214 | + $avatar = $manager->getAvatar($user->getUID()); |
|
1215 | + $avatar->remove(); |
|
1216 | + } catch (NotFoundException $e) { |
|
1217 | + // no avatar to remove |
|
1218 | + } catch (\Exception $e) { |
|
1219 | + // Ignore exceptions |
|
1220 | + $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1221 | + } |
|
1222 | + }); |
|
1223 | + |
|
1224 | + $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1225 | + $manager = $this->getAvatarManager(); |
|
1226 | + /** @var IUser $user */ |
|
1227 | + $user = $e->getSubject(); |
|
1228 | + $feature = $e->getArgument('feature'); |
|
1229 | + $oldValue = $e->getArgument('oldValue'); |
|
1230 | + $value = $e->getArgument('value'); |
|
1231 | + |
|
1232 | + try { |
|
1233 | + $avatar = $manager->getAvatar($user->getUID()); |
|
1234 | + $avatar->userChanged($feature, $oldValue, $value); |
|
1235 | + } catch (NotFoundException $e) { |
|
1236 | + // no avatar to remove |
|
1237 | + } |
|
1238 | + }); |
|
1239 | + } |
|
1240 | + |
|
1241 | + /** |
|
1242 | + * @return \OCP\Contacts\IManager |
|
1243 | + */ |
|
1244 | + public function getContactsManager() { |
|
1245 | + return $this->query('ContactsManager'); |
|
1246 | + } |
|
1247 | + |
|
1248 | + /** |
|
1249 | + * @return \OC\Encryption\Manager |
|
1250 | + */ |
|
1251 | + public function getEncryptionManager() { |
|
1252 | + return $this->query('EncryptionManager'); |
|
1253 | + } |
|
1254 | + |
|
1255 | + /** |
|
1256 | + * @return \OC\Encryption\File |
|
1257 | + */ |
|
1258 | + public function getEncryptionFilesHelper() { |
|
1259 | + return $this->query('EncryptionFileHelper'); |
|
1260 | + } |
|
1261 | + |
|
1262 | + /** |
|
1263 | + * @return \OCP\Encryption\Keys\IStorage |
|
1264 | + */ |
|
1265 | + public function getEncryptionKeyStorage() { |
|
1266 | + return $this->query('EncryptionKeyStorage'); |
|
1267 | + } |
|
1268 | + |
|
1269 | + /** |
|
1270 | + * The current request object holding all information about the request |
|
1271 | + * currently being processed is returned from this method. |
|
1272 | + * In case the current execution was not initiated by a web request null is returned |
|
1273 | + * |
|
1274 | + * @return \OCP\IRequest |
|
1275 | + */ |
|
1276 | + public function getRequest() { |
|
1277 | + return $this->query('Request'); |
|
1278 | + } |
|
1279 | + |
|
1280 | + /** |
|
1281 | + * Returns the preview manager which can create preview images for a given file |
|
1282 | + * |
|
1283 | + * @return \OCP\IPreview |
|
1284 | + */ |
|
1285 | + public function getPreviewManager() { |
|
1286 | + return $this->query('PreviewManager'); |
|
1287 | + } |
|
1288 | + |
|
1289 | + /** |
|
1290 | + * Returns the tag manager which can get and set tags for different object types |
|
1291 | + * |
|
1292 | + * @see \OCP\ITagManager::load() |
|
1293 | + * @return \OCP\ITagManager |
|
1294 | + */ |
|
1295 | + public function getTagManager() { |
|
1296 | + return $this->query('TagManager'); |
|
1297 | + } |
|
1298 | + |
|
1299 | + /** |
|
1300 | + * Returns the system-tag manager |
|
1301 | + * |
|
1302 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1303 | + * |
|
1304 | + * @since 9.0.0 |
|
1305 | + */ |
|
1306 | + public function getSystemTagManager() { |
|
1307 | + return $this->query('SystemTagManager'); |
|
1308 | + } |
|
1309 | + |
|
1310 | + /** |
|
1311 | + * Returns the system-tag object mapper |
|
1312 | + * |
|
1313 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1314 | + * |
|
1315 | + * @since 9.0.0 |
|
1316 | + */ |
|
1317 | + public function getSystemTagObjectMapper() { |
|
1318 | + return $this->query('SystemTagObjectMapper'); |
|
1319 | + } |
|
1320 | + |
|
1321 | + /** |
|
1322 | + * Returns the avatar manager, used for avatar functionality |
|
1323 | + * |
|
1324 | + * @return \OCP\IAvatarManager |
|
1325 | + */ |
|
1326 | + public function getAvatarManager() { |
|
1327 | + return $this->query('AvatarManager'); |
|
1328 | + } |
|
1329 | + |
|
1330 | + /** |
|
1331 | + * Returns the root folder of ownCloud's data directory |
|
1332 | + * |
|
1333 | + * @return \OCP\Files\IRootFolder |
|
1334 | + */ |
|
1335 | + public function getRootFolder() { |
|
1336 | + return $this->query('LazyRootFolder'); |
|
1337 | + } |
|
1338 | + |
|
1339 | + /** |
|
1340 | + * Returns the root folder of ownCloud's data directory |
|
1341 | + * This is the lazy variant so this gets only initialized once it |
|
1342 | + * is actually used. |
|
1343 | + * |
|
1344 | + * @return \OCP\Files\IRootFolder |
|
1345 | + */ |
|
1346 | + public function getLazyRootFolder() { |
|
1347 | + return $this->query('LazyRootFolder'); |
|
1348 | + } |
|
1349 | + |
|
1350 | + /** |
|
1351 | + * Returns a view to ownCloud's files folder |
|
1352 | + * |
|
1353 | + * @param string $userId user ID |
|
1354 | + * @return \OCP\Files\Folder|null |
|
1355 | + */ |
|
1356 | + public function getUserFolder($userId = null) { |
|
1357 | + if ($userId === null) { |
|
1358 | + $user = $this->getUserSession()->getUser(); |
|
1359 | + if (!$user) { |
|
1360 | + return null; |
|
1361 | + } |
|
1362 | + $userId = $user->getUID(); |
|
1363 | + } |
|
1364 | + $root = $this->getRootFolder(); |
|
1365 | + return $root->getUserFolder($userId); |
|
1366 | + } |
|
1367 | + |
|
1368 | + /** |
|
1369 | + * Returns an app-specific view in ownClouds data directory |
|
1370 | + * |
|
1371 | + * @return \OCP\Files\Folder |
|
1372 | + * @deprecated since 9.2.0 use IAppData |
|
1373 | + */ |
|
1374 | + public function getAppFolder() { |
|
1375 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1376 | + $root = $this->getRootFolder(); |
|
1377 | + if (!$root->nodeExists($dir)) { |
|
1378 | + $folder = $root->newFolder($dir); |
|
1379 | + } else { |
|
1380 | + $folder = $root->get($dir); |
|
1381 | + } |
|
1382 | + return $folder; |
|
1383 | + } |
|
1384 | + |
|
1385 | + /** |
|
1386 | + * @return \OC\User\Manager |
|
1387 | + */ |
|
1388 | + public function getUserManager() { |
|
1389 | + return $this->query('UserManager'); |
|
1390 | + } |
|
1391 | + |
|
1392 | + /** |
|
1393 | + * @return \OC\Group\Manager |
|
1394 | + */ |
|
1395 | + public function getGroupManager() { |
|
1396 | + return $this->query('GroupManager'); |
|
1397 | + } |
|
1398 | + |
|
1399 | + /** |
|
1400 | + * @return \OC\User\Session |
|
1401 | + */ |
|
1402 | + public function getUserSession() { |
|
1403 | + return $this->query('UserSession'); |
|
1404 | + } |
|
1405 | + |
|
1406 | + /** |
|
1407 | + * @return \OCP\ISession |
|
1408 | + */ |
|
1409 | + public function getSession() { |
|
1410 | + return $this->query('UserSession')->getSession(); |
|
1411 | + } |
|
1412 | + |
|
1413 | + /** |
|
1414 | + * @param \OCP\ISession $session |
|
1415 | + */ |
|
1416 | + public function setSession(\OCP\ISession $session) { |
|
1417 | + $this->query(SessionStorage::class)->setSession($session); |
|
1418 | + $this->query('UserSession')->setSession($session); |
|
1419 | + $this->query(Store::class)->setSession($session); |
|
1420 | + } |
|
1421 | + |
|
1422 | + /** |
|
1423 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1424 | + */ |
|
1425 | + public function getTwoFactorAuthManager() { |
|
1426 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1427 | + } |
|
1428 | + |
|
1429 | + /** |
|
1430 | + * @return \OC\NavigationManager |
|
1431 | + */ |
|
1432 | + public function getNavigationManager() { |
|
1433 | + return $this->query('NavigationManager'); |
|
1434 | + } |
|
1435 | + |
|
1436 | + /** |
|
1437 | + * @return \OCP\IConfig |
|
1438 | + */ |
|
1439 | + public function getConfig() { |
|
1440 | + return $this->query('AllConfig'); |
|
1441 | + } |
|
1442 | + |
|
1443 | + /** |
|
1444 | + * @return \OC\SystemConfig |
|
1445 | + */ |
|
1446 | + public function getSystemConfig() { |
|
1447 | + return $this->query('SystemConfig'); |
|
1448 | + } |
|
1449 | + |
|
1450 | + /** |
|
1451 | + * Returns the app config manager |
|
1452 | + * |
|
1453 | + * @return \OCP\IAppConfig |
|
1454 | + */ |
|
1455 | + public function getAppConfig() { |
|
1456 | + return $this->query('AppConfig'); |
|
1457 | + } |
|
1458 | + |
|
1459 | + /** |
|
1460 | + * @return \OCP\L10N\IFactory |
|
1461 | + */ |
|
1462 | + public function getL10NFactory() { |
|
1463 | + return $this->query('L10NFactory'); |
|
1464 | + } |
|
1465 | + |
|
1466 | + /** |
|
1467 | + * get an L10N instance |
|
1468 | + * |
|
1469 | + * @param string $app appid |
|
1470 | + * @param string $lang |
|
1471 | + * @return IL10N |
|
1472 | + */ |
|
1473 | + public function getL10N($app, $lang = null) { |
|
1474 | + return $this->getL10NFactory()->get($app, $lang); |
|
1475 | + } |
|
1476 | + |
|
1477 | + /** |
|
1478 | + * @return \OCP\IURLGenerator |
|
1479 | + */ |
|
1480 | + public function getURLGenerator() { |
|
1481 | + return $this->query('URLGenerator'); |
|
1482 | + } |
|
1483 | + |
|
1484 | + /** |
|
1485 | + * @return AppFetcher |
|
1486 | + */ |
|
1487 | + public function getAppFetcher() { |
|
1488 | + return $this->query(AppFetcher::class); |
|
1489 | + } |
|
1490 | + |
|
1491 | + /** |
|
1492 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1493 | + * getMemCacheFactory() instead. |
|
1494 | + * |
|
1495 | + * @return \OCP\ICache |
|
1496 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1497 | + */ |
|
1498 | + public function getCache() { |
|
1499 | + return $this->query('UserCache'); |
|
1500 | + } |
|
1501 | + |
|
1502 | + /** |
|
1503 | + * Returns an \OCP\CacheFactory instance |
|
1504 | + * |
|
1505 | + * @return \OCP\ICacheFactory |
|
1506 | + */ |
|
1507 | + public function getMemCacheFactory() { |
|
1508 | + return $this->query('MemCacheFactory'); |
|
1509 | + } |
|
1510 | + |
|
1511 | + /** |
|
1512 | + * Returns an \OC\RedisFactory instance |
|
1513 | + * |
|
1514 | + * @return \OC\RedisFactory |
|
1515 | + */ |
|
1516 | + public function getGetRedisFactory() { |
|
1517 | + return $this->query('RedisFactory'); |
|
1518 | + } |
|
1519 | + |
|
1520 | + |
|
1521 | + /** |
|
1522 | + * Returns the current session |
|
1523 | + * |
|
1524 | + * @return \OCP\IDBConnection |
|
1525 | + */ |
|
1526 | + public function getDatabaseConnection() { |
|
1527 | + return $this->query('DatabaseConnection'); |
|
1528 | + } |
|
1529 | + |
|
1530 | + /** |
|
1531 | + * Returns the activity manager |
|
1532 | + * |
|
1533 | + * @return \OCP\Activity\IManager |
|
1534 | + */ |
|
1535 | + public function getActivityManager() { |
|
1536 | + return $this->query('ActivityManager'); |
|
1537 | + } |
|
1538 | + |
|
1539 | + /** |
|
1540 | + * Returns an job list for controlling background jobs |
|
1541 | + * |
|
1542 | + * @return \OCP\BackgroundJob\IJobList |
|
1543 | + */ |
|
1544 | + public function getJobList() { |
|
1545 | + return $this->query('JobList'); |
|
1546 | + } |
|
1547 | + |
|
1548 | + /** |
|
1549 | + * Returns a logger instance |
|
1550 | + * |
|
1551 | + * @return \OCP\ILogger |
|
1552 | + */ |
|
1553 | + public function getLogger() { |
|
1554 | + return $this->query('Logger'); |
|
1555 | + } |
|
1556 | + |
|
1557 | + /** |
|
1558 | + * @return ILogFactory |
|
1559 | + * @throws \OCP\AppFramework\QueryException |
|
1560 | + */ |
|
1561 | + public function getLogFactory() { |
|
1562 | + return $this->query(ILogFactory::class); |
|
1563 | + } |
|
1564 | + |
|
1565 | + /** |
|
1566 | + * Returns a router for generating and matching urls |
|
1567 | + * |
|
1568 | + * @return \OCP\Route\IRouter |
|
1569 | + */ |
|
1570 | + public function getRouter() { |
|
1571 | + return $this->query('Router'); |
|
1572 | + } |
|
1573 | + |
|
1574 | + /** |
|
1575 | + * Returns a search instance |
|
1576 | + * |
|
1577 | + * @return \OCP\ISearch |
|
1578 | + */ |
|
1579 | + public function getSearch() { |
|
1580 | + return $this->query('Search'); |
|
1581 | + } |
|
1582 | + |
|
1583 | + /** |
|
1584 | + * Returns a SecureRandom instance |
|
1585 | + * |
|
1586 | + * @return \OCP\Security\ISecureRandom |
|
1587 | + */ |
|
1588 | + public function getSecureRandom() { |
|
1589 | + return $this->query('SecureRandom'); |
|
1590 | + } |
|
1591 | + |
|
1592 | + /** |
|
1593 | + * Returns a Crypto instance |
|
1594 | + * |
|
1595 | + * @return \OCP\Security\ICrypto |
|
1596 | + */ |
|
1597 | + public function getCrypto() { |
|
1598 | + return $this->query('Crypto'); |
|
1599 | + } |
|
1600 | + |
|
1601 | + /** |
|
1602 | + * Returns a Hasher instance |
|
1603 | + * |
|
1604 | + * @return \OCP\Security\IHasher |
|
1605 | + */ |
|
1606 | + public function getHasher() { |
|
1607 | + return $this->query('Hasher'); |
|
1608 | + } |
|
1609 | + |
|
1610 | + /** |
|
1611 | + * Returns a CredentialsManager instance |
|
1612 | + * |
|
1613 | + * @return \OCP\Security\ICredentialsManager |
|
1614 | + */ |
|
1615 | + public function getCredentialsManager() { |
|
1616 | + return $this->query('CredentialsManager'); |
|
1617 | + } |
|
1618 | + |
|
1619 | + /** |
|
1620 | + * Get the certificate manager for the user |
|
1621 | + * |
|
1622 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1623 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1624 | + */ |
|
1625 | + public function getCertificateManager($userId = '') { |
|
1626 | + if ($userId === '') { |
|
1627 | + $userSession = $this->getUserSession(); |
|
1628 | + $user = $userSession->getUser(); |
|
1629 | + if (is_null($user)) { |
|
1630 | + return null; |
|
1631 | + } |
|
1632 | + $userId = $user->getUID(); |
|
1633 | + } |
|
1634 | + return new CertificateManager( |
|
1635 | + $userId, |
|
1636 | + new View(), |
|
1637 | + $this->getConfig(), |
|
1638 | + $this->getLogger(), |
|
1639 | + $this->getSecureRandom() |
|
1640 | + ); |
|
1641 | + } |
|
1642 | + |
|
1643 | + /** |
|
1644 | + * Returns an instance of the HTTP client service |
|
1645 | + * |
|
1646 | + * @return \OCP\Http\Client\IClientService |
|
1647 | + */ |
|
1648 | + public function getHTTPClientService() { |
|
1649 | + return $this->query('HttpClientService'); |
|
1650 | + } |
|
1651 | + |
|
1652 | + /** |
|
1653 | + * Create a new event source |
|
1654 | + * |
|
1655 | + * @return \OCP\IEventSource |
|
1656 | + */ |
|
1657 | + public function createEventSource() { |
|
1658 | + return new \OC_EventSource(); |
|
1659 | + } |
|
1660 | + |
|
1661 | + /** |
|
1662 | + * Get the active event logger |
|
1663 | + * |
|
1664 | + * The returned logger only logs data when debug mode is enabled |
|
1665 | + * |
|
1666 | + * @return \OCP\Diagnostics\IEventLogger |
|
1667 | + */ |
|
1668 | + public function getEventLogger() { |
|
1669 | + return $this->query('EventLogger'); |
|
1670 | + } |
|
1671 | + |
|
1672 | + /** |
|
1673 | + * Get the active query logger |
|
1674 | + * |
|
1675 | + * The returned logger only logs data when debug mode is enabled |
|
1676 | + * |
|
1677 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1678 | + */ |
|
1679 | + public function getQueryLogger() { |
|
1680 | + return $this->query('QueryLogger'); |
|
1681 | + } |
|
1682 | + |
|
1683 | + /** |
|
1684 | + * Get the manager for temporary files and folders |
|
1685 | + * |
|
1686 | + * @return \OCP\ITempManager |
|
1687 | + */ |
|
1688 | + public function getTempManager() { |
|
1689 | + return $this->query('TempManager'); |
|
1690 | + } |
|
1691 | + |
|
1692 | + /** |
|
1693 | + * Get the app manager |
|
1694 | + * |
|
1695 | + * @return \OCP\App\IAppManager |
|
1696 | + */ |
|
1697 | + public function getAppManager() { |
|
1698 | + return $this->query('AppManager'); |
|
1699 | + } |
|
1700 | + |
|
1701 | + /** |
|
1702 | + * Creates a new mailer |
|
1703 | + * |
|
1704 | + * @return \OCP\Mail\IMailer |
|
1705 | + */ |
|
1706 | + public function getMailer() { |
|
1707 | + return $this->query('Mailer'); |
|
1708 | + } |
|
1709 | + |
|
1710 | + /** |
|
1711 | + * Get the webroot |
|
1712 | + * |
|
1713 | + * @return string |
|
1714 | + */ |
|
1715 | + public function getWebRoot() { |
|
1716 | + return $this->webRoot; |
|
1717 | + } |
|
1718 | + |
|
1719 | + /** |
|
1720 | + * @return \OC\OCSClient |
|
1721 | + */ |
|
1722 | + public function getOcsClient() { |
|
1723 | + return $this->query('OcsClient'); |
|
1724 | + } |
|
1725 | + |
|
1726 | + /** |
|
1727 | + * @return \OCP\IDateTimeZone |
|
1728 | + */ |
|
1729 | + public function getDateTimeZone() { |
|
1730 | + return $this->query('DateTimeZone'); |
|
1731 | + } |
|
1732 | + |
|
1733 | + /** |
|
1734 | + * @return \OCP\IDateTimeFormatter |
|
1735 | + */ |
|
1736 | + public function getDateTimeFormatter() { |
|
1737 | + return $this->query('DateTimeFormatter'); |
|
1738 | + } |
|
1739 | + |
|
1740 | + /** |
|
1741 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1742 | + */ |
|
1743 | + public function getMountProviderCollection() { |
|
1744 | + return $this->query('MountConfigManager'); |
|
1745 | + } |
|
1746 | + |
|
1747 | + /** |
|
1748 | + * Get the IniWrapper |
|
1749 | + * |
|
1750 | + * @return IniGetWrapper |
|
1751 | + */ |
|
1752 | + public function getIniWrapper() { |
|
1753 | + return $this->query('IniWrapper'); |
|
1754 | + } |
|
1755 | + |
|
1756 | + /** |
|
1757 | + * @return \OCP\Command\IBus |
|
1758 | + */ |
|
1759 | + public function getCommandBus() { |
|
1760 | + return $this->query('AsyncCommandBus'); |
|
1761 | + } |
|
1762 | + |
|
1763 | + /** |
|
1764 | + * Get the trusted domain helper |
|
1765 | + * |
|
1766 | + * @return TrustedDomainHelper |
|
1767 | + */ |
|
1768 | + public function getTrustedDomainHelper() { |
|
1769 | + return $this->query('TrustedDomainHelper'); |
|
1770 | + } |
|
1771 | + |
|
1772 | + /** |
|
1773 | + * Get the locking provider |
|
1774 | + * |
|
1775 | + * @return \OCP\Lock\ILockingProvider |
|
1776 | + * @since 8.1.0 |
|
1777 | + */ |
|
1778 | + public function getLockingProvider() { |
|
1779 | + return $this->query('LockingProvider'); |
|
1780 | + } |
|
1781 | + |
|
1782 | + /** |
|
1783 | + * @return \OCP\Files\Mount\IMountManager |
|
1784 | + **/ |
|
1785 | + function getMountManager() { |
|
1786 | + return $this->query('MountManager'); |
|
1787 | + } |
|
1788 | + |
|
1789 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1790 | + function getUserMountCache() { |
|
1791 | + return $this->query('UserMountCache'); |
|
1792 | + } |
|
1793 | + |
|
1794 | + /** |
|
1795 | + * Get the MimeTypeDetector |
|
1796 | + * |
|
1797 | + * @return \OCP\Files\IMimeTypeDetector |
|
1798 | + */ |
|
1799 | + public function getMimeTypeDetector() { |
|
1800 | + return $this->query('MimeTypeDetector'); |
|
1801 | + } |
|
1802 | + |
|
1803 | + /** |
|
1804 | + * Get the MimeTypeLoader |
|
1805 | + * |
|
1806 | + * @return \OCP\Files\IMimeTypeLoader |
|
1807 | + */ |
|
1808 | + public function getMimeTypeLoader() { |
|
1809 | + return $this->query('MimeTypeLoader'); |
|
1810 | + } |
|
1811 | + |
|
1812 | + /** |
|
1813 | + * Get the manager of all the capabilities |
|
1814 | + * |
|
1815 | + * @return \OC\CapabilitiesManager |
|
1816 | + */ |
|
1817 | + public function getCapabilitiesManager() { |
|
1818 | + return $this->query('CapabilitiesManager'); |
|
1819 | + } |
|
1820 | + |
|
1821 | + /** |
|
1822 | + * Get the EventDispatcher |
|
1823 | + * |
|
1824 | + * @return EventDispatcherInterface |
|
1825 | + * @since 8.2.0 |
|
1826 | + */ |
|
1827 | + public function getEventDispatcher() { |
|
1828 | + return $this->query('EventDispatcher'); |
|
1829 | + } |
|
1830 | + |
|
1831 | + /** |
|
1832 | + * Get the Notification Manager |
|
1833 | + * |
|
1834 | + * @return \OCP\Notification\IManager |
|
1835 | + * @since 8.2.0 |
|
1836 | + */ |
|
1837 | + public function getNotificationManager() { |
|
1838 | + return $this->query('NotificationManager'); |
|
1839 | + } |
|
1840 | + |
|
1841 | + /** |
|
1842 | + * @return \OCP\Comments\ICommentsManager |
|
1843 | + */ |
|
1844 | + public function getCommentsManager() { |
|
1845 | + return $this->query('CommentsManager'); |
|
1846 | + } |
|
1847 | + |
|
1848 | + /** |
|
1849 | + * @return \OCA\Theming\ThemingDefaults |
|
1850 | + */ |
|
1851 | + public function getThemingDefaults() { |
|
1852 | + return $this->query('ThemingDefaults'); |
|
1853 | + } |
|
1854 | + |
|
1855 | + /** |
|
1856 | + * @return \OC\IntegrityCheck\Checker |
|
1857 | + */ |
|
1858 | + public function getIntegrityCodeChecker() { |
|
1859 | + return $this->query('IntegrityCodeChecker'); |
|
1860 | + } |
|
1861 | + |
|
1862 | + /** |
|
1863 | + * @return \OC\Session\CryptoWrapper |
|
1864 | + */ |
|
1865 | + public function getSessionCryptoWrapper() { |
|
1866 | + return $this->query('CryptoWrapper'); |
|
1867 | + } |
|
1868 | + |
|
1869 | + /** |
|
1870 | + * @return CsrfTokenManager |
|
1871 | + */ |
|
1872 | + public function getCsrfTokenManager() { |
|
1873 | + return $this->query('CsrfTokenManager'); |
|
1874 | + } |
|
1875 | + |
|
1876 | + /** |
|
1877 | + * @return Throttler |
|
1878 | + */ |
|
1879 | + public function getBruteForceThrottler() { |
|
1880 | + return $this->query('Throttler'); |
|
1881 | + } |
|
1882 | + |
|
1883 | + /** |
|
1884 | + * @return IContentSecurityPolicyManager |
|
1885 | + */ |
|
1886 | + public function getContentSecurityPolicyManager() { |
|
1887 | + return $this->query('ContentSecurityPolicyManager'); |
|
1888 | + } |
|
1889 | + |
|
1890 | + /** |
|
1891 | + * @return ContentSecurityPolicyNonceManager |
|
1892 | + */ |
|
1893 | + public function getContentSecurityPolicyNonceManager() { |
|
1894 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1895 | + } |
|
1896 | + |
|
1897 | + /** |
|
1898 | + * Not a public API as of 8.2, wait for 9.0 |
|
1899 | + * |
|
1900 | + * @return \OCA\Files_External\Service\BackendService |
|
1901 | + */ |
|
1902 | + public function getStoragesBackendService() { |
|
1903 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1904 | + } |
|
1905 | + |
|
1906 | + /** |
|
1907 | + * Not a public API as of 8.2, wait for 9.0 |
|
1908 | + * |
|
1909 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1910 | + */ |
|
1911 | + public function getGlobalStoragesService() { |
|
1912 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1913 | + } |
|
1914 | + |
|
1915 | + /** |
|
1916 | + * Not a public API as of 8.2, wait for 9.0 |
|
1917 | + * |
|
1918 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1919 | + */ |
|
1920 | + public function getUserGlobalStoragesService() { |
|
1921 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1922 | + } |
|
1923 | + |
|
1924 | + /** |
|
1925 | + * Not a public API as of 8.2, wait for 9.0 |
|
1926 | + * |
|
1927 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1928 | + */ |
|
1929 | + public function getUserStoragesService() { |
|
1930 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1931 | + } |
|
1932 | + |
|
1933 | + /** |
|
1934 | + * @return \OCP\Share\IManager |
|
1935 | + */ |
|
1936 | + public function getShareManager() { |
|
1937 | + return $this->query('ShareManager'); |
|
1938 | + } |
|
1939 | + |
|
1940 | + /** |
|
1941 | + * @return \OCP\Collaboration\Collaborators\ISearch |
|
1942 | + */ |
|
1943 | + public function getCollaboratorSearch() { |
|
1944 | + return $this->query('CollaboratorSearch'); |
|
1945 | + } |
|
1946 | + |
|
1947 | + /** |
|
1948 | + * @return \OCP\Collaboration\AutoComplete\IManager |
|
1949 | + */ |
|
1950 | + public function getAutoCompleteManager(){ |
|
1951 | + return $this->query(IManager::class); |
|
1952 | + } |
|
1953 | + |
|
1954 | + /** |
|
1955 | + * Returns the LDAP Provider |
|
1956 | + * |
|
1957 | + * @return \OCP\LDAP\ILDAPProvider |
|
1958 | + */ |
|
1959 | + public function getLDAPProvider() { |
|
1960 | + return $this->query('LDAPProvider'); |
|
1961 | + } |
|
1962 | + |
|
1963 | + /** |
|
1964 | + * @return \OCP\Settings\IManager |
|
1965 | + */ |
|
1966 | + public function getSettingsManager() { |
|
1967 | + return $this->query('SettingsManager'); |
|
1968 | + } |
|
1969 | + |
|
1970 | + /** |
|
1971 | + * @return \OCP\Files\IAppData |
|
1972 | + */ |
|
1973 | + public function getAppDataDir($app) { |
|
1974 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1975 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1976 | + return $factory->get($app); |
|
1977 | + } |
|
1978 | + |
|
1979 | + /** |
|
1980 | + * @return \OCP\Lockdown\ILockdownManager |
|
1981 | + */ |
|
1982 | + public function getLockdownManager() { |
|
1983 | + return $this->query('LockdownManager'); |
|
1984 | + } |
|
1985 | + |
|
1986 | + /** |
|
1987 | + * @return \OCP\Federation\ICloudIdManager |
|
1988 | + */ |
|
1989 | + public function getCloudIdManager() { |
|
1990 | + return $this->query(ICloudIdManager::class); |
|
1991 | + } |
|
1992 | + |
|
1993 | + /** |
|
1994 | + * @return \OCP\GlobalScale\IConfig |
|
1995 | + */ |
|
1996 | + public function getGlobalScaleConfig() { |
|
1997 | + return $this->query(IConfig::class); |
|
1998 | + } |
|
1999 | + |
|
2000 | + /** |
|
2001 | + * @return \OCP\Federation\ICloudFederationProviderManager |
|
2002 | + */ |
|
2003 | + public function getCloudFederationProviderManager() { |
|
2004 | + return $this->query(ICloudFederationProviderManager::class); |
|
2005 | + } |
|
2006 | + |
|
2007 | + /** |
|
2008 | + * @return \OCP\Remote\Api\IApiFactory |
|
2009 | + */ |
|
2010 | + public function getRemoteApiFactory() { |
|
2011 | + return $this->query(IApiFactory::class); |
|
2012 | + } |
|
2013 | + |
|
2014 | + /** |
|
2015 | + * @return \OCP\Federation\ICloudFederationFactory |
|
2016 | + */ |
|
2017 | + public function getCloudFederationFactory() { |
|
2018 | + return $this->query(ICloudFederationFactory::class); |
|
2019 | + } |
|
2020 | + |
|
2021 | + /** |
|
2022 | + * @return \OCP\Remote\IInstanceFactory |
|
2023 | + */ |
|
2024 | + public function getRemoteInstanceFactory() { |
|
2025 | + return $this->query(IInstanceFactory::class); |
|
2026 | + } |
|
2027 | 2027 | } |
@@ -60,528 +60,528 @@ |
||
60 | 60 | */ |
61 | 61 | interface IServerContainer extends IContainer { |
62 | 62 | |
63 | - /** |
|
64 | - * The calendar manager will act as a broker between consumers for calendar information and |
|
65 | - * providers which actual deliver the calendar information. |
|
66 | - * |
|
67 | - * @return \OCP\Calendar\IManager |
|
68 | - * @since 13.0.0 |
|
69 | - */ |
|
70 | - public function getCalendarManager(); |
|
71 | - |
|
72 | - /** |
|
73 | - * The calendar resource backend manager will act as a broker between consumers |
|
74 | - * for calendar resource information an providers which actual deliver the room information. |
|
75 | - * |
|
76 | - * @return \OCP\Calendar\Resource\IBackend |
|
77 | - * @since 14.0.0 |
|
78 | - */ |
|
79 | - public function getCalendarResourceBackendManager(); |
|
80 | - |
|
81 | - /** |
|
82 | - * The calendar room backend manager will act as a broker between consumers |
|
83 | - * for calendar room information an providers which actual deliver the room information. |
|
84 | - * |
|
85 | - * @return \OCP\Calendar\Room\IBackend |
|
86 | - * @since 14.0.0 |
|
87 | - */ |
|
88 | - public function getCalendarRoomBackendManager(); |
|
89 | - |
|
90 | - /** |
|
91 | - * The contacts manager will act as a broker between consumers for contacts information and |
|
92 | - * providers which actual deliver the contact information. |
|
93 | - * |
|
94 | - * @return \OCP\Contacts\IManager |
|
95 | - * @since 6.0.0 |
|
96 | - */ |
|
97 | - public function getContactsManager(); |
|
98 | - |
|
99 | - /** |
|
100 | - * The current request object holding all information about the request currently being processed |
|
101 | - * is returned from this method. |
|
102 | - * In case the current execution was not initiated by a web request null is returned |
|
103 | - * |
|
104 | - * @return \OCP\IRequest |
|
105 | - * @since 6.0.0 |
|
106 | - */ |
|
107 | - public function getRequest(); |
|
108 | - |
|
109 | - /** |
|
110 | - * Returns the preview manager which can create preview images for a given file |
|
111 | - * |
|
112 | - * @return \OCP\IPreview |
|
113 | - * @since 6.0.0 |
|
114 | - */ |
|
115 | - public function getPreviewManager(); |
|
116 | - |
|
117 | - /** |
|
118 | - * Returns the tag manager which can get and set tags for different object types |
|
119 | - * |
|
120 | - * @see \OCP\ITagManager::load() |
|
121 | - * @return \OCP\ITagManager |
|
122 | - * @since 6.0.0 |
|
123 | - */ |
|
124 | - public function getTagManager(); |
|
125 | - |
|
126 | - /** |
|
127 | - * Returns the root folder of ownCloud's data directory |
|
128 | - * |
|
129 | - * @return \OCP\Files\IRootFolder |
|
130 | - * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
131 | - */ |
|
132 | - public function getRootFolder(); |
|
133 | - |
|
134 | - /** |
|
135 | - * Returns a view to ownCloud's files folder |
|
136 | - * |
|
137 | - * @param string $userId user ID |
|
138 | - * @return \OCP\Files\Folder |
|
139 | - * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
140 | - * @see getUserFolder in \OCP\Files\IRootFolder |
|
141 | - */ |
|
142 | - public function getUserFolder($userId = null); |
|
143 | - |
|
144 | - /** |
|
145 | - * Returns an app-specific view in ownClouds data directory |
|
146 | - * |
|
147 | - * @return \OCP\Files\Folder |
|
148 | - * @since 6.0.0 |
|
149 | - * @deprecated 9.2.0 use IAppData |
|
150 | - */ |
|
151 | - public function getAppFolder(); |
|
152 | - |
|
153 | - /** |
|
154 | - * Returns a user manager |
|
155 | - * |
|
156 | - * @return \OCP\IUserManager |
|
157 | - * @since 8.0.0 |
|
158 | - */ |
|
159 | - public function getUserManager(); |
|
160 | - |
|
161 | - /** |
|
162 | - * Returns a group manager |
|
163 | - * |
|
164 | - * @return \OCP\IGroupManager |
|
165 | - * @since 8.0.0 |
|
166 | - */ |
|
167 | - public function getGroupManager(); |
|
168 | - |
|
169 | - /** |
|
170 | - * Returns the user session |
|
171 | - * |
|
172 | - * @return \OCP\IUserSession |
|
173 | - * @since 6.0.0 |
|
174 | - */ |
|
175 | - public function getUserSession(); |
|
176 | - |
|
177 | - /** |
|
178 | - * Returns the navigation manager |
|
179 | - * |
|
180 | - * @return \OCP\INavigationManager |
|
181 | - * @since 6.0.0 |
|
182 | - */ |
|
183 | - public function getNavigationManager(); |
|
184 | - |
|
185 | - /** |
|
186 | - * Returns the config manager |
|
187 | - * |
|
188 | - * @return \OCP\IConfig |
|
189 | - * @since 6.0.0 |
|
190 | - */ |
|
191 | - public function getConfig(); |
|
192 | - |
|
193 | - /** |
|
194 | - * Returns a Crypto instance |
|
195 | - * |
|
196 | - * @return \OCP\Security\ICrypto |
|
197 | - * @since 8.0.0 |
|
198 | - */ |
|
199 | - public function getCrypto(); |
|
200 | - |
|
201 | - /** |
|
202 | - * Returns a Hasher instance |
|
203 | - * |
|
204 | - * @return \OCP\Security\IHasher |
|
205 | - * @since 8.0.0 |
|
206 | - */ |
|
207 | - public function getHasher(); |
|
208 | - |
|
209 | - /** |
|
210 | - * Returns a SecureRandom instance |
|
211 | - * |
|
212 | - * @return \OCP\Security\ISecureRandom |
|
213 | - * @since 8.1.0 |
|
214 | - */ |
|
215 | - public function getSecureRandom(); |
|
216 | - |
|
217 | - /** |
|
218 | - * Returns a CredentialsManager instance |
|
219 | - * |
|
220 | - * @return \OCP\Security\ICredentialsManager |
|
221 | - * @since 9.0.0 |
|
222 | - */ |
|
223 | - public function getCredentialsManager(); |
|
224 | - |
|
225 | - /** |
|
226 | - * Returns the app config manager |
|
227 | - * |
|
228 | - * @return \OCP\IAppConfig |
|
229 | - * @since 7.0.0 |
|
230 | - */ |
|
231 | - public function getAppConfig(); |
|
232 | - |
|
233 | - /** |
|
234 | - * @return \OCP\L10N\IFactory |
|
235 | - * @since 8.2.0 |
|
236 | - */ |
|
237 | - public function getL10NFactory(); |
|
238 | - |
|
239 | - /** |
|
240 | - * get an L10N instance |
|
241 | - * @param string $app appid |
|
242 | - * @param string $lang |
|
243 | - * @return \OCP\IL10N |
|
244 | - * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
245 | - */ |
|
246 | - public function getL10N($app, $lang = null); |
|
247 | - |
|
248 | - /** |
|
249 | - * @return \OC\Encryption\Manager |
|
250 | - * @since 8.1.0 |
|
251 | - */ |
|
252 | - public function getEncryptionManager(); |
|
253 | - |
|
254 | - /** |
|
255 | - * @return \OC\Encryption\File |
|
256 | - * @since 8.1.0 |
|
257 | - */ |
|
258 | - public function getEncryptionFilesHelper(); |
|
259 | - |
|
260 | - /** |
|
261 | - * @return \OCP\Encryption\Keys\IStorage |
|
262 | - * @since 8.1.0 |
|
263 | - */ |
|
264 | - public function getEncryptionKeyStorage(); |
|
265 | - |
|
266 | - /** |
|
267 | - * Returns the URL generator |
|
268 | - * |
|
269 | - * @return \OCP\IURLGenerator |
|
270 | - * @since 6.0.0 |
|
271 | - */ |
|
272 | - public function getURLGenerator(); |
|
273 | - |
|
274 | - /** |
|
275 | - * Returns an ICache instance |
|
276 | - * |
|
277 | - * @return \OCP\ICache |
|
278 | - * @since 6.0.0 |
|
279 | - */ |
|
280 | - public function getCache(); |
|
281 | - |
|
282 | - /** |
|
283 | - * Returns an \OCP\CacheFactory instance |
|
284 | - * |
|
285 | - * @return \OCP\ICacheFactory |
|
286 | - * @since 7.0.0 |
|
287 | - */ |
|
288 | - public function getMemCacheFactory(); |
|
289 | - |
|
290 | - /** |
|
291 | - * Returns the current session |
|
292 | - * |
|
293 | - * @return \OCP\ISession |
|
294 | - * @since 6.0.0 |
|
295 | - */ |
|
296 | - public function getSession(); |
|
297 | - |
|
298 | - /** |
|
299 | - * Returns the activity manager |
|
300 | - * |
|
301 | - * @return \OCP\Activity\IManager |
|
302 | - * @since 6.0.0 |
|
303 | - */ |
|
304 | - public function getActivityManager(); |
|
305 | - |
|
306 | - /** |
|
307 | - * Returns the current session |
|
308 | - * |
|
309 | - * @return \OCP\IDBConnection |
|
310 | - * @since 6.0.0 |
|
311 | - */ |
|
312 | - public function getDatabaseConnection(); |
|
313 | - |
|
314 | - /** |
|
315 | - * Returns an avatar manager, used for avatar functionality |
|
316 | - * |
|
317 | - * @return \OCP\IAvatarManager |
|
318 | - * @since 6.0.0 |
|
319 | - */ |
|
320 | - public function getAvatarManager(); |
|
321 | - |
|
322 | - /** |
|
323 | - * Returns an job list for controlling background jobs |
|
324 | - * |
|
325 | - * @return \OCP\BackgroundJob\IJobList |
|
326 | - * @since 7.0.0 |
|
327 | - */ |
|
328 | - public function getJobList(); |
|
329 | - |
|
330 | - /** |
|
331 | - * Returns a logger instance |
|
332 | - * |
|
333 | - * @return \OCP\ILogger |
|
334 | - * @since 8.0.0 |
|
335 | - */ |
|
336 | - public function getLogger(); |
|
337 | - |
|
338 | - /** |
|
339 | - * returns a log factory instance |
|
340 | - * |
|
341 | - * @return ILogFactory |
|
342 | - * @since 14.0.0 |
|
343 | - */ |
|
344 | - public function getLogFactory(); |
|
345 | - |
|
346 | - /** |
|
347 | - * Returns a router for generating and matching urls |
|
348 | - * |
|
349 | - * @return \OCP\Route\IRouter |
|
350 | - * @since 7.0.0 |
|
351 | - */ |
|
352 | - public function getRouter(); |
|
353 | - |
|
354 | - /** |
|
355 | - * Returns a search instance |
|
356 | - * |
|
357 | - * @return \OCP\ISearch |
|
358 | - * @since 7.0.0 |
|
359 | - */ |
|
360 | - public function getSearch(); |
|
361 | - |
|
362 | - /** |
|
363 | - * Get the certificate manager for the user |
|
364 | - * |
|
365 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
366 | - * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
367 | - * @since 8.0.0 |
|
368 | - */ |
|
369 | - public function getCertificateManager($userId = null); |
|
370 | - |
|
371 | - /** |
|
372 | - * Create a new event source |
|
373 | - * |
|
374 | - * @return \OCP\IEventSource |
|
375 | - * @since 8.0.0 |
|
376 | - */ |
|
377 | - public function createEventSource(); |
|
378 | - |
|
379 | - /** |
|
380 | - * Returns an instance of the HTTP client service |
|
381 | - * |
|
382 | - * @return \OCP\Http\Client\IClientService |
|
383 | - * @since 8.1.0 |
|
384 | - */ |
|
385 | - public function getHTTPClientService(); |
|
386 | - |
|
387 | - /** |
|
388 | - * Get the active event logger |
|
389 | - * |
|
390 | - * @return \OCP\Diagnostics\IEventLogger |
|
391 | - * @since 8.0.0 |
|
392 | - */ |
|
393 | - public function getEventLogger(); |
|
394 | - |
|
395 | - /** |
|
396 | - * Get the active query logger |
|
397 | - * |
|
398 | - * The returned logger only logs data when debug mode is enabled |
|
399 | - * |
|
400 | - * @return \OCP\Diagnostics\IQueryLogger |
|
401 | - * @since 8.0.0 |
|
402 | - */ |
|
403 | - public function getQueryLogger(); |
|
404 | - |
|
405 | - /** |
|
406 | - * Get the manager for temporary files and folders |
|
407 | - * |
|
408 | - * @return \OCP\ITempManager |
|
409 | - * @since 8.0.0 |
|
410 | - */ |
|
411 | - public function getTempManager(); |
|
412 | - |
|
413 | - /** |
|
414 | - * Get the app manager |
|
415 | - * |
|
416 | - * @return \OCP\App\IAppManager |
|
417 | - * @since 8.0.0 |
|
418 | - */ |
|
419 | - public function getAppManager(); |
|
420 | - |
|
421 | - /** |
|
422 | - * Get the webroot |
|
423 | - * |
|
424 | - * @return string |
|
425 | - * @since 8.0.0 |
|
426 | - */ |
|
427 | - public function getWebRoot(); |
|
428 | - |
|
429 | - /** |
|
430 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
431 | - * @since 8.0.0 |
|
432 | - */ |
|
433 | - public function getMountProviderCollection(); |
|
434 | - |
|
435 | - /** |
|
436 | - * Get the IniWrapper |
|
437 | - * |
|
438 | - * @return \bantu\IniGetWrapper\IniGetWrapper |
|
439 | - * @since 8.0.0 |
|
440 | - */ |
|
441 | - public function getIniWrapper(); |
|
442 | - /** |
|
443 | - * @return \OCP\Command\IBus |
|
444 | - * @since 8.1.0 |
|
445 | - */ |
|
446 | - public function getCommandBus(); |
|
447 | - |
|
448 | - /** |
|
449 | - * Creates a new mailer |
|
450 | - * |
|
451 | - * @return \OCP\Mail\IMailer |
|
452 | - * @since 8.1.0 |
|
453 | - */ |
|
454 | - public function getMailer(); |
|
455 | - |
|
456 | - /** |
|
457 | - * Get the locking provider |
|
458 | - * |
|
459 | - * @return \OCP\Lock\ILockingProvider |
|
460 | - * @since 8.1.0 |
|
461 | - */ |
|
462 | - public function getLockingProvider(); |
|
463 | - |
|
464 | - /** |
|
465 | - * @return \OCP\Files\Mount\IMountManager |
|
466 | - * @since 8.2.0 |
|
467 | - */ |
|
468 | - public function getMountManager(); |
|
469 | - |
|
470 | - /** |
|
471 | - * Get the MimeTypeDetector |
|
472 | - * |
|
473 | - * @return \OCP\Files\IMimeTypeDetector |
|
474 | - * @since 8.2.0 |
|
475 | - */ |
|
476 | - public function getMimeTypeDetector(); |
|
477 | - |
|
478 | - /** |
|
479 | - * Get the MimeTypeLoader |
|
480 | - * |
|
481 | - * @return \OCP\Files\IMimeTypeLoader |
|
482 | - * @since 8.2.0 |
|
483 | - */ |
|
484 | - public function getMimeTypeLoader(); |
|
485 | - |
|
486 | - /** |
|
487 | - * Get the EventDispatcher |
|
488 | - * |
|
489 | - * @return EventDispatcherInterface |
|
490 | - * @since 8.2.0 |
|
491 | - */ |
|
492 | - public function getEventDispatcher(); |
|
493 | - |
|
494 | - /** |
|
495 | - * Get the Notification Manager |
|
496 | - * |
|
497 | - * @return \OCP\Notification\IManager |
|
498 | - * @since 9.0.0 |
|
499 | - */ |
|
500 | - public function getNotificationManager(); |
|
501 | - |
|
502 | - /** |
|
503 | - * @return \OCP\Comments\ICommentsManager |
|
504 | - * @since 9.0.0 |
|
505 | - */ |
|
506 | - public function getCommentsManager(); |
|
507 | - |
|
508 | - /** |
|
509 | - * Returns the system-tag manager |
|
510 | - * |
|
511 | - * @return \OCP\SystemTag\ISystemTagManager |
|
512 | - * |
|
513 | - * @since 9.0.0 |
|
514 | - */ |
|
515 | - public function getSystemTagManager(); |
|
516 | - |
|
517 | - /** |
|
518 | - * Returns the system-tag object mapper |
|
519 | - * |
|
520 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
521 | - * |
|
522 | - * @since 9.0.0 |
|
523 | - */ |
|
524 | - public function getSystemTagObjectMapper(); |
|
525 | - |
|
526 | - /** |
|
527 | - * Returns the share manager |
|
528 | - * |
|
529 | - * @return \OCP\Share\IManager |
|
530 | - * @since 9.0.0 |
|
531 | - */ |
|
532 | - public function getShareManager(); |
|
533 | - |
|
534 | - /** |
|
535 | - * @return IContentSecurityPolicyManager |
|
536 | - * @since 9.0.0 |
|
537 | - */ |
|
538 | - public function getContentSecurityPolicyManager(); |
|
539 | - |
|
540 | - /** |
|
541 | - * @return \OCP\IDateTimeZone |
|
542 | - * @since 8.0.0 |
|
543 | - */ |
|
544 | - public function getDateTimeZone(); |
|
545 | - |
|
546 | - /** |
|
547 | - * @return \OCP\IDateTimeFormatter |
|
548 | - * @since 8.0.0 |
|
549 | - */ |
|
550 | - public function getDateTimeFormatter(); |
|
551 | - |
|
552 | - /** |
|
553 | - * @return \OCP\Federation\ICloudIdManager |
|
554 | - * @since 12.0.0 |
|
555 | - */ |
|
556 | - public function getCloudIdManager(); |
|
557 | - |
|
558 | - /** |
|
559 | - * @return \OCP\GlobalScale\IConfig |
|
560 | - * @since 14.0.0 |
|
561 | - */ |
|
562 | - public function getGlobalScaleConfig(); |
|
563 | - |
|
564 | - /** |
|
565 | - * @return ICloudFederationFactory |
|
566 | - * @since 14.0.0 |
|
567 | - */ |
|
568 | - public function getCloudFederationFactory(); |
|
569 | - |
|
570 | - /** |
|
571 | - * @return ICloudFederationProviderManager |
|
572 | - * @since 14.0.0 |
|
573 | - */ |
|
574 | - public function getCloudFederationProviderManager(); |
|
575 | - |
|
576 | - /** |
|
577 | - * @return \OCP\Remote\Api\IApiFactory |
|
578 | - * @since 13.0.0 |
|
579 | - */ |
|
580 | - public function getRemoteApiFactory(); |
|
581 | - |
|
582 | - /** |
|
583 | - * @return \OCP\Remote\IInstanceFactory |
|
584 | - * @since 13.0.0 |
|
585 | - */ |
|
586 | - public function getRemoteInstanceFactory(); |
|
63 | + /** |
|
64 | + * The calendar manager will act as a broker between consumers for calendar information and |
|
65 | + * providers which actual deliver the calendar information. |
|
66 | + * |
|
67 | + * @return \OCP\Calendar\IManager |
|
68 | + * @since 13.0.0 |
|
69 | + */ |
|
70 | + public function getCalendarManager(); |
|
71 | + |
|
72 | + /** |
|
73 | + * The calendar resource backend manager will act as a broker between consumers |
|
74 | + * for calendar resource information an providers which actual deliver the room information. |
|
75 | + * |
|
76 | + * @return \OCP\Calendar\Resource\IBackend |
|
77 | + * @since 14.0.0 |
|
78 | + */ |
|
79 | + public function getCalendarResourceBackendManager(); |
|
80 | + |
|
81 | + /** |
|
82 | + * The calendar room backend manager will act as a broker between consumers |
|
83 | + * for calendar room information an providers which actual deliver the room information. |
|
84 | + * |
|
85 | + * @return \OCP\Calendar\Room\IBackend |
|
86 | + * @since 14.0.0 |
|
87 | + */ |
|
88 | + public function getCalendarRoomBackendManager(); |
|
89 | + |
|
90 | + /** |
|
91 | + * The contacts manager will act as a broker between consumers for contacts information and |
|
92 | + * providers which actual deliver the contact information. |
|
93 | + * |
|
94 | + * @return \OCP\Contacts\IManager |
|
95 | + * @since 6.0.0 |
|
96 | + */ |
|
97 | + public function getContactsManager(); |
|
98 | + |
|
99 | + /** |
|
100 | + * The current request object holding all information about the request currently being processed |
|
101 | + * is returned from this method. |
|
102 | + * In case the current execution was not initiated by a web request null is returned |
|
103 | + * |
|
104 | + * @return \OCP\IRequest |
|
105 | + * @since 6.0.0 |
|
106 | + */ |
|
107 | + public function getRequest(); |
|
108 | + |
|
109 | + /** |
|
110 | + * Returns the preview manager which can create preview images for a given file |
|
111 | + * |
|
112 | + * @return \OCP\IPreview |
|
113 | + * @since 6.0.0 |
|
114 | + */ |
|
115 | + public function getPreviewManager(); |
|
116 | + |
|
117 | + /** |
|
118 | + * Returns the tag manager which can get and set tags for different object types |
|
119 | + * |
|
120 | + * @see \OCP\ITagManager::load() |
|
121 | + * @return \OCP\ITagManager |
|
122 | + * @since 6.0.0 |
|
123 | + */ |
|
124 | + public function getTagManager(); |
|
125 | + |
|
126 | + /** |
|
127 | + * Returns the root folder of ownCloud's data directory |
|
128 | + * |
|
129 | + * @return \OCP\Files\IRootFolder |
|
130 | + * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
131 | + */ |
|
132 | + public function getRootFolder(); |
|
133 | + |
|
134 | + /** |
|
135 | + * Returns a view to ownCloud's files folder |
|
136 | + * |
|
137 | + * @param string $userId user ID |
|
138 | + * @return \OCP\Files\Folder |
|
139 | + * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
140 | + * @see getUserFolder in \OCP\Files\IRootFolder |
|
141 | + */ |
|
142 | + public function getUserFolder($userId = null); |
|
143 | + |
|
144 | + /** |
|
145 | + * Returns an app-specific view in ownClouds data directory |
|
146 | + * |
|
147 | + * @return \OCP\Files\Folder |
|
148 | + * @since 6.0.0 |
|
149 | + * @deprecated 9.2.0 use IAppData |
|
150 | + */ |
|
151 | + public function getAppFolder(); |
|
152 | + |
|
153 | + /** |
|
154 | + * Returns a user manager |
|
155 | + * |
|
156 | + * @return \OCP\IUserManager |
|
157 | + * @since 8.0.0 |
|
158 | + */ |
|
159 | + public function getUserManager(); |
|
160 | + |
|
161 | + /** |
|
162 | + * Returns a group manager |
|
163 | + * |
|
164 | + * @return \OCP\IGroupManager |
|
165 | + * @since 8.0.0 |
|
166 | + */ |
|
167 | + public function getGroupManager(); |
|
168 | + |
|
169 | + /** |
|
170 | + * Returns the user session |
|
171 | + * |
|
172 | + * @return \OCP\IUserSession |
|
173 | + * @since 6.0.0 |
|
174 | + */ |
|
175 | + public function getUserSession(); |
|
176 | + |
|
177 | + /** |
|
178 | + * Returns the navigation manager |
|
179 | + * |
|
180 | + * @return \OCP\INavigationManager |
|
181 | + * @since 6.0.0 |
|
182 | + */ |
|
183 | + public function getNavigationManager(); |
|
184 | + |
|
185 | + /** |
|
186 | + * Returns the config manager |
|
187 | + * |
|
188 | + * @return \OCP\IConfig |
|
189 | + * @since 6.0.0 |
|
190 | + */ |
|
191 | + public function getConfig(); |
|
192 | + |
|
193 | + /** |
|
194 | + * Returns a Crypto instance |
|
195 | + * |
|
196 | + * @return \OCP\Security\ICrypto |
|
197 | + * @since 8.0.0 |
|
198 | + */ |
|
199 | + public function getCrypto(); |
|
200 | + |
|
201 | + /** |
|
202 | + * Returns a Hasher instance |
|
203 | + * |
|
204 | + * @return \OCP\Security\IHasher |
|
205 | + * @since 8.0.0 |
|
206 | + */ |
|
207 | + public function getHasher(); |
|
208 | + |
|
209 | + /** |
|
210 | + * Returns a SecureRandom instance |
|
211 | + * |
|
212 | + * @return \OCP\Security\ISecureRandom |
|
213 | + * @since 8.1.0 |
|
214 | + */ |
|
215 | + public function getSecureRandom(); |
|
216 | + |
|
217 | + /** |
|
218 | + * Returns a CredentialsManager instance |
|
219 | + * |
|
220 | + * @return \OCP\Security\ICredentialsManager |
|
221 | + * @since 9.0.0 |
|
222 | + */ |
|
223 | + public function getCredentialsManager(); |
|
224 | + |
|
225 | + /** |
|
226 | + * Returns the app config manager |
|
227 | + * |
|
228 | + * @return \OCP\IAppConfig |
|
229 | + * @since 7.0.0 |
|
230 | + */ |
|
231 | + public function getAppConfig(); |
|
232 | + |
|
233 | + /** |
|
234 | + * @return \OCP\L10N\IFactory |
|
235 | + * @since 8.2.0 |
|
236 | + */ |
|
237 | + public function getL10NFactory(); |
|
238 | + |
|
239 | + /** |
|
240 | + * get an L10N instance |
|
241 | + * @param string $app appid |
|
242 | + * @param string $lang |
|
243 | + * @return \OCP\IL10N |
|
244 | + * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
245 | + */ |
|
246 | + public function getL10N($app, $lang = null); |
|
247 | + |
|
248 | + /** |
|
249 | + * @return \OC\Encryption\Manager |
|
250 | + * @since 8.1.0 |
|
251 | + */ |
|
252 | + public function getEncryptionManager(); |
|
253 | + |
|
254 | + /** |
|
255 | + * @return \OC\Encryption\File |
|
256 | + * @since 8.1.0 |
|
257 | + */ |
|
258 | + public function getEncryptionFilesHelper(); |
|
259 | + |
|
260 | + /** |
|
261 | + * @return \OCP\Encryption\Keys\IStorage |
|
262 | + * @since 8.1.0 |
|
263 | + */ |
|
264 | + public function getEncryptionKeyStorage(); |
|
265 | + |
|
266 | + /** |
|
267 | + * Returns the URL generator |
|
268 | + * |
|
269 | + * @return \OCP\IURLGenerator |
|
270 | + * @since 6.0.0 |
|
271 | + */ |
|
272 | + public function getURLGenerator(); |
|
273 | + |
|
274 | + /** |
|
275 | + * Returns an ICache instance |
|
276 | + * |
|
277 | + * @return \OCP\ICache |
|
278 | + * @since 6.0.0 |
|
279 | + */ |
|
280 | + public function getCache(); |
|
281 | + |
|
282 | + /** |
|
283 | + * Returns an \OCP\CacheFactory instance |
|
284 | + * |
|
285 | + * @return \OCP\ICacheFactory |
|
286 | + * @since 7.0.0 |
|
287 | + */ |
|
288 | + public function getMemCacheFactory(); |
|
289 | + |
|
290 | + /** |
|
291 | + * Returns the current session |
|
292 | + * |
|
293 | + * @return \OCP\ISession |
|
294 | + * @since 6.0.0 |
|
295 | + */ |
|
296 | + public function getSession(); |
|
297 | + |
|
298 | + /** |
|
299 | + * Returns the activity manager |
|
300 | + * |
|
301 | + * @return \OCP\Activity\IManager |
|
302 | + * @since 6.0.0 |
|
303 | + */ |
|
304 | + public function getActivityManager(); |
|
305 | + |
|
306 | + /** |
|
307 | + * Returns the current session |
|
308 | + * |
|
309 | + * @return \OCP\IDBConnection |
|
310 | + * @since 6.0.0 |
|
311 | + */ |
|
312 | + public function getDatabaseConnection(); |
|
313 | + |
|
314 | + /** |
|
315 | + * Returns an avatar manager, used for avatar functionality |
|
316 | + * |
|
317 | + * @return \OCP\IAvatarManager |
|
318 | + * @since 6.0.0 |
|
319 | + */ |
|
320 | + public function getAvatarManager(); |
|
321 | + |
|
322 | + /** |
|
323 | + * Returns an job list for controlling background jobs |
|
324 | + * |
|
325 | + * @return \OCP\BackgroundJob\IJobList |
|
326 | + * @since 7.0.0 |
|
327 | + */ |
|
328 | + public function getJobList(); |
|
329 | + |
|
330 | + /** |
|
331 | + * Returns a logger instance |
|
332 | + * |
|
333 | + * @return \OCP\ILogger |
|
334 | + * @since 8.0.0 |
|
335 | + */ |
|
336 | + public function getLogger(); |
|
337 | + |
|
338 | + /** |
|
339 | + * returns a log factory instance |
|
340 | + * |
|
341 | + * @return ILogFactory |
|
342 | + * @since 14.0.0 |
|
343 | + */ |
|
344 | + public function getLogFactory(); |
|
345 | + |
|
346 | + /** |
|
347 | + * Returns a router for generating and matching urls |
|
348 | + * |
|
349 | + * @return \OCP\Route\IRouter |
|
350 | + * @since 7.0.0 |
|
351 | + */ |
|
352 | + public function getRouter(); |
|
353 | + |
|
354 | + /** |
|
355 | + * Returns a search instance |
|
356 | + * |
|
357 | + * @return \OCP\ISearch |
|
358 | + * @since 7.0.0 |
|
359 | + */ |
|
360 | + public function getSearch(); |
|
361 | + |
|
362 | + /** |
|
363 | + * Get the certificate manager for the user |
|
364 | + * |
|
365 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
366 | + * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
367 | + * @since 8.0.0 |
|
368 | + */ |
|
369 | + public function getCertificateManager($userId = null); |
|
370 | + |
|
371 | + /** |
|
372 | + * Create a new event source |
|
373 | + * |
|
374 | + * @return \OCP\IEventSource |
|
375 | + * @since 8.0.0 |
|
376 | + */ |
|
377 | + public function createEventSource(); |
|
378 | + |
|
379 | + /** |
|
380 | + * Returns an instance of the HTTP client service |
|
381 | + * |
|
382 | + * @return \OCP\Http\Client\IClientService |
|
383 | + * @since 8.1.0 |
|
384 | + */ |
|
385 | + public function getHTTPClientService(); |
|
386 | + |
|
387 | + /** |
|
388 | + * Get the active event logger |
|
389 | + * |
|
390 | + * @return \OCP\Diagnostics\IEventLogger |
|
391 | + * @since 8.0.0 |
|
392 | + */ |
|
393 | + public function getEventLogger(); |
|
394 | + |
|
395 | + /** |
|
396 | + * Get the active query logger |
|
397 | + * |
|
398 | + * The returned logger only logs data when debug mode is enabled |
|
399 | + * |
|
400 | + * @return \OCP\Diagnostics\IQueryLogger |
|
401 | + * @since 8.0.0 |
|
402 | + */ |
|
403 | + public function getQueryLogger(); |
|
404 | + |
|
405 | + /** |
|
406 | + * Get the manager for temporary files and folders |
|
407 | + * |
|
408 | + * @return \OCP\ITempManager |
|
409 | + * @since 8.0.0 |
|
410 | + */ |
|
411 | + public function getTempManager(); |
|
412 | + |
|
413 | + /** |
|
414 | + * Get the app manager |
|
415 | + * |
|
416 | + * @return \OCP\App\IAppManager |
|
417 | + * @since 8.0.0 |
|
418 | + */ |
|
419 | + public function getAppManager(); |
|
420 | + |
|
421 | + /** |
|
422 | + * Get the webroot |
|
423 | + * |
|
424 | + * @return string |
|
425 | + * @since 8.0.0 |
|
426 | + */ |
|
427 | + public function getWebRoot(); |
|
428 | + |
|
429 | + /** |
|
430 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
431 | + * @since 8.0.0 |
|
432 | + */ |
|
433 | + public function getMountProviderCollection(); |
|
434 | + |
|
435 | + /** |
|
436 | + * Get the IniWrapper |
|
437 | + * |
|
438 | + * @return \bantu\IniGetWrapper\IniGetWrapper |
|
439 | + * @since 8.0.0 |
|
440 | + */ |
|
441 | + public function getIniWrapper(); |
|
442 | + /** |
|
443 | + * @return \OCP\Command\IBus |
|
444 | + * @since 8.1.0 |
|
445 | + */ |
|
446 | + public function getCommandBus(); |
|
447 | + |
|
448 | + /** |
|
449 | + * Creates a new mailer |
|
450 | + * |
|
451 | + * @return \OCP\Mail\IMailer |
|
452 | + * @since 8.1.0 |
|
453 | + */ |
|
454 | + public function getMailer(); |
|
455 | + |
|
456 | + /** |
|
457 | + * Get the locking provider |
|
458 | + * |
|
459 | + * @return \OCP\Lock\ILockingProvider |
|
460 | + * @since 8.1.0 |
|
461 | + */ |
|
462 | + public function getLockingProvider(); |
|
463 | + |
|
464 | + /** |
|
465 | + * @return \OCP\Files\Mount\IMountManager |
|
466 | + * @since 8.2.0 |
|
467 | + */ |
|
468 | + public function getMountManager(); |
|
469 | + |
|
470 | + /** |
|
471 | + * Get the MimeTypeDetector |
|
472 | + * |
|
473 | + * @return \OCP\Files\IMimeTypeDetector |
|
474 | + * @since 8.2.0 |
|
475 | + */ |
|
476 | + public function getMimeTypeDetector(); |
|
477 | + |
|
478 | + /** |
|
479 | + * Get the MimeTypeLoader |
|
480 | + * |
|
481 | + * @return \OCP\Files\IMimeTypeLoader |
|
482 | + * @since 8.2.0 |
|
483 | + */ |
|
484 | + public function getMimeTypeLoader(); |
|
485 | + |
|
486 | + /** |
|
487 | + * Get the EventDispatcher |
|
488 | + * |
|
489 | + * @return EventDispatcherInterface |
|
490 | + * @since 8.2.0 |
|
491 | + */ |
|
492 | + public function getEventDispatcher(); |
|
493 | + |
|
494 | + /** |
|
495 | + * Get the Notification Manager |
|
496 | + * |
|
497 | + * @return \OCP\Notification\IManager |
|
498 | + * @since 9.0.0 |
|
499 | + */ |
|
500 | + public function getNotificationManager(); |
|
501 | + |
|
502 | + /** |
|
503 | + * @return \OCP\Comments\ICommentsManager |
|
504 | + * @since 9.0.0 |
|
505 | + */ |
|
506 | + public function getCommentsManager(); |
|
507 | + |
|
508 | + /** |
|
509 | + * Returns the system-tag manager |
|
510 | + * |
|
511 | + * @return \OCP\SystemTag\ISystemTagManager |
|
512 | + * |
|
513 | + * @since 9.0.0 |
|
514 | + */ |
|
515 | + public function getSystemTagManager(); |
|
516 | + |
|
517 | + /** |
|
518 | + * Returns the system-tag object mapper |
|
519 | + * |
|
520 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
521 | + * |
|
522 | + * @since 9.0.0 |
|
523 | + */ |
|
524 | + public function getSystemTagObjectMapper(); |
|
525 | + |
|
526 | + /** |
|
527 | + * Returns the share manager |
|
528 | + * |
|
529 | + * @return \OCP\Share\IManager |
|
530 | + * @since 9.0.0 |
|
531 | + */ |
|
532 | + public function getShareManager(); |
|
533 | + |
|
534 | + /** |
|
535 | + * @return IContentSecurityPolicyManager |
|
536 | + * @since 9.0.0 |
|
537 | + */ |
|
538 | + public function getContentSecurityPolicyManager(); |
|
539 | + |
|
540 | + /** |
|
541 | + * @return \OCP\IDateTimeZone |
|
542 | + * @since 8.0.0 |
|
543 | + */ |
|
544 | + public function getDateTimeZone(); |
|
545 | + |
|
546 | + /** |
|
547 | + * @return \OCP\IDateTimeFormatter |
|
548 | + * @since 8.0.0 |
|
549 | + */ |
|
550 | + public function getDateTimeFormatter(); |
|
551 | + |
|
552 | + /** |
|
553 | + * @return \OCP\Federation\ICloudIdManager |
|
554 | + * @since 12.0.0 |
|
555 | + */ |
|
556 | + public function getCloudIdManager(); |
|
557 | + |
|
558 | + /** |
|
559 | + * @return \OCP\GlobalScale\IConfig |
|
560 | + * @since 14.0.0 |
|
561 | + */ |
|
562 | + public function getGlobalScaleConfig(); |
|
563 | + |
|
564 | + /** |
|
565 | + * @return ICloudFederationFactory |
|
566 | + * @since 14.0.0 |
|
567 | + */ |
|
568 | + public function getCloudFederationFactory(); |
|
569 | + |
|
570 | + /** |
|
571 | + * @return ICloudFederationProviderManager |
|
572 | + * @since 14.0.0 |
|
573 | + */ |
|
574 | + public function getCloudFederationProviderManager(); |
|
575 | + |
|
576 | + /** |
|
577 | + * @return \OCP\Remote\Api\IApiFactory |
|
578 | + * @since 13.0.0 |
|
579 | + */ |
|
580 | + public function getRemoteApiFactory(); |
|
581 | + |
|
582 | + /** |
|
583 | + * @return \OCP\Remote\IInstanceFactory |
|
584 | + * @since 13.0.0 |
|
585 | + */ |
|
586 | + public function getRemoteInstanceFactory(); |
|
587 | 587 | } |
@@ -32,76 +32,76 @@ |
||
32 | 32 | */ |
33 | 33 | interface ICloudFederationProviderManager { |
34 | 34 | |
35 | - /** |
|
36 | - * Registers an callback function which must return an cloud federation provider |
|
37 | - * |
|
38 | - * @param string $resourceType which resource type does the provider handles |
|
39 | - * @param string $displayName user facing name of the federated share provider |
|
40 | - * @param callable $callback |
|
41 | - * @throws Exceptions\ProviderAlreadyExistsException |
|
42 | - * |
|
43 | - * @since 14.0.0 |
|
44 | - */ |
|
45 | - public function addCloudFederationProvider($resourceType, $displayName, callable $callback); |
|
35 | + /** |
|
36 | + * Registers an callback function which must return an cloud federation provider |
|
37 | + * |
|
38 | + * @param string $resourceType which resource type does the provider handles |
|
39 | + * @param string $displayName user facing name of the federated share provider |
|
40 | + * @param callable $callback |
|
41 | + * @throws Exceptions\ProviderAlreadyExistsException |
|
42 | + * |
|
43 | + * @since 14.0.0 |
|
44 | + */ |
|
45 | + public function addCloudFederationProvider($resourceType, $displayName, callable $callback); |
|
46 | 46 | |
47 | - /** |
|
48 | - * remove cloud federation provider |
|
49 | - * |
|
50 | - * @param string $resourceType |
|
51 | - * |
|
52 | - * @since 14.0.0 |
|
53 | - */ |
|
54 | - public function removeCloudFederationProvider($resourceType); |
|
47 | + /** |
|
48 | + * remove cloud federation provider |
|
49 | + * |
|
50 | + * @param string $resourceType |
|
51 | + * |
|
52 | + * @since 14.0.0 |
|
53 | + */ |
|
54 | + public function removeCloudFederationProvider($resourceType); |
|
55 | 55 | |
56 | - /** |
|
57 | - * get a list of all cloudFederationProviders |
|
58 | - * |
|
59 | - * @return array [resourceType => ['resourceType' => $resourceType, 'displayName' => $displayName, 'callback' => callback]] |
|
60 | - * |
|
61 | - * @since 14.0.0 |
|
62 | - */ |
|
63 | - public function getAllCloudFederationProviders(); |
|
56 | + /** |
|
57 | + * get a list of all cloudFederationProviders |
|
58 | + * |
|
59 | + * @return array [resourceType => ['resourceType' => $resourceType, 'displayName' => $displayName, 'callback' => callback]] |
|
60 | + * |
|
61 | + * @since 14.0.0 |
|
62 | + */ |
|
63 | + public function getAllCloudFederationProviders(); |
|
64 | 64 | |
65 | - /** |
|
66 | - * get a specific cloud federation provider |
|
67 | - * |
|
68 | - * @param string $resourceType |
|
69 | - * @return ICloudFederationProvider |
|
70 | - * @throws Exceptions\ProviderDoesNotExistsException; |
|
71 | - * |
|
72 | - * @since 14.0.0 |
|
73 | - */ |
|
74 | - public function getCloudFederationProvider($resourceType); |
|
65 | + /** |
|
66 | + * get a specific cloud federation provider |
|
67 | + * |
|
68 | + * @param string $resourceType |
|
69 | + * @return ICloudFederationProvider |
|
70 | + * @throws Exceptions\ProviderDoesNotExistsException; |
|
71 | + * |
|
72 | + * @since 14.0.0 |
|
73 | + */ |
|
74 | + public function getCloudFederationProvider($resourceType); |
|
75 | 75 | |
76 | - /** |
|
77 | - * send federated share |
|
78 | - * |
|
79 | - * @param ICloudFederationShare $share |
|
80 | - * @return mixed |
|
81 | - * |
|
82 | - * @since 14.0.0 |
|
83 | - */ |
|
84 | - public function sendShare(ICloudFederationShare $share); |
|
76 | + /** |
|
77 | + * send federated share |
|
78 | + * |
|
79 | + * @param ICloudFederationShare $share |
|
80 | + * @return mixed |
|
81 | + * |
|
82 | + * @since 14.0.0 |
|
83 | + */ |
|
84 | + public function sendShare(ICloudFederationShare $share); |
|
85 | 85 | |
86 | - /** |
|
87 | - * send notification about existing share |
|
88 | - * |
|
89 | - * @param string $url |
|
90 | - * @param ICloudFederationNotification $notification |
|
91 | - * @return mixed |
|
92 | - * |
|
93 | - * @since 14.0.0 |
|
94 | - */ |
|
95 | - public function sendNotification($url, ICloudFederationNotification $notification); |
|
86 | + /** |
|
87 | + * send notification about existing share |
|
88 | + * |
|
89 | + * @param string $url |
|
90 | + * @param ICloudFederationNotification $notification |
|
91 | + * @return mixed |
|
92 | + * |
|
93 | + * @since 14.0.0 |
|
94 | + */ |
|
95 | + public function sendNotification($url, ICloudFederationNotification $notification); |
|
96 | 96 | |
97 | - /** |
|
98 | - * check if the new cloud federation API is ready to be used |
|
99 | - * |
|
100 | - * @return bool |
|
101 | - * |
|
102 | - * @since 14.0.0 |
|
103 | - */ |
|
104 | - public function isReady(); |
|
97 | + /** |
|
98 | + * check if the new cloud federation API is ready to be used |
|
99 | + * |
|
100 | + * @return bool |
|
101 | + * |
|
102 | + * @since 14.0.0 |
|
103 | + */ |
|
104 | + public function isReady(); |
|
105 | 105 | |
106 | 106 | |
107 | 107 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * share received from another server |
151 | 151 | * |
152 | 152 | * @param ICloudFederationShare $share |
153 | - * @return string provider specific unique ID of the share |
|
153 | + * @return integer provider specific unique ID of the share |
|
154 | 154 | * |
155 | 155 | * @throws ProviderCouldNotAddShareException |
156 | 156 | * @throws \OCP\AppFramework\QueryException |
@@ -325,11 +325,11 @@ discard block |
||
325 | 325 | /** |
326 | 326 | * notify user about new federated share |
327 | 327 | * |
328 | - * @param $shareWith |
|
329 | - * @param $shareId |
|
330 | - * @param $ownerFederatedId |
|
331 | - * @param $sharedByFederatedId |
|
332 | - * @param $name |
|
328 | + * @param string $shareWith |
|
329 | + * @param integer $shareId |
|
330 | + * @param string $ownerFederatedId |
|
331 | + * @param string $sharedByFederatedId |
|
332 | + * @param string $name |
|
333 | 333 | */ |
334 | 334 | private function notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name) { |
335 | 335 | $notification = $this->notificationManager->createNotification(); |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | /** |
822 | 822 | * get the supported share types, e.g. "user", "group", etc. |
823 | 823 | * |
824 | - * @return array |
|
824 | + * @return string[] |
|
825 | 825 | * |
826 | 826 | * @since 14.0.0 |
827 | 827 | */ |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | // for backward compatibility make sure that the remote url stored in the |
173 | 173 | // database ends with a trailing slash |
174 | 174 | if (substr($remote, -1) !== '/') { |
175 | - $remote = $remote . '/'; |
|
175 | + $remote = $remote.'/'; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | $token = $share->getShareSecret(); |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | |
201 | 201 | // FIXME this should be a method in the user management instead |
202 | 202 | if ($shareType === Share::SHARE_TYPE_USER) { |
203 | - $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); |
|
203 | + $this->logger->debug('shareWith before, '.$shareWith, ['app' => 'files_sharing']); |
|
204 | 204 | Util::emitHook( |
205 | 205 | '\OCA\Files_Sharing\API\Server2Server', |
206 | 206 | 'preLoginNameUsedAsUserName', |
207 | 207 | array('uid' => &$shareWith) |
208 | 208 | ); |
209 | - $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); |
|
209 | + $this->logger->debug('shareWith after, '.$shareWith, ['app' => 'files_sharing']); |
|
210 | 210 | |
211 | 211 | if (!$this->userManager->userExists($shareWith)) { |
212 | - throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST); |
|
212 | + throw new ProviderCouldNotAddShareException('User does not exists', '', Http::STATUS_BAD_REQUEST); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | \OC_Util::setupFS($shareWith); |
216 | 216 | } |
217 | 217 | |
218 | 218 | if ($shareType === Share::SHARE_TYPE_GROUP && !$this->groupManager->groupExists($shareWith)) { |
219 | - throw new ProviderCouldNotAddShareException('Group does not exists', '',Http::STATUS_BAD_REQUEST); |
|
219 | + throw new ProviderCouldNotAddShareException('Group does not exists', '', Http::STATUS_BAD_REQUEST); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | $externalManager = new \OCA\Files_Sharing\External\Manager( |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | ); |
233 | 233 | |
234 | 234 | try { |
235 | - $externalManager->addShare($remote, $token, '', $name, $owner, $shareType,false, $shareWith, $remoteId); |
|
235 | + $externalManager->addShare($remote, $token, '', $name, $owner, $shareType, false, $shareWith, $remoteId); |
|
236 | 236 | $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external'); |
237 | 237 | |
238 | 238 | if ($shareType === Share::SHARE_TYPE_USER) { |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | ->setType('remote_share') |
242 | 242 | ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
243 | 243 | ->setAffectedUser($shareWith) |
244 | - ->setObject('remote_share', (int)$shareId, $name); |
|
244 | + ->setObject('remote_share', (int) $shareId, $name); |
|
245 | 245 | \OC::$server->getActivityManager()->publish($event); |
246 | 246 | $this->notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name); |
247 | 247 | } else { |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | ->setType('remote_share') |
253 | 253 | ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
254 | 254 | ->setAffectedUser($user->getUID()) |
255 | - ->setObject('remote_share', (int)$shareId, $name); |
|
255 | + ->setObject('remote_share', (int) $shareId, $name); |
|
256 | 256 | \OC::$server->getActivityManager()->publish($event); |
257 | 257 | $this->notifyAboutNewShare($user->getUID(), $shareId, $ownerFederatedId, $sharedByFederatedId, $name); |
258 | 258 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | 'level' => ILogger::ERROR, |
265 | 265 | 'app' => 'files_sharing' |
266 | 266 | ]); |
267 | - throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
267 | + throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from '.$remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | |
342 | 342 | $declineAction = $notification->createAction(); |
343 | 343 | $declineAction->setLabel('decline') |
344 | - ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE'); |
|
344 | + ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'DELETE'); |
|
345 | 345 | $notification->addAction($declineAction); |
346 | 346 | |
347 | 347 | $acceptAction = $notification->createAction(); |
348 | 348 | $acceptAction->setLabel('accept') |
349 | - ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST'); |
|
349 | + ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'POST'); |
|
350 | 350 | $notification->addAction($acceptAction); |
351 | 351 | |
352 | 352 | $this->notificationManager->notify($notification); |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | */ |
407 | 407 | protected function executeAcceptShare(IShare $share) { |
408 | 408 | try { |
409 | - $fileId = (int)$share->getNode()->getId(); |
|
409 | + $fileId = (int) $share->getNode()->getId(); |
|
410 | 410 | list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
411 | 411 | } catch (\Exception $e) { |
412 | 412 | throw new ShareNotFound(); |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | $this->federatedShareProvider->removeShareFromTable($share); |
485 | 485 | |
486 | 486 | try { |
487 | - $fileId = (int)$share->getNode()->getId(); |
|
487 | + $fileId = (int) $share->getNode()->getId(); |
|
488 | 488 | list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
489 | 489 | } catch (\Exception $e) { |
490 | 490 | throw new ShareNotFound(); |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | $notification = $this->notificationManager->createNotification(); |
586 | 586 | $notification->setApp('files_sharing') |
587 | 587 | ->setUser($share['user']) |
588 | - ->setObject('remote_share', (int)$share['id']); |
|
588 | + ->setObject('remote_share', (int) $share['id']); |
|
589 | 589 | $this->notificationManager->markProcessed($notification); |
590 | 590 | |
591 | 591 | $event = $this->activityManager->generateEvent(); |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | ->setType('remote_share') |
594 | 594 | ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path]) |
595 | 595 | ->setAffectedUser($user) |
596 | - ->setObject('remote_share', (int)$share['id'], $path); |
|
596 | + ->setObject('remote_share', (int) $share['id'], $path); |
|
597 | 597 | \OC::$server->getActivityManager()->publish($event); |
598 | 598 | } |
599 | 599 | |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | $owner = $share->getShareOwner(); |
642 | 642 | $currentServer = $this->addressHandler->generateRemoteURL(); |
643 | 643 | if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) { |
644 | - throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: ' . $id); |
|
644 | + throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: '.$id); |
|
645 | 645 | } |
646 | 646 | } catch (\Exception $e) { |
647 | 647 | throw new ProviderCouldNotAddShareException($e->getMessage()); |
@@ -655,10 +655,10 @@ discard block |
||
655 | 655 | $share->setSharedBy($share->getSharedWith()); |
656 | 656 | $share->setSharedWith($shareWith); |
657 | 657 | $result = $this->federatedShareProvider->create($share); |
658 | - $this->federatedShareProvider->storeRemoteId((int)$result->getId(), $senderId); |
|
658 | + $this->federatedShareProvider->storeRemoteId((int) $result->getId(), $senderId); |
|
659 | 659 | return ['token' => $result->getToken(), 'providerId' => $result->getId()]; |
660 | 660 | } else { |
661 | - throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id); |
|
661 | + throw new ProviderCouldNotAddShareException('resharing not allowed for share: '.$id); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | */ |
705 | 705 | protected function ocmPermissions2ncPermissions(array $ocmPermissions) { |
706 | 706 | $ncPermissions = 0; |
707 | - foreach($ocmPermissions as $permission) { |
|
707 | + foreach ($ocmPermissions as $permission) { |
|
708 | 708 | switch (strtolower($permission)) { |
709 | 709 | case 'read': |
710 | 710 | $ncPermissions += Constants::PERMISSION_READ; |
@@ -52,782 +52,782 @@ |
||
52 | 52 | |
53 | 53 | class CloudFederationProviderFiles implements ICloudFederationProvider { |
54 | 54 | |
55 | - /** @var IAppManager */ |
|
56 | - private $appManager; |
|
57 | - |
|
58 | - /** @var FederatedShareProvider */ |
|
59 | - private $federatedShareProvider; |
|
60 | - |
|
61 | - /** @var AddressHandler */ |
|
62 | - private $addressHandler; |
|
63 | - |
|
64 | - /** @var ILogger */ |
|
65 | - private $logger; |
|
66 | - |
|
67 | - /** @var IUserManager */ |
|
68 | - private $userManager; |
|
69 | - |
|
70 | - /** @var ICloudIdManager */ |
|
71 | - private $cloudIdManager; |
|
72 | - |
|
73 | - /** @var IActivityManager */ |
|
74 | - private $activityManager; |
|
75 | - |
|
76 | - /** @var INotificationManager */ |
|
77 | - private $notificationManager; |
|
78 | - |
|
79 | - /** @var IURLGenerator */ |
|
80 | - private $urlGenerator; |
|
81 | - |
|
82 | - /** @var ICloudFederationFactory */ |
|
83 | - private $cloudFederationFactory; |
|
84 | - |
|
85 | - /** @var ICloudFederationProviderManager */ |
|
86 | - private $cloudFederationProviderManager; |
|
87 | - |
|
88 | - /** @var IDBConnection */ |
|
89 | - private $connection; |
|
90 | - |
|
91 | - /** @var IGroupManager */ |
|
92 | - private $groupManager; |
|
93 | - |
|
94 | - /** |
|
95 | - * CloudFederationProvider constructor. |
|
96 | - * |
|
97 | - * @param IAppManager $appManager |
|
98 | - * @param FederatedShareProvider $federatedShareProvider |
|
99 | - * @param AddressHandler $addressHandler |
|
100 | - * @param ILogger $logger |
|
101 | - * @param IUserManager $userManager |
|
102 | - * @param ICloudIdManager $cloudIdManager |
|
103 | - * @param IActivityManager $activityManager |
|
104 | - * @param INotificationManager $notificationManager |
|
105 | - * @param IURLGenerator $urlGenerator |
|
106 | - * @param ICloudFederationFactory $cloudFederationFactory |
|
107 | - * @param ICloudFederationProviderManager $cloudFederationProviderManager |
|
108 | - * @param IDBConnection $connection |
|
109 | - * @param IGroupManager $groupManager |
|
110 | - */ |
|
111 | - public function __construct(IAppManager $appManager, |
|
112 | - FederatedShareProvider $federatedShareProvider, |
|
113 | - AddressHandler $addressHandler, |
|
114 | - ILogger $logger, |
|
115 | - IUserManager $userManager, |
|
116 | - ICloudIdManager $cloudIdManager, |
|
117 | - IActivityManager $activityManager, |
|
118 | - INotificationManager $notificationManager, |
|
119 | - IURLGenerator $urlGenerator, |
|
120 | - ICloudFederationFactory $cloudFederationFactory, |
|
121 | - ICloudFederationProviderManager $cloudFederationProviderManager, |
|
122 | - IDBConnection $connection, |
|
123 | - IGroupManager $groupManager |
|
124 | - ) { |
|
125 | - $this->appManager = $appManager; |
|
126 | - $this->federatedShareProvider = $federatedShareProvider; |
|
127 | - $this->addressHandler = $addressHandler; |
|
128 | - $this->logger = $logger; |
|
129 | - $this->userManager = $userManager; |
|
130 | - $this->cloudIdManager = $cloudIdManager; |
|
131 | - $this->activityManager = $activityManager; |
|
132 | - $this->notificationManager = $notificationManager; |
|
133 | - $this->urlGenerator = $urlGenerator; |
|
134 | - $this->cloudFederationFactory = $cloudFederationFactory; |
|
135 | - $this->cloudFederationProviderManager = $cloudFederationProviderManager; |
|
136 | - $this->connection = $connection; |
|
137 | - $this->groupManager = $groupManager; |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * @return string |
|
144 | - */ |
|
145 | - public function getShareType() { |
|
146 | - return 'file'; |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * share received from another server |
|
151 | - * |
|
152 | - * @param ICloudFederationShare $share |
|
153 | - * @return string provider specific unique ID of the share |
|
154 | - * |
|
155 | - * @throws ProviderCouldNotAddShareException |
|
156 | - * @throws \OCP\AppFramework\QueryException |
|
157 | - * @throws \OC\HintException |
|
158 | - * @since 14.0.0 |
|
159 | - */ |
|
160 | - public function shareReceived(ICloudFederationShare $share) { |
|
161 | - |
|
162 | - if (!$this->isS2SEnabled(true)) { |
|
163 | - throw new ProviderCouldNotAddShareException('Server does not support federated cloud sharing', '', Http::STATUS_SERVICE_UNAVAILABLE); |
|
164 | - } |
|
165 | - |
|
166 | - $protocol = $share->getProtocol(); |
|
167 | - if ($protocol['name'] !== 'webdav') { |
|
168 | - throw new ProviderCouldNotAddShareException('Unsupported protocol for data exchange.', '', Http::STATUS_NOT_IMPLEMENTED); |
|
169 | - } |
|
170 | - |
|
171 | - list($ownerUid, $remote) = $this->addressHandler->splitUserRemote($share->getOwner()); |
|
172 | - // for backward compatibility make sure that the remote url stored in the |
|
173 | - // database ends with a trailing slash |
|
174 | - if (substr($remote, -1) !== '/') { |
|
175 | - $remote = $remote . '/'; |
|
176 | - } |
|
177 | - |
|
178 | - $token = $share->getShareSecret(); |
|
179 | - $name = $share->getResourceName(); |
|
180 | - $owner = $share->getOwnerDisplayName(); |
|
181 | - $sharedBy = $share->getSharedByDisplayName(); |
|
182 | - $shareWith = $share->getShareWith(); |
|
183 | - $remoteId = $share->getProviderId(); |
|
184 | - $sharedByFederatedId = $share->getSharedBy(); |
|
185 | - $ownerFederatedId = $share->getOwner(); |
|
186 | - $shareType = $this->mapShareTypeToNextcloud($share->getShareType()); |
|
187 | - |
|
188 | - // if no explicit information about the person who created the share was send |
|
189 | - // we assume that the share comes from the owner |
|
190 | - if ($sharedByFederatedId === null) { |
|
191 | - $sharedBy = $owner; |
|
192 | - $sharedByFederatedId = $ownerFederatedId; |
|
193 | - } |
|
194 | - |
|
195 | - if ($remote && $token && $name && $owner && $remoteId && $shareWith) { |
|
196 | - |
|
197 | - if (!Util::isValidFileName($name)) { |
|
198 | - throw new ProviderCouldNotAddShareException('The mountpoint name contains invalid characters.', '', Http::STATUS_BAD_REQUEST); |
|
199 | - } |
|
200 | - |
|
201 | - // FIXME this should be a method in the user management instead |
|
202 | - if ($shareType === Share::SHARE_TYPE_USER) { |
|
203 | - $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); |
|
204 | - Util::emitHook( |
|
205 | - '\OCA\Files_Sharing\API\Server2Server', |
|
206 | - 'preLoginNameUsedAsUserName', |
|
207 | - array('uid' => &$shareWith) |
|
208 | - ); |
|
209 | - $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); |
|
210 | - |
|
211 | - if (!$this->userManager->userExists($shareWith)) { |
|
212 | - throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST); |
|
213 | - } |
|
214 | - |
|
215 | - \OC_Util::setupFS($shareWith); |
|
216 | - } |
|
217 | - |
|
218 | - if ($shareType === Share::SHARE_TYPE_GROUP && !$this->groupManager->groupExists($shareWith)) { |
|
219 | - throw new ProviderCouldNotAddShareException('Group does not exists', '',Http::STATUS_BAD_REQUEST); |
|
220 | - } |
|
221 | - |
|
222 | - $externalManager = new \OCA\Files_Sharing\External\Manager( |
|
223 | - \OC::$server->getDatabaseConnection(), |
|
224 | - Filesystem::getMountManager(), |
|
225 | - Filesystem::getLoader(), |
|
226 | - \OC::$server->getHTTPClientService(), |
|
227 | - \OC::$server->getNotificationManager(), |
|
228 | - \OC::$server->query(\OCP\OCS\IDiscoveryService::class), |
|
229 | - \OC::$server->getCloudFederationProviderManager(), |
|
230 | - \OC::$server->getCloudFederationFactory(), |
|
231 | - \OC::$server->getGroupManager(), |
|
232 | - \OC::$server->getUserManager(), |
|
233 | - $shareWith |
|
234 | - ); |
|
235 | - |
|
236 | - try { |
|
237 | - $externalManager->addShare($remote, $token, '', $name, $owner, $shareType,false, $shareWith, $remoteId); |
|
238 | - $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external'); |
|
239 | - |
|
240 | - if ($shareType === Share::SHARE_TYPE_USER) { |
|
241 | - $event = $this->activityManager->generateEvent(); |
|
242 | - $event->setApp('files_sharing') |
|
243 | - ->setType('remote_share') |
|
244 | - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
|
245 | - ->setAffectedUser($shareWith) |
|
246 | - ->setObject('remote_share', (int)$shareId, $name); |
|
247 | - \OC::$server->getActivityManager()->publish($event); |
|
248 | - $this->notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name); |
|
249 | - } else { |
|
250 | - $groupMembers = $this->groupManager->get($shareWith)->getUsers(); |
|
251 | - foreach ($groupMembers as $user) { |
|
252 | - $event = $this->activityManager->generateEvent(); |
|
253 | - $event->setApp('files_sharing') |
|
254 | - ->setType('remote_share') |
|
255 | - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
|
256 | - ->setAffectedUser($user->getUID()) |
|
257 | - ->setObject('remote_share', (int)$shareId, $name); |
|
258 | - \OC::$server->getActivityManager()->publish($event); |
|
259 | - $this->notifyAboutNewShare($user->getUID(), $shareId, $ownerFederatedId, $sharedByFederatedId, $name); |
|
260 | - } |
|
261 | - } |
|
262 | - return $shareId; |
|
263 | - } catch (\Exception $e) { |
|
264 | - $this->logger->logException($e, [ |
|
265 | - 'message' => 'Server can not add remote share.', |
|
266 | - 'level' => ILogger::ERROR, |
|
267 | - 'app' => 'files_sharing' |
|
268 | - ]); |
|
269 | - throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
270 | - } |
|
271 | - } |
|
272 | - |
|
273 | - throw new ProviderCouldNotAddShareException('server can not add remote share, missing parameter', '', HTTP::STATUS_BAD_REQUEST); |
|
274 | - |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * notification received from another server |
|
279 | - * |
|
280 | - * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
281 | - * @param string $providerId id of the share |
|
282 | - * @param array $notification payload of the notification |
|
283 | - * @return array data send back to the sender |
|
284 | - * |
|
285 | - * @throws ActionNotSupportedException |
|
286 | - * @throws AuthenticationFailedException |
|
287 | - * @throws BadRequestException |
|
288 | - * @throws \OC\HintException |
|
289 | - * @since 14.0.0 |
|
290 | - */ |
|
291 | - public function notificationReceived($notificationType, $providerId, array $notification) { |
|
292 | - |
|
293 | - switch ($notificationType) { |
|
294 | - case 'SHARE_ACCEPTED': |
|
295 | - return $this->shareAccepted($providerId, $notification); |
|
296 | - case 'SHARE_DECLINED': |
|
297 | - return $this->shareDeclined($providerId, $notification); |
|
298 | - case 'SHARE_UNSHARED': |
|
299 | - return $this->unshare($providerId, $notification); |
|
300 | - case 'REQUEST_RESHARE': |
|
301 | - return $this->reshareRequested($providerId, $notification); |
|
302 | - case 'RESHARE_UNDO': |
|
303 | - return $this->undoReshare($providerId, $notification); |
|
304 | - case 'RESHARE_CHANGE_PERMISSION': |
|
305 | - return $this->updateResharePermissions($providerId, $notification); |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - throw new BadRequestException([$notificationType]); |
|
310 | - } |
|
311 | - |
|
312 | - /** |
|
313 | - * map OCM share type (strings) to Nextcloud internal share types (integer) |
|
314 | - * |
|
315 | - * @param string $shareType |
|
316 | - * @return int |
|
317 | - */ |
|
318 | - private function mapShareTypeToNextcloud($shareType) { |
|
319 | - $result = Share::SHARE_TYPE_USER; |
|
320 | - if ($shareType === 'group') { |
|
321 | - $result = Share::SHARE_TYPE_GROUP; |
|
322 | - } |
|
323 | - |
|
324 | - return $result; |
|
325 | - } |
|
326 | - |
|
327 | - /** |
|
328 | - * notify user about new federated share |
|
329 | - * |
|
330 | - * @param $shareWith |
|
331 | - * @param $shareId |
|
332 | - * @param $ownerFederatedId |
|
333 | - * @param $sharedByFederatedId |
|
334 | - * @param $name |
|
335 | - */ |
|
336 | - private function notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name) { |
|
337 | - $notification = $this->notificationManager->createNotification(); |
|
338 | - $notification->setApp('files_sharing') |
|
339 | - ->setUser($shareWith) |
|
340 | - ->setDateTime(new \DateTime()) |
|
341 | - ->setObject('remote_share', $shareId) |
|
342 | - ->setSubject('remote_share', [$ownerFederatedId, $sharedByFederatedId, trim($name, '/')]); |
|
343 | - |
|
344 | - $declineAction = $notification->createAction(); |
|
345 | - $declineAction->setLabel('decline') |
|
346 | - ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE'); |
|
347 | - $notification->addAction($declineAction); |
|
348 | - |
|
349 | - $acceptAction = $notification->createAction(); |
|
350 | - $acceptAction->setLabel('accept') |
|
351 | - ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST'); |
|
352 | - $notification->addAction($acceptAction); |
|
353 | - |
|
354 | - $this->notificationManager->notify($notification); |
|
355 | - } |
|
356 | - |
|
357 | - /** |
|
358 | - * process notification that the recipient accepted a share |
|
359 | - * |
|
360 | - * @param string $id |
|
361 | - * @param array $notification |
|
362 | - * @return array |
|
363 | - * @throws ActionNotSupportedException |
|
364 | - * @throws AuthenticationFailedException |
|
365 | - * @throws BadRequestException |
|
366 | - * @throws \OC\HintException |
|
367 | - */ |
|
368 | - private function shareAccepted($id, array $notification) { |
|
369 | - |
|
370 | - if (!$this->isS2SEnabled()) { |
|
371 | - throw new ActionNotSupportedException('Server does not support federated cloud sharing'); |
|
372 | - } |
|
373 | - |
|
374 | - if (!isset($notification['sharedSecret'])) { |
|
375 | - throw new BadRequestException(['sharedSecret']); |
|
376 | - } |
|
377 | - |
|
378 | - $token = $notification['sharedSecret']; |
|
379 | - |
|
380 | - $share = $this->federatedShareProvider->getShareById($id); |
|
381 | - |
|
382 | - $this->verifyShare($share, $token); |
|
383 | - $this->executeAcceptShare($share); |
|
384 | - if ($share->getShareOwner() !== $share->getSharedBy()) { |
|
385 | - list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); |
|
386 | - $remoteId = $this->federatedShareProvider->getRemoteId($share); |
|
387 | - $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
388 | - $notification->setMessage( |
|
389 | - 'SHARE_ACCEPTED', |
|
390 | - 'file', |
|
391 | - $remoteId, |
|
392 | - [ |
|
393 | - 'sharedSecret' => $token, |
|
394 | - 'message' => 'Recipient accepted the re-share' |
|
395 | - ] |
|
396 | - |
|
397 | - ); |
|
398 | - $this->cloudFederationProviderManager->sendNotification($remote, $notification); |
|
399 | - |
|
400 | - } |
|
401 | - |
|
402 | - return []; |
|
403 | - } |
|
404 | - |
|
405 | - /** |
|
406 | - * @param IShare $share |
|
407 | - * @throws ShareNotFound |
|
408 | - */ |
|
409 | - protected function executeAcceptShare(IShare $share) { |
|
410 | - try { |
|
411 | - $fileId = (int)$share->getNode()->getId(); |
|
412 | - list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
413 | - } catch (\Exception $e) { |
|
414 | - throw new ShareNotFound(); |
|
415 | - } |
|
416 | - |
|
417 | - $event = $this->activityManager->generateEvent(); |
|
418 | - $event->setApp('files_sharing') |
|
419 | - ->setType('remote_share') |
|
420 | - ->setAffectedUser($this->getCorrectUid($share)) |
|
421 | - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_ACCEPTED, [$share->getSharedWith(), [$fileId => $file]]) |
|
422 | - ->setObject('files', $fileId, $file) |
|
423 | - ->setLink($link); |
|
424 | - $this->activityManager->publish($event); |
|
425 | - } |
|
426 | - |
|
427 | - /** |
|
428 | - * process notification that the recipient declined a share |
|
429 | - * |
|
430 | - * @param string $id |
|
431 | - * @param array $notification |
|
432 | - * @return array |
|
433 | - * @throws ActionNotSupportedException |
|
434 | - * @throws AuthenticationFailedException |
|
435 | - * @throws BadRequestException |
|
436 | - * @throws ShareNotFound |
|
437 | - * @throws \OC\HintException |
|
438 | - * |
|
439 | - */ |
|
440 | - protected function shareDeclined($id, array $notification) { |
|
441 | - |
|
442 | - if (!$this->isS2SEnabled()) { |
|
443 | - throw new ActionNotSupportedException('Server does not support federated cloud sharing'); |
|
444 | - } |
|
445 | - |
|
446 | - if (!isset($notification['sharedSecret'])) { |
|
447 | - throw new BadRequestException(['sharedSecret']); |
|
448 | - } |
|
449 | - |
|
450 | - $token = $notification['sharedSecret']; |
|
451 | - |
|
452 | - $share = $this->federatedShareProvider->getShareById($id); |
|
453 | - |
|
454 | - $this->verifyShare($share, $token); |
|
455 | - |
|
456 | - if ($share->getShareOwner() !== $share->getSharedBy()) { |
|
457 | - list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); |
|
458 | - $remoteId = $this->federatedShareProvider->getRemoteId($share); |
|
459 | - $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
460 | - $notification->setMessage( |
|
461 | - 'SHARE_DECLINED', |
|
462 | - 'file', |
|
463 | - $remoteId, |
|
464 | - [ |
|
465 | - 'sharedSecret' => $token, |
|
466 | - 'message' => 'Recipient declined the re-share' |
|
467 | - ] |
|
468 | - |
|
469 | - ); |
|
470 | - $this->cloudFederationProviderManager->sendNotification($remote, $notification); |
|
471 | - } |
|
472 | - |
|
473 | - $this->executeDeclineShare($share); |
|
474 | - |
|
475 | - return []; |
|
476 | - |
|
477 | - } |
|
478 | - |
|
479 | - /** |
|
480 | - * delete declined share and create a activity |
|
481 | - * |
|
482 | - * @param IShare $share |
|
483 | - * @throws ShareNotFound |
|
484 | - */ |
|
485 | - protected function executeDeclineShare(IShare $share) { |
|
486 | - $this->federatedShareProvider->removeShareFromTable($share); |
|
487 | - |
|
488 | - try { |
|
489 | - $fileId = (int)$share->getNode()->getId(); |
|
490 | - list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
491 | - } catch (\Exception $e) { |
|
492 | - throw new ShareNotFound(); |
|
493 | - } |
|
494 | - |
|
495 | - $event = $this->activityManager->generateEvent(); |
|
496 | - $event->setApp('files_sharing') |
|
497 | - ->setType('remote_share') |
|
498 | - ->setAffectedUser($this->getCorrectUid($share)) |
|
499 | - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), [$fileId => $file]]) |
|
500 | - ->setObject('files', $fileId, $file) |
|
501 | - ->setLink($link); |
|
502 | - $this->activityManager->publish($event); |
|
503 | - |
|
504 | - } |
|
505 | - |
|
506 | - /** |
|
507 | - * received the notification that the owner unshared a file from you |
|
508 | - * |
|
509 | - * @param string $id |
|
510 | - * @param array $notification |
|
511 | - * @return array |
|
512 | - * @throws AuthenticationFailedException |
|
513 | - * @throws BadRequestException |
|
514 | - */ |
|
515 | - private function undoReshare($id, array $notification) { |
|
516 | - if (!isset($notification['sharedSecret'])) { |
|
517 | - throw new BadRequestException(['sharedSecret']); |
|
518 | - } |
|
519 | - $token = $notification['sharedSecret']; |
|
520 | - |
|
521 | - $share = $this->federatedShareProvider->getShareById($id); |
|
522 | - |
|
523 | - $this->verifyShare($share, $token); |
|
524 | - $this->federatedShareProvider->removeShareFromTable($share); |
|
525 | - return []; |
|
526 | - } |
|
527 | - |
|
528 | - /** |
|
529 | - * unshare file from self |
|
530 | - * |
|
531 | - * @param string $id |
|
532 | - * @param array $notification |
|
533 | - * @return array |
|
534 | - * @throws ActionNotSupportedException |
|
535 | - * @throws BadRequestException |
|
536 | - */ |
|
537 | - private function unshare($id, array $notification) { |
|
538 | - |
|
539 | - if (!$this->isS2SEnabled(true)) { |
|
540 | - throw new ActionNotSupportedException("incoming shares disabled!"); |
|
541 | - } |
|
542 | - |
|
543 | - if (!isset($notification['sharedSecret'])) { |
|
544 | - throw new BadRequestException(['sharedSecret']); |
|
545 | - } |
|
546 | - $token = $notification['sharedSecret']; |
|
547 | - |
|
548 | - $qb = $this->connection->getQueryBuilder(); |
|
549 | - $qb->select('*') |
|
550 | - ->from('share_external') |
|
551 | - ->where( |
|
552 | - $qb->expr()->andX( |
|
553 | - $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)), |
|
554 | - $qb->expr()->eq('share_token', $qb->createNamedParameter($token)) |
|
555 | - ) |
|
556 | - ); |
|
557 | - |
|
558 | - $result = $qb->execute(); |
|
559 | - $share = $result->fetch(); |
|
560 | - $result->closeCursor(); |
|
561 | - |
|
562 | - if ($token && $id && !empty($share)) { |
|
563 | - |
|
564 | - $remote = $this->cleanupRemote($share['remote']); |
|
565 | - |
|
566 | - $owner = $this->cloudIdManager->getCloudId($share['owner'], $remote); |
|
567 | - $mountpoint = $share['mountpoint']; |
|
568 | - $user = $share['user']; |
|
569 | - |
|
570 | - $qb = $this->connection->getQueryBuilder(); |
|
571 | - $qb->delete('share_external') |
|
572 | - ->where( |
|
573 | - $qb->expr()->andX( |
|
574 | - $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)), |
|
575 | - $qb->expr()->eq('share_token', $qb->createNamedParameter($token)) |
|
576 | - ) |
|
577 | - ); |
|
578 | - |
|
579 | - $qb->execute(); |
|
580 | - |
|
581 | - if ($share['accepted']) { |
|
582 | - $path = trim($mountpoint, '/'); |
|
583 | - } else { |
|
584 | - $path = trim($share['name'], '/'); |
|
585 | - } |
|
586 | - |
|
587 | - $notification = $this->notificationManager->createNotification(); |
|
588 | - $notification->setApp('files_sharing') |
|
589 | - ->setUser($share['user']) |
|
590 | - ->setObject('remote_share', (int)$share['id']); |
|
591 | - $this->notificationManager->markProcessed($notification); |
|
592 | - |
|
593 | - $event = $this->activityManager->generateEvent(); |
|
594 | - $event->setApp('files_sharing') |
|
595 | - ->setType('remote_share') |
|
596 | - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path]) |
|
597 | - ->setAffectedUser($user) |
|
598 | - ->setObject('remote_share', (int)$share['id'], $path); |
|
599 | - \OC::$server->getActivityManager()->publish($event); |
|
600 | - } |
|
601 | - |
|
602 | - return []; |
|
603 | - } |
|
604 | - |
|
605 | - private function cleanupRemote($remote) { |
|
606 | - $remote = substr($remote, strpos($remote, '://') + 3); |
|
607 | - |
|
608 | - return rtrim($remote, '/'); |
|
609 | - } |
|
610 | - |
|
611 | - /** |
|
612 | - * recipient of a share request to re-share the file with another user |
|
613 | - * |
|
614 | - * @param string $id |
|
615 | - * @param array $notification |
|
616 | - * @return array |
|
617 | - * @throws AuthenticationFailedException |
|
618 | - * @throws BadRequestException |
|
619 | - * @throws ProviderCouldNotAddShareException |
|
620 | - * @throws ShareNotFound |
|
621 | - */ |
|
622 | - protected function reshareRequested($id, array $notification) { |
|
623 | - |
|
624 | - if (!isset($notification['sharedSecret'])) { |
|
625 | - throw new BadRequestException(['sharedSecret']); |
|
626 | - } |
|
627 | - $token = $notification['sharedSecret']; |
|
628 | - |
|
629 | - if (!isset($notification['shareWith'])) { |
|
630 | - throw new BadRequestException(['shareWith']); |
|
631 | - } |
|
632 | - $shareWith = $notification['shareWith']; |
|
633 | - |
|
634 | - if (!isset($notification['senderId'])) { |
|
635 | - throw new BadRequestException(['senderId']); |
|
636 | - } |
|
637 | - $senderId = $notification['senderId']; |
|
638 | - |
|
639 | - $share = $this->federatedShareProvider->getShareById($id); |
|
640 | - // don't allow to share a file back to the owner |
|
641 | - try { |
|
642 | - list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith); |
|
643 | - $owner = $share->getShareOwner(); |
|
644 | - $currentServer = $this->addressHandler->generateRemoteURL(); |
|
645 | - if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) { |
|
646 | - throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: ' . $id); |
|
647 | - } |
|
648 | - } catch (\Exception $e) { |
|
649 | - throw new ProviderCouldNotAddShareException($e->getMessage()); |
|
650 | - } |
|
651 | - |
|
652 | - $this->verifyShare($share, $token); |
|
653 | - |
|
654 | - // check if re-sharing is allowed |
|
655 | - if ($share->getPermissions() & Constants::PERMISSION_SHARE) { |
|
656 | - // the recipient of the initial share is now the initiator for the re-share |
|
657 | - $share->setSharedBy($share->getSharedWith()); |
|
658 | - $share->setSharedWith($shareWith); |
|
659 | - $result = $this->federatedShareProvider->create($share); |
|
660 | - $this->federatedShareProvider->storeRemoteId((int)$result->getId(), $senderId); |
|
661 | - return ['token' => $result->getToken(), 'providerId' => $result->getId()]; |
|
662 | - } else { |
|
663 | - throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id); |
|
664 | - } |
|
665 | - |
|
666 | - } |
|
667 | - |
|
668 | - /** |
|
669 | - * update permission of a re-share so that the share dialog shows the right |
|
670 | - * permission if the owner or the sender changes the permission |
|
671 | - * |
|
672 | - * @param string $id |
|
673 | - * @param array $notification |
|
674 | - * @return array |
|
675 | - * @throws AuthenticationFailedException |
|
676 | - * @throws BadRequestException |
|
677 | - */ |
|
678 | - protected function updateResharePermissions($id, array $notification) { |
|
679 | - |
|
680 | - if (!isset($notification['sharedSecret'])) { |
|
681 | - throw new BadRequestException(['sharedSecret']); |
|
682 | - } |
|
683 | - $token = $notification['sharedSecret']; |
|
684 | - |
|
685 | - if (!isset($notification['permission'])) { |
|
686 | - throw new BadRequestException(['permission']); |
|
687 | - } |
|
688 | - $ocmPermissions = $notification['permission']; |
|
689 | - |
|
690 | - $share = $this->federatedShareProvider->getShareById($id); |
|
691 | - |
|
692 | - $ncPermission = $this->ocmPermissions2ncPermissions($ocmPermissions); |
|
693 | - |
|
694 | - $this->verifyShare($share, $token); |
|
695 | - $this->updatePermissionsInDatabase($share, $ncPermission); |
|
696 | - |
|
697 | - return []; |
|
698 | - } |
|
699 | - |
|
700 | - /** |
|
701 | - * translate OCM Permissions to Nextcloud permissions |
|
702 | - * |
|
703 | - * @param array $ocmPermissions |
|
704 | - * @return int |
|
705 | - * @throws BadRequestException |
|
706 | - */ |
|
707 | - protected function ocmPermissions2ncPermissions(array $ocmPermissions) { |
|
708 | - $ncPermissions = 0; |
|
709 | - foreach($ocmPermissions as $permission) { |
|
710 | - switch (strtolower($permission)) { |
|
711 | - case 'read': |
|
712 | - $ncPermissions += Constants::PERMISSION_READ; |
|
713 | - break; |
|
714 | - case 'write': |
|
715 | - $ncPermissions += Constants::PERMISSION_CREATE + Constants::PERMISSION_UPDATE; |
|
716 | - break; |
|
717 | - case 'share': |
|
718 | - $ncPermissions += Constants::PERMISSION_SHARE; |
|
719 | - break; |
|
720 | - default: |
|
721 | - throw new BadRequestException(['permission']); |
|
722 | - } |
|
723 | - |
|
724 | - } |
|
725 | - |
|
726 | - return $ncPermissions; |
|
727 | - } |
|
728 | - |
|
729 | - /** |
|
730 | - * update permissions in database |
|
731 | - * |
|
732 | - * @param IShare $share |
|
733 | - * @param int $permissions |
|
734 | - */ |
|
735 | - protected function updatePermissionsInDatabase(IShare $share, $permissions) { |
|
736 | - $query = $this->connection->getQueryBuilder(); |
|
737 | - $query->update('share') |
|
738 | - ->where($query->expr()->eq('id', $query->createNamedParameter($share->getId()))) |
|
739 | - ->set('permissions', $query->createNamedParameter($permissions)) |
|
740 | - ->execute(); |
|
741 | - } |
|
742 | - |
|
743 | - |
|
744 | - /** |
|
745 | - * get file |
|
746 | - * |
|
747 | - * @param string $user |
|
748 | - * @param int $fileSource |
|
749 | - * @return array with internal path of the file and a absolute link to it |
|
750 | - */ |
|
751 | - private function getFile($user, $fileSource) { |
|
752 | - \OC_Util::setupFS($user); |
|
753 | - |
|
754 | - try { |
|
755 | - $file = Filesystem::getPath($fileSource); |
|
756 | - } catch (NotFoundException $e) { |
|
757 | - $file = null; |
|
758 | - } |
|
759 | - $args = Filesystem::is_dir($file) ? array('dir' => $file) : array('dir' => dirname($file), 'scrollto' => $file); |
|
760 | - $link = Util::linkToAbsolute('files', 'index.php', $args); |
|
761 | - |
|
762 | - return [$file, $link]; |
|
763 | - |
|
764 | - } |
|
765 | - |
|
766 | - /** |
|
767 | - * check if we are the initiator or the owner of a re-share and return the correct UID |
|
768 | - * |
|
769 | - * @param IShare $share |
|
770 | - * @return string |
|
771 | - */ |
|
772 | - protected function getCorrectUid(IShare $share) { |
|
773 | - if ($this->userManager->userExists($share->getShareOwner())) { |
|
774 | - return $share->getShareOwner(); |
|
775 | - } |
|
776 | - |
|
777 | - return $share->getSharedBy(); |
|
778 | - } |
|
779 | - |
|
780 | - |
|
781 | - |
|
782 | - /** |
|
783 | - * check if we got the right share |
|
784 | - * |
|
785 | - * @param IShare $share |
|
786 | - * @param string $token |
|
787 | - * @return bool |
|
788 | - * @throws AuthenticationFailedException |
|
789 | - */ |
|
790 | - protected function verifyShare(IShare $share, $token) { |
|
791 | - if ( |
|
792 | - $share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE && |
|
793 | - $share->getToken() === $token |
|
794 | - ) { |
|
795 | - return true; |
|
796 | - } |
|
797 | - |
|
798 | - throw new AuthenticationFailedException(); |
|
799 | - } |
|
800 | - |
|
801 | - |
|
802 | - |
|
803 | - /** |
|
804 | - * check if server-to-server sharing is enabled |
|
805 | - * |
|
806 | - * @param bool $incoming |
|
807 | - * @return bool |
|
808 | - */ |
|
809 | - private function isS2SEnabled($incoming = false) { |
|
810 | - |
|
811 | - $result = $this->appManager->isEnabledForUser('files_sharing'); |
|
812 | - |
|
813 | - if ($incoming) { |
|
814 | - $result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled(); |
|
815 | - } else { |
|
816 | - $result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(); |
|
817 | - } |
|
818 | - |
|
819 | - return $result; |
|
820 | - } |
|
821 | - |
|
822 | - |
|
823 | - /** |
|
824 | - * get the supported share types, e.g. "user", "group", etc. |
|
825 | - * |
|
826 | - * @return array |
|
827 | - * |
|
828 | - * @since 14.0.0 |
|
829 | - */ |
|
830 | - public function getSupportedShareTypes() { |
|
831 | - return ['user', 'group']; |
|
832 | - } |
|
55 | + /** @var IAppManager */ |
|
56 | + private $appManager; |
|
57 | + |
|
58 | + /** @var FederatedShareProvider */ |
|
59 | + private $federatedShareProvider; |
|
60 | + |
|
61 | + /** @var AddressHandler */ |
|
62 | + private $addressHandler; |
|
63 | + |
|
64 | + /** @var ILogger */ |
|
65 | + private $logger; |
|
66 | + |
|
67 | + /** @var IUserManager */ |
|
68 | + private $userManager; |
|
69 | + |
|
70 | + /** @var ICloudIdManager */ |
|
71 | + private $cloudIdManager; |
|
72 | + |
|
73 | + /** @var IActivityManager */ |
|
74 | + private $activityManager; |
|
75 | + |
|
76 | + /** @var INotificationManager */ |
|
77 | + private $notificationManager; |
|
78 | + |
|
79 | + /** @var IURLGenerator */ |
|
80 | + private $urlGenerator; |
|
81 | + |
|
82 | + /** @var ICloudFederationFactory */ |
|
83 | + private $cloudFederationFactory; |
|
84 | + |
|
85 | + /** @var ICloudFederationProviderManager */ |
|
86 | + private $cloudFederationProviderManager; |
|
87 | + |
|
88 | + /** @var IDBConnection */ |
|
89 | + private $connection; |
|
90 | + |
|
91 | + /** @var IGroupManager */ |
|
92 | + private $groupManager; |
|
93 | + |
|
94 | + /** |
|
95 | + * CloudFederationProvider constructor. |
|
96 | + * |
|
97 | + * @param IAppManager $appManager |
|
98 | + * @param FederatedShareProvider $federatedShareProvider |
|
99 | + * @param AddressHandler $addressHandler |
|
100 | + * @param ILogger $logger |
|
101 | + * @param IUserManager $userManager |
|
102 | + * @param ICloudIdManager $cloudIdManager |
|
103 | + * @param IActivityManager $activityManager |
|
104 | + * @param INotificationManager $notificationManager |
|
105 | + * @param IURLGenerator $urlGenerator |
|
106 | + * @param ICloudFederationFactory $cloudFederationFactory |
|
107 | + * @param ICloudFederationProviderManager $cloudFederationProviderManager |
|
108 | + * @param IDBConnection $connection |
|
109 | + * @param IGroupManager $groupManager |
|
110 | + */ |
|
111 | + public function __construct(IAppManager $appManager, |
|
112 | + FederatedShareProvider $federatedShareProvider, |
|
113 | + AddressHandler $addressHandler, |
|
114 | + ILogger $logger, |
|
115 | + IUserManager $userManager, |
|
116 | + ICloudIdManager $cloudIdManager, |
|
117 | + IActivityManager $activityManager, |
|
118 | + INotificationManager $notificationManager, |
|
119 | + IURLGenerator $urlGenerator, |
|
120 | + ICloudFederationFactory $cloudFederationFactory, |
|
121 | + ICloudFederationProviderManager $cloudFederationProviderManager, |
|
122 | + IDBConnection $connection, |
|
123 | + IGroupManager $groupManager |
|
124 | + ) { |
|
125 | + $this->appManager = $appManager; |
|
126 | + $this->federatedShareProvider = $federatedShareProvider; |
|
127 | + $this->addressHandler = $addressHandler; |
|
128 | + $this->logger = $logger; |
|
129 | + $this->userManager = $userManager; |
|
130 | + $this->cloudIdManager = $cloudIdManager; |
|
131 | + $this->activityManager = $activityManager; |
|
132 | + $this->notificationManager = $notificationManager; |
|
133 | + $this->urlGenerator = $urlGenerator; |
|
134 | + $this->cloudFederationFactory = $cloudFederationFactory; |
|
135 | + $this->cloudFederationProviderManager = $cloudFederationProviderManager; |
|
136 | + $this->connection = $connection; |
|
137 | + $this->groupManager = $groupManager; |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * @return string |
|
144 | + */ |
|
145 | + public function getShareType() { |
|
146 | + return 'file'; |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * share received from another server |
|
151 | + * |
|
152 | + * @param ICloudFederationShare $share |
|
153 | + * @return string provider specific unique ID of the share |
|
154 | + * |
|
155 | + * @throws ProviderCouldNotAddShareException |
|
156 | + * @throws \OCP\AppFramework\QueryException |
|
157 | + * @throws \OC\HintException |
|
158 | + * @since 14.0.0 |
|
159 | + */ |
|
160 | + public function shareReceived(ICloudFederationShare $share) { |
|
161 | + |
|
162 | + if (!$this->isS2SEnabled(true)) { |
|
163 | + throw new ProviderCouldNotAddShareException('Server does not support federated cloud sharing', '', Http::STATUS_SERVICE_UNAVAILABLE); |
|
164 | + } |
|
165 | + |
|
166 | + $protocol = $share->getProtocol(); |
|
167 | + if ($protocol['name'] !== 'webdav') { |
|
168 | + throw new ProviderCouldNotAddShareException('Unsupported protocol for data exchange.', '', Http::STATUS_NOT_IMPLEMENTED); |
|
169 | + } |
|
170 | + |
|
171 | + list($ownerUid, $remote) = $this->addressHandler->splitUserRemote($share->getOwner()); |
|
172 | + // for backward compatibility make sure that the remote url stored in the |
|
173 | + // database ends with a trailing slash |
|
174 | + if (substr($remote, -1) !== '/') { |
|
175 | + $remote = $remote . '/'; |
|
176 | + } |
|
177 | + |
|
178 | + $token = $share->getShareSecret(); |
|
179 | + $name = $share->getResourceName(); |
|
180 | + $owner = $share->getOwnerDisplayName(); |
|
181 | + $sharedBy = $share->getSharedByDisplayName(); |
|
182 | + $shareWith = $share->getShareWith(); |
|
183 | + $remoteId = $share->getProviderId(); |
|
184 | + $sharedByFederatedId = $share->getSharedBy(); |
|
185 | + $ownerFederatedId = $share->getOwner(); |
|
186 | + $shareType = $this->mapShareTypeToNextcloud($share->getShareType()); |
|
187 | + |
|
188 | + // if no explicit information about the person who created the share was send |
|
189 | + // we assume that the share comes from the owner |
|
190 | + if ($sharedByFederatedId === null) { |
|
191 | + $sharedBy = $owner; |
|
192 | + $sharedByFederatedId = $ownerFederatedId; |
|
193 | + } |
|
194 | + |
|
195 | + if ($remote && $token && $name && $owner && $remoteId && $shareWith) { |
|
196 | + |
|
197 | + if (!Util::isValidFileName($name)) { |
|
198 | + throw new ProviderCouldNotAddShareException('The mountpoint name contains invalid characters.', '', Http::STATUS_BAD_REQUEST); |
|
199 | + } |
|
200 | + |
|
201 | + // FIXME this should be a method in the user management instead |
|
202 | + if ($shareType === Share::SHARE_TYPE_USER) { |
|
203 | + $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); |
|
204 | + Util::emitHook( |
|
205 | + '\OCA\Files_Sharing\API\Server2Server', |
|
206 | + 'preLoginNameUsedAsUserName', |
|
207 | + array('uid' => &$shareWith) |
|
208 | + ); |
|
209 | + $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); |
|
210 | + |
|
211 | + if (!$this->userManager->userExists($shareWith)) { |
|
212 | + throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST); |
|
213 | + } |
|
214 | + |
|
215 | + \OC_Util::setupFS($shareWith); |
|
216 | + } |
|
217 | + |
|
218 | + if ($shareType === Share::SHARE_TYPE_GROUP && !$this->groupManager->groupExists($shareWith)) { |
|
219 | + throw new ProviderCouldNotAddShareException('Group does not exists', '',Http::STATUS_BAD_REQUEST); |
|
220 | + } |
|
221 | + |
|
222 | + $externalManager = new \OCA\Files_Sharing\External\Manager( |
|
223 | + \OC::$server->getDatabaseConnection(), |
|
224 | + Filesystem::getMountManager(), |
|
225 | + Filesystem::getLoader(), |
|
226 | + \OC::$server->getHTTPClientService(), |
|
227 | + \OC::$server->getNotificationManager(), |
|
228 | + \OC::$server->query(\OCP\OCS\IDiscoveryService::class), |
|
229 | + \OC::$server->getCloudFederationProviderManager(), |
|
230 | + \OC::$server->getCloudFederationFactory(), |
|
231 | + \OC::$server->getGroupManager(), |
|
232 | + \OC::$server->getUserManager(), |
|
233 | + $shareWith |
|
234 | + ); |
|
235 | + |
|
236 | + try { |
|
237 | + $externalManager->addShare($remote, $token, '', $name, $owner, $shareType,false, $shareWith, $remoteId); |
|
238 | + $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external'); |
|
239 | + |
|
240 | + if ($shareType === Share::SHARE_TYPE_USER) { |
|
241 | + $event = $this->activityManager->generateEvent(); |
|
242 | + $event->setApp('files_sharing') |
|
243 | + ->setType('remote_share') |
|
244 | + ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
|
245 | + ->setAffectedUser($shareWith) |
|
246 | + ->setObject('remote_share', (int)$shareId, $name); |
|
247 | + \OC::$server->getActivityManager()->publish($event); |
|
248 | + $this->notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name); |
|
249 | + } else { |
|
250 | + $groupMembers = $this->groupManager->get($shareWith)->getUsers(); |
|
251 | + foreach ($groupMembers as $user) { |
|
252 | + $event = $this->activityManager->generateEvent(); |
|
253 | + $event->setApp('files_sharing') |
|
254 | + ->setType('remote_share') |
|
255 | + ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
|
256 | + ->setAffectedUser($user->getUID()) |
|
257 | + ->setObject('remote_share', (int)$shareId, $name); |
|
258 | + \OC::$server->getActivityManager()->publish($event); |
|
259 | + $this->notifyAboutNewShare($user->getUID(), $shareId, $ownerFederatedId, $sharedByFederatedId, $name); |
|
260 | + } |
|
261 | + } |
|
262 | + return $shareId; |
|
263 | + } catch (\Exception $e) { |
|
264 | + $this->logger->logException($e, [ |
|
265 | + 'message' => 'Server can not add remote share.', |
|
266 | + 'level' => ILogger::ERROR, |
|
267 | + 'app' => 'files_sharing' |
|
268 | + ]); |
|
269 | + throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
270 | + } |
|
271 | + } |
|
272 | + |
|
273 | + throw new ProviderCouldNotAddShareException('server can not add remote share, missing parameter', '', HTTP::STATUS_BAD_REQUEST); |
|
274 | + |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * notification received from another server |
|
279 | + * |
|
280 | + * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
281 | + * @param string $providerId id of the share |
|
282 | + * @param array $notification payload of the notification |
|
283 | + * @return array data send back to the sender |
|
284 | + * |
|
285 | + * @throws ActionNotSupportedException |
|
286 | + * @throws AuthenticationFailedException |
|
287 | + * @throws BadRequestException |
|
288 | + * @throws \OC\HintException |
|
289 | + * @since 14.0.0 |
|
290 | + */ |
|
291 | + public function notificationReceived($notificationType, $providerId, array $notification) { |
|
292 | + |
|
293 | + switch ($notificationType) { |
|
294 | + case 'SHARE_ACCEPTED': |
|
295 | + return $this->shareAccepted($providerId, $notification); |
|
296 | + case 'SHARE_DECLINED': |
|
297 | + return $this->shareDeclined($providerId, $notification); |
|
298 | + case 'SHARE_UNSHARED': |
|
299 | + return $this->unshare($providerId, $notification); |
|
300 | + case 'REQUEST_RESHARE': |
|
301 | + return $this->reshareRequested($providerId, $notification); |
|
302 | + case 'RESHARE_UNDO': |
|
303 | + return $this->undoReshare($providerId, $notification); |
|
304 | + case 'RESHARE_CHANGE_PERMISSION': |
|
305 | + return $this->updateResharePermissions($providerId, $notification); |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + throw new BadRequestException([$notificationType]); |
|
310 | + } |
|
311 | + |
|
312 | + /** |
|
313 | + * map OCM share type (strings) to Nextcloud internal share types (integer) |
|
314 | + * |
|
315 | + * @param string $shareType |
|
316 | + * @return int |
|
317 | + */ |
|
318 | + private function mapShareTypeToNextcloud($shareType) { |
|
319 | + $result = Share::SHARE_TYPE_USER; |
|
320 | + if ($shareType === 'group') { |
|
321 | + $result = Share::SHARE_TYPE_GROUP; |
|
322 | + } |
|
323 | + |
|
324 | + return $result; |
|
325 | + } |
|
326 | + |
|
327 | + /** |
|
328 | + * notify user about new federated share |
|
329 | + * |
|
330 | + * @param $shareWith |
|
331 | + * @param $shareId |
|
332 | + * @param $ownerFederatedId |
|
333 | + * @param $sharedByFederatedId |
|
334 | + * @param $name |
|
335 | + */ |
|
336 | + private function notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name) { |
|
337 | + $notification = $this->notificationManager->createNotification(); |
|
338 | + $notification->setApp('files_sharing') |
|
339 | + ->setUser($shareWith) |
|
340 | + ->setDateTime(new \DateTime()) |
|
341 | + ->setObject('remote_share', $shareId) |
|
342 | + ->setSubject('remote_share', [$ownerFederatedId, $sharedByFederatedId, trim($name, '/')]); |
|
343 | + |
|
344 | + $declineAction = $notification->createAction(); |
|
345 | + $declineAction->setLabel('decline') |
|
346 | + ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE'); |
|
347 | + $notification->addAction($declineAction); |
|
348 | + |
|
349 | + $acceptAction = $notification->createAction(); |
|
350 | + $acceptAction->setLabel('accept') |
|
351 | + ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST'); |
|
352 | + $notification->addAction($acceptAction); |
|
353 | + |
|
354 | + $this->notificationManager->notify($notification); |
|
355 | + } |
|
356 | + |
|
357 | + /** |
|
358 | + * process notification that the recipient accepted a share |
|
359 | + * |
|
360 | + * @param string $id |
|
361 | + * @param array $notification |
|
362 | + * @return array |
|
363 | + * @throws ActionNotSupportedException |
|
364 | + * @throws AuthenticationFailedException |
|
365 | + * @throws BadRequestException |
|
366 | + * @throws \OC\HintException |
|
367 | + */ |
|
368 | + private function shareAccepted($id, array $notification) { |
|
369 | + |
|
370 | + if (!$this->isS2SEnabled()) { |
|
371 | + throw new ActionNotSupportedException('Server does not support federated cloud sharing'); |
|
372 | + } |
|
373 | + |
|
374 | + if (!isset($notification['sharedSecret'])) { |
|
375 | + throw new BadRequestException(['sharedSecret']); |
|
376 | + } |
|
377 | + |
|
378 | + $token = $notification['sharedSecret']; |
|
379 | + |
|
380 | + $share = $this->federatedShareProvider->getShareById($id); |
|
381 | + |
|
382 | + $this->verifyShare($share, $token); |
|
383 | + $this->executeAcceptShare($share); |
|
384 | + if ($share->getShareOwner() !== $share->getSharedBy()) { |
|
385 | + list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); |
|
386 | + $remoteId = $this->federatedShareProvider->getRemoteId($share); |
|
387 | + $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
388 | + $notification->setMessage( |
|
389 | + 'SHARE_ACCEPTED', |
|
390 | + 'file', |
|
391 | + $remoteId, |
|
392 | + [ |
|
393 | + 'sharedSecret' => $token, |
|
394 | + 'message' => 'Recipient accepted the re-share' |
|
395 | + ] |
|
396 | + |
|
397 | + ); |
|
398 | + $this->cloudFederationProviderManager->sendNotification($remote, $notification); |
|
399 | + |
|
400 | + } |
|
401 | + |
|
402 | + return []; |
|
403 | + } |
|
404 | + |
|
405 | + /** |
|
406 | + * @param IShare $share |
|
407 | + * @throws ShareNotFound |
|
408 | + */ |
|
409 | + protected function executeAcceptShare(IShare $share) { |
|
410 | + try { |
|
411 | + $fileId = (int)$share->getNode()->getId(); |
|
412 | + list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
413 | + } catch (\Exception $e) { |
|
414 | + throw new ShareNotFound(); |
|
415 | + } |
|
416 | + |
|
417 | + $event = $this->activityManager->generateEvent(); |
|
418 | + $event->setApp('files_sharing') |
|
419 | + ->setType('remote_share') |
|
420 | + ->setAffectedUser($this->getCorrectUid($share)) |
|
421 | + ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_ACCEPTED, [$share->getSharedWith(), [$fileId => $file]]) |
|
422 | + ->setObject('files', $fileId, $file) |
|
423 | + ->setLink($link); |
|
424 | + $this->activityManager->publish($event); |
|
425 | + } |
|
426 | + |
|
427 | + /** |
|
428 | + * process notification that the recipient declined a share |
|
429 | + * |
|
430 | + * @param string $id |
|
431 | + * @param array $notification |
|
432 | + * @return array |
|
433 | + * @throws ActionNotSupportedException |
|
434 | + * @throws AuthenticationFailedException |
|
435 | + * @throws BadRequestException |
|
436 | + * @throws ShareNotFound |
|
437 | + * @throws \OC\HintException |
|
438 | + * |
|
439 | + */ |
|
440 | + protected function shareDeclined($id, array $notification) { |
|
441 | + |
|
442 | + if (!$this->isS2SEnabled()) { |
|
443 | + throw new ActionNotSupportedException('Server does not support federated cloud sharing'); |
|
444 | + } |
|
445 | + |
|
446 | + if (!isset($notification['sharedSecret'])) { |
|
447 | + throw new BadRequestException(['sharedSecret']); |
|
448 | + } |
|
449 | + |
|
450 | + $token = $notification['sharedSecret']; |
|
451 | + |
|
452 | + $share = $this->federatedShareProvider->getShareById($id); |
|
453 | + |
|
454 | + $this->verifyShare($share, $token); |
|
455 | + |
|
456 | + if ($share->getShareOwner() !== $share->getSharedBy()) { |
|
457 | + list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); |
|
458 | + $remoteId = $this->federatedShareProvider->getRemoteId($share); |
|
459 | + $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
460 | + $notification->setMessage( |
|
461 | + 'SHARE_DECLINED', |
|
462 | + 'file', |
|
463 | + $remoteId, |
|
464 | + [ |
|
465 | + 'sharedSecret' => $token, |
|
466 | + 'message' => 'Recipient declined the re-share' |
|
467 | + ] |
|
468 | + |
|
469 | + ); |
|
470 | + $this->cloudFederationProviderManager->sendNotification($remote, $notification); |
|
471 | + } |
|
472 | + |
|
473 | + $this->executeDeclineShare($share); |
|
474 | + |
|
475 | + return []; |
|
476 | + |
|
477 | + } |
|
478 | + |
|
479 | + /** |
|
480 | + * delete declined share and create a activity |
|
481 | + * |
|
482 | + * @param IShare $share |
|
483 | + * @throws ShareNotFound |
|
484 | + */ |
|
485 | + protected function executeDeclineShare(IShare $share) { |
|
486 | + $this->federatedShareProvider->removeShareFromTable($share); |
|
487 | + |
|
488 | + try { |
|
489 | + $fileId = (int)$share->getNode()->getId(); |
|
490 | + list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
491 | + } catch (\Exception $e) { |
|
492 | + throw new ShareNotFound(); |
|
493 | + } |
|
494 | + |
|
495 | + $event = $this->activityManager->generateEvent(); |
|
496 | + $event->setApp('files_sharing') |
|
497 | + ->setType('remote_share') |
|
498 | + ->setAffectedUser($this->getCorrectUid($share)) |
|
499 | + ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), [$fileId => $file]]) |
|
500 | + ->setObject('files', $fileId, $file) |
|
501 | + ->setLink($link); |
|
502 | + $this->activityManager->publish($event); |
|
503 | + |
|
504 | + } |
|
505 | + |
|
506 | + /** |
|
507 | + * received the notification that the owner unshared a file from you |
|
508 | + * |
|
509 | + * @param string $id |
|
510 | + * @param array $notification |
|
511 | + * @return array |
|
512 | + * @throws AuthenticationFailedException |
|
513 | + * @throws BadRequestException |
|
514 | + */ |
|
515 | + private function undoReshare($id, array $notification) { |
|
516 | + if (!isset($notification['sharedSecret'])) { |
|
517 | + throw new BadRequestException(['sharedSecret']); |
|
518 | + } |
|
519 | + $token = $notification['sharedSecret']; |
|
520 | + |
|
521 | + $share = $this->federatedShareProvider->getShareById($id); |
|
522 | + |
|
523 | + $this->verifyShare($share, $token); |
|
524 | + $this->federatedShareProvider->removeShareFromTable($share); |
|
525 | + return []; |
|
526 | + } |
|
527 | + |
|
528 | + /** |
|
529 | + * unshare file from self |
|
530 | + * |
|
531 | + * @param string $id |
|
532 | + * @param array $notification |
|
533 | + * @return array |
|
534 | + * @throws ActionNotSupportedException |
|
535 | + * @throws BadRequestException |
|
536 | + */ |
|
537 | + private function unshare($id, array $notification) { |
|
538 | + |
|
539 | + if (!$this->isS2SEnabled(true)) { |
|
540 | + throw new ActionNotSupportedException("incoming shares disabled!"); |
|
541 | + } |
|
542 | + |
|
543 | + if (!isset($notification['sharedSecret'])) { |
|
544 | + throw new BadRequestException(['sharedSecret']); |
|
545 | + } |
|
546 | + $token = $notification['sharedSecret']; |
|
547 | + |
|
548 | + $qb = $this->connection->getQueryBuilder(); |
|
549 | + $qb->select('*') |
|
550 | + ->from('share_external') |
|
551 | + ->where( |
|
552 | + $qb->expr()->andX( |
|
553 | + $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)), |
|
554 | + $qb->expr()->eq('share_token', $qb->createNamedParameter($token)) |
|
555 | + ) |
|
556 | + ); |
|
557 | + |
|
558 | + $result = $qb->execute(); |
|
559 | + $share = $result->fetch(); |
|
560 | + $result->closeCursor(); |
|
561 | + |
|
562 | + if ($token && $id && !empty($share)) { |
|
563 | + |
|
564 | + $remote = $this->cleanupRemote($share['remote']); |
|
565 | + |
|
566 | + $owner = $this->cloudIdManager->getCloudId($share['owner'], $remote); |
|
567 | + $mountpoint = $share['mountpoint']; |
|
568 | + $user = $share['user']; |
|
569 | + |
|
570 | + $qb = $this->connection->getQueryBuilder(); |
|
571 | + $qb->delete('share_external') |
|
572 | + ->where( |
|
573 | + $qb->expr()->andX( |
|
574 | + $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)), |
|
575 | + $qb->expr()->eq('share_token', $qb->createNamedParameter($token)) |
|
576 | + ) |
|
577 | + ); |
|
578 | + |
|
579 | + $qb->execute(); |
|
580 | + |
|
581 | + if ($share['accepted']) { |
|
582 | + $path = trim($mountpoint, '/'); |
|
583 | + } else { |
|
584 | + $path = trim($share['name'], '/'); |
|
585 | + } |
|
586 | + |
|
587 | + $notification = $this->notificationManager->createNotification(); |
|
588 | + $notification->setApp('files_sharing') |
|
589 | + ->setUser($share['user']) |
|
590 | + ->setObject('remote_share', (int)$share['id']); |
|
591 | + $this->notificationManager->markProcessed($notification); |
|
592 | + |
|
593 | + $event = $this->activityManager->generateEvent(); |
|
594 | + $event->setApp('files_sharing') |
|
595 | + ->setType('remote_share') |
|
596 | + ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path]) |
|
597 | + ->setAffectedUser($user) |
|
598 | + ->setObject('remote_share', (int)$share['id'], $path); |
|
599 | + \OC::$server->getActivityManager()->publish($event); |
|
600 | + } |
|
601 | + |
|
602 | + return []; |
|
603 | + } |
|
604 | + |
|
605 | + private function cleanupRemote($remote) { |
|
606 | + $remote = substr($remote, strpos($remote, '://') + 3); |
|
607 | + |
|
608 | + return rtrim($remote, '/'); |
|
609 | + } |
|
610 | + |
|
611 | + /** |
|
612 | + * recipient of a share request to re-share the file with another user |
|
613 | + * |
|
614 | + * @param string $id |
|
615 | + * @param array $notification |
|
616 | + * @return array |
|
617 | + * @throws AuthenticationFailedException |
|
618 | + * @throws BadRequestException |
|
619 | + * @throws ProviderCouldNotAddShareException |
|
620 | + * @throws ShareNotFound |
|
621 | + */ |
|
622 | + protected function reshareRequested($id, array $notification) { |
|
623 | + |
|
624 | + if (!isset($notification['sharedSecret'])) { |
|
625 | + throw new BadRequestException(['sharedSecret']); |
|
626 | + } |
|
627 | + $token = $notification['sharedSecret']; |
|
628 | + |
|
629 | + if (!isset($notification['shareWith'])) { |
|
630 | + throw new BadRequestException(['shareWith']); |
|
631 | + } |
|
632 | + $shareWith = $notification['shareWith']; |
|
633 | + |
|
634 | + if (!isset($notification['senderId'])) { |
|
635 | + throw new BadRequestException(['senderId']); |
|
636 | + } |
|
637 | + $senderId = $notification['senderId']; |
|
638 | + |
|
639 | + $share = $this->federatedShareProvider->getShareById($id); |
|
640 | + // don't allow to share a file back to the owner |
|
641 | + try { |
|
642 | + list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith); |
|
643 | + $owner = $share->getShareOwner(); |
|
644 | + $currentServer = $this->addressHandler->generateRemoteURL(); |
|
645 | + if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) { |
|
646 | + throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: ' . $id); |
|
647 | + } |
|
648 | + } catch (\Exception $e) { |
|
649 | + throw new ProviderCouldNotAddShareException($e->getMessage()); |
|
650 | + } |
|
651 | + |
|
652 | + $this->verifyShare($share, $token); |
|
653 | + |
|
654 | + // check if re-sharing is allowed |
|
655 | + if ($share->getPermissions() & Constants::PERMISSION_SHARE) { |
|
656 | + // the recipient of the initial share is now the initiator for the re-share |
|
657 | + $share->setSharedBy($share->getSharedWith()); |
|
658 | + $share->setSharedWith($shareWith); |
|
659 | + $result = $this->federatedShareProvider->create($share); |
|
660 | + $this->federatedShareProvider->storeRemoteId((int)$result->getId(), $senderId); |
|
661 | + return ['token' => $result->getToken(), 'providerId' => $result->getId()]; |
|
662 | + } else { |
|
663 | + throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id); |
|
664 | + } |
|
665 | + |
|
666 | + } |
|
667 | + |
|
668 | + /** |
|
669 | + * update permission of a re-share so that the share dialog shows the right |
|
670 | + * permission if the owner or the sender changes the permission |
|
671 | + * |
|
672 | + * @param string $id |
|
673 | + * @param array $notification |
|
674 | + * @return array |
|
675 | + * @throws AuthenticationFailedException |
|
676 | + * @throws BadRequestException |
|
677 | + */ |
|
678 | + protected function updateResharePermissions($id, array $notification) { |
|
679 | + |
|
680 | + if (!isset($notification['sharedSecret'])) { |
|
681 | + throw new BadRequestException(['sharedSecret']); |
|
682 | + } |
|
683 | + $token = $notification['sharedSecret']; |
|
684 | + |
|
685 | + if (!isset($notification['permission'])) { |
|
686 | + throw new BadRequestException(['permission']); |
|
687 | + } |
|
688 | + $ocmPermissions = $notification['permission']; |
|
689 | + |
|
690 | + $share = $this->federatedShareProvider->getShareById($id); |
|
691 | + |
|
692 | + $ncPermission = $this->ocmPermissions2ncPermissions($ocmPermissions); |
|
693 | + |
|
694 | + $this->verifyShare($share, $token); |
|
695 | + $this->updatePermissionsInDatabase($share, $ncPermission); |
|
696 | + |
|
697 | + return []; |
|
698 | + } |
|
699 | + |
|
700 | + /** |
|
701 | + * translate OCM Permissions to Nextcloud permissions |
|
702 | + * |
|
703 | + * @param array $ocmPermissions |
|
704 | + * @return int |
|
705 | + * @throws BadRequestException |
|
706 | + */ |
|
707 | + protected function ocmPermissions2ncPermissions(array $ocmPermissions) { |
|
708 | + $ncPermissions = 0; |
|
709 | + foreach($ocmPermissions as $permission) { |
|
710 | + switch (strtolower($permission)) { |
|
711 | + case 'read': |
|
712 | + $ncPermissions += Constants::PERMISSION_READ; |
|
713 | + break; |
|
714 | + case 'write': |
|
715 | + $ncPermissions += Constants::PERMISSION_CREATE + Constants::PERMISSION_UPDATE; |
|
716 | + break; |
|
717 | + case 'share': |
|
718 | + $ncPermissions += Constants::PERMISSION_SHARE; |
|
719 | + break; |
|
720 | + default: |
|
721 | + throw new BadRequestException(['permission']); |
|
722 | + } |
|
723 | + |
|
724 | + } |
|
725 | + |
|
726 | + return $ncPermissions; |
|
727 | + } |
|
728 | + |
|
729 | + /** |
|
730 | + * update permissions in database |
|
731 | + * |
|
732 | + * @param IShare $share |
|
733 | + * @param int $permissions |
|
734 | + */ |
|
735 | + protected function updatePermissionsInDatabase(IShare $share, $permissions) { |
|
736 | + $query = $this->connection->getQueryBuilder(); |
|
737 | + $query->update('share') |
|
738 | + ->where($query->expr()->eq('id', $query->createNamedParameter($share->getId()))) |
|
739 | + ->set('permissions', $query->createNamedParameter($permissions)) |
|
740 | + ->execute(); |
|
741 | + } |
|
742 | + |
|
743 | + |
|
744 | + /** |
|
745 | + * get file |
|
746 | + * |
|
747 | + * @param string $user |
|
748 | + * @param int $fileSource |
|
749 | + * @return array with internal path of the file and a absolute link to it |
|
750 | + */ |
|
751 | + private function getFile($user, $fileSource) { |
|
752 | + \OC_Util::setupFS($user); |
|
753 | + |
|
754 | + try { |
|
755 | + $file = Filesystem::getPath($fileSource); |
|
756 | + } catch (NotFoundException $e) { |
|
757 | + $file = null; |
|
758 | + } |
|
759 | + $args = Filesystem::is_dir($file) ? array('dir' => $file) : array('dir' => dirname($file), 'scrollto' => $file); |
|
760 | + $link = Util::linkToAbsolute('files', 'index.php', $args); |
|
761 | + |
|
762 | + return [$file, $link]; |
|
763 | + |
|
764 | + } |
|
765 | + |
|
766 | + /** |
|
767 | + * check if we are the initiator or the owner of a re-share and return the correct UID |
|
768 | + * |
|
769 | + * @param IShare $share |
|
770 | + * @return string |
|
771 | + */ |
|
772 | + protected function getCorrectUid(IShare $share) { |
|
773 | + if ($this->userManager->userExists($share->getShareOwner())) { |
|
774 | + return $share->getShareOwner(); |
|
775 | + } |
|
776 | + |
|
777 | + return $share->getSharedBy(); |
|
778 | + } |
|
779 | + |
|
780 | + |
|
781 | + |
|
782 | + /** |
|
783 | + * check if we got the right share |
|
784 | + * |
|
785 | + * @param IShare $share |
|
786 | + * @param string $token |
|
787 | + * @return bool |
|
788 | + * @throws AuthenticationFailedException |
|
789 | + */ |
|
790 | + protected function verifyShare(IShare $share, $token) { |
|
791 | + if ( |
|
792 | + $share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE && |
|
793 | + $share->getToken() === $token |
|
794 | + ) { |
|
795 | + return true; |
|
796 | + } |
|
797 | + |
|
798 | + throw new AuthenticationFailedException(); |
|
799 | + } |
|
800 | + |
|
801 | + |
|
802 | + |
|
803 | + /** |
|
804 | + * check if server-to-server sharing is enabled |
|
805 | + * |
|
806 | + * @param bool $incoming |
|
807 | + * @return bool |
|
808 | + */ |
|
809 | + private function isS2SEnabled($incoming = false) { |
|
810 | + |
|
811 | + $result = $this->appManager->isEnabledForUser('files_sharing'); |
|
812 | + |
|
813 | + if ($incoming) { |
|
814 | + $result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled(); |
|
815 | + } else { |
|
816 | + $result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(); |
|
817 | + } |
|
818 | + |
|
819 | + return $result; |
|
820 | + } |
|
821 | + |
|
822 | + |
|
823 | + /** |
|
824 | + * get the supported share types, e.g. "user", "group", etc. |
|
825 | + * |
|
826 | + * @return array |
|
827 | + * |
|
828 | + * @since 14.0.0 |
|
829 | + */ |
|
830 | + public function getSupportedShareTypes() { |
|
831 | + return ['user', 'group']; |
|
832 | + } |
|
833 | 833 | } |
@@ -25,332 +25,332 @@ |
||
25 | 25 | |
26 | 26 | class CloudFederationShare implements ICloudFederationShare { |
27 | 27 | |
28 | - private $share = [ |
|
29 | - 'shareWith' => '', |
|
30 | - 'shareType' => '', |
|
31 | - 'name' => '', |
|
32 | - 'resourceType' => '', |
|
33 | - 'description' => '', |
|
34 | - 'providerId' => '', |
|
35 | - 'owner' => '', |
|
36 | - 'ownerDisplayName' => '', |
|
37 | - 'sharedBy' => '', |
|
38 | - 'sharedByDisplayName' => '', |
|
39 | - 'protocol' => [] |
|
40 | - ]; |
|
28 | + private $share = [ |
|
29 | + 'shareWith' => '', |
|
30 | + 'shareType' => '', |
|
31 | + 'name' => '', |
|
32 | + 'resourceType' => '', |
|
33 | + 'description' => '', |
|
34 | + 'providerId' => '', |
|
35 | + 'owner' => '', |
|
36 | + 'ownerDisplayName' => '', |
|
37 | + 'sharedBy' => '', |
|
38 | + 'sharedByDisplayName' => '', |
|
39 | + 'protocol' => [] |
|
40 | + ]; |
|
41 | 41 | |
42 | - /** |
|
43 | - * get a CloudFederationShare Object to prepare a share you want to send |
|
44 | - * |
|
45 | - * @param string $shareWith |
|
46 | - * @param string $name resource name (e.g. document.odt) |
|
47 | - * @param string $description share description (optional) |
|
48 | - * @param string $providerId resource UID on the provider side |
|
49 | - * @param string $owner provider specific UID of the user who owns the resource |
|
50 | - * @param string $ownerDisplayName display name of the user who shared the item |
|
51 | - * @param string $sharedBy provider specific UID of the user who shared the resource |
|
52 | - * @param string $sharedByDisplayName display name of the user who shared the resource |
|
53 | - * @param string $shareType ('group' or 'user' share) |
|
54 | - * @param string $resourceType ('file', 'calendar',...) |
|
55 | - * @param string $sharedSecret |
|
56 | - */ |
|
57 | - public function __construct($shareWith = '', |
|
58 | - $name = '', |
|
59 | - $description = '', |
|
60 | - $providerId = '', |
|
61 | - $owner = '', |
|
62 | - $ownerDisplayName = '', |
|
63 | - $sharedBy = '', |
|
64 | - $sharedByDisplayName = '', |
|
65 | - $shareType = '', |
|
66 | - $resourceType = '', |
|
67 | - $sharedSecret = '' |
|
68 | - ) { |
|
69 | - $this->setShareWith($shareWith); |
|
70 | - $this->setResourceName($name); |
|
71 | - $this->setDescription($description); |
|
72 | - $this->setProviderId($providerId); |
|
73 | - $this->setOwner($owner); |
|
74 | - $this->setOwnerDisplayName($ownerDisplayName); |
|
75 | - $this->setSharedBy($sharedBy); |
|
76 | - $this->setSharedByDisplayName($sharedByDisplayName); |
|
77 | - $this->setProtocol([ |
|
78 | - 'name' => 'webdav', |
|
79 | - 'options' => [ |
|
80 | - 'sharedSecret' => $sharedSecret, |
|
81 | - 'permissions' => '{http://open-cloud-mesh.org/ns}share-permissions' |
|
82 | - ] |
|
83 | - ]); |
|
84 | - $this->setShareType($shareType); |
|
85 | - $this->setResourceType($resourceType); |
|
42 | + /** |
|
43 | + * get a CloudFederationShare Object to prepare a share you want to send |
|
44 | + * |
|
45 | + * @param string $shareWith |
|
46 | + * @param string $name resource name (e.g. document.odt) |
|
47 | + * @param string $description share description (optional) |
|
48 | + * @param string $providerId resource UID on the provider side |
|
49 | + * @param string $owner provider specific UID of the user who owns the resource |
|
50 | + * @param string $ownerDisplayName display name of the user who shared the item |
|
51 | + * @param string $sharedBy provider specific UID of the user who shared the resource |
|
52 | + * @param string $sharedByDisplayName display name of the user who shared the resource |
|
53 | + * @param string $shareType ('group' or 'user' share) |
|
54 | + * @param string $resourceType ('file', 'calendar',...) |
|
55 | + * @param string $sharedSecret |
|
56 | + */ |
|
57 | + public function __construct($shareWith = '', |
|
58 | + $name = '', |
|
59 | + $description = '', |
|
60 | + $providerId = '', |
|
61 | + $owner = '', |
|
62 | + $ownerDisplayName = '', |
|
63 | + $sharedBy = '', |
|
64 | + $sharedByDisplayName = '', |
|
65 | + $shareType = '', |
|
66 | + $resourceType = '', |
|
67 | + $sharedSecret = '' |
|
68 | + ) { |
|
69 | + $this->setShareWith($shareWith); |
|
70 | + $this->setResourceName($name); |
|
71 | + $this->setDescription($description); |
|
72 | + $this->setProviderId($providerId); |
|
73 | + $this->setOwner($owner); |
|
74 | + $this->setOwnerDisplayName($ownerDisplayName); |
|
75 | + $this->setSharedBy($sharedBy); |
|
76 | + $this->setSharedByDisplayName($sharedByDisplayName); |
|
77 | + $this->setProtocol([ |
|
78 | + 'name' => 'webdav', |
|
79 | + 'options' => [ |
|
80 | + 'sharedSecret' => $sharedSecret, |
|
81 | + 'permissions' => '{http://open-cloud-mesh.org/ns}share-permissions' |
|
82 | + ] |
|
83 | + ]); |
|
84 | + $this->setShareType($shareType); |
|
85 | + $this->setResourceType($resourceType); |
|
86 | 86 | |
87 | - } |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * set uid of the recipient |
|
91 | - * |
|
92 | - * @param string $user |
|
93 | - * |
|
94 | - * @since 14.0.0 |
|
95 | - */ |
|
96 | - public function setShareWith($user) { |
|
97 | - $this->share['shareWith'] = $user; |
|
98 | - } |
|
89 | + /** |
|
90 | + * set uid of the recipient |
|
91 | + * |
|
92 | + * @param string $user |
|
93 | + * |
|
94 | + * @since 14.0.0 |
|
95 | + */ |
|
96 | + public function setShareWith($user) { |
|
97 | + $this->share['shareWith'] = $user; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * set resource name (e.g. document.odt) |
|
102 | - * |
|
103 | - * @param string $name |
|
104 | - * |
|
105 | - * @since 14.0.0 |
|
106 | - */ |
|
107 | - public function setResourceName($name) { |
|
108 | - $this->share['name'] = $name; |
|
109 | - } |
|
100 | + /** |
|
101 | + * set resource name (e.g. document.odt) |
|
102 | + * |
|
103 | + * @param string $name |
|
104 | + * |
|
105 | + * @since 14.0.0 |
|
106 | + */ |
|
107 | + public function setResourceName($name) { |
|
108 | + $this->share['name'] = $name; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * set resource type (e.g. file, calendar, contact,...) |
|
113 | - * |
|
114 | - * @param string $resourceType |
|
115 | - * |
|
116 | - * @since 14.0.0 |
|
117 | - */ |
|
118 | - public function setResourceType($resourceType) { |
|
119 | - $this->share['resourceType'] = $resourceType; |
|
120 | - } |
|
111 | + /** |
|
112 | + * set resource type (e.g. file, calendar, contact,...) |
|
113 | + * |
|
114 | + * @param string $resourceType |
|
115 | + * |
|
116 | + * @since 14.0.0 |
|
117 | + */ |
|
118 | + public function setResourceType($resourceType) { |
|
119 | + $this->share['resourceType'] = $resourceType; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * set resource description (optional) |
|
124 | - * |
|
125 | - * @param string $description |
|
126 | - * |
|
127 | - * @since 14.0.0 |
|
128 | - */ |
|
129 | - public function setDescription($description) { |
|
130 | - $this->share['description'] = $description; |
|
131 | - } |
|
122 | + /** |
|
123 | + * set resource description (optional) |
|
124 | + * |
|
125 | + * @param string $description |
|
126 | + * |
|
127 | + * @since 14.0.0 |
|
128 | + */ |
|
129 | + public function setDescription($description) { |
|
130 | + $this->share['description'] = $description; |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * set provider ID (e.g. file ID) |
|
135 | - * |
|
136 | - * @param string $providerId |
|
137 | - * |
|
138 | - * @since 14.0.0 |
|
139 | - */ |
|
140 | - public function setProviderId($providerId) { |
|
141 | - $this->share['providerId'] = $providerId; |
|
142 | - } |
|
133 | + /** |
|
134 | + * set provider ID (e.g. file ID) |
|
135 | + * |
|
136 | + * @param string $providerId |
|
137 | + * |
|
138 | + * @since 14.0.0 |
|
139 | + */ |
|
140 | + public function setProviderId($providerId) { |
|
141 | + $this->share['providerId'] = $providerId; |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * set owner UID |
|
146 | - * |
|
147 | - * @param string $owner |
|
148 | - * |
|
149 | - * @since 14.0.0 |
|
150 | - */ |
|
151 | - public function setOwner($owner) { |
|
152 | - $this->share['owner'] = $owner; |
|
153 | - } |
|
144 | + /** |
|
145 | + * set owner UID |
|
146 | + * |
|
147 | + * @param string $owner |
|
148 | + * |
|
149 | + * @since 14.0.0 |
|
150 | + */ |
|
151 | + public function setOwner($owner) { |
|
152 | + $this->share['owner'] = $owner; |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * set owner display name |
|
157 | - * |
|
158 | - * @param string $ownerDisplayName |
|
159 | - * |
|
160 | - * @since 14.0.0 |
|
161 | - */ |
|
162 | - public function setOwnerDisplayName($ownerDisplayName) { |
|
163 | - $this->share['ownerDisplayName'] = $ownerDisplayName; |
|
164 | - } |
|
155 | + /** |
|
156 | + * set owner display name |
|
157 | + * |
|
158 | + * @param string $ownerDisplayName |
|
159 | + * |
|
160 | + * @since 14.0.0 |
|
161 | + */ |
|
162 | + public function setOwnerDisplayName($ownerDisplayName) { |
|
163 | + $this->share['ownerDisplayName'] = $ownerDisplayName; |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * set UID of the user who sends the share |
|
168 | - * |
|
169 | - * @param string $sharedBy |
|
170 | - * |
|
171 | - * @since 14.0.0 |
|
172 | - */ |
|
173 | - public function setSharedBy($sharedBy) { |
|
174 | - $this->share['sharedBy'] = $sharedBy; |
|
175 | - } |
|
166 | + /** |
|
167 | + * set UID of the user who sends the share |
|
168 | + * |
|
169 | + * @param string $sharedBy |
|
170 | + * |
|
171 | + * @since 14.0.0 |
|
172 | + */ |
|
173 | + public function setSharedBy($sharedBy) { |
|
174 | + $this->share['sharedBy'] = $sharedBy; |
|
175 | + } |
|
176 | 176 | |
177 | - /** |
|
178 | - * set display name of the user who sends the share |
|
179 | - * |
|
180 | - * @param $sharedByDisplayName |
|
181 | - * |
|
182 | - * @since 14.0.0 |
|
183 | - */ |
|
184 | - public function setSharedByDisplayName($sharedByDisplayName) { |
|
185 | - $this->share['sharedByDisplayName'] = $sharedByDisplayName; |
|
186 | - } |
|
177 | + /** |
|
178 | + * set display name of the user who sends the share |
|
179 | + * |
|
180 | + * @param $sharedByDisplayName |
|
181 | + * |
|
182 | + * @since 14.0.0 |
|
183 | + */ |
|
184 | + public function setSharedByDisplayName($sharedByDisplayName) { |
|
185 | + $this->share['sharedByDisplayName'] = $sharedByDisplayName; |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * set protocol specification |
|
190 | - * |
|
191 | - * @param array $protocol |
|
192 | - * |
|
193 | - * @since 14.0.0 |
|
194 | - */ |
|
195 | - public function setProtocol(array $protocol) { |
|
196 | - $this->share['protocol'] = $protocol; |
|
197 | - } |
|
188 | + /** |
|
189 | + * set protocol specification |
|
190 | + * |
|
191 | + * @param array $protocol |
|
192 | + * |
|
193 | + * @since 14.0.0 |
|
194 | + */ |
|
195 | + public function setProtocol(array $protocol) { |
|
196 | + $this->share['protocol'] = $protocol; |
|
197 | + } |
|
198 | 198 | |
199 | - /** |
|
200 | - * share type (group or user) |
|
201 | - * |
|
202 | - * @param string $shareType |
|
203 | - * |
|
204 | - * @since 14.0.0 |
|
205 | - */ |
|
206 | - public function setShareType($shareType) { |
|
207 | - if ($shareType === 'group' || $shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) { |
|
208 | - $this->share['shareType'] = 'group'; |
|
209 | - } else { |
|
210 | - $this->share['shareType'] = 'user'; |
|
211 | - } |
|
212 | - } |
|
199 | + /** |
|
200 | + * share type (group or user) |
|
201 | + * |
|
202 | + * @param string $shareType |
|
203 | + * |
|
204 | + * @since 14.0.0 |
|
205 | + */ |
|
206 | + public function setShareType($shareType) { |
|
207 | + if ($shareType === 'group' || $shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) { |
|
208 | + $this->share['shareType'] = 'group'; |
|
209 | + } else { |
|
210 | + $this->share['shareType'] = 'user'; |
|
211 | + } |
|
212 | + } |
|
213 | 213 | |
214 | - /** |
|
215 | - * get the whole share, ready to send out |
|
216 | - * |
|
217 | - * @return array |
|
218 | - * |
|
219 | - * @since 14.0.0 |
|
220 | - */ |
|
221 | - public function getShare() { |
|
222 | - return $this->share; |
|
223 | - } |
|
214 | + /** |
|
215 | + * get the whole share, ready to send out |
|
216 | + * |
|
217 | + * @return array |
|
218 | + * |
|
219 | + * @since 14.0.0 |
|
220 | + */ |
|
221 | + public function getShare() { |
|
222 | + return $this->share; |
|
223 | + } |
|
224 | 224 | |
225 | - /** |
|
226 | - * get uid of the recipient |
|
227 | - * |
|
228 | - * @return string |
|
229 | - * |
|
230 | - * @since 14.0.0 |
|
231 | - */ |
|
232 | - public function getShareWith() { |
|
233 | - return $this->share['shareWith']; |
|
234 | - } |
|
225 | + /** |
|
226 | + * get uid of the recipient |
|
227 | + * |
|
228 | + * @return string |
|
229 | + * |
|
230 | + * @since 14.0.0 |
|
231 | + */ |
|
232 | + public function getShareWith() { |
|
233 | + return $this->share['shareWith']; |
|
234 | + } |
|
235 | 235 | |
236 | - /** |
|
237 | - * get resource name (e.g. file, calendar, contact,...) |
|
238 | - * |
|
239 | - * @return string |
|
240 | - * |
|
241 | - * @since 14.0.0 |
|
242 | - */ |
|
243 | - public function getResourceName() { |
|
244 | - return $this->share['name']; |
|
245 | - } |
|
236 | + /** |
|
237 | + * get resource name (e.g. file, calendar, contact,...) |
|
238 | + * |
|
239 | + * @return string |
|
240 | + * |
|
241 | + * @since 14.0.0 |
|
242 | + */ |
|
243 | + public function getResourceName() { |
|
244 | + return $this->share['name']; |
|
245 | + } |
|
246 | 246 | |
247 | - /** |
|
248 | - * get resource type (e.g. file, calendar, contact,...) |
|
249 | - * |
|
250 | - * @return string |
|
251 | - * |
|
252 | - * @since 14.0.0 |
|
253 | - */ |
|
254 | - public function getResourceType() { |
|
255 | - return $this->share['resourceType']; |
|
256 | - } |
|
247 | + /** |
|
248 | + * get resource type (e.g. file, calendar, contact,...) |
|
249 | + * |
|
250 | + * @return string |
|
251 | + * |
|
252 | + * @since 14.0.0 |
|
253 | + */ |
|
254 | + public function getResourceType() { |
|
255 | + return $this->share['resourceType']; |
|
256 | + } |
|
257 | 257 | |
258 | - /** |
|
259 | - * get resource description (optional) |
|
260 | - * |
|
261 | - * @return string |
|
262 | - * |
|
263 | - * @since 14.0.0 |
|
264 | - */ |
|
265 | - public function getDescription() { |
|
266 | - return $this->share['description']; |
|
267 | - } |
|
258 | + /** |
|
259 | + * get resource description (optional) |
|
260 | + * |
|
261 | + * @return string |
|
262 | + * |
|
263 | + * @since 14.0.0 |
|
264 | + */ |
|
265 | + public function getDescription() { |
|
266 | + return $this->share['description']; |
|
267 | + } |
|
268 | 268 | |
269 | - /** |
|
270 | - * get provider ID (e.g. file ID) |
|
271 | - * |
|
272 | - * @return string |
|
273 | - * |
|
274 | - * @since 14.0.0 |
|
275 | - */ |
|
276 | - public function getProviderId() { |
|
277 | - return $this->share['providerId']; |
|
278 | - } |
|
269 | + /** |
|
270 | + * get provider ID (e.g. file ID) |
|
271 | + * |
|
272 | + * @return string |
|
273 | + * |
|
274 | + * @since 14.0.0 |
|
275 | + */ |
|
276 | + public function getProviderId() { |
|
277 | + return $this->share['providerId']; |
|
278 | + } |
|
279 | 279 | |
280 | - /** |
|
281 | - * get owner UID |
|
282 | - * |
|
283 | - * @return string |
|
284 | - * |
|
285 | - * @since 14.0.0 |
|
286 | - */ |
|
287 | - public function getOwner() { |
|
288 | - return $this->share['owner']; |
|
289 | - } |
|
280 | + /** |
|
281 | + * get owner UID |
|
282 | + * |
|
283 | + * @return string |
|
284 | + * |
|
285 | + * @since 14.0.0 |
|
286 | + */ |
|
287 | + public function getOwner() { |
|
288 | + return $this->share['owner']; |
|
289 | + } |
|
290 | 290 | |
291 | - /** |
|
292 | - * get owner display name |
|
293 | - * |
|
294 | - * @return string |
|
295 | - * |
|
296 | - * @since 14.0.0 |
|
297 | - */ |
|
298 | - public function getOwnerDisplayName() { |
|
299 | - return $this->share['ownerDisplayName']; |
|
300 | - } |
|
291 | + /** |
|
292 | + * get owner display name |
|
293 | + * |
|
294 | + * @return string |
|
295 | + * |
|
296 | + * @since 14.0.0 |
|
297 | + */ |
|
298 | + public function getOwnerDisplayName() { |
|
299 | + return $this->share['ownerDisplayName']; |
|
300 | + } |
|
301 | 301 | |
302 | - /** |
|
303 | - * get UID of the user who sends the share |
|
304 | - * |
|
305 | - * @return string |
|
306 | - * |
|
307 | - * @since 14.0.0 |
|
308 | - */ |
|
309 | - public function getSharedBy() { |
|
310 | - return $this->share['sharedBy']; |
|
311 | - } |
|
302 | + /** |
|
303 | + * get UID of the user who sends the share |
|
304 | + * |
|
305 | + * @return string |
|
306 | + * |
|
307 | + * @since 14.0.0 |
|
308 | + */ |
|
309 | + public function getSharedBy() { |
|
310 | + return $this->share['sharedBy']; |
|
311 | + } |
|
312 | 312 | |
313 | - /** |
|
314 | - * get display name of the user who sends the share |
|
315 | - * |
|
316 | - * @return string |
|
317 | - * |
|
318 | - * @since 14.0.0 |
|
319 | - */ |
|
320 | - public function getSharedByDisplayName() { |
|
321 | - return $this->share['sharedByDisplayName']; |
|
322 | - } |
|
313 | + /** |
|
314 | + * get display name of the user who sends the share |
|
315 | + * |
|
316 | + * @return string |
|
317 | + * |
|
318 | + * @since 14.0.0 |
|
319 | + */ |
|
320 | + public function getSharedByDisplayName() { |
|
321 | + return $this->share['sharedByDisplayName']; |
|
322 | + } |
|
323 | 323 | |
324 | - /** |
|
325 | - * get share type (group or user) |
|
326 | - * |
|
327 | - * @return string |
|
328 | - * |
|
329 | - * @since 14.0.0 |
|
330 | - */ |
|
331 | - public function getShareType() { |
|
332 | - return $this->share['shareType']; |
|
333 | - } |
|
324 | + /** |
|
325 | + * get share type (group or user) |
|
326 | + * |
|
327 | + * @return string |
|
328 | + * |
|
329 | + * @since 14.0.0 |
|
330 | + */ |
|
331 | + public function getShareType() { |
|
332 | + return $this->share['shareType']; |
|
333 | + } |
|
334 | 334 | |
335 | - /** |
|
336 | - * get share Secret |
|
337 | - * |
|
338 | - * @return string |
|
339 | - * |
|
340 | - * @since 14.0.0 |
|
341 | - */ |
|
342 | - public function getShareSecret() { |
|
343 | - return $this->share['protocol']['options']['sharedSecret']; |
|
344 | - } |
|
335 | + /** |
|
336 | + * get share Secret |
|
337 | + * |
|
338 | + * @return string |
|
339 | + * |
|
340 | + * @since 14.0.0 |
|
341 | + */ |
|
342 | + public function getShareSecret() { |
|
343 | + return $this->share['protocol']['options']['sharedSecret']; |
|
344 | + } |
|
345 | 345 | |
346 | - /** |
|
347 | - * get protocol specification |
|
348 | - * |
|
349 | - * @return array |
|
350 | - * |
|
351 | - * @since 14.0.0 |
|
352 | - */ |
|
353 | - public function getProtocol() { |
|
354 | - return $this->share['protocol']; |
|
355 | - } |
|
346 | + /** |
|
347 | + * get protocol specification |
|
348 | + * |
|
349 | + * @return array |
|
350 | + * |
|
351 | + * @since 14.0.0 |
|
352 | + */ |
|
353 | + public function getProtocol() { |
|
354 | + return $this->share['protocol']; |
|
355 | + } |
|
356 | 356 | } |
@@ -39,117 +39,117 @@ |
||
39 | 39 | |
40 | 40 | class Application extends App { |
41 | 41 | |
42 | - /** @var FederatedShareProvider */ |
|
43 | - protected $federatedShareProvider; |
|
42 | + /** @var FederatedShareProvider */ |
|
43 | + protected $federatedShareProvider; |
|
44 | 44 | |
45 | - public function __construct() { |
|
46 | - parent::__construct('federatedfilesharing'); |
|
45 | + public function __construct() { |
|
46 | + parent::__construct('federatedfilesharing'); |
|
47 | 47 | |
48 | - $container = $this->getContainer(); |
|
49 | - $server = $container->getServer(); |
|
48 | + $container = $this->getContainer(); |
|
49 | + $server = $container->getServer(); |
|
50 | 50 | |
51 | - $cloudFederationManager = $server->getCloudFederationProviderManager(); |
|
52 | - $cloudFederationManager->addCloudFederationProvider('file', |
|
53 | - 'Federated Files Sharing', |
|
54 | - function() use ($container) { |
|
55 | - $server = $container->getServer(); |
|
56 | - return new CloudFederationProviderFiles( |
|
57 | - $server->getAppManager(), |
|
58 | - $server->query(FederatedShareProvider::class), |
|
59 | - $server->query(AddressHandler::class), |
|
60 | - $server->getLogger(), |
|
61 | - $server->getUserManager(), |
|
62 | - $server->getCloudIdManager(), |
|
63 | - $server->getActivityManager(), |
|
64 | - $server->getNotificationManager(), |
|
65 | - $server->getURLGenerator(), |
|
66 | - $server->getCloudFederationFactory(), |
|
67 | - $server->getCloudFederationProviderManager(), |
|
68 | - $server->getDatabaseConnection(), |
|
69 | - $server->getGroupManager() |
|
70 | - ); |
|
71 | - }); |
|
51 | + $cloudFederationManager = $server->getCloudFederationProviderManager(); |
|
52 | + $cloudFederationManager->addCloudFederationProvider('file', |
|
53 | + 'Federated Files Sharing', |
|
54 | + function() use ($container) { |
|
55 | + $server = $container->getServer(); |
|
56 | + return new CloudFederationProviderFiles( |
|
57 | + $server->getAppManager(), |
|
58 | + $server->query(FederatedShareProvider::class), |
|
59 | + $server->query(AddressHandler::class), |
|
60 | + $server->getLogger(), |
|
61 | + $server->getUserManager(), |
|
62 | + $server->getCloudIdManager(), |
|
63 | + $server->getActivityManager(), |
|
64 | + $server->getNotificationManager(), |
|
65 | + $server->getURLGenerator(), |
|
66 | + $server->getCloudFederationFactory(), |
|
67 | + $server->getCloudFederationProviderManager(), |
|
68 | + $server->getDatabaseConnection(), |
|
69 | + $server->getGroupManager() |
|
70 | + ); |
|
71 | + }); |
|
72 | 72 | |
73 | - $container->registerService('RequestHandlerController', function(SimpleContainer $c) use ($server) { |
|
74 | - $addressHandler = new AddressHandler( |
|
75 | - $server->getURLGenerator(), |
|
76 | - $server->getL10N('federatedfilesharing'), |
|
77 | - $server->getCloudIdManager() |
|
78 | - ); |
|
79 | - $notification = new Notifications( |
|
80 | - $addressHandler, |
|
81 | - $server->getHTTPClientService(), |
|
82 | - $server->query(\OCP\OCS\IDiscoveryService::class), |
|
83 | - \OC::$server->getJobList(), |
|
84 | - \OC::$server->getCloudFederationProviderManager(), |
|
85 | - \OC::$server->getCloudFederationFactory() |
|
86 | - ); |
|
87 | - return new RequestHandlerController( |
|
88 | - $c->query('AppName'), |
|
89 | - $server->getRequest(), |
|
90 | - $this->getFederatedShareProvider(), |
|
91 | - $server->getDatabaseConnection(), |
|
92 | - $server->getShareManager(), |
|
93 | - $notification, |
|
94 | - $addressHandler, |
|
95 | - $server->getUserManager(), |
|
96 | - $server->getCloudIdManager(), |
|
97 | - $server->getLogger(), |
|
98 | - $server->getCloudFederationFactory(), |
|
99 | - $server->getCloudFederationProviderManager() |
|
100 | - ); |
|
101 | - }); |
|
102 | - } |
|
73 | + $container->registerService('RequestHandlerController', function(SimpleContainer $c) use ($server) { |
|
74 | + $addressHandler = new AddressHandler( |
|
75 | + $server->getURLGenerator(), |
|
76 | + $server->getL10N('federatedfilesharing'), |
|
77 | + $server->getCloudIdManager() |
|
78 | + ); |
|
79 | + $notification = new Notifications( |
|
80 | + $addressHandler, |
|
81 | + $server->getHTTPClientService(), |
|
82 | + $server->query(\OCP\OCS\IDiscoveryService::class), |
|
83 | + \OC::$server->getJobList(), |
|
84 | + \OC::$server->getCloudFederationProviderManager(), |
|
85 | + \OC::$server->getCloudFederationFactory() |
|
86 | + ); |
|
87 | + return new RequestHandlerController( |
|
88 | + $c->query('AppName'), |
|
89 | + $server->getRequest(), |
|
90 | + $this->getFederatedShareProvider(), |
|
91 | + $server->getDatabaseConnection(), |
|
92 | + $server->getShareManager(), |
|
93 | + $notification, |
|
94 | + $addressHandler, |
|
95 | + $server->getUserManager(), |
|
96 | + $server->getCloudIdManager(), |
|
97 | + $server->getLogger(), |
|
98 | + $server->getCloudFederationFactory(), |
|
99 | + $server->getCloudFederationProviderManager() |
|
100 | + ); |
|
101 | + }); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * get instance of federated share provider |
|
106 | - * |
|
107 | - * @return FederatedShareProvider |
|
108 | - */ |
|
109 | - public function getFederatedShareProvider() { |
|
110 | - if ($this->federatedShareProvider === null) { |
|
111 | - $this->initFederatedShareProvider(); |
|
112 | - } |
|
113 | - return $this->federatedShareProvider; |
|
114 | - } |
|
104 | + /** |
|
105 | + * get instance of federated share provider |
|
106 | + * |
|
107 | + * @return FederatedShareProvider |
|
108 | + */ |
|
109 | + public function getFederatedShareProvider() { |
|
110 | + if ($this->federatedShareProvider === null) { |
|
111 | + $this->initFederatedShareProvider(); |
|
112 | + } |
|
113 | + return $this->federatedShareProvider; |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * initialize federated share provider |
|
118 | - */ |
|
119 | - protected function initFederatedShareProvider() { |
|
120 | - $c = $this->getContainer(); |
|
121 | - $addressHandler = new \OCA\FederatedFileSharing\AddressHandler( |
|
122 | - \OC::$server->getURLGenerator(), |
|
123 | - \OC::$server->getL10N('federatedfilesharing'), |
|
124 | - \OC::$server->getCloudIdManager() |
|
125 | - ); |
|
126 | - $notifications = new \OCA\FederatedFileSharing\Notifications( |
|
127 | - $addressHandler, |
|
128 | - \OC::$server->getHTTPClientService(), |
|
129 | - \OC::$server->query(\OCP\OCS\IDiscoveryService::class), |
|
130 | - \OC::$server->getJobList(), |
|
131 | - \OC::$server->getCloudFederationProviderManager(), |
|
132 | - \OC::$server->getCloudFederationFactory() |
|
133 | - ); |
|
134 | - $tokenHandler = new \OCA\FederatedFileSharing\TokenHandler( |
|
135 | - \OC::$server->getSecureRandom() |
|
136 | - ); |
|
116 | + /** |
|
117 | + * initialize federated share provider |
|
118 | + */ |
|
119 | + protected function initFederatedShareProvider() { |
|
120 | + $c = $this->getContainer(); |
|
121 | + $addressHandler = new \OCA\FederatedFileSharing\AddressHandler( |
|
122 | + \OC::$server->getURLGenerator(), |
|
123 | + \OC::$server->getL10N('federatedfilesharing'), |
|
124 | + \OC::$server->getCloudIdManager() |
|
125 | + ); |
|
126 | + $notifications = new \OCA\FederatedFileSharing\Notifications( |
|
127 | + $addressHandler, |
|
128 | + \OC::$server->getHTTPClientService(), |
|
129 | + \OC::$server->query(\OCP\OCS\IDiscoveryService::class), |
|
130 | + \OC::$server->getJobList(), |
|
131 | + \OC::$server->getCloudFederationProviderManager(), |
|
132 | + \OC::$server->getCloudFederationFactory() |
|
133 | + ); |
|
134 | + $tokenHandler = new \OCA\FederatedFileSharing\TokenHandler( |
|
135 | + \OC::$server->getSecureRandom() |
|
136 | + ); |
|
137 | 137 | |
138 | - $this->federatedShareProvider = new \OCA\FederatedFileSharing\FederatedShareProvider( |
|
139 | - \OC::$server->getDatabaseConnection(), |
|
140 | - $addressHandler, |
|
141 | - $notifications, |
|
142 | - $tokenHandler, |
|
143 | - \OC::$server->getL10N('federatedfilesharing'), |
|
144 | - \OC::$server->getLogger(), |
|
145 | - \OC::$server->getLazyRootFolder(), |
|
146 | - \OC::$server->getConfig(), |
|
147 | - \OC::$server->getUserManager(), |
|
148 | - \OC::$server->getCloudIdManager(), |
|
149 | - $c->query(IConfig::class), |
|
150 | - \OC::$server->getCloudFederationProviderManager() |
|
138 | + $this->federatedShareProvider = new \OCA\FederatedFileSharing\FederatedShareProvider( |
|
139 | + \OC::$server->getDatabaseConnection(), |
|
140 | + $addressHandler, |
|
141 | + $notifications, |
|
142 | + $tokenHandler, |
|
143 | + \OC::$server->getL10N('federatedfilesharing'), |
|
144 | + \OC::$server->getLogger(), |
|
145 | + \OC::$server->getLazyRootFolder(), |
|
146 | + \OC::$server->getConfig(), |
|
147 | + \OC::$server->getUserManager(), |
|
148 | + \OC::$server->getCloudIdManager(), |
|
149 | + $c->query(IConfig::class), |
|
150 | + \OC::$server->getCloudFederationProviderManager() |
|
151 | 151 | |
152 | - ); |
|
153 | - } |
|
152 | + ); |
|
153 | + } |
|
154 | 154 | |
155 | 155 | } |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | * @param $password |
211 | 211 | * @param $name |
212 | 212 | * @param $owner |
213 | - * @param $user |
|
213 | + * @param string $user |
|
214 | 214 | * @param $mountPoint |
215 | 215 | * @param $hash |
216 | - * @param $accepted |
|
216 | + * @param integer $accepted |
|
217 | 217 | * @param $remoteId |
218 | - * @param $parent |
|
218 | + * @param integer $parent |
|
219 | 219 | * @param $shareType |
220 | 220 | */ |
221 | 221 | private function writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType) { |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @param string $remoteDomain |
410 | 410 | * @param string $token |
411 | - * @param $remoteId id of the share |
|
411 | + * @param integer $remoteId id of the share |
|
412 | 412 | * @param string $feedback |
413 | 413 | * @return bool |
414 | 414 | */ |
@@ -505,6 +505,9 @@ discard block |
||
505 | 505 | return $result; |
506 | 506 | } |
507 | 507 | |
508 | + /** |
|
509 | + * @param string $mountPoint |
|
510 | + */ |
|
508 | 511 | public function removeShare($mountPoint) { |
509 | 512 | |
510 | 513 | $mountPointObj = $this->mountManager->find($mountPoint); |
@@ -46,594 +46,594 @@ |
||
46 | 46 | use OCP\Share; |
47 | 47 | |
48 | 48 | class Manager { |
49 | - const STORAGE = '\OCA\Files_Sharing\External\Storage'; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - private $uid; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var IDBConnection |
|
58 | - */ |
|
59 | - private $connection; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var \OC\Files\Mount\Manager |
|
63 | - */ |
|
64 | - private $mountManager; |
|
65 | - |
|
66 | - /** |
|
67 | - * @var IStorageFactory |
|
68 | - */ |
|
69 | - private $storageLoader; |
|
70 | - |
|
71 | - /** |
|
72 | - * @var IClientService |
|
73 | - */ |
|
74 | - private $clientService; |
|
75 | - |
|
76 | - /** |
|
77 | - * @var IManager |
|
78 | - */ |
|
79 | - private $notificationManager; |
|
80 | - |
|
81 | - /** |
|
82 | - * @var IDiscoveryService |
|
83 | - */ |
|
84 | - private $discoveryService; |
|
85 | - |
|
86 | - /** @var ICloudFederationProviderManager */ |
|
87 | - private $cloudFederationProviderManager; |
|
88 | - |
|
89 | - /** @var ICloudFederationFactory */ |
|
90 | - private $cloudFederationFactory; |
|
91 | - |
|
92 | - /** @var IGroupManager */ |
|
93 | - private $groupManager; |
|
94 | - |
|
95 | - /** @var IUserManager */ |
|
96 | - private $userManager; |
|
97 | - |
|
98 | - /** |
|
99 | - * @param IDBConnection $connection |
|
100 | - * @param \OC\Files\Mount\Manager $mountManager |
|
101 | - * @param IStorageFactory $storageLoader |
|
102 | - * @param IClientService $clientService |
|
103 | - * @param IManager $notificationManager |
|
104 | - * @param IDiscoveryService $discoveryService |
|
105 | - * @param ICloudFederationProviderManager $cloudFederationProviderManager |
|
106 | - * @param ICloudFederationFactory $cloudFederationFactory |
|
107 | - * @param IGroupManager $groupManager |
|
108 | - * @param IUserManager $userManager |
|
109 | - * @param string $uid |
|
110 | - */ |
|
111 | - public function __construct(IDBConnection $connection, |
|
112 | - \OC\Files\Mount\Manager $mountManager, |
|
113 | - IStorageFactory $storageLoader, |
|
114 | - IClientService $clientService, |
|
115 | - IManager $notificationManager, |
|
116 | - IDiscoveryService $discoveryService, |
|
117 | - ICloudFederationProviderManager $cloudFederationProviderManager, |
|
118 | - ICloudFederationFactory $cloudFederationFactory, |
|
119 | - IGroupManager $groupManager, |
|
120 | - IUserManager $userManager, |
|
121 | - $uid) { |
|
122 | - $this->connection = $connection; |
|
123 | - $this->mountManager = $mountManager; |
|
124 | - $this->storageLoader = $storageLoader; |
|
125 | - $this->clientService = $clientService; |
|
126 | - $this->uid = $uid; |
|
127 | - $this->notificationManager = $notificationManager; |
|
128 | - $this->discoveryService = $discoveryService; |
|
129 | - $this->cloudFederationProviderManager = $cloudFederationProviderManager; |
|
130 | - $this->cloudFederationFactory = $cloudFederationFactory; |
|
131 | - $this->groupManager = $groupManager; |
|
132 | - $this->userManager = $userManager; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * add new server-to-server share |
|
137 | - * |
|
138 | - * @param string $remote |
|
139 | - * @param string $token |
|
140 | - * @param string $password |
|
141 | - * @param string $name |
|
142 | - * @param string $owner |
|
143 | - * @param int $shareType |
|
144 | - * @param boolean $accepted |
|
145 | - * @param string $user |
|
146 | - * @param int $remoteId |
|
147 | - * @param int $parent |
|
148 | - * @return Mount|null |
|
149 | - * @throws \Doctrine\DBAL\DBALException |
|
150 | - */ |
|
151 | - public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted=false, $user = null, $remoteId = -1, $parent = -1) { |
|
152 | - |
|
153 | - $user = $user ? $user : $this->uid; |
|
154 | - $accepted = $accepted ? 1 : 0; |
|
155 | - $name = Filesystem::normalizePath('/' . $name); |
|
156 | - |
|
157 | - if (!$accepted) { |
|
158 | - // To avoid conflicts with the mount point generation later, |
|
159 | - // we only use a temporary mount point name here. The real |
|
160 | - // mount point name will be generated when accepting the share, |
|
161 | - // using the original share item name. |
|
162 | - $tmpMountPointName = '{{TemporaryMountPointName#' . $name . '}}'; |
|
163 | - $mountPoint = $tmpMountPointName; |
|
164 | - $hash = md5($tmpMountPointName); |
|
165 | - $data = [ |
|
166 | - 'remote' => $remote, |
|
167 | - 'share_token' => $token, |
|
168 | - 'password' => $password, |
|
169 | - 'name' => $name, |
|
170 | - 'owner' => $owner, |
|
171 | - 'user' => $user, |
|
172 | - 'mountpoint' => $mountPoint, |
|
173 | - 'mountpoint_hash' => $hash, |
|
174 | - 'accepted' => $accepted, |
|
175 | - 'remote_id' => $remoteId, |
|
176 | - 'share_type' => $shareType, |
|
177 | - ]; |
|
178 | - |
|
179 | - $i = 1; |
|
180 | - while (!$this->connection->insertIfNotExist('*PREFIX*share_external', $data, ['user', 'mountpoint_hash'])) { |
|
181 | - // The external share already exists for the user |
|
182 | - $data['mountpoint'] = $tmpMountPointName . '-' . $i; |
|
183 | - $data['mountpoint_hash'] = md5($data['mountpoint']); |
|
184 | - $i++; |
|
185 | - } |
|
186 | - return null; |
|
187 | - } |
|
188 | - |
|
189 | - $mountPoint = Files::buildNotExistingFileName('/', $name); |
|
190 | - $mountPoint = Filesystem::normalizePath('/' . $mountPoint); |
|
191 | - $hash = md5($mountPoint); |
|
192 | - |
|
193 | - $this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType); |
|
194 | - |
|
195 | - $options = array( |
|
196 | - 'remote' => $remote, |
|
197 | - 'token' => $token, |
|
198 | - 'password' => $password, |
|
199 | - 'mountpoint' => $mountPoint, |
|
200 | - 'owner' => $owner |
|
201 | - ); |
|
202 | - return $this->mountShare($options); |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * write remote share to the database |
|
207 | - * |
|
208 | - * @param $remote |
|
209 | - * @param $token |
|
210 | - * @param $password |
|
211 | - * @param $name |
|
212 | - * @param $owner |
|
213 | - * @param $user |
|
214 | - * @param $mountPoint |
|
215 | - * @param $hash |
|
216 | - * @param $accepted |
|
217 | - * @param $remoteId |
|
218 | - * @param $parent |
|
219 | - * @param $shareType |
|
220 | - */ |
|
221 | - private function writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType) { |
|
222 | - $query = $this->connection->prepare(' |
|
49 | + const STORAGE = '\OCA\Files_Sharing\External\Storage'; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + private $uid; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var IDBConnection |
|
58 | + */ |
|
59 | + private $connection; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var \OC\Files\Mount\Manager |
|
63 | + */ |
|
64 | + private $mountManager; |
|
65 | + |
|
66 | + /** |
|
67 | + * @var IStorageFactory |
|
68 | + */ |
|
69 | + private $storageLoader; |
|
70 | + |
|
71 | + /** |
|
72 | + * @var IClientService |
|
73 | + */ |
|
74 | + private $clientService; |
|
75 | + |
|
76 | + /** |
|
77 | + * @var IManager |
|
78 | + */ |
|
79 | + private $notificationManager; |
|
80 | + |
|
81 | + /** |
|
82 | + * @var IDiscoveryService |
|
83 | + */ |
|
84 | + private $discoveryService; |
|
85 | + |
|
86 | + /** @var ICloudFederationProviderManager */ |
|
87 | + private $cloudFederationProviderManager; |
|
88 | + |
|
89 | + /** @var ICloudFederationFactory */ |
|
90 | + private $cloudFederationFactory; |
|
91 | + |
|
92 | + /** @var IGroupManager */ |
|
93 | + private $groupManager; |
|
94 | + |
|
95 | + /** @var IUserManager */ |
|
96 | + private $userManager; |
|
97 | + |
|
98 | + /** |
|
99 | + * @param IDBConnection $connection |
|
100 | + * @param \OC\Files\Mount\Manager $mountManager |
|
101 | + * @param IStorageFactory $storageLoader |
|
102 | + * @param IClientService $clientService |
|
103 | + * @param IManager $notificationManager |
|
104 | + * @param IDiscoveryService $discoveryService |
|
105 | + * @param ICloudFederationProviderManager $cloudFederationProviderManager |
|
106 | + * @param ICloudFederationFactory $cloudFederationFactory |
|
107 | + * @param IGroupManager $groupManager |
|
108 | + * @param IUserManager $userManager |
|
109 | + * @param string $uid |
|
110 | + */ |
|
111 | + public function __construct(IDBConnection $connection, |
|
112 | + \OC\Files\Mount\Manager $mountManager, |
|
113 | + IStorageFactory $storageLoader, |
|
114 | + IClientService $clientService, |
|
115 | + IManager $notificationManager, |
|
116 | + IDiscoveryService $discoveryService, |
|
117 | + ICloudFederationProviderManager $cloudFederationProviderManager, |
|
118 | + ICloudFederationFactory $cloudFederationFactory, |
|
119 | + IGroupManager $groupManager, |
|
120 | + IUserManager $userManager, |
|
121 | + $uid) { |
|
122 | + $this->connection = $connection; |
|
123 | + $this->mountManager = $mountManager; |
|
124 | + $this->storageLoader = $storageLoader; |
|
125 | + $this->clientService = $clientService; |
|
126 | + $this->uid = $uid; |
|
127 | + $this->notificationManager = $notificationManager; |
|
128 | + $this->discoveryService = $discoveryService; |
|
129 | + $this->cloudFederationProviderManager = $cloudFederationProviderManager; |
|
130 | + $this->cloudFederationFactory = $cloudFederationFactory; |
|
131 | + $this->groupManager = $groupManager; |
|
132 | + $this->userManager = $userManager; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * add new server-to-server share |
|
137 | + * |
|
138 | + * @param string $remote |
|
139 | + * @param string $token |
|
140 | + * @param string $password |
|
141 | + * @param string $name |
|
142 | + * @param string $owner |
|
143 | + * @param int $shareType |
|
144 | + * @param boolean $accepted |
|
145 | + * @param string $user |
|
146 | + * @param int $remoteId |
|
147 | + * @param int $parent |
|
148 | + * @return Mount|null |
|
149 | + * @throws \Doctrine\DBAL\DBALException |
|
150 | + */ |
|
151 | + public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted=false, $user = null, $remoteId = -1, $parent = -1) { |
|
152 | + |
|
153 | + $user = $user ? $user : $this->uid; |
|
154 | + $accepted = $accepted ? 1 : 0; |
|
155 | + $name = Filesystem::normalizePath('/' . $name); |
|
156 | + |
|
157 | + if (!$accepted) { |
|
158 | + // To avoid conflicts with the mount point generation later, |
|
159 | + // we only use a temporary mount point name here. The real |
|
160 | + // mount point name will be generated when accepting the share, |
|
161 | + // using the original share item name. |
|
162 | + $tmpMountPointName = '{{TemporaryMountPointName#' . $name . '}}'; |
|
163 | + $mountPoint = $tmpMountPointName; |
|
164 | + $hash = md5($tmpMountPointName); |
|
165 | + $data = [ |
|
166 | + 'remote' => $remote, |
|
167 | + 'share_token' => $token, |
|
168 | + 'password' => $password, |
|
169 | + 'name' => $name, |
|
170 | + 'owner' => $owner, |
|
171 | + 'user' => $user, |
|
172 | + 'mountpoint' => $mountPoint, |
|
173 | + 'mountpoint_hash' => $hash, |
|
174 | + 'accepted' => $accepted, |
|
175 | + 'remote_id' => $remoteId, |
|
176 | + 'share_type' => $shareType, |
|
177 | + ]; |
|
178 | + |
|
179 | + $i = 1; |
|
180 | + while (!$this->connection->insertIfNotExist('*PREFIX*share_external', $data, ['user', 'mountpoint_hash'])) { |
|
181 | + // The external share already exists for the user |
|
182 | + $data['mountpoint'] = $tmpMountPointName . '-' . $i; |
|
183 | + $data['mountpoint_hash'] = md5($data['mountpoint']); |
|
184 | + $i++; |
|
185 | + } |
|
186 | + return null; |
|
187 | + } |
|
188 | + |
|
189 | + $mountPoint = Files::buildNotExistingFileName('/', $name); |
|
190 | + $mountPoint = Filesystem::normalizePath('/' . $mountPoint); |
|
191 | + $hash = md5($mountPoint); |
|
192 | + |
|
193 | + $this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType); |
|
194 | + |
|
195 | + $options = array( |
|
196 | + 'remote' => $remote, |
|
197 | + 'token' => $token, |
|
198 | + 'password' => $password, |
|
199 | + 'mountpoint' => $mountPoint, |
|
200 | + 'owner' => $owner |
|
201 | + ); |
|
202 | + return $this->mountShare($options); |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * write remote share to the database |
|
207 | + * |
|
208 | + * @param $remote |
|
209 | + * @param $token |
|
210 | + * @param $password |
|
211 | + * @param $name |
|
212 | + * @param $owner |
|
213 | + * @param $user |
|
214 | + * @param $mountPoint |
|
215 | + * @param $hash |
|
216 | + * @param $accepted |
|
217 | + * @param $remoteId |
|
218 | + * @param $parent |
|
219 | + * @param $shareType |
|
220 | + */ |
|
221 | + private function writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType) { |
|
222 | + $query = $this->connection->prepare(' |
|
223 | 223 | INSERT INTO `*PREFIX*share_external` |
224 | 224 | (`remote`, `share_token`, `password`, `name`, `owner`, `user`, `mountpoint`, `mountpoint_hash`, `accepted`, `remote_id`, `parent`, `share_type`) |
225 | 225 | VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) |
226 | 226 | '); |
227 | - $query->execute(array($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType)); |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * get share |
|
232 | - * |
|
233 | - * @param int $id share id |
|
234 | - * @return mixed share of false |
|
235 | - */ |
|
236 | - public function getShare($id) { |
|
237 | - $getShare = $this->connection->prepare(' |
|
227 | + $query->execute(array($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType)); |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * get share |
|
232 | + * |
|
233 | + * @param int $id share id |
|
234 | + * @return mixed share of false |
|
235 | + */ |
|
236 | + public function getShare($id) { |
|
237 | + $getShare = $this->connection->prepare(' |
|
238 | 238 | SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`, `parent`, `share_type`, `password`, `mountpoint_hash` |
239 | 239 | FROM `*PREFIX*share_external` |
240 | 240 | WHERE `id` = ?'); |
241 | - $result = $getShare->execute(array($id)); |
|
242 | - |
|
243 | - $share = $result ? $getShare->fetch() : []; |
|
244 | - |
|
245 | - $validShare = is_array($share) && isset($share['share_type']) && isset($share['user']); |
|
246 | - |
|
247 | - // check if the user is allowed to access it |
|
248 | - if ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_USER && $share['user'] === $this->uid) { |
|
249 | - return $share; |
|
250 | - } else if ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { |
|
251 | - $user = $this->userManager->get($this->uid); |
|
252 | - if ($this->groupManager->get($share['user'])->inGroup($user)) { |
|
253 | - return $share; |
|
254 | - } |
|
255 | - } |
|
256 | - |
|
257 | - return false; |
|
258 | - |
|
259 | - } |
|
260 | - |
|
261 | - /** |
|
262 | - * accept server-to-server share |
|
263 | - * |
|
264 | - * @param int $id |
|
265 | - * @return bool True if the share could be accepted, false otherwise |
|
266 | - */ |
|
267 | - public function acceptShare($id) { |
|
268 | - |
|
269 | - $share = $this->getShare($id); |
|
270 | - $result = false; |
|
271 | - |
|
272 | - if ($share) { |
|
273 | - \OC_Util::setupFS($this->uid); |
|
274 | - $shareFolder = Helper::getShareFolder(); |
|
275 | - $mountPoint = Files::buildNotExistingFileName($shareFolder, $share['name']); |
|
276 | - $mountPoint = Filesystem::normalizePath($mountPoint); |
|
277 | - $hash = md5($mountPoint); |
|
278 | - |
|
279 | - if($share['share_type'] === Share::SHARE_TYPE_USER) { |
|
280 | - $acceptShare = $this->connection->prepare(' |
|
241 | + $result = $getShare->execute(array($id)); |
|
242 | + |
|
243 | + $share = $result ? $getShare->fetch() : []; |
|
244 | + |
|
245 | + $validShare = is_array($share) && isset($share['share_type']) && isset($share['user']); |
|
246 | + |
|
247 | + // check if the user is allowed to access it |
|
248 | + if ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_USER && $share['user'] === $this->uid) { |
|
249 | + return $share; |
|
250 | + } else if ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { |
|
251 | + $user = $this->userManager->get($this->uid); |
|
252 | + if ($this->groupManager->get($share['user'])->inGroup($user)) { |
|
253 | + return $share; |
|
254 | + } |
|
255 | + } |
|
256 | + |
|
257 | + return false; |
|
258 | + |
|
259 | + } |
|
260 | + |
|
261 | + /** |
|
262 | + * accept server-to-server share |
|
263 | + * |
|
264 | + * @param int $id |
|
265 | + * @return bool True if the share could be accepted, false otherwise |
|
266 | + */ |
|
267 | + public function acceptShare($id) { |
|
268 | + |
|
269 | + $share = $this->getShare($id); |
|
270 | + $result = false; |
|
271 | + |
|
272 | + if ($share) { |
|
273 | + \OC_Util::setupFS($this->uid); |
|
274 | + $shareFolder = Helper::getShareFolder(); |
|
275 | + $mountPoint = Files::buildNotExistingFileName($shareFolder, $share['name']); |
|
276 | + $mountPoint = Filesystem::normalizePath($mountPoint); |
|
277 | + $hash = md5($mountPoint); |
|
278 | + |
|
279 | + if($share['share_type'] === Share::SHARE_TYPE_USER) { |
|
280 | + $acceptShare = $this->connection->prepare(' |
|
281 | 281 | UPDATE `*PREFIX*share_external` |
282 | 282 | SET `accepted` = ?, |
283 | 283 | `mountpoint` = ?, |
284 | 284 | `mountpoint_hash` = ? |
285 | 285 | WHERE `id` = ? AND `user` = ?'); |
286 | - $updated = $acceptShare->execute(array(1, $mountPoint, $hash, $id, $this->uid)); |
|
287 | - } else { |
|
288 | - $this->writeShareToDb( |
|
289 | - $share['remote'], |
|
290 | - $share['share_token'], |
|
291 | - $share['password'], |
|
292 | - $share['name'], |
|
293 | - $share['owner'], |
|
294 | - $this->uid, |
|
295 | - $mountPoint, $hash, 1, |
|
296 | - $share['remote_id'], |
|
297 | - $id, |
|
298 | - $share['share_type']); |
|
299 | - // TODO group share, add additional row for the user who accepted it |
|
300 | - } |
|
301 | - if ($updated === true) { |
|
302 | - $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept'); |
|
303 | - \OC_Hook::emit(Share::class, 'federated_share_added', ['server' => $share['remote']]); |
|
304 | - $result = true; |
|
305 | - } |
|
306 | - } |
|
307 | - |
|
308 | - // Make sure the user has no notification for something that does not exist anymore. |
|
309 | - $this->processNotification($id); |
|
310 | - |
|
311 | - return $result; |
|
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * decline server-to-server share |
|
316 | - * |
|
317 | - * @param int $id |
|
318 | - * @return bool True if the share could be declined, false otherwise |
|
319 | - */ |
|
320 | - public function declineShare($id) { |
|
321 | - |
|
322 | - $share = $this->getShare($id); |
|
323 | - |
|
324 | - if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_USER) { |
|
325 | - $removeShare = $this->connection->prepare(' |
|
286 | + $updated = $acceptShare->execute(array(1, $mountPoint, $hash, $id, $this->uid)); |
|
287 | + } else { |
|
288 | + $this->writeShareToDb( |
|
289 | + $share['remote'], |
|
290 | + $share['share_token'], |
|
291 | + $share['password'], |
|
292 | + $share['name'], |
|
293 | + $share['owner'], |
|
294 | + $this->uid, |
|
295 | + $mountPoint, $hash, 1, |
|
296 | + $share['remote_id'], |
|
297 | + $id, |
|
298 | + $share['share_type']); |
|
299 | + // TODO group share, add additional row for the user who accepted it |
|
300 | + } |
|
301 | + if ($updated === true) { |
|
302 | + $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept'); |
|
303 | + \OC_Hook::emit(Share::class, 'federated_share_added', ['server' => $share['remote']]); |
|
304 | + $result = true; |
|
305 | + } |
|
306 | + } |
|
307 | + |
|
308 | + // Make sure the user has no notification for something that does not exist anymore. |
|
309 | + $this->processNotification($id); |
|
310 | + |
|
311 | + return $result; |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * decline server-to-server share |
|
316 | + * |
|
317 | + * @param int $id |
|
318 | + * @return bool True if the share could be declined, false otherwise |
|
319 | + */ |
|
320 | + public function declineShare($id) { |
|
321 | + |
|
322 | + $share = $this->getShare($id); |
|
323 | + |
|
324 | + if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_USER) { |
|
325 | + $removeShare = $this->connection->prepare(' |
|
326 | 326 | DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?'); |
327 | - $removeShare->execute(array($id, $this->uid)); |
|
328 | - $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); |
|
329 | - |
|
330 | - $this->processNotification($id); |
|
331 | - return true; |
|
332 | - } else if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { |
|
333 | - $this->writeShareToDb( |
|
334 | - $share['remote'], |
|
335 | - $share['share_token'], |
|
336 | - $share['password'], |
|
337 | - $share['name'], |
|
338 | - $share['owner'], |
|
339 | - $this->uid, |
|
340 | - $share['mountpoint'], |
|
341 | - $share['mountpoint_hash'], |
|
342 | - 0, |
|
343 | - $share['remote_id'], |
|
344 | - $id, |
|
345 | - $share['share_type']); |
|
346 | - $this->processNotification($id); |
|
347 | - return true; |
|
348 | - } |
|
349 | - |
|
350 | - return false; |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * @param int $remoteShare |
|
355 | - */ |
|
356 | - public function processNotification($remoteShare) { |
|
357 | - $filter = $this->notificationManager->createNotification(); |
|
358 | - $filter->setApp('files_sharing') |
|
359 | - ->setUser($this->uid) |
|
360 | - ->setObject('remote_share', (int) $remoteShare); |
|
361 | - $this->notificationManager->markProcessed($filter); |
|
362 | - } |
|
363 | - |
|
364 | - /** |
|
365 | - * inform remote server whether server-to-server share was accepted/declined |
|
366 | - * |
|
367 | - * @param string $remote |
|
368 | - * @param string $token |
|
369 | - * @param int $remoteId Share id on the remote host |
|
370 | - * @param string $feedback |
|
371 | - * @return boolean |
|
372 | - */ |
|
373 | - private function sendFeedbackToRemote($remote, $token, $remoteId, $feedback) { |
|
374 | - |
|
375 | - $result = $this->tryOCMEndPoint($remote, $token, $remoteId, $feedback); |
|
376 | - |
|
377 | - if($result === true) { |
|
378 | - return true; |
|
379 | - } |
|
380 | - |
|
381 | - $federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING'); |
|
382 | - $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; |
|
383 | - |
|
384 | - $url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT; |
|
385 | - $fields = array('token' => $token); |
|
386 | - |
|
387 | - $client = $this->clientService->newClient(); |
|
388 | - |
|
389 | - try { |
|
390 | - $response = $client->post( |
|
391 | - $url, |
|
392 | - [ |
|
393 | - 'body' => $fields, |
|
394 | - 'connect_timeout' => 10, |
|
395 | - ] |
|
396 | - ); |
|
397 | - } catch (\Exception $e) { |
|
398 | - return false; |
|
399 | - } |
|
400 | - |
|
401 | - $status = json_decode($response->getBody(), true); |
|
402 | - |
|
403 | - return ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200); |
|
404 | - } |
|
405 | - |
|
406 | - /** |
|
407 | - * try send accept message to ocm end-point |
|
408 | - * |
|
409 | - * @param string $remoteDomain |
|
410 | - * @param string $token |
|
411 | - * @param $remoteId id of the share |
|
412 | - * @param string $feedback |
|
413 | - * @return bool |
|
414 | - */ |
|
415 | - protected function tryOCMEndPoint($remoteDomain, $token, $remoteId, $feedback) { |
|
416 | - switch ($feedback) { |
|
417 | - case 'accept': |
|
418 | - $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
419 | - $notification->setMessage( |
|
420 | - 'SHARE_ACCEPTED', |
|
421 | - 'file', |
|
422 | - $remoteId, |
|
423 | - [ |
|
424 | - 'sharedSecret' => $token, |
|
425 | - 'message' => 'Recipient accept the share' |
|
426 | - ] |
|
427 | - |
|
428 | - ); |
|
429 | - return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification); |
|
430 | - case 'decline': |
|
431 | - $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
432 | - $notification->setMessage( |
|
433 | - 'SHARE_DECLINED', |
|
434 | - 'file', |
|
435 | - $remoteId, |
|
436 | - [ |
|
437 | - 'sharedSecret' => $token, |
|
438 | - 'message' => 'Recipient declined the share' |
|
439 | - ] |
|
440 | - |
|
441 | - ); |
|
442 | - return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification); |
|
443 | - } |
|
444 | - |
|
445 | - return false; |
|
446 | - |
|
447 | - } |
|
448 | - |
|
449 | - |
|
450 | - /** |
|
451 | - * remove '/user/files' from the path and trailing slashes |
|
452 | - * |
|
453 | - * @param string $path |
|
454 | - * @return string |
|
455 | - */ |
|
456 | - protected function stripPath($path) { |
|
457 | - $prefix = '/' . $this->uid . '/files'; |
|
458 | - return rtrim(substr($path, strlen($prefix)), '/'); |
|
459 | - } |
|
460 | - |
|
461 | - public function getMount($data) { |
|
462 | - $data['manager'] = $this; |
|
463 | - $mountPoint = '/' . $this->uid . '/files' . $data['mountpoint']; |
|
464 | - $data['mountpoint'] = $mountPoint; |
|
465 | - $data['certificateManager'] = \OC::$server->getCertificateManager($this->uid); |
|
466 | - return new Mount(self::STORAGE, $mountPoint, $data, $this, $this->storageLoader); |
|
467 | - } |
|
468 | - |
|
469 | - /** |
|
470 | - * @param array $data |
|
471 | - * @return Mount |
|
472 | - */ |
|
473 | - protected function mountShare($data) { |
|
474 | - $mount = $this->getMount($data); |
|
475 | - $this->mountManager->addMount($mount); |
|
476 | - return $mount; |
|
477 | - } |
|
478 | - |
|
479 | - /** |
|
480 | - * @return \OC\Files\Mount\Manager |
|
481 | - */ |
|
482 | - public function getMountManager() { |
|
483 | - return $this->mountManager; |
|
484 | - } |
|
485 | - |
|
486 | - /** |
|
487 | - * @param string $source |
|
488 | - * @param string $target |
|
489 | - * @return bool |
|
490 | - */ |
|
491 | - public function setMountPoint($source, $target) { |
|
492 | - $source = $this->stripPath($source); |
|
493 | - $target = $this->stripPath($target); |
|
494 | - $sourceHash = md5($source); |
|
495 | - $targetHash = md5($target); |
|
496 | - |
|
497 | - $query = $this->connection->prepare(' |
|
327 | + $removeShare->execute(array($id, $this->uid)); |
|
328 | + $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); |
|
329 | + |
|
330 | + $this->processNotification($id); |
|
331 | + return true; |
|
332 | + } else if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { |
|
333 | + $this->writeShareToDb( |
|
334 | + $share['remote'], |
|
335 | + $share['share_token'], |
|
336 | + $share['password'], |
|
337 | + $share['name'], |
|
338 | + $share['owner'], |
|
339 | + $this->uid, |
|
340 | + $share['mountpoint'], |
|
341 | + $share['mountpoint_hash'], |
|
342 | + 0, |
|
343 | + $share['remote_id'], |
|
344 | + $id, |
|
345 | + $share['share_type']); |
|
346 | + $this->processNotification($id); |
|
347 | + return true; |
|
348 | + } |
|
349 | + |
|
350 | + return false; |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * @param int $remoteShare |
|
355 | + */ |
|
356 | + public function processNotification($remoteShare) { |
|
357 | + $filter = $this->notificationManager->createNotification(); |
|
358 | + $filter->setApp('files_sharing') |
|
359 | + ->setUser($this->uid) |
|
360 | + ->setObject('remote_share', (int) $remoteShare); |
|
361 | + $this->notificationManager->markProcessed($filter); |
|
362 | + } |
|
363 | + |
|
364 | + /** |
|
365 | + * inform remote server whether server-to-server share was accepted/declined |
|
366 | + * |
|
367 | + * @param string $remote |
|
368 | + * @param string $token |
|
369 | + * @param int $remoteId Share id on the remote host |
|
370 | + * @param string $feedback |
|
371 | + * @return boolean |
|
372 | + */ |
|
373 | + private function sendFeedbackToRemote($remote, $token, $remoteId, $feedback) { |
|
374 | + |
|
375 | + $result = $this->tryOCMEndPoint($remote, $token, $remoteId, $feedback); |
|
376 | + |
|
377 | + if($result === true) { |
|
378 | + return true; |
|
379 | + } |
|
380 | + |
|
381 | + $federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING'); |
|
382 | + $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; |
|
383 | + |
|
384 | + $url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT; |
|
385 | + $fields = array('token' => $token); |
|
386 | + |
|
387 | + $client = $this->clientService->newClient(); |
|
388 | + |
|
389 | + try { |
|
390 | + $response = $client->post( |
|
391 | + $url, |
|
392 | + [ |
|
393 | + 'body' => $fields, |
|
394 | + 'connect_timeout' => 10, |
|
395 | + ] |
|
396 | + ); |
|
397 | + } catch (\Exception $e) { |
|
398 | + return false; |
|
399 | + } |
|
400 | + |
|
401 | + $status = json_decode($response->getBody(), true); |
|
402 | + |
|
403 | + return ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200); |
|
404 | + } |
|
405 | + |
|
406 | + /** |
|
407 | + * try send accept message to ocm end-point |
|
408 | + * |
|
409 | + * @param string $remoteDomain |
|
410 | + * @param string $token |
|
411 | + * @param $remoteId id of the share |
|
412 | + * @param string $feedback |
|
413 | + * @return bool |
|
414 | + */ |
|
415 | + protected function tryOCMEndPoint($remoteDomain, $token, $remoteId, $feedback) { |
|
416 | + switch ($feedback) { |
|
417 | + case 'accept': |
|
418 | + $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
419 | + $notification->setMessage( |
|
420 | + 'SHARE_ACCEPTED', |
|
421 | + 'file', |
|
422 | + $remoteId, |
|
423 | + [ |
|
424 | + 'sharedSecret' => $token, |
|
425 | + 'message' => 'Recipient accept the share' |
|
426 | + ] |
|
427 | + |
|
428 | + ); |
|
429 | + return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification); |
|
430 | + case 'decline': |
|
431 | + $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
432 | + $notification->setMessage( |
|
433 | + 'SHARE_DECLINED', |
|
434 | + 'file', |
|
435 | + $remoteId, |
|
436 | + [ |
|
437 | + 'sharedSecret' => $token, |
|
438 | + 'message' => 'Recipient declined the share' |
|
439 | + ] |
|
440 | + |
|
441 | + ); |
|
442 | + return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification); |
|
443 | + } |
|
444 | + |
|
445 | + return false; |
|
446 | + |
|
447 | + } |
|
448 | + |
|
449 | + |
|
450 | + /** |
|
451 | + * remove '/user/files' from the path and trailing slashes |
|
452 | + * |
|
453 | + * @param string $path |
|
454 | + * @return string |
|
455 | + */ |
|
456 | + protected function stripPath($path) { |
|
457 | + $prefix = '/' . $this->uid . '/files'; |
|
458 | + return rtrim(substr($path, strlen($prefix)), '/'); |
|
459 | + } |
|
460 | + |
|
461 | + public function getMount($data) { |
|
462 | + $data['manager'] = $this; |
|
463 | + $mountPoint = '/' . $this->uid . '/files' . $data['mountpoint']; |
|
464 | + $data['mountpoint'] = $mountPoint; |
|
465 | + $data['certificateManager'] = \OC::$server->getCertificateManager($this->uid); |
|
466 | + return new Mount(self::STORAGE, $mountPoint, $data, $this, $this->storageLoader); |
|
467 | + } |
|
468 | + |
|
469 | + /** |
|
470 | + * @param array $data |
|
471 | + * @return Mount |
|
472 | + */ |
|
473 | + protected function mountShare($data) { |
|
474 | + $mount = $this->getMount($data); |
|
475 | + $this->mountManager->addMount($mount); |
|
476 | + return $mount; |
|
477 | + } |
|
478 | + |
|
479 | + /** |
|
480 | + * @return \OC\Files\Mount\Manager |
|
481 | + */ |
|
482 | + public function getMountManager() { |
|
483 | + return $this->mountManager; |
|
484 | + } |
|
485 | + |
|
486 | + /** |
|
487 | + * @param string $source |
|
488 | + * @param string $target |
|
489 | + * @return bool |
|
490 | + */ |
|
491 | + public function setMountPoint($source, $target) { |
|
492 | + $source = $this->stripPath($source); |
|
493 | + $target = $this->stripPath($target); |
|
494 | + $sourceHash = md5($source); |
|
495 | + $targetHash = md5($target); |
|
496 | + |
|
497 | + $query = $this->connection->prepare(' |
|
498 | 498 | UPDATE `*PREFIX*share_external` |
499 | 499 | SET `mountpoint` = ?, `mountpoint_hash` = ? |
500 | 500 | WHERE `mountpoint_hash` = ? |
501 | 501 | AND `user` = ? |
502 | 502 | '); |
503 | - $result = (bool)$query->execute(array($target, $targetHash, $sourceHash, $this->uid)); |
|
503 | + $result = (bool)$query->execute(array($target, $targetHash, $sourceHash, $this->uid)); |
|
504 | 504 | |
505 | - return $result; |
|
506 | - } |
|
505 | + return $result; |
|
506 | + } |
|
507 | 507 | |
508 | - public function removeShare($mountPoint) { |
|
508 | + public function removeShare($mountPoint) { |
|
509 | 509 | |
510 | - $mountPointObj = $this->mountManager->find($mountPoint); |
|
511 | - $id = $mountPointObj->getStorage()->getCache()->getId(''); |
|
510 | + $mountPointObj = $this->mountManager->find($mountPoint); |
|
511 | + $id = $mountPointObj->getStorage()->getCache()->getId(''); |
|
512 | 512 | |
513 | - $mountPoint = $this->stripPath($mountPoint); |
|
514 | - $hash = md5($mountPoint); |
|
513 | + $mountPoint = $this->stripPath($mountPoint); |
|
514 | + $hash = md5($mountPoint); |
|
515 | 515 | |
516 | - $getShare = $this->connection->prepare(' |
|
516 | + $getShare = $this->connection->prepare(' |
|
517 | 517 | SELECT `remote`, `share_token`, `remote_id` |
518 | 518 | FROM `*PREFIX*share_external` |
519 | 519 | WHERE `mountpoint_hash` = ? AND `user` = ?'); |
520 | - $result = $getShare->execute(array($hash, $this->uid)); |
|
521 | - |
|
522 | - if ($result) { |
|
523 | - try { |
|
524 | - $share = $getShare->fetch(); |
|
525 | - $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); |
|
526 | - } catch (\Exception $e) { |
|
527 | - // if we fail to notify the remote (probably cause the remote is down) |
|
528 | - // we still want the share to be gone to prevent undeletable remotes |
|
529 | - } |
|
530 | - } |
|
531 | - $getShare->closeCursor(); |
|
532 | - |
|
533 | - $query = $this->connection->prepare(' |
|
520 | + $result = $getShare->execute(array($hash, $this->uid)); |
|
521 | + |
|
522 | + if ($result) { |
|
523 | + try { |
|
524 | + $share = $getShare->fetch(); |
|
525 | + $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); |
|
526 | + } catch (\Exception $e) { |
|
527 | + // if we fail to notify the remote (probably cause the remote is down) |
|
528 | + // we still want the share to be gone to prevent undeletable remotes |
|
529 | + } |
|
530 | + } |
|
531 | + $getShare->closeCursor(); |
|
532 | + |
|
533 | + $query = $this->connection->prepare(' |
|
534 | 534 | DELETE FROM `*PREFIX*share_external` |
535 | 535 | WHERE `mountpoint_hash` = ? |
536 | 536 | AND `user` = ? |
537 | 537 | '); |
538 | - $result = (bool)$query->execute(array($hash, $this->uid)); |
|
539 | - |
|
540 | - if($result) { |
|
541 | - $this->removeReShares($id); |
|
542 | - } |
|
543 | - |
|
544 | - return $result; |
|
545 | - } |
|
546 | - |
|
547 | - /** |
|
548 | - * remove re-shares from share table and mapping in the federated_reshares table |
|
549 | - * |
|
550 | - * @param $mountPointId |
|
551 | - */ |
|
552 | - protected function removeReShares($mountPointId) { |
|
553 | - $selectQuery = $this->connection->getQueryBuilder(); |
|
554 | - $query = $this->connection->getQueryBuilder(); |
|
555 | - $selectQuery->select('id')->from('share') |
|
556 | - ->where($selectQuery->expr()->eq('file_source', $query->createNamedParameter($mountPointId))); |
|
557 | - $select = $selectQuery->getSQL(); |
|
558 | - |
|
559 | - |
|
560 | - $query->delete('federated_reshares') |
|
561 | - ->where($query->expr()->in('share_id', $query->createFunction('(' . $select . ')'))); |
|
562 | - $query->execute(); |
|
563 | - |
|
564 | - $deleteReShares = $this->connection->getQueryBuilder(); |
|
565 | - $deleteReShares->delete('share') |
|
566 | - ->where($deleteReShares->expr()->eq('file_source', $deleteReShares->createNamedParameter($mountPointId))); |
|
567 | - $deleteReShares->execute(); |
|
568 | - } |
|
569 | - |
|
570 | - /** |
|
571 | - * remove all shares for user $uid if the user was deleted |
|
572 | - * |
|
573 | - * @param string $uid |
|
574 | - * @return bool |
|
575 | - */ |
|
576 | - public function removeUserShares($uid) { |
|
577 | - $getShare = $this->connection->prepare(' |
|
538 | + $result = (bool)$query->execute(array($hash, $this->uid)); |
|
539 | + |
|
540 | + if($result) { |
|
541 | + $this->removeReShares($id); |
|
542 | + } |
|
543 | + |
|
544 | + return $result; |
|
545 | + } |
|
546 | + |
|
547 | + /** |
|
548 | + * remove re-shares from share table and mapping in the federated_reshares table |
|
549 | + * |
|
550 | + * @param $mountPointId |
|
551 | + */ |
|
552 | + protected function removeReShares($mountPointId) { |
|
553 | + $selectQuery = $this->connection->getQueryBuilder(); |
|
554 | + $query = $this->connection->getQueryBuilder(); |
|
555 | + $selectQuery->select('id')->from('share') |
|
556 | + ->where($selectQuery->expr()->eq('file_source', $query->createNamedParameter($mountPointId))); |
|
557 | + $select = $selectQuery->getSQL(); |
|
558 | + |
|
559 | + |
|
560 | + $query->delete('federated_reshares') |
|
561 | + ->where($query->expr()->in('share_id', $query->createFunction('(' . $select . ')'))); |
|
562 | + $query->execute(); |
|
563 | + |
|
564 | + $deleteReShares = $this->connection->getQueryBuilder(); |
|
565 | + $deleteReShares->delete('share') |
|
566 | + ->where($deleteReShares->expr()->eq('file_source', $deleteReShares->createNamedParameter($mountPointId))); |
|
567 | + $deleteReShares->execute(); |
|
568 | + } |
|
569 | + |
|
570 | + /** |
|
571 | + * remove all shares for user $uid if the user was deleted |
|
572 | + * |
|
573 | + * @param string $uid |
|
574 | + * @return bool |
|
575 | + */ |
|
576 | + public function removeUserShares($uid) { |
|
577 | + $getShare = $this->connection->prepare(' |
|
578 | 578 | SELECT `remote`, `share_token`, `remote_id` |
579 | 579 | FROM `*PREFIX*share_external` |
580 | 580 | WHERE `user` = ?'); |
581 | - $result = $getShare->execute(array($uid)); |
|
581 | + $result = $getShare->execute(array($uid)); |
|
582 | 582 | |
583 | - if ($result) { |
|
584 | - $shares = $getShare->fetchAll(); |
|
585 | - foreach($shares as $share) { |
|
586 | - $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); |
|
587 | - } |
|
588 | - } |
|
583 | + if ($result) { |
|
584 | + $shares = $getShare->fetchAll(); |
|
585 | + foreach($shares as $share) { |
|
586 | + $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); |
|
587 | + } |
|
588 | + } |
|
589 | 589 | |
590 | - $query = $this->connection->prepare(' |
|
590 | + $query = $this->connection->prepare(' |
|
591 | 591 | DELETE FROM `*PREFIX*share_external` |
592 | 592 | WHERE `user` = ? |
593 | 593 | '); |
594 | - return (bool)$query->execute(array($uid)); |
|
595 | - } |
|
596 | - |
|
597 | - /** |
|
598 | - * return a list of shares which are not yet accepted by the user |
|
599 | - * |
|
600 | - * @return array list of open server-to-server shares |
|
601 | - */ |
|
602 | - public function getOpenShares() { |
|
603 | - return $this->getShares(false); |
|
604 | - } |
|
605 | - |
|
606 | - /** |
|
607 | - * return a list of shares which are accepted by the user |
|
608 | - * |
|
609 | - * @return array list of accepted server-to-server shares |
|
610 | - */ |
|
611 | - public function getAcceptedShares() { |
|
612 | - return $this->getShares(true); |
|
613 | - } |
|
614 | - |
|
615 | - /** |
|
616 | - * return a list of shares for the user |
|
617 | - * |
|
618 | - * @param bool|null $accepted True for accepted only, |
|
619 | - * false for not accepted, |
|
620 | - * null for all shares of the user |
|
621 | - * @return array list of open server-to-server shares |
|
622 | - */ |
|
623 | - private function getShares($accepted) { |
|
624 | - $query = 'SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted` |
|
594 | + return (bool)$query->execute(array($uid)); |
|
595 | + } |
|
596 | + |
|
597 | + /** |
|
598 | + * return a list of shares which are not yet accepted by the user |
|
599 | + * |
|
600 | + * @return array list of open server-to-server shares |
|
601 | + */ |
|
602 | + public function getOpenShares() { |
|
603 | + return $this->getShares(false); |
|
604 | + } |
|
605 | + |
|
606 | + /** |
|
607 | + * return a list of shares which are accepted by the user |
|
608 | + * |
|
609 | + * @return array list of accepted server-to-server shares |
|
610 | + */ |
|
611 | + public function getAcceptedShares() { |
|
612 | + return $this->getShares(true); |
|
613 | + } |
|
614 | + |
|
615 | + /** |
|
616 | + * return a list of shares for the user |
|
617 | + * |
|
618 | + * @param bool|null $accepted True for accepted only, |
|
619 | + * false for not accepted, |
|
620 | + * null for all shares of the user |
|
621 | + * @return array list of open server-to-server shares |
|
622 | + */ |
|
623 | + private function getShares($accepted) { |
|
624 | + $query = 'SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted` |
|
625 | 625 | FROM `*PREFIX*share_external` |
626 | 626 | WHERE `user` = ?'; |
627 | - $parameters = [$this->uid]; |
|
628 | - if (!is_null($accepted)) { |
|
629 | - $query .= ' AND `accepted` = ?'; |
|
630 | - $parameters[] = (int) $accepted; |
|
631 | - } |
|
632 | - $query .= ' ORDER BY `id` ASC'; |
|
633 | - |
|
634 | - $shares = $this->connection->prepare($query); |
|
635 | - $result = $shares->execute($parameters); |
|
636 | - |
|
637 | - return $result ? $shares->fetchAll() : []; |
|
638 | - } |
|
627 | + $parameters = [$this->uid]; |
|
628 | + if (!is_null($accepted)) { |
|
629 | + $query .= ' AND `accepted` = ?'; |
|
630 | + $parameters[] = (int) $accepted; |
|
631 | + } |
|
632 | + $query .= ' ORDER BY `id` ASC'; |
|
633 | + |
|
634 | + $shares = $this->connection->prepare($query); |
|
635 | + $result = $shares->execute($parameters); |
|
636 | + |
|
637 | + return $result ? $shares->fetchAll() : []; |
|
638 | + } |
|
639 | 639 | } |
@@ -148,18 +148,18 @@ discard block |
||
148 | 148 | * @return Mount|null |
149 | 149 | * @throws \Doctrine\DBAL\DBALException |
150 | 150 | */ |
151 | - public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted=false, $user = null, $remoteId = -1, $parent = -1) { |
|
151 | + public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted = false, $user = null, $remoteId = -1, $parent = -1) { |
|
152 | 152 | |
153 | 153 | $user = $user ? $user : $this->uid; |
154 | 154 | $accepted = $accepted ? 1 : 0; |
155 | - $name = Filesystem::normalizePath('/' . $name); |
|
155 | + $name = Filesystem::normalizePath('/'.$name); |
|
156 | 156 | |
157 | 157 | if (!$accepted) { |
158 | 158 | // To avoid conflicts with the mount point generation later, |
159 | 159 | // we only use a temporary mount point name here. The real |
160 | 160 | // mount point name will be generated when accepting the share, |
161 | 161 | // using the original share item name. |
162 | - $tmpMountPointName = '{{TemporaryMountPointName#' . $name . '}}'; |
|
162 | + $tmpMountPointName = '{{TemporaryMountPointName#'.$name.'}}'; |
|
163 | 163 | $mountPoint = $tmpMountPointName; |
164 | 164 | $hash = md5($tmpMountPointName); |
165 | 165 | $data = [ |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $i = 1; |
180 | 180 | while (!$this->connection->insertIfNotExist('*PREFIX*share_external', $data, ['user', 'mountpoint_hash'])) { |
181 | 181 | // The external share already exists for the user |
182 | - $data['mountpoint'] = $tmpMountPointName . '-' . $i; |
|
182 | + $data['mountpoint'] = $tmpMountPointName.'-'.$i; |
|
183 | 183 | $data['mountpoint_hash'] = md5($data['mountpoint']); |
184 | 184 | $i++; |
185 | 185 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | $mountPoint = Files::buildNotExistingFileName('/', $name); |
190 | - $mountPoint = Filesystem::normalizePath('/' . $mountPoint); |
|
190 | + $mountPoint = Filesystem::normalizePath('/'.$mountPoint); |
|
191 | 191 | $hash = md5($mountPoint); |
192 | 192 | |
193 | 193 | $this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType); |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | $validShare = is_array($share) && isset($share['share_type']) && isset($share['user']); |
246 | 246 | |
247 | 247 | // check if the user is allowed to access it |
248 | - if ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_USER && $share['user'] === $this->uid) { |
|
248 | + if ($validShare && (int) $share['share_type'] === Share::SHARE_TYPE_USER && $share['user'] === $this->uid) { |
|
249 | 249 | return $share; |
250 | - } else if ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { |
|
250 | + } else if ($validShare && (int) $share['share_type'] === Share::SHARE_TYPE_GROUP) { |
|
251 | 251 | $user = $this->userManager->get($this->uid); |
252 | 252 | if ($this->groupManager->get($share['user'])->inGroup($user)) { |
253 | 253 | return $share; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $mountPoint = Filesystem::normalizePath($mountPoint); |
277 | 277 | $hash = md5($mountPoint); |
278 | 278 | |
279 | - if($share['share_type'] === Share::SHARE_TYPE_USER) { |
|
279 | + if ($share['share_type'] === Share::SHARE_TYPE_USER) { |
|
280 | 280 | $acceptShare = $this->connection->prepare(' |
281 | 281 | UPDATE `*PREFIX*share_external` |
282 | 282 | SET `accepted` = ?, |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | |
322 | 322 | $share = $this->getShare($id); |
323 | 323 | |
324 | - if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_USER) { |
|
324 | + if ($share && (int) $share['share_type'] === Share::SHARE_TYPE_USER) { |
|
325 | 325 | $removeShare = $this->connection->prepare(' |
326 | 326 | DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?'); |
327 | 327 | $removeShare->execute(array($id, $this->uid)); |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | |
330 | 330 | $this->processNotification($id); |
331 | 331 | return true; |
332 | - } else if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { |
|
332 | + } else if ($share && (int) $share['share_type'] === Share::SHARE_TYPE_GROUP) { |
|
333 | 333 | $this->writeShareToDb( |
334 | 334 | $share['remote'], |
335 | 335 | $share['share_token'], |
@@ -374,14 +374,14 @@ discard block |
||
374 | 374 | |
375 | 375 | $result = $this->tryOCMEndPoint($remote, $token, $remoteId, $feedback); |
376 | 376 | |
377 | - if($result === true) { |
|
377 | + if ($result === true) { |
|
378 | 378 | return true; |
379 | 379 | } |
380 | 380 | |
381 | 381 | $federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING'); |
382 | 382 | $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; |
383 | 383 | |
384 | - $url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT; |
|
384 | + $url = rtrim($remote, '/').$endpoint.'/'.$remoteId.'/'.$feedback.'?format='.Share::RESPONSE_FORMAT; |
|
385 | 385 | $fields = array('token' => $token); |
386 | 386 | |
387 | 387 | $client = $this->clientService->newClient(); |
@@ -454,13 +454,13 @@ discard block |
||
454 | 454 | * @return string |
455 | 455 | */ |
456 | 456 | protected function stripPath($path) { |
457 | - $prefix = '/' . $this->uid . '/files'; |
|
457 | + $prefix = '/'.$this->uid.'/files'; |
|
458 | 458 | return rtrim(substr($path, strlen($prefix)), '/'); |
459 | 459 | } |
460 | 460 | |
461 | 461 | public function getMount($data) { |
462 | 462 | $data['manager'] = $this; |
463 | - $mountPoint = '/' . $this->uid . '/files' . $data['mountpoint']; |
|
463 | + $mountPoint = '/'.$this->uid.'/files'.$data['mountpoint']; |
|
464 | 464 | $data['mountpoint'] = $mountPoint; |
465 | 465 | $data['certificateManager'] = \OC::$server->getCertificateManager($this->uid); |
466 | 466 | return new Mount(self::STORAGE, $mountPoint, $data, $this, $this->storageLoader); |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | WHERE `mountpoint_hash` = ? |
501 | 501 | AND `user` = ? |
502 | 502 | '); |
503 | - $result = (bool)$query->execute(array($target, $targetHash, $sourceHash, $this->uid)); |
|
503 | + $result = (bool) $query->execute(array($target, $targetHash, $sourceHash, $this->uid)); |
|
504 | 504 | |
505 | 505 | return $result; |
506 | 506 | } |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | WHERE `mountpoint_hash` = ? |
536 | 536 | AND `user` = ? |
537 | 537 | '); |
538 | - $result = (bool)$query->execute(array($hash, $this->uid)); |
|
538 | + $result = (bool) $query->execute(array($hash, $this->uid)); |
|
539 | 539 | |
540 | - if($result) { |
|
540 | + if ($result) { |
|
541 | 541 | $this->removeReShares($id); |
542 | 542 | } |
543 | 543 | |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | |
559 | 559 | |
560 | 560 | $query->delete('federated_reshares') |
561 | - ->where($query->expr()->in('share_id', $query->createFunction('(' . $select . ')'))); |
|
561 | + ->where($query->expr()->in('share_id', $query->createFunction('('.$select.')'))); |
|
562 | 562 | $query->execute(); |
563 | 563 | |
564 | 564 | $deleteReShares = $this->connection->getQueryBuilder(); |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | |
583 | 583 | if ($result) { |
584 | 584 | $shares = $getShare->fetchAll(); |
585 | - foreach($shares as $share) { |
|
585 | + foreach ($shares as $share) { |
|
586 | 586 | $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); |
587 | 587 | } |
588 | 588 | } |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | DELETE FROM `*PREFIX*share_external` |
592 | 592 | WHERE `user` = ? |
593 | 593 | '); |
594 | - return (bool)$query->execute(array($uid)); |
|
594 | + return (bool) $query->execute(array($uid)); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |