1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Arthur Schiwon <[email protected]> |
4
|
|
|
* @author Bart Visscher <[email protected]> |
5
|
|
|
* @author Bernhard Posselt <[email protected]> |
6
|
|
|
* @author Bernhard Reiter <[email protected]> |
7
|
|
|
* @author Björn Schießle <[email protected]> |
8
|
|
|
* @author Christopher Schäpers <[email protected]> |
9
|
|
|
* @author Joas Schilling <[email protected]> |
10
|
|
|
* @author Jörn Friedrich Dreyer <[email protected]> |
11
|
|
|
* @author Lukas Reschke <[email protected]> |
12
|
|
|
* @author Morris Jobke <[email protected]> |
13
|
|
|
* @author Robin Appelman <[email protected]> |
14
|
|
|
* @author Robin McCorkell <[email protected]> |
15
|
|
|
* @author Roeland Jago Douma <[email protected]> |
16
|
|
|
* @author Sander <[email protected]> |
17
|
|
|
* @author Thomas Müller <[email protected]> |
18
|
|
|
* @author Thomas Tanghus <[email protected]> |
19
|
|
|
* @author Vincent Petry <[email protected]> |
20
|
|
|
* |
21
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
22
|
|
|
* @license AGPL-3.0 |
23
|
|
|
* |
24
|
|
|
* This code is free software: you can redistribute it and/or modify |
25
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
26
|
|
|
* as published by the Free Software Foundation. |
27
|
|
|
* |
28
|
|
|
* This program is distributed in the hope that it will be useful, |
29
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
30
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31
|
|
|
* GNU Affero General Public License for more details. |
32
|
|
|
* |
33
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
34
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
35
|
|
|
* |
36
|
|
|
*/ |
37
|
|
|
namespace OC; |
38
|
|
|
|
39
|
|
|
use bantu\IniGetWrapper\IniGetWrapper; |
40
|
|
|
use OC\AppFramework\Http\Request; |
41
|
|
|
use OC\AppFramework\Db\Db; |
42
|
|
|
use OC\AppFramework\Utility\TimeFactory; |
43
|
|
|
use OC\Command\AsyncBus; |
44
|
|
|
use OC\Diagnostics\EventLogger; |
45
|
|
|
use OC\Diagnostics\NullEventLogger; |
46
|
|
|
use OC\Diagnostics\NullQueryLogger; |
47
|
|
|
use OC\Diagnostics\QueryLogger; |
48
|
|
|
use OC\Files\Config\UserMountCache; |
49
|
|
|
use OC\Files\Config\UserMountCacheListener; |
50
|
|
|
use OC\Files\Node\HookConnector; |
51
|
|
|
use OC\Files\Node\LazyRoot; |
52
|
|
|
use OC\Files\Node\Root; |
53
|
|
|
use OC\Files\View; |
54
|
|
|
use OC\Http\Client\ClientService; |
55
|
|
|
use OC\IntegrityCheck\Checker; |
56
|
|
|
use OC\IntegrityCheck\Helpers\AppLocator; |
57
|
|
|
use OC\IntegrityCheck\Helpers\EnvironmentHelper; |
58
|
|
|
use OC\IntegrityCheck\Helpers\FileAccessHelper; |
59
|
|
|
use OC\Lock\DBLockingProvider; |
60
|
|
|
use OC\Lock\MemcacheLockingProvider; |
61
|
|
|
use OC\Lock\NoopLockingProvider; |
62
|
|
|
use OC\Mail\Mailer; |
63
|
|
|
use OC\Memcache\ArrayCache; |
64
|
|
|
use OC\Notification\Manager; |
65
|
|
|
use OC\Security\CertificateManager; |
66
|
|
|
use OC\Security\CSP\ContentSecurityPolicyManager; |
67
|
|
|
use OC\Security\Crypto; |
68
|
|
|
use OC\Security\CSRF\CsrfTokenGenerator; |
69
|
|
|
use OC\Security\CSRF\CsrfTokenManager; |
70
|
|
|
use OC\Security\CSRF\TokenStorage\SessionStorage; |
71
|
|
|
use OC\Security\Hasher; |
72
|
|
|
use OC\Security\CredentialsManager; |
73
|
|
|
use OC\Security\SecureRandom; |
74
|
|
|
use OC\Security\TrustedDomainHelper; |
75
|
|
|
use OC\Session\CryptoWrapper; |
76
|
|
|
use OC\Tagging\TagMapper; |
77
|
|
|
use OCP\IServerContainer; |
78
|
|
|
use OCP\Security\IContentSecurityPolicyManager; |
79
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher; |
80
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Class Server |
84
|
|
|
* |
85
|
|
|
* @package OC |
86
|
|
|
* |
87
|
|
|
* TODO: hookup all manager classes |
88
|
|
|
*/ |
89
|
|
|
class Server extends ServerContainer implements IServerContainer { |
90
|
|
|
/** @var string */ |
91
|
|
|
private $webRoot; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param string $webRoot |
95
|
|
|
* @param \OC\Config $config |
96
|
|
|
*/ |
97
|
|
|
public function __construct($webRoot, \OC\Config $config) { |
98
|
|
|
parent::__construct(); |
99
|
|
|
$this->webRoot = $webRoot; |
100
|
|
|
|
101
|
|
|
$this->registerService('ContactsManager', function ($c) { |
|
|
|
|
102
|
|
|
return new ContactsManager(); |
103
|
|
|
}); |
104
|
|
|
|
105
|
|
|
$this->registerService('PreviewManager', function (Server $c) { |
106
|
|
|
return new PreviewManager($c->getConfig()); |
107
|
|
|
}); |
108
|
|
|
|
109
|
|
|
$this->registerService('EncryptionManager', function (Server $c) { |
110
|
|
|
$view = new View(); |
111
|
|
|
$util = new Encryption\Util( |
112
|
|
|
$view, |
113
|
|
|
$c->getUserManager(), |
114
|
|
|
$c->getGroupManager(), |
115
|
|
|
$c->getConfig() |
116
|
|
|
); |
117
|
|
|
return new Encryption\Manager( |
118
|
|
|
$c->getConfig(), |
119
|
|
|
$c->getLogger(), |
120
|
|
|
$c->getL10N('core'), |
121
|
|
|
new View(), |
122
|
|
|
$util, |
123
|
|
|
new ArrayCache() |
124
|
|
|
); |
125
|
|
|
}); |
126
|
|
|
|
127
|
|
|
$this->registerService('EncryptionFileHelper', function (Server $c) { |
128
|
|
|
$util = new Encryption\Util( |
129
|
|
|
new View(), |
130
|
|
|
$c->getUserManager(), |
131
|
|
|
$c->getGroupManager(), |
132
|
|
|
$c->getConfig() |
133
|
|
|
); |
134
|
|
|
return new Encryption\File($util); |
135
|
|
|
}); |
136
|
|
|
|
137
|
|
|
$this->registerService('EncryptionKeyStorage', function (Server $c) { |
138
|
|
|
$view = new View(); |
139
|
|
|
$util = new Encryption\Util( |
140
|
|
|
$view, |
141
|
|
|
$c->getUserManager(), |
142
|
|
|
$c->getGroupManager(), |
143
|
|
|
$c->getConfig() |
144
|
|
|
); |
145
|
|
|
|
146
|
|
|
return new Encryption\Keys\Storage($view, $util); |
147
|
|
|
}); |
148
|
|
|
$this->registerService('TagMapper', function (Server $c) { |
149
|
|
|
return new TagMapper($c->getDatabaseConnection()); |
150
|
|
|
}); |
151
|
|
|
$this->registerService('TagManager', function (Server $c) { |
152
|
|
|
$tagMapper = $c->query('TagMapper'); |
153
|
|
|
return new TagManager($tagMapper, $c->getUserSession()); |
154
|
|
|
}); |
155
|
|
View Code Duplication |
$this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
|
|
|
156
|
|
|
$config = $c->getConfig(); |
157
|
|
|
$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
158
|
|
|
/** @var \OC\SystemTag\ManagerFactory $factory */ |
159
|
|
|
$factory = new $factoryClass($this); |
160
|
|
|
return $factory; |
161
|
|
|
}); |
162
|
|
|
$this->registerService('SystemTagManager', function (Server $c) { |
163
|
|
|
return $c->query('SystemTagManagerFactory')->getManager(); |
164
|
|
|
}); |
165
|
|
|
$this->registerService('SystemTagObjectMapper', function (Server $c) { |
166
|
|
|
return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
167
|
|
|
}); |
168
|
|
|
$this->registerService('RootFolder', function () { |
169
|
|
|
$manager = \OC\Files\Filesystem::getMountManager(null); |
170
|
|
|
$view = new View(); |
171
|
|
|
$root = new Root($manager, $view, null); |
172
|
|
|
$connector = new HookConnector($root, $view); |
173
|
|
|
$connector->viewToNode(); |
174
|
|
|
return $root; |
175
|
|
|
}); |
176
|
|
|
$this->registerService('LazyRootFolder', function(Server $c) { |
177
|
|
|
return new LazyRoot(function() use ($c) { |
178
|
|
|
return $c->getRootFolder(); |
179
|
|
|
}); |
180
|
|
|
}); |
181
|
|
|
$this->registerService('UserManager', function (Server $c) { |
182
|
|
|
$config = $c->getConfig(); |
183
|
|
|
return new \OC\User\Manager($config); |
184
|
|
|
}); |
185
|
|
|
$this->registerService('GroupManager', function (Server $c) { |
|
|
|
|
186
|
|
|
$groupManager = new \OC\Group\Manager($this->getUserManager()); |
187
|
|
|
$groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
188
|
|
|
\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
189
|
|
|
}); |
190
|
|
|
$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
191
|
|
|
\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
192
|
|
|
}); |
193
|
|
|
$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
194
|
|
|
\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
195
|
|
|
}); |
196
|
|
|
$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
197
|
|
|
\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
198
|
|
|
}); |
199
|
|
|
$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
200
|
|
|
\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
201
|
|
|
}); |
202
|
|
|
$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
203
|
|
|
\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
204
|
|
|
//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
205
|
|
|
\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
206
|
|
|
}); |
207
|
|
|
return $groupManager; |
208
|
|
|
}); |
209
|
|
|
$this->registerService('UserSession', function (Server $c) { |
210
|
|
|
$manager = $c->getUserManager(); |
211
|
|
|
|
212
|
|
|
$session = new \OC\Session\Memory(''); |
213
|
|
|
|
214
|
|
|
$userSession = new \OC\User\Session($manager, $session); |
215
|
|
|
$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
216
|
|
|
\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
217
|
|
|
}); |
218
|
|
|
$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
219
|
|
|
/** @var $user \OC\User\User */ |
220
|
|
|
\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
221
|
|
|
}); |
222
|
|
|
$userSession->listen('\OC\User', 'preDelete', function ($user) { |
223
|
|
|
/** @var $user \OC\User\User */ |
224
|
|
|
\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
225
|
|
|
}); |
226
|
|
|
$userSession->listen('\OC\User', 'postDelete', function ($user) { |
227
|
|
|
/** @var $user \OC\User\User */ |
228
|
|
|
\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
229
|
|
|
}); |
230
|
|
View Code Duplication |
$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
|
|
|
231
|
|
|
/** @var $user \OC\User\User */ |
232
|
|
|
\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
233
|
|
|
}); |
234
|
|
View Code Duplication |
$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
|
|
|
235
|
|
|
/** @var $user \OC\User\User */ |
236
|
|
|
\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
237
|
|
|
}); |
238
|
|
|
$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
239
|
|
|
\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
240
|
|
|
}); |
241
|
|
|
$userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
242
|
|
|
/** @var $user \OC\User\User */ |
243
|
|
|
\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
244
|
|
|
}); |
245
|
|
|
$userSession->listen('\OC\User', 'logout', function () { |
246
|
|
|
\OC_Hook::emit('OC_User', 'logout', array()); |
247
|
|
|
}); |
248
|
|
|
$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
249
|
|
|
/** @var $user \OC\User\User */ |
250
|
|
|
\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
251
|
|
|
}); |
252
|
|
|
return $userSession; |
253
|
|
|
}); |
254
|
|
|
$this->registerService('NavigationManager', function ($c) { |
|
|
|
|
255
|
|
|
return new \OC\NavigationManager(); |
256
|
|
|
}); |
257
|
|
|
$this->registerService('AllConfig', function (Server $c) { |
258
|
|
|
return new \OC\AllConfig( |
259
|
|
|
$c->getSystemConfig() |
260
|
|
|
); |
261
|
|
|
}); |
262
|
|
|
$this->registerService('SystemConfig', function ($c) use ($config) { |
|
|
|
|
263
|
|
|
return new \OC\SystemConfig($config); |
264
|
|
|
}); |
265
|
|
|
$this->registerService('AppConfig', function (Server $c) { |
266
|
|
|
return new \OC\AppConfig($c->getDatabaseConnection()); |
267
|
|
|
}); |
268
|
|
|
$this->registerService('L10NFactory', function (Server $c) { |
269
|
|
|
return new \OC\L10N\Factory( |
270
|
|
|
$c->getConfig(), |
271
|
|
|
$c->getRequest(), |
272
|
|
|
$c->getUserSession(), |
273
|
|
|
\OC::$SERVERROOT |
274
|
|
|
); |
275
|
|
|
}); |
276
|
|
|
$this->registerService('URLGenerator', function (Server $c) { |
277
|
|
|
$config = $c->getConfig(); |
278
|
|
|
$cacheFactory = $c->getMemCacheFactory(); |
279
|
|
|
return new \OC\URLGenerator( |
280
|
|
|
$config, |
281
|
|
|
$cacheFactory |
282
|
|
|
); |
283
|
|
|
}); |
284
|
|
|
$this->registerService('AppHelper', function ($c) { |
|
|
|
|
285
|
|
|
return new \OC\AppHelper(); |
|
|
|
|
286
|
|
|
}); |
287
|
|
|
$this->registerService('UserCache', function ($c) { |
|
|
|
|
288
|
|
|
return new Cache\File(); |
289
|
|
|
}); |
290
|
|
|
$this->registerService('MemCacheFactory', function (Server $c) { |
291
|
|
|
$config = $c->getConfig(); |
292
|
|
|
|
293
|
|
|
if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
294
|
|
|
$v = \OC_App::getAppVersions(); |
295
|
|
|
$v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
296
|
|
|
$version = implode(',', $v); |
297
|
|
|
$instanceId = \OC_Util::getInstanceId(); |
298
|
|
|
$path = \OC::$SERVERROOT; |
299
|
|
|
$prefix = md5($instanceId . '-' . $version . '-' . $path); |
300
|
|
|
return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
301
|
|
|
$config->getSystemValue('memcache.local', null), |
302
|
|
|
$config->getSystemValue('memcache.distributed', null), |
303
|
|
|
$config->getSystemValue('memcache.locking', null) |
304
|
|
|
); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
return new \OC\Memcache\Factory('', $c->getLogger(), |
308
|
|
|
'\\OC\\Memcache\\ArrayCache', |
309
|
|
|
'\\OC\\Memcache\\ArrayCache', |
310
|
|
|
'\\OC\\Memcache\\ArrayCache' |
311
|
|
|
); |
312
|
|
|
}); |
313
|
|
|
$this->registerService('ActivityManager', function (Server $c) { |
314
|
|
|
return new ActivityManager( |
315
|
|
|
$c->getRequest(), |
316
|
|
|
$c->getUserSession(), |
317
|
|
|
$c->getConfig() |
318
|
|
|
); |
319
|
|
|
}); |
320
|
|
|
$this->registerService('AvatarManager', function (Server $c) { |
321
|
|
|
return new AvatarManager( |
322
|
|
|
$c->getUserManager(), |
323
|
|
|
$c->getRootFolder(), |
324
|
|
|
$c->getL10N('lib'), |
325
|
|
|
$c->getLogger() |
326
|
|
|
); |
327
|
|
|
}); |
328
|
|
|
$this->registerService('Logger', function (Server $c) { |
329
|
|
|
$logClass = $c->query('AllConfig')->getSystemValue('log_type', 'owncloud'); |
330
|
|
|
$logger = 'OC_Log_' . ucfirst($logClass); |
331
|
|
|
call_user_func(array($logger, 'init')); |
332
|
|
|
|
333
|
|
|
return new Log($logger); |
334
|
|
|
}); |
335
|
|
|
$this->registerService('JobList', function (Server $c) { |
336
|
|
|
$config = $c->getConfig(); |
337
|
|
|
return new \OC\BackgroundJob\JobList($c->getDatabaseConnection(), $config); |
338
|
|
|
}); |
339
|
|
|
$this->registerService('Router', function (Server $c) { |
340
|
|
|
$cacheFactory = $c->getMemCacheFactory(); |
341
|
|
|
$logger = $c->getLogger(); |
342
|
|
|
if ($cacheFactory->isAvailable()) { |
343
|
|
|
$router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
344
|
|
|
} else { |
345
|
|
|
$router = new \OC\Route\Router($logger); |
346
|
|
|
} |
347
|
|
|
return $router; |
348
|
|
|
}); |
349
|
|
|
$this->registerService('Search', function ($c) { |
|
|
|
|
350
|
|
|
return new Search(); |
351
|
|
|
}); |
352
|
|
|
$this->registerService('SecureRandom', function ($c) { |
|
|
|
|
353
|
|
|
return new SecureRandom(); |
354
|
|
|
}); |
355
|
|
|
$this->registerService('Crypto', function (Server $c) { |
356
|
|
|
return new Crypto($c->getConfig(), $c->getSecureRandom()); |
357
|
|
|
}); |
358
|
|
|
$this->registerService('Hasher', function (Server $c) { |
359
|
|
|
return new Hasher($c->getConfig()); |
360
|
|
|
}); |
361
|
|
|
$this->registerService('CredentialsManager', function (Server $c) { |
362
|
|
|
return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
363
|
|
|
}); |
364
|
|
|
$this->registerService('DatabaseConnection', function (Server $c) { |
365
|
|
|
$factory = new \OC\DB\ConnectionFactory(); |
366
|
|
|
$systemConfig = $c->getSystemConfig(); |
367
|
|
|
$type = $systemConfig->getValue('dbtype', 'sqlite'); |
368
|
|
|
if (!$factory->isValidType($type)) { |
369
|
|
|
throw new \OC\DatabaseException('Invalid database type'); |
370
|
|
|
} |
371
|
|
|
$connectionParams = $factory->createConnectionParams($systemConfig); |
372
|
|
|
$connection = $factory->getConnection($type, $connectionParams); |
373
|
|
|
$connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
374
|
|
|
return $connection; |
375
|
|
|
}); |
376
|
|
|
$this->registerService('Db', function (Server $c) { |
377
|
|
|
return new Db($c->getDatabaseConnection()); |
|
|
|
|
378
|
|
|
}); |
379
|
|
|
$this->registerService('HTTPHelper', function (Server $c) { |
380
|
|
|
$config = $c->getConfig(); |
381
|
|
|
return new HTTPHelper( |
|
|
|
|
382
|
|
|
$config, |
383
|
|
|
$c->getHTTPClientService() |
384
|
|
|
); |
385
|
|
|
}); |
386
|
|
|
$this->registerService('HttpClientService', function (Server $c) { |
387
|
|
|
$user = \OC_User::getUser(); |
388
|
|
|
$uid = $user ? $user : null; |
389
|
|
|
return new ClientService( |
390
|
|
|
$c->getConfig(), |
391
|
|
|
new \OC\Security\CertificateManager($uid, new View(), $c->getConfig()) |
392
|
|
|
); |
393
|
|
|
}); |
394
|
|
|
$this->registerService('EventLogger', function (Server $c) { |
395
|
|
|
if ($c->getSystemConfig()->getValue('debug', false)) { |
396
|
|
|
return new EventLogger(); |
397
|
|
|
} else { |
398
|
|
|
return new NullEventLogger(); |
399
|
|
|
} |
400
|
|
|
}); |
401
|
|
|
$this->registerService('QueryLogger', function (Server $c) { |
402
|
|
|
if ($c->getSystemConfig()->getValue('debug', false)) { |
403
|
|
|
return new QueryLogger(); |
404
|
|
|
} else { |
405
|
|
|
return new NullQueryLogger(); |
406
|
|
|
} |
407
|
|
|
}); |
408
|
|
|
$this->registerService('TempManager', function (Server $c) { |
409
|
|
|
return new TempManager( |
410
|
|
|
$c->getLogger(), |
411
|
|
|
$c->getConfig() |
412
|
|
|
); |
413
|
|
|
}); |
414
|
|
|
$this->registerService('AppManager', function (Server $c) { |
415
|
|
|
return new \OC\App\AppManager( |
416
|
|
|
$c->getUserSession(), |
417
|
|
|
$c->getAppConfig(), |
418
|
|
|
$c->getGroupManager(), |
419
|
|
|
$c->getMemCacheFactory(), |
420
|
|
|
$c->getEventDispatcher() |
421
|
|
|
); |
422
|
|
|
}); |
423
|
|
|
$this->registerService('DateTimeZone', function (Server $c) { |
424
|
|
|
return new DateTimeZone( |
425
|
|
|
$c->getConfig(), |
426
|
|
|
$c->getSession() |
427
|
|
|
); |
428
|
|
|
}); |
429
|
|
|
$this->registerService('DateTimeFormatter', function (Server $c) { |
430
|
|
|
$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
431
|
|
|
|
432
|
|
|
return new DateTimeFormatter( |
433
|
|
|
$c->getDateTimeZone()->getTimeZone(), |
434
|
|
|
$c->getL10N('lib', $language) |
435
|
|
|
); |
436
|
|
|
}); |
437
|
|
|
$this->registerService('UserMountCache', function (Server $c) { |
438
|
|
|
$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
439
|
|
|
$listener = new UserMountCacheListener($mountCache); |
440
|
|
|
$listener->listen($c->getUserManager()); |
441
|
|
|
return $mountCache; |
442
|
|
|
}); |
443
|
|
|
$this->registerService('MountConfigManager', function (Server $c) { |
444
|
|
|
$loader = \OC\Files\Filesystem::getLoader(); |
445
|
|
|
$mountCache = $c->query('UserMountCache'); |
446
|
|
|
return new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
447
|
|
|
}); |
448
|
|
|
$this->registerService('IniWrapper', function ($c) { |
|
|
|
|
449
|
|
|
return new IniGetWrapper(); |
450
|
|
|
}); |
451
|
|
|
$this->registerService('AsyncCommandBus', function (Server $c) { |
452
|
|
|
$jobList = $c->getJobList(); |
453
|
|
|
return new AsyncBus($jobList); |
454
|
|
|
}); |
455
|
|
|
$this->registerService('TrustedDomainHelper', function ($c) { |
|
|
|
|
456
|
|
|
return new TrustedDomainHelper($this->getConfig()); |
457
|
|
|
}); |
458
|
|
|
$this->registerService('IntegrityCodeChecker', function (Server $c) { |
459
|
|
|
// IConfig and IAppManager requires a working database. This code |
460
|
|
|
// might however be called when ownCloud is not yet setup. |
461
|
|
|
if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
462
|
|
|
$config = $c->getConfig(); |
463
|
|
|
$appManager = $c->getAppManager(); |
464
|
|
|
} else { |
465
|
|
|
$config = null; |
466
|
|
|
$appManager = null; |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
return new Checker( |
470
|
|
|
new EnvironmentHelper(), |
471
|
|
|
new FileAccessHelper(), |
472
|
|
|
new AppLocator(), |
473
|
|
|
$config, |
474
|
|
|
$c->getMemCacheFactory(), |
475
|
|
|
$appManager, |
476
|
|
|
$c->getTempManager() |
477
|
|
|
); |
478
|
|
|
}); |
479
|
|
|
$this->registerService('Request', function ($c) { |
|
|
|
|
480
|
|
|
if (isset($this['urlParams'])) { |
481
|
|
|
$urlParams = $this['urlParams']; |
482
|
|
|
} else { |
483
|
|
|
$urlParams = []; |
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
487
|
|
|
&& in_array('fakeinput', stream_get_wrappers()) |
488
|
|
|
) { |
489
|
|
|
$stream = 'fakeinput://data'; |
490
|
|
|
} else { |
491
|
|
|
$stream = 'php://input'; |
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
return new Request( |
495
|
|
|
[ |
496
|
|
|
'get' => $_GET, |
497
|
|
|
'post' => $_POST, |
498
|
|
|
'files' => $_FILES, |
499
|
|
|
'server' => $_SERVER, |
500
|
|
|
'env' => $_ENV, |
501
|
|
|
'cookies' => $_COOKIE, |
502
|
|
|
'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
503
|
|
|
? $_SERVER['REQUEST_METHOD'] |
504
|
|
|
: null, |
505
|
|
|
'urlParams' => $urlParams, |
506
|
|
|
], |
507
|
|
|
$this->getSecureRandom(), |
508
|
|
|
$this->getConfig(), |
509
|
|
|
$this->getCsrfTokenManager(), |
510
|
|
|
$stream |
511
|
|
|
); |
512
|
|
|
}); |
513
|
|
|
$this->registerService('Mailer', function (Server $c) { |
514
|
|
|
return new Mailer( |
515
|
|
|
$c->getConfig(), |
516
|
|
|
$c->getLogger(), |
517
|
|
|
new \OC_Defaults() |
518
|
|
|
); |
519
|
|
|
}); |
520
|
|
|
$this->registerService('OcsClient', function (Server $c) { |
|
|
|
|
521
|
|
|
return new OCSClient( |
522
|
|
|
$this->getHTTPClientService(), |
523
|
|
|
$this->getConfig(), |
524
|
|
|
$this->getLogger() |
525
|
|
|
); |
526
|
|
|
}); |
527
|
|
|
$this->registerService('LockingProvider', function (Server $c) { |
528
|
|
|
$ini = $c->getIniWrapper(); |
529
|
|
|
$config = $c->getConfig(); |
530
|
|
|
$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
531
|
|
|
if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
532
|
|
|
/** @var \OC\Memcache\Factory $memcacheFactory */ |
533
|
|
|
$memcacheFactory = $c->getMemCacheFactory(); |
534
|
|
|
$memcache = $memcacheFactory->createLocking('lock'); |
535
|
|
|
if (!($memcache instanceof \OC\Memcache\NullCache)) { |
536
|
|
|
return new MemcacheLockingProvider($memcache, $ttl); |
537
|
|
|
} |
538
|
|
|
return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
539
|
|
|
} |
540
|
|
|
return new NoopLockingProvider(); |
541
|
|
|
}); |
542
|
|
|
$this->registerService('MountManager', function () { |
543
|
|
|
return new \OC\Files\Mount\Manager(); |
544
|
|
|
}); |
545
|
|
|
$this->registerService('MimeTypeDetector', function (Server $c) { |
546
|
|
|
return new \OC\Files\Type\Detection( |
547
|
|
|
$c->getURLGenerator(), |
548
|
|
|
\OC::$SERVERROOT . '/config/', |
549
|
|
|
\OC::$SERVERROOT . '/resources/config/' |
550
|
|
|
); |
551
|
|
|
}); |
552
|
|
|
$this->registerService('MimeTypeLoader', function (Server $c) { |
553
|
|
|
return new \OC\Files\Type\Loader( |
554
|
|
|
$c->getDatabaseConnection() |
555
|
|
|
); |
556
|
|
|
}); |
557
|
|
|
$this->registerService('NotificationManager', function () { |
558
|
|
|
return new Manager(); |
559
|
|
|
}); |
560
|
|
|
$this->registerService('CapabilitiesManager', function (Server $c) { |
561
|
|
|
$manager = new \OC\CapabilitiesManager(); |
562
|
|
|
$manager->registerCapability(function () use ($c) { |
563
|
|
|
return new \OC\OCS\CoreCapabilities($c->getConfig()); |
564
|
|
|
}); |
565
|
|
|
return $manager; |
566
|
|
|
}); |
567
|
|
View Code Duplication |
$this->registerService('CommentsManager', function(Server $c) { |
|
|
|
|
568
|
|
|
$config = $c->getConfig(); |
569
|
|
|
$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
570
|
|
|
/** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
571
|
|
|
$factory = new $factoryClass($this); |
572
|
|
|
return $factory->getManager(); |
573
|
|
|
}); |
574
|
|
|
$this->registerService('EventDispatcher', function () { |
575
|
|
|
return new EventDispatcher(); |
576
|
|
|
}); |
577
|
|
|
$this->registerService('CryptoWrapper', function (Server $c) { |
578
|
|
|
// FIXME: Instantiiated here due to cyclic dependency |
579
|
|
|
$request = new Request( |
580
|
|
|
[ |
581
|
|
|
'get' => $_GET, |
582
|
|
|
'post' => $_POST, |
583
|
|
|
'files' => $_FILES, |
584
|
|
|
'server' => $_SERVER, |
585
|
|
|
'env' => $_ENV, |
586
|
|
|
'cookies' => $_COOKIE, |
587
|
|
|
'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
588
|
|
|
? $_SERVER['REQUEST_METHOD'] |
589
|
|
|
: null, |
590
|
|
|
], |
591
|
|
|
$c->getSecureRandom(), |
592
|
|
|
$c->getConfig() |
593
|
|
|
); |
594
|
|
|
|
595
|
|
|
return new CryptoWrapper( |
596
|
|
|
$c->getConfig(), |
597
|
|
|
$c->getCrypto(), |
598
|
|
|
$c->getSecureRandom(), |
599
|
|
|
$request |
600
|
|
|
); |
601
|
|
|
}); |
602
|
|
|
$this->registerService('CsrfTokenManager', function (Server $c) { |
603
|
|
|
$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
604
|
|
|
$sessionStorage = new SessionStorage($c->getSession()); |
605
|
|
|
|
606
|
|
|
return new CsrfTokenManager( |
607
|
|
|
$tokenGenerator, |
608
|
|
|
$sessionStorage |
609
|
|
|
); |
610
|
|
|
}); |
611
|
|
|
$this->registerService('ContentSecurityPolicyManager', function (Server $c) { |
|
|
|
|
612
|
|
|
return new ContentSecurityPolicyManager(); |
613
|
|
|
}); |
614
|
|
|
$this->registerService('ShareManager', function(Server $c) { |
615
|
|
|
$config = $c->getConfig(); |
616
|
|
|
$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
617
|
|
|
/** @var \OC\Share20\IProviderFactory $factory */ |
618
|
|
|
$factory = new $factoryClass($this); |
619
|
|
|
|
620
|
|
|
$manager = new \OC\Share20\Manager( |
621
|
|
|
$c->getLogger(), |
622
|
|
|
$c->getConfig(), |
623
|
|
|
$c->getSecureRandom(), |
624
|
|
|
$c->getHasher(), |
625
|
|
|
$c->getMountManager(), |
626
|
|
|
$c->getGroupManager(), |
627
|
|
|
$c->getL10N('core'), |
628
|
|
|
$factory, |
629
|
|
|
$c->getUserManager(), |
630
|
|
|
$c->getLazyRootFolder() |
631
|
|
|
); |
632
|
|
|
|
633
|
|
|
return $manager; |
634
|
|
|
}); |
635
|
|
|
} |
636
|
|
|
|
637
|
|
|
/** |
638
|
|
|
* @return \OCP\Contacts\IManager |
639
|
|
|
*/ |
640
|
|
|
public function getContactsManager() { |
641
|
|
|
return $this->query('ContactsManager'); |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
/** |
645
|
|
|
* @return \OC\Encryption\Manager |
646
|
|
|
*/ |
647
|
|
|
public function getEncryptionManager() { |
648
|
|
|
return $this->query('EncryptionManager'); |
649
|
|
|
} |
650
|
|
|
|
651
|
|
|
/** |
652
|
|
|
* @return \OC\Encryption\File |
653
|
|
|
*/ |
654
|
|
|
public function getEncryptionFilesHelper() { |
655
|
|
|
return $this->query('EncryptionFileHelper'); |
656
|
|
|
} |
657
|
|
|
|
658
|
|
|
/** |
659
|
|
|
* @return \OCP\Encryption\Keys\IStorage |
660
|
|
|
*/ |
661
|
|
|
public function getEncryptionKeyStorage() { |
662
|
|
|
return $this->query('EncryptionKeyStorage'); |
663
|
|
|
} |
664
|
|
|
|
665
|
|
|
/** |
666
|
|
|
* The current request object holding all information about the request |
667
|
|
|
* currently being processed is returned from this method. |
668
|
|
|
* In case the current execution was not initiated by a web request null is returned |
669
|
|
|
* |
670
|
|
|
* @return \OCP\IRequest |
671
|
|
|
*/ |
672
|
|
|
public function getRequest() { |
673
|
|
|
return $this->query('Request'); |
674
|
|
|
} |
675
|
|
|
|
676
|
|
|
/** |
677
|
|
|
* Returns the preview manager which can create preview images for a given file |
678
|
|
|
* |
679
|
|
|
* @return \OCP\IPreview |
680
|
|
|
*/ |
681
|
|
|
public function getPreviewManager() { |
682
|
|
|
return $this->query('PreviewManager'); |
683
|
|
|
} |
684
|
|
|
|
685
|
|
|
/** |
686
|
|
|
* Returns the tag manager which can get and set tags for different object types |
687
|
|
|
* |
688
|
|
|
* @see \OCP\ITagManager::load() |
689
|
|
|
* @return \OCP\ITagManager |
690
|
|
|
*/ |
691
|
|
|
public function getTagManager() { |
692
|
|
|
return $this->query('TagManager'); |
693
|
|
|
} |
694
|
|
|
|
695
|
|
|
/** |
696
|
|
|
* Returns the system-tag manager |
697
|
|
|
* |
698
|
|
|
* @return \OCP\SystemTag\ISystemTagManager |
699
|
|
|
* |
700
|
|
|
* @since 9.0.0 |
701
|
|
|
*/ |
702
|
|
|
public function getSystemTagManager() { |
703
|
|
|
return $this->query('SystemTagManager'); |
704
|
|
|
} |
705
|
|
|
|
706
|
|
|
/** |
707
|
|
|
* Returns the system-tag object mapper |
708
|
|
|
* |
709
|
|
|
* @return \OCP\SystemTag\ISystemTagObjectMapper |
710
|
|
|
* |
711
|
|
|
* @since 9.0.0 |
712
|
|
|
*/ |
713
|
|
|
public function getSystemTagObjectMapper() { |
714
|
|
|
return $this->query('SystemTagObjectMapper'); |
715
|
|
|
} |
716
|
|
|
|
717
|
|
|
|
718
|
|
|
/** |
719
|
|
|
* Returns the avatar manager, used for avatar functionality |
720
|
|
|
* |
721
|
|
|
* @return \OCP\IAvatarManager |
722
|
|
|
*/ |
723
|
|
|
public function getAvatarManager() { |
724
|
|
|
return $this->query('AvatarManager'); |
725
|
|
|
} |
726
|
|
|
|
727
|
|
|
/** |
728
|
|
|
* Returns the root folder of ownCloud's data directory |
729
|
|
|
* |
730
|
|
|
* @return \OCP\Files\IRootFolder |
731
|
|
|
*/ |
732
|
|
|
public function getRootFolder() { |
733
|
|
|
return $this->query('RootFolder'); |
734
|
|
|
} |
735
|
|
|
|
736
|
|
|
/** |
737
|
|
|
* Returns the root folder of ownCloud's data directory |
738
|
|
|
* This is the lazy variant so this gets only initialized once it |
739
|
|
|
* is actually used. |
740
|
|
|
* |
741
|
|
|
* @return \OCP\Files\IRootFolder |
742
|
|
|
*/ |
743
|
|
|
public function getLazyRootFolder() { |
744
|
|
|
return $this->query('LazyRootFolder'); |
745
|
|
|
} |
746
|
|
|
|
747
|
|
|
/** |
748
|
|
|
* Returns a view to ownCloud's files folder |
749
|
|
|
* |
750
|
|
|
* @param string $userId user ID |
751
|
|
|
* @return \OCP\Files\Folder|null |
752
|
|
|
*/ |
753
|
|
|
public function getUserFolder($userId = null) { |
754
|
|
View Code Duplication |
if ($userId === null) { |
|
|
|
|
755
|
|
|
$user = $this->getUserSession()->getUser(); |
756
|
|
|
if (!$user) { |
757
|
|
|
return null; |
758
|
|
|
} |
759
|
|
|
$userId = $user->getUID(); |
760
|
|
|
} |
761
|
|
|
$root = $this->getRootFolder(); |
762
|
|
|
return $root->getUserFolder($userId); |
763
|
|
|
} |
764
|
|
|
|
765
|
|
|
/** |
766
|
|
|
* Returns an app-specific view in ownClouds data directory |
767
|
|
|
* |
768
|
|
|
* @return \OCP\Files\Folder |
769
|
|
|
*/ |
770
|
|
|
public function getAppFolder() { |
771
|
|
|
$dir = '/' . \OC_App::getCurrentApp(); |
772
|
|
|
$root = $this->getRootFolder(); |
773
|
|
|
if (!$root->nodeExists($dir)) { |
774
|
|
|
$folder = $root->newFolder($dir); |
775
|
|
|
} else { |
776
|
|
|
$folder = $root->get($dir); |
777
|
|
|
} |
778
|
|
|
return $folder; |
779
|
|
|
} |
780
|
|
|
|
781
|
|
|
/** |
782
|
|
|
* @return \OC\User\Manager |
783
|
|
|
*/ |
784
|
|
|
public function getUserManager() { |
785
|
|
|
return $this->query('UserManager'); |
786
|
|
|
} |
787
|
|
|
|
788
|
|
|
/** |
789
|
|
|
* @return \OC\Group\Manager |
790
|
|
|
*/ |
791
|
|
|
public function getGroupManager() { |
792
|
|
|
return $this->query('GroupManager'); |
793
|
|
|
} |
794
|
|
|
|
795
|
|
|
/** |
796
|
|
|
* @return \OC\User\Session |
797
|
|
|
*/ |
798
|
|
|
public function getUserSession() { |
799
|
|
|
return $this->query('UserSession'); |
800
|
|
|
} |
801
|
|
|
|
802
|
|
|
/** |
803
|
|
|
* @return \OCP\ISession |
804
|
|
|
*/ |
805
|
|
|
public function getSession() { |
806
|
|
|
return $this->query('UserSession')->getSession(); |
807
|
|
|
} |
808
|
|
|
|
809
|
|
|
/** |
810
|
|
|
* @param \OCP\ISession $session |
811
|
|
|
*/ |
812
|
|
|
public function setSession(\OCP\ISession $session) { |
813
|
|
|
return $this->query('UserSession')->setSession($session); |
814
|
|
|
} |
815
|
|
|
|
816
|
|
|
/** |
817
|
|
|
* @return \OC\NavigationManager |
818
|
|
|
*/ |
819
|
|
|
public function getNavigationManager() { |
820
|
|
|
return $this->query('NavigationManager'); |
821
|
|
|
} |
822
|
|
|
|
823
|
|
|
/** |
824
|
|
|
* @return \OCP\IConfig |
825
|
|
|
*/ |
826
|
|
|
public function getConfig() { |
827
|
|
|
return $this->query('AllConfig'); |
828
|
|
|
} |
829
|
|
|
|
830
|
|
|
/** |
831
|
|
|
* For internal use only |
832
|
|
|
* |
833
|
|
|
* @return \OC\SystemConfig |
834
|
|
|
*/ |
835
|
|
|
public function getSystemConfig() { |
836
|
|
|
return $this->query('SystemConfig'); |
837
|
|
|
} |
838
|
|
|
|
839
|
|
|
/** |
840
|
|
|
* Returns the app config manager |
841
|
|
|
* |
842
|
|
|
* @return \OCP\IAppConfig |
843
|
|
|
*/ |
844
|
|
|
public function getAppConfig() { |
845
|
|
|
return $this->query('AppConfig'); |
846
|
|
|
} |
847
|
|
|
|
848
|
|
|
/** |
849
|
|
|
* @return \OCP\L10N\IFactory |
850
|
|
|
*/ |
851
|
|
|
public function getL10NFactory() { |
852
|
|
|
return $this->query('L10NFactory'); |
853
|
|
|
} |
854
|
|
|
|
855
|
|
|
/** |
856
|
|
|
* get an L10N instance |
857
|
|
|
* |
858
|
|
|
* @param string $app appid |
859
|
|
|
* @param string $lang |
860
|
|
|
* @return \OC_L10N |
861
|
|
|
*/ |
862
|
|
|
public function getL10N($app, $lang = null) { |
863
|
|
|
return $this->getL10NFactory()->get($app, $lang); |
864
|
|
|
} |
865
|
|
|
|
866
|
|
|
/** |
867
|
|
|
* @return \OCP\IURLGenerator |
868
|
|
|
*/ |
869
|
|
|
public function getURLGenerator() { |
870
|
|
|
return $this->query('URLGenerator'); |
871
|
|
|
} |
872
|
|
|
|
873
|
|
|
/** |
874
|
|
|
* @return \OCP\IHelper |
875
|
|
|
*/ |
876
|
|
|
public function getHelper() { |
877
|
|
|
return $this->query('AppHelper'); |
878
|
|
|
} |
879
|
|
|
|
880
|
|
|
/** |
881
|
|
|
* Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
882
|
|
|
* getMemCacheFactory() instead. |
883
|
|
|
* |
884
|
|
|
* @return \OCP\ICache |
885
|
|
|
* @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
886
|
|
|
*/ |
887
|
|
|
public function getCache() { |
888
|
|
|
return $this->query('UserCache'); |
889
|
|
|
} |
890
|
|
|
|
891
|
|
|
/** |
892
|
|
|
* Returns an \OCP\CacheFactory instance |
893
|
|
|
* |
894
|
|
|
* @return \OCP\ICacheFactory |
895
|
|
|
*/ |
896
|
|
|
public function getMemCacheFactory() { |
897
|
|
|
return $this->query('MemCacheFactory'); |
898
|
|
|
} |
899
|
|
|
|
900
|
|
|
/** |
901
|
|
|
* Returns the current session |
902
|
|
|
* |
903
|
|
|
* @return \OCP\IDBConnection |
904
|
|
|
*/ |
905
|
|
|
public function getDatabaseConnection() { |
906
|
|
|
return $this->query('DatabaseConnection'); |
907
|
|
|
} |
908
|
|
|
|
909
|
|
|
/** |
910
|
|
|
* Returns the activity manager |
911
|
|
|
* |
912
|
|
|
* @return \OCP\Activity\IManager |
913
|
|
|
*/ |
914
|
|
|
public function getActivityManager() { |
915
|
|
|
return $this->query('ActivityManager'); |
916
|
|
|
} |
917
|
|
|
|
918
|
|
|
/** |
919
|
|
|
* Returns an job list for controlling background jobs |
920
|
|
|
* |
921
|
|
|
* @return \OCP\BackgroundJob\IJobList |
922
|
|
|
*/ |
923
|
|
|
public function getJobList() { |
924
|
|
|
return $this->query('JobList'); |
925
|
|
|
} |
926
|
|
|
|
927
|
|
|
/** |
928
|
|
|
* Returns a logger instance |
929
|
|
|
* |
930
|
|
|
* @return \OCP\ILogger |
931
|
|
|
*/ |
932
|
|
|
public function getLogger() { |
933
|
|
|
return $this->query('Logger'); |
934
|
|
|
} |
935
|
|
|
|
936
|
|
|
/** |
937
|
|
|
* Returns a router for generating and matching urls |
938
|
|
|
* |
939
|
|
|
* @return \OCP\Route\IRouter |
940
|
|
|
*/ |
941
|
|
|
public function getRouter() { |
942
|
|
|
return $this->query('Router'); |
943
|
|
|
} |
944
|
|
|
|
945
|
|
|
/** |
946
|
|
|
* Returns a search instance |
947
|
|
|
* |
948
|
|
|
* @return \OCP\ISearch |
949
|
|
|
*/ |
950
|
|
|
public function getSearch() { |
951
|
|
|
return $this->query('Search'); |
952
|
|
|
} |
953
|
|
|
|
954
|
|
|
/** |
955
|
|
|
* Returns a SecureRandom instance |
956
|
|
|
* |
957
|
|
|
* @return \OCP\Security\ISecureRandom |
958
|
|
|
*/ |
959
|
|
|
public function getSecureRandom() { |
960
|
|
|
return $this->query('SecureRandom'); |
961
|
|
|
} |
962
|
|
|
|
963
|
|
|
/** |
964
|
|
|
* Returns a Crypto instance |
965
|
|
|
* |
966
|
|
|
* @return \OCP\Security\ICrypto |
967
|
|
|
*/ |
968
|
|
|
public function getCrypto() { |
969
|
|
|
return $this->query('Crypto'); |
970
|
|
|
} |
971
|
|
|
|
972
|
|
|
/** |
973
|
|
|
* Returns a Hasher instance |
974
|
|
|
* |
975
|
|
|
* @return \OCP\Security\IHasher |
976
|
|
|
*/ |
977
|
|
|
public function getHasher() { |
978
|
|
|
return $this->query('Hasher'); |
979
|
|
|
} |
980
|
|
|
|
981
|
|
|
/** |
982
|
|
|
* Returns a CredentialsManager instance |
983
|
|
|
* |
984
|
|
|
* @return \OCP\Security\ICredentialsManager |
985
|
|
|
*/ |
986
|
|
|
public function getCredentialsManager() { |
987
|
|
|
return $this->query('CredentialsManager'); |
988
|
|
|
} |
989
|
|
|
|
990
|
|
|
/** |
991
|
|
|
* Returns an instance of the db facade |
992
|
|
|
* |
993
|
|
|
* @deprecated use getDatabaseConnection, will be removed in ownCloud 10 |
994
|
|
|
* @return \OCP\IDb |
995
|
|
|
*/ |
996
|
|
|
public function getDb() { |
997
|
|
|
return $this->query('Db'); |
998
|
|
|
} |
999
|
|
|
|
1000
|
|
|
/** |
1001
|
|
|
* Returns an instance of the HTTP helper class |
1002
|
|
|
* |
1003
|
|
|
* @deprecated Use getHTTPClientService() |
1004
|
|
|
* @return \OC\HTTPHelper |
1005
|
|
|
*/ |
1006
|
|
|
public function getHTTPHelper() { |
1007
|
|
|
return $this->query('HTTPHelper'); |
1008
|
|
|
} |
1009
|
|
|
|
1010
|
|
|
/** |
1011
|
|
|
* Get the certificate manager for the user |
1012
|
|
|
* |
1013
|
|
|
* @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
1014
|
|
|
* @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
1015
|
|
|
*/ |
1016
|
|
|
public function getCertificateManager($userId = '') { |
1017
|
|
View Code Duplication |
if ($userId === '') { |
|
|
|
|
1018
|
|
|
$userSession = $this->getUserSession(); |
1019
|
|
|
$user = $userSession->getUser(); |
1020
|
|
|
if (is_null($user)) { |
1021
|
|
|
return null; |
1022
|
|
|
} |
1023
|
|
|
$userId = $user->getUID(); |
1024
|
|
|
} |
1025
|
|
|
return new CertificateManager($userId, new View(), $this->getConfig()); |
1026
|
|
|
} |
1027
|
|
|
|
1028
|
|
|
/** |
1029
|
|
|
* Returns an instance of the HTTP client service |
1030
|
|
|
* |
1031
|
|
|
* @return \OCP\Http\Client\IClientService |
1032
|
|
|
*/ |
1033
|
|
|
public function getHTTPClientService() { |
1034
|
|
|
return $this->query('HttpClientService'); |
1035
|
|
|
} |
1036
|
|
|
|
1037
|
|
|
/** |
1038
|
|
|
* Create a new event source |
1039
|
|
|
* |
1040
|
|
|
* @return \OCP\IEventSource |
1041
|
|
|
*/ |
1042
|
|
|
public function createEventSource() { |
1043
|
|
|
return new \OC_EventSource(); |
1044
|
|
|
} |
1045
|
|
|
|
1046
|
|
|
/** |
1047
|
|
|
* Get the active event logger |
1048
|
|
|
* |
1049
|
|
|
* The returned logger only logs data when debug mode is enabled |
1050
|
|
|
* |
1051
|
|
|
* @return \OCP\Diagnostics\IEventLogger |
1052
|
|
|
*/ |
1053
|
|
|
public function getEventLogger() { |
1054
|
|
|
return $this->query('EventLogger'); |
1055
|
|
|
} |
1056
|
|
|
|
1057
|
|
|
/** |
1058
|
|
|
* Get the active query logger |
1059
|
|
|
* |
1060
|
|
|
* The returned logger only logs data when debug mode is enabled |
1061
|
|
|
* |
1062
|
|
|
* @return \OCP\Diagnostics\IQueryLogger |
1063
|
|
|
*/ |
1064
|
|
|
public function getQueryLogger() { |
1065
|
|
|
return $this->query('QueryLogger'); |
1066
|
|
|
} |
1067
|
|
|
|
1068
|
|
|
/** |
1069
|
|
|
* Get the manager for temporary files and folders |
1070
|
|
|
* |
1071
|
|
|
* @return \OCP\ITempManager |
1072
|
|
|
*/ |
1073
|
|
|
public function getTempManager() { |
1074
|
|
|
return $this->query('TempManager'); |
1075
|
|
|
} |
1076
|
|
|
|
1077
|
|
|
/** |
1078
|
|
|
* Get the app manager |
1079
|
|
|
* |
1080
|
|
|
* @return \OCP\App\IAppManager |
1081
|
|
|
*/ |
1082
|
|
|
public function getAppManager() { |
1083
|
|
|
return $this->query('AppManager'); |
1084
|
|
|
} |
1085
|
|
|
|
1086
|
|
|
/** |
1087
|
|
|
* Creates a new mailer |
1088
|
|
|
* |
1089
|
|
|
* @return \OCP\Mail\IMailer |
1090
|
|
|
*/ |
1091
|
|
|
public function getMailer() { |
1092
|
|
|
return $this->query('Mailer'); |
1093
|
|
|
} |
1094
|
|
|
|
1095
|
|
|
/** |
1096
|
|
|
* Get the webroot |
1097
|
|
|
* |
1098
|
|
|
* @return string |
1099
|
|
|
*/ |
1100
|
|
|
public function getWebRoot() { |
1101
|
|
|
return $this->webRoot; |
1102
|
|
|
} |
1103
|
|
|
|
1104
|
|
|
/** |
1105
|
|
|
* @return \OC\OCSClient |
1106
|
|
|
*/ |
1107
|
|
|
public function getOcsClient() { |
1108
|
|
|
return $this->query('OcsClient'); |
1109
|
|
|
} |
1110
|
|
|
|
1111
|
|
|
/** |
1112
|
|
|
* @return \OCP\IDateTimeZone |
1113
|
|
|
*/ |
1114
|
|
|
public function getDateTimeZone() { |
1115
|
|
|
return $this->query('DateTimeZone'); |
1116
|
|
|
} |
1117
|
|
|
|
1118
|
|
|
/** |
1119
|
|
|
* @return \OCP\IDateTimeFormatter |
1120
|
|
|
*/ |
1121
|
|
|
public function getDateTimeFormatter() { |
1122
|
|
|
return $this->query('DateTimeFormatter'); |
1123
|
|
|
} |
1124
|
|
|
|
1125
|
|
|
/** |
1126
|
|
|
* @return \OCP\Files\Config\IMountProviderCollection |
1127
|
|
|
*/ |
1128
|
|
|
public function getMountProviderCollection() { |
1129
|
|
|
return $this->query('MountConfigManager'); |
1130
|
|
|
} |
1131
|
|
|
|
1132
|
|
|
/** |
1133
|
|
|
* Get the IniWrapper |
1134
|
|
|
* |
1135
|
|
|
* @return IniGetWrapper |
1136
|
|
|
*/ |
1137
|
|
|
public function getIniWrapper() { |
1138
|
|
|
return $this->query('IniWrapper'); |
1139
|
|
|
} |
1140
|
|
|
|
1141
|
|
|
/** |
1142
|
|
|
* @return \OCP\Command\IBus |
1143
|
|
|
*/ |
1144
|
|
|
public function getCommandBus() { |
1145
|
|
|
return $this->query('AsyncCommandBus'); |
1146
|
|
|
} |
1147
|
|
|
|
1148
|
|
|
/** |
1149
|
|
|
* Get the trusted domain helper |
1150
|
|
|
* |
1151
|
|
|
* @return TrustedDomainHelper |
1152
|
|
|
*/ |
1153
|
|
|
public function getTrustedDomainHelper() { |
1154
|
|
|
return $this->query('TrustedDomainHelper'); |
1155
|
|
|
} |
1156
|
|
|
|
1157
|
|
|
/** |
1158
|
|
|
* Get the locking provider |
1159
|
|
|
* |
1160
|
|
|
* @return \OCP\Lock\ILockingProvider |
1161
|
|
|
* @since 8.1.0 |
1162
|
|
|
*/ |
1163
|
|
|
public function getLockingProvider() { |
1164
|
|
|
return $this->query('LockingProvider'); |
1165
|
|
|
} |
1166
|
|
|
|
1167
|
|
|
/** |
1168
|
|
|
* @return \OCP\Files\Mount\IMountManager |
1169
|
|
|
**/ |
1170
|
|
|
function getMountManager() { |
1171
|
|
|
return $this->query('MountManager'); |
1172
|
|
|
} |
1173
|
|
|
|
1174
|
|
|
/* |
1175
|
|
|
* Get the MimeTypeDetector |
1176
|
|
|
* |
1177
|
|
|
* @return \OCP\Files\IMimeTypeDetector |
1178
|
|
|
*/ |
1179
|
|
|
public function getMimeTypeDetector() { |
1180
|
|
|
return $this->query('MimeTypeDetector'); |
1181
|
|
|
} |
1182
|
|
|
|
1183
|
|
|
/** |
1184
|
|
|
* Get the MimeTypeLoader |
1185
|
|
|
* |
1186
|
|
|
* @return \OCP\Files\IMimeTypeLoader |
1187
|
|
|
*/ |
1188
|
|
|
public function getMimeTypeLoader() { |
1189
|
|
|
return $this->query('MimeTypeLoader'); |
1190
|
|
|
} |
1191
|
|
|
|
1192
|
|
|
/** |
1193
|
|
|
* Get the manager of all the capabilities |
1194
|
|
|
* |
1195
|
|
|
* @return \OC\CapabilitiesManager |
1196
|
|
|
*/ |
1197
|
|
|
public function getCapabilitiesManager() { |
1198
|
|
|
return $this->query('CapabilitiesManager'); |
1199
|
|
|
} |
1200
|
|
|
|
1201
|
|
|
/** |
1202
|
|
|
* Get the EventDispatcher |
1203
|
|
|
* |
1204
|
|
|
* @return EventDispatcherInterface |
1205
|
|
|
* @since 8.2.0 |
1206
|
|
|
*/ |
1207
|
|
|
public function getEventDispatcher() { |
1208
|
|
|
return $this->query('EventDispatcher'); |
1209
|
|
|
} |
1210
|
|
|
|
1211
|
|
|
/** |
1212
|
|
|
* Get the Notification Manager |
1213
|
|
|
* |
1214
|
|
|
* @return \OCP\Notification\IManager |
1215
|
|
|
* @since 8.2.0 |
1216
|
|
|
*/ |
1217
|
|
|
public function getNotificationManager() { |
1218
|
|
|
return $this->query('NotificationManager'); |
1219
|
|
|
} |
1220
|
|
|
|
1221
|
|
|
/** |
1222
|
|
|
* @return \OCP\Comments\ICommentsManager |
1223
|
|
|
*/ |
1224
|
|
|
public function getCommentsManager() { |
1225
|
|
|
return $this->query('CommentsManager'); |
1226
|
|
|
} |
1227
|
|
|
|
1228
|
|
|
/** |
1229
|
|
|
* @return \OC\IntegrityCheck\Checker |
1230
|
|
|
*/ |
1231
|
|
|
public function getIntegrityCodeChecker() { |
1232
|
|
|
return $this->query('IntegrityCodeChecker'); |
1233
|
|
|
} |
1234
|
|
|
|
1235
|
|
|
/** |
1236
|
|
|
* @return \OC\Session\CryptoWrapper |
1237
|
|
|
*/ |
1238
|
|
|
public function getSessionCryptoWrapper() { |
1239
|
|
|
return $this->query('CryptoWrapper'); |
1240
|
|
|
} |
1241
|
|
|
|
1242
|
|
|
/** |
1243
|
|
|
* @return CsrfTokenManager |
1244
|
|
|
*/ |
1245
|
|
|
public function getCsrfTokenManager() { |
1246
|
|
|
return $this->query('CsrfTokenManager'); |
1247
|
|
|
} |
1248
|
|
|
|
1249
|
|
|
/** |
1250
|
|
|
* @return IContentSecurityPolicyManager |
1251
|
|
|
*/ |
1252
|
|
|
public function getContentSecurityPolicyManager() { |
1253
|
|
|
return $this->query('ContentSecurityPolicyManager'); |
1254
|
|
|
} |
1255
|
|
|
|
1256
|
|
|
/** |
1257
|
|
|
* Not a public API as of 8.2, wait for 9.0 |
1258
|
|
|
* |
1259
|
|
|
* @return \OCA\Files_External\Service\BackendService |
1260
|
|
|
*/ |
1261
|
|
|
public function getStoragesBackendService() { |
1262
|
|
|
return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\BackendService'); |
1263
|
|
|
} |
1264
|
|
|
|
1265
|
|
|
/** |
1266
|
|
|
* Not a public API as of 8.2, wait for 9.0 |
1267
|
|
|
* |
1268
|
|
|
* @return \OCA\Files_External\Service\GlobalStoragesService |
1269
|
|
|
*/ |
1270
|
|
|
public function getGlobalStoragesService() { |
1271
|
|
|
return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
1272
|
|
|
} |
1273
|
|
|
|
1274
|
|
|
/** |
1275
|
|
|
* Not a public API as of 8.2, wait for 9.0 |
1276
|
|
|
* |
1277
|
|
|
* @return \OCA\Files_External\Service\UserGlobalStoragesService |
1278
|
|
|
*/ |
1279
|
|
|
public function getUserGlobalStoragesService() { |
1280
|
|
|
return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
1281
|
|
|
} |
1282
|
|
|
|
1283
|
|
|
/** |
1284
|
|
|
* Not a public API as of 8.2, wait for 9.0 |
1285
|
|
|
* |
1286
|
|
|
* @return \OCA\Files_External\Service\UserStoragesService |
1287
|
|
|
*/ |
1288
|
|
|
public function getUserStoragesService() { |
1289
|
|
|
return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\UserStoragesService'); |
1290
|
|
|
} |
1291
|
|
|
|
1292
|
|
|
/** |
1293
|
|
|
* @return \OCP\Share\IManager |
1294
|
|
|
*/ |
1295
|
|
|
public function getShareManager() { |
1296
|
|
|
return $this->query('ShareManager'); |
1297
|
|
|
} |
1298
|
|
|
|
1299
|
|
|
} |
1300
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.