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