|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Björn Schießle <[email protected]> |
|
6
|
|
|
* @author Christoph Wurst <[email protected]> |
|
7
|
|
|
* @author Georg Ehrke <[email protected]> |
|
8
|
|
|
* @author Joas Schilling <[email protected]> |
|
9
|
|
|
* @author Lukas Reschke <[email protected]> |
|
10
|
|
|
* @author Morris Jobke <[email protected]> |
|
11
|
|
|
* @author Robin Appelman <[email protected]> |
|
12
|
|
|
* @author Roeland Jago Douma <[email protected]> |
|
13
|
|
|
* @author Thomas Müller <[email protected]> |
|
14
|
|
|
* |
|
15
|
|
|
* @license AGPL-3.0 |
|
16
|
|
|
* |
|
17
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
18
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
19
|
|
|
* as published by the Free Software Foundation. |
|
20
|
|
|
* |
|
21
|
|
|
* This program is distributed in the hope that it will be useful, |
|
22
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
23
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
24
|
|
|
* GNU Affero General Public License for more details. |
|
25
|
|
|
* |
|
26
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
27
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
28
|
|
|
* |
|
29
|
|
|
*/ |
|
30
|
|
|
|
|
31
|
|
|
namespace OC\Settings; |
|
32
|
|
|
|
|
33
|
|
|
use OC\Authentication\Token\IProvider; |
|
34
|
|
|
use OC\Settings\Middleware\SubadminMiddleware; |
|
35
|
|
|
use OCP\AppFramework\App; |
|
36
|
|
|
use OCP\IContainer; |
|
37
|
|
|
use OCP\Settings\IManager; |
|
38
|
|
|
use OCP\Util; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @package OC\Settings |
|
42
|
|
|
*/ |
|
43
|
|
|
class Application extends App { |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param array $urlParams |
|
48
|
|
|
*/ |
|
49
|
|
|
public function __construct(array $urlParams=[]){ |
|
50
|
|
|
parent::__construct('settings', $urlParams); |
|
51
|
|
|
|
|
52
|
|
|
$container = $this->getContainer(); |
|
53
|
|
|
|
|
54
|
|
|
// Register Middleware |
|
55
|
|
|
$container->registerAlias('SubadminMiddleware', SubadminMiddleware::class); |
|
56
|
|
|
$container->registerMiddleWare('SubadminMiddleware'); |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Core class wrappers |
|
60
|
|
|
*/ |
|
61
|
|
|
/** FIXME: Remove once OC_User is non-static and mockable */ |
|
62
|
|
|
$container->registerService('isAdmin', function() { |
|
63
|
|
|
return \OC_User::isAdminUser(\OC_User::getUser()); |
|
64
|
|
|
}); |
|
65
|
|
|
/** FIXME: Remove once OC_SubAdmin is non-static and mockable */ |
|
66
|
|
|
$container->registerService('isSubAdmin', function(IContainer $c) { |
|
|
|
|
|
|
67
|
|
|
$userObject = \OC::$server->getUserSession()->getUser(); |
|
68
|
|
|
$isSubAdmin = false; |
|
69
|
|
|
if($userObject !== null) { |
|
70
|
|
|
$isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
|
71
|
|
|
} |
|
72
|
|
|
return $isSubAdmin; |
|
73
|
|
|
}); |
|
74
|
|
|
$container->registerService('fromMailAddress', function() { |
|
75
|
|
|
return Util::getDefaultEmailAddress('no-reply'); |
|
76
|
|
|
}); |
|
77
|
|
|
$container->registerService('userCertificateManager', function(IContainer $c) { |
|
78
|
|
|
return $c->query('ServerContainer')->getCertificateManager(); |
|
79
|
|
|
}, false); |
|
80
|
|
|
$container->registerService('systemCertificateManager', function (IContainer $c) { |
|
81
|
|
|
return $c->query('ServerContainer')->getCertificateManager(null); |
|
82
|
|
|
}, false); |
|
83
|
|
|
$container->registerService(IProvider::class, function (IContainer $c) { |
|
84
|
|
|
return $c->query('ServerContainer')->query(IProvider::class); |
|
85
|
|
|
}); |
|
86
|
|
|
$container->registerService(IManager::class, function (IContainer $c) { |
|
87
|
|
|
return $c->query('ServerContainer')->getSettingsManager(); |
|
88
|
|
|
}); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.