@@ -21,5 +21,5 @@ |
||
21 | 21 | * |
22 | 22 | */ |
23 | 23 | |
24 | - # used for Personal/Additional settings as fallback for legacy settings |
|
24 | + # used for Personal/Additional settings as fallback for legacy settings |
|
25 | 25 | ?> |
@@ -28,27 +28,27 @@ |
||
28 | 28 | use OCP\Util; |
29 | 29 | |
30 | 30 | class Application extends App { |
31 | - public function __construct () { |
|
32 | - parent::__construct('twofactor_backupcodes'); |
|
33 | - } |
|
31 | + public function __construct () { |
|
32 | + parent::__construct('twofactor_backupcodes'); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Register the different app parts |
|
37 | - */ |
|
38 | - public function register() { |
|
39 | - $this->registerHooksAndEvents(); |
|
40 | - } |
|
35 | + /** |
|
36 | + * Register the different app parts |
|
37 | + */ |
|
38 | + public function register() { |
|
39 | + $this->registerHooksAndEvents(); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Register the hooks and events |
|
44 | - */ |
|
45 | - public function registerHooksAndEvents() { |
|
46 | - Util::connectHook('OC_User', 'post_deleteUser', $this, 'deleteUser'); |
|
47 | - } |
|
42 | + /** |
|
43 | + * Register the hooks and events |
|
44 | + */ |
|
45 | + public function registerHooksAndEvents() { |
|
46 | + Util::connectHook('OC_User', 'post_deleteUser', $this, 'deleteUser'); |
|
47 | + } |
|
48 | 48 | |
49 | - public function deleteUser($params) { |
|
50 | - /** @var BackupCodeMapper $mapper */ |
|
51 | - $mapper = $this->getContainer()->query(BackupCodeMapper::class); |
|
52 | - $mapper->deleteCodesByUserId($params['uid']); |
|
53 | - } |
|
49 | + public function deleteUser($params) { |
|
50 | + /** @var BackupCodeMapper $mapper */ |
|
51 | + $mapper = $this->getContainer()->query(BackupCodeMapper::class); |
|
52 | + $mapper->deleteCodesByUserId($params['uid']); |
|
53 | + } |
|
54 | 54 | } |
@@ -51,6 +51,9 @@ discard block |
||
51 | 51 | ]; |
52 | 52 | } |
53 | 53 | |
54 | + /** |
|
55 | + * @param string $type |
|
56 | + */ |
|
54 | 57 | protected function formatSections($sections, $currentSection, $type, $currentType) { |
55 | 58 | $templateParameters = []; |
56 | 59 | /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
@@ -84,6 +87,9 @@ discard block |
||
84 | 87 | return $templateParameters; |
85 | 88 | } |
86 | 89 | |
90 | + /** |
|
91 | + * @param string $currentSections |
|
92 | + */ |
|
87 | 93 | protected function formatPersonalSections($currentType, $currentSections) { |
88 | 94 | $sections = $this->settingsManager->getPersonalSections(); |
89 | 95 | $templateParameters = $this->formatSections($sections, $currentSections, 'personal', $currentType); |
@@ -91,6 +97,9 @@ discard block |
||
91 | 97 | return $templateParameters; |
92 | 98 | } |
93 | 99 | |
100 | + /** |
|
101 | + * @param string $currentSections |
|
102 | + */ |
|
94 | 103 | protected function formatAdminSections($currentType, $currentSections) { |
95 | 104 | $sections = $this->settingsManager->getAdminSections(); |
96 | 105 | $templateParameters = $this->formatSections($sections, $currentSections, 'admin', $currentType); |
@@ -114,6 +123,10 @@ discard block |
||
114 | 123 | return ['content' => $html]; |
115 | 124 | } |
116 | 125 | |
126 | + /** |
|
127 | + * @param string $type |
|
128 | + * @param string $section |
|
129 | + */ |
|
117 | 130 | private function getIndexResponse($type, $section) { |
118 | 131 | $templateParams = []; |
119 | 132 | $templateParams = array_merge($templateParams, $this->getNavigationParameters($type, $section)); |
@@ -29,98 +29,98 @@ |
||
29 | 29 | use OCP\Settings\ISettings; |
30 | 30 | |
31 | 31 | trait CommonSettingsTrait { |
32 | - /** @var ISettingsManager */ |
|
33 | - private $settingsManager; |
|
34 | - |
|
35 | - /** |
|
36 | - * @param string $currentSection |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - private function getNavigationParameters($currentType, $currentSection) { |
|
40 | - $templateParameters = [ |
|
41 | - 'personal' => $this->formatPersonalSections($currentType, $currentSection), |
|
42 | - 'admin' => [] |
|
43 | - ]; |
|
44 | - |
|
45 | - if(\OC_User::isAdminUser(\OC_User::getUser())) { |
|
46 | - $templateParameters['admin'] = $this->formatAdminSections($currentType, $currentSection); |
|
47 | - } |
|
48 | - |
|
49 | - return [ |
|
50 | - 'forms' => $templateParameters |
|
51 | - ]; |
|
52 | - } |
|
53 | - |
|
54 | - protected function formatSections($sections, $currentSection, $type, $currentType) { |
|
55 | - $templateParameters = []; |
|
56 | - /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
|
57 | - foreach($sections as $prioritizedSections) { |
|
58 | - foreach ($prioritizedSections as $section) { |
|
59 | - if($type === 'admin') { |
|
60 | - $settings = $this->settingsManager->getAdminSettings($section->getID()); |
|
61 | - } else if($type === 'personal') { |
|
62 | - $settings = $this->settingsManager->getPersonalSettings($section->getID()); |
|
63 | - } |
|
64 | - if (empty($settings)) { |
|
65 | - continue; |
|
66 | - } |
|
67 | - |
|
68 | - $icon = ''; |
|
69 | - if ($section instanceof IIconSection) { |
|
70 | - $icon = $section->getIcon(); |
|
71 | - } |
|
72 | - |
|
73 | - $active = $section->getID() === $currentSection |
|
74 | - && $type === $currentType; |
|
75 | - |
|
76 | - $templateParameters[] = [ |
|
77 | - 'anchor' => $section->getID(), |
|
78 | - 'section-name' => $section->getName(), |
|
79 | - 'active' => $active, |
|
80 | - 'icon' => $icon, |
|
81 | - ]; |
|
82 | - } |
|
83 | - } |
|
84 | - return $templateParameters; |
|
85 | - } |
|
86 | - |
|
87 | - protected function formatPersonalSections($currentType, $currentSections) { |
|
88 | - $sections = $this->settingsManager->getPersonalSections(); |
|
89 | - $templateParameters = $this->formatSections($sections, $currentSections, 'personal', $currentType); |
|
90 | - |
|
91 | - return $templateParameters; |
|
92 | - } |
|
93 | - |
|
94 | - protected function formatAdminSections($currentType, $currentSections) { |
|
95 | - $sections = $this->settingsManager->getAdminSections(); |
|
96 | - $templateParameters = $this->formatSections($sections, $currentSections, 'admin', $currentType); |
|
97 | - |
|
98 | - return $templateParameters; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @param ISettings[] $settings |
|
103 | - * @return array |
|
104 | - */ |
|
105 | - private function formatSettings($settings) { |
|
106 | - $html = ''; |
|
107 | - foreach ($settings as $prioritizedSettings) { |
|
108 | - foreach ($prioritizedSettings as $setting) { |
|
109 | - /** @var \OCP\Settings\ISettings $setting */ |
|
110 | - $form = $setting->getForm(); |
|
111 | - $html .= $form->renderAs('')->render(); |
|
112 | - } |
|
113 | - } |
|
114 | - return ['content' => $html]; |
|
115 | - } |
|
116 | - |
|
117 | - private function getIndexResponse($type, $section) { |
|
118 | - $templateParams = []; |
|
119 | - $templateParams = array_merge($templateParams, $this->getNavigationParameters($type, $section)); |
|
120 | - $templateParams = array_merge($templateParams, $this->getSettings($section)); |
|
121 | - |
|
122 | - return new TemplateResponse('settings', 'settings/frame', $templateParams); |
|
123 | - } |
|
124 | - |
|
125 | - abstract protected function getSettings($section); |
|
32 | + /** @var ISettingsManager */ |
|
33 | + private $settingsManager; |
|
34 | + |
|
35 | + /** |
|
36 | + * @param string $currentSection |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + private function getNavigationParameters($currentType, $currentSection) { |
|
40 | + $templateParameters = [ |
|
41 | + 'personal' => $this->formatPersonalSections($currentType, $currentSection), |
|
42 | + 'admin' => [] |
|
43 | + ]; |
|
44 | + |
|
45 | + if(\OC_User::isAdminUser(\OC_User::getUser())) { |
|
46 | + $templateParameters['admin'] = $this->formatAdminSections($currentType, $currentSection); |
|
47 | + } |
|
48 | + |
|
49 | + return [ |
|
50 | + 'forms' => $templateParameters |
|
51 | + ]; |
|
52 | + } |
|
53 | + |
|
54 | + protected function formatSections($sections, $currentSection, $type, $currentType) { |
|
55 | + $templateParameters = []; |
|
56 | + /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
|
57 | + foreach($sections as $prioritizedSections) { |
|
58 | + foreach ($prioritizedSections as $section) { |
|
59 | + if($type === 'admin') { |
|
60 | + $settings = $this->settingsManager->getAdminSettings($section->getID()); |
|
61 | + } else if($type === 'personal') { |
|
62 | + $settings = $this->settingsManager->getPersonalSettings($section->getID()); |
|
63 | + } |
|
64 | + if (empty($settings)) { |
|
65 | + continue; |
|
66 | + } |
|
67 | + |
|
68 | + $icon = ''; |
|
69 | + if ($section instanceof IIconSection) { |
|
70 | + $icon = $section->getIcon(); |
|
71 | + } |
|
72 | + |
|
73 | + $active = $section->getID() === $currentSection |
|
74 | + && $type === $currentType; |
|
75 | + |
|
76 | + $templateParameters[] = [ |
|
77 | + 'anchor' => $section->getID(), |
|
78 | + 'section-name' => $section->getName(), |
|
79 | + 'active' => $active, |
|
80 | + 'icon' => $icon, |
|
81 | + ]; |
|
82 | + } |
|
83 | + } |
|
84 | + return $templateParameters; |
|
85 | + } |
|
86 | + |
|
87 | + protected function formatPersonalSections($currentType, $currentSections) { |
|
88 | + $sections = $this->settingsManager->getPersonalSections(); |
|
89 | + $templateParameters = $this->formatSections($sections, $currentSections, 'personal', $currentType); |
|
90 | + |
|
91 | + return $templateParameters; |
|
92 | + } |
|
93 | + |
|
94 | + protected function formatAdminSections($currentType, $currentSections) { |
|
95 | + $sections = $this->settingsManager->getAdminSections(); |
|
96 | + $templateParameters = $this->formatSections($sections, $currentSections, 'admin', $currentType); |
|
97 | + |
|
98 | + return $templateParameters; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @param ISettings[] $settings |
|
103 | + * @return array |
|
104 | + */ |
|
105 | + private function formatSettings($settings) { |
|
106 | + $html = ''; |
|
107 | + foreach ($settings as $prioritizedSettings) { |
|
108 | + foreach ($prioritizedSettings as $setting) { |
|
109 | + /** @var \OCP\Settings\ISettings $setting */ |
|
110 | + $form = $setting->getForm(); |
|
111 | + $html .= $form->renderAs('')->render(); |
|
112 | + } |
|
113 | + } |
|
114 | + return ['content' => $html]; |
|
115 | + } |
|
116 | + |
|
117 | + private function getIndexResponse($type, $section) { |
|
118 | + $templateParams = []; |
|
119 | + $templateParams = array_merge($templateParams, $this->getNavigationParameters($type, $section)); |
|
120 | + $templateParams = array_merge($templateParams, $this->getSettings($section)); |
|
121 | + |
|
122 | + return new TemplateResponse('settings', 'settings/frame', $templateParams); |
|
123 | + } |
|
124 | + |
|
125 | + abstract protected function getSettings($section); |
|
126 | 126 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | use OCP\Settings\IIconSection; |
29 | 29 | use OCP\Settings\ISettings; |
30 | 30 | |
31 | -trait CommonSettingsTrait { |
|
31 | +trait CommonSettingsTrait { |
|
32 | 32 | /** @var ISettingsManager */ |
33 | 33 | private $settingsManager; |
34 | 34 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | 'admin' => [] |
43 | 43 | ]; |
44 | 44 | |
45 | - if(\OC_User::isAdminUser(\OC_User::getUser())) { |
|
45 | + if (\OC_User::isAdminUser(\OC_User::getUser())) { |
|
46 | 46 | $templateParameters['admin'] = $this->formatAdminSections($currentType, $currentSection); |
47 | 47 | } |
48 | 48 | |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | protected function formatSections($sections, $currentSection, $type, $currentType) { |
55 | 55 | $templateParameters = []; |
56 | 56 | /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
57 | - foreach($sections as $prioritizedSections) { |
|
57 | + foreach ($sections as $prioritizedSections) { |
|
58 | 58 | foreach ($prioritizedSections as $section) { |
59 | - if($type === 'admin') { |
|
59 | + if ($type === 'admin') { |
|
60 | 60 | $settings = $this->settingsManager->getAdminSettings($section->getID()); |
61 | - } else if($type === 'personal') { |
|
61 | + } else if ($type === 'personal') { |
|
62 | 62 | $settings = $this->settingsManager->getPersonalSettings($section->getID()); |
63 | 63 | } |
64 | 64 | if (empty($settings)) { |
@@ -48,222 +48,222 @@ |
||
48 | 48 | |
49 | 49 | class Application extends \OCP\AppFramework\App { |
50 | 50 | |
51 | - /** @var IManager */ |
|
52 | - private $encryptionManager; |
|
53 | - /** @var IConfig */ |
|
54 | - private $config; |
|
55 | - |
|
56 | - /** |
|
57 | - * @param array $urlParams |
|
58 | - * @param bool $encryptionSystemReady |
|
59 | - */ |
|
60 | - public function __construct($urlParams = array(), $encryptionSystemReady = true) { |
|
61 | - parent::__construct('encryption', $urlParams); |
|
62 | - $this->encryptionManager = \OC::$server->getEncryptionManager(); |
|
63 | - $this->config = \OC::$server->getConfig(); |
|
64 | - $this->registerServices(); |
|
65 | - if($encryptionSystemReady === false) { |
|
66 | - /** @var Session $session */ |
|
67 | - $session = $this->getContainer()->query('Session'); |
|
68 | - $session->setStatus(Session::RUN_MIGRATION); |
|
69 | - } |
|
70 | - if ($this->encryptionManager->isEnabled() && $encryptionSystemReady) { |
|
71 | - /** @var Setup $setup */ |
|
72 | - $setup = $this->getContainer()->query('UserSetup'); |
|
73 | - $setup->setupSystem(); |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * register hooks |
|
79 | - */ |
|
80 | - |
|
81 | - public function registerHooks() { |
|
82 | - if (!$this->config->getSystemValue('maintenance', false)) { |
|
83 | - |
|
84 | - $container = $this->getContainer(); |
|
85 | - $server = $container->getServer(); |
|
86 | - // Register our hooks and fire them. |
|
87 | - $hookManager = new HookManager(); |
|
88 | - |
|
89 | - $hookManager->registerHook([ |
|
90 | - new UserHooks($container->query('KeyManager'), |
|
91 | - $server->getUserManager(), |
|
92 | - $server->getLogger(), |
|
93 | - $container->query('UserSetup'), |
|
94 | - $server->getUserSession(), |
|
95 | - $container->query('Util'), |
|
96 | - $container->query('Session'), |
|
97 | - $container->query('Crypt'), |
|
98 | - $container->query('Recovery')) |
|
99 | - ]); |
|
100 | - |
|
101 | - $hookManager->fireHooks(); |
|
102 | - |
|
103 | - } else { |
|
104 | - // Logout user if we are in maintenance to force re-login |
|
105 | - $this->getContainer()->getServer()->getUserSession()->logout(); |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - public function registerEncryptionModule() { |
|
110 | - $container = $this->getContainer(); |
|
111 | - |
|
112 | - |
|
113 | - $this->encryptionManager->registerEncryptionModule( |
|
114 | - Encryption::ID, |
|
115 | - Encryption::DISPLAY_NAME, |
|
116 | - function() use ($container) { |
|
117 | - |
|
118 | - return new Encryption( |
|
119 | - $container->query('Crypt'), |
|
120 | - $container->query('KeyManager'), |
|
121 | - $container->query('Util'), |
|
122 | - $container->query('Session'), |
|
123 | - $container->query('EncryptAll'), |
|
124 | - $container->query('DecryptAll'), |
|
125 | - $container->getServer()->getLogger(), |
|
126 | - $container->getServer()->getL10N($container->getAppName()) |
|
127 | - ); |
|
128 | - }); |
|
129 | - |
|
130 | - } |
|
131 | - |
|
132 | - public function registerServices() { |
|
133 | - $container = $this->getContainer(); |
|
134 | - |
|
135 | - $container->registerService('Crypt', |
|
136 | - function (IAppContainer $c) { |
|
137 | - $server = $c->getServer(); |
|
138 | - return new Crypt($server->getLogger(), |
|
139 | - $server->getUserSession(), |
|
140 | - $server->getConfig(), |
|
141 | - $server->getL10N($c->getAppName())); |
|
142 | - }); |
|
143 | - |
|
144 | - $container->registerService('Session', |
|
145 | - function (IAppContainer $c) { |
|
146 | - $server = $c->getServer(); |
|
147 | - return new Session($server->getSession()); |
|
148 | - } |
|
149 | - ); |
|
150 | - |
|
151 | - $container->registerService('KeyManager', |
|
152 | - function (IAppContainer $c) { |
|
153 | - $server = $c->getServer(); |
|
154 | - |
|
155 | - return new KeyManager($server->getEncryptionKeyStorage(), |
|
156 | - $c->query('Crypt'), |
|
157 | - $server->getConfig(), |
|
158 | - $server->getUserSession(), |
|
159 | - new Session($server->getSession()), |
|
160 | - $server->getLogger(), |
|
161 | - $c->query('Util') |
|
162 | - ); |
|
163 | - }); |
|
164 | - |
|
165 | - $container->registerService('Recovery', |
|
166 | - function (IAppContainer $c) { |
|
167 | - $server = $c->getServer(); |
|
168 | - |
|
169 | - return new Recovery( |
|
170 | - $server->getUserSession(), |
|
171 | - $c->query('Crypt'), |
|
172 | - $server->getSecureRandom(), |
|
173 | - $c->query('KeyManager'), |
|
174 | - $server->getConfig(), |
|
175 | - $server->getEncryptionKeyStorage(), |
|
176 | - $server->getEncryptionFilesHelper(), |
|
177 | - new View()); |
|
178 | - }); |
|
179 | - |
|
180 | - $container->registerService('RecoveryController', function (IAppContainer $c) { |
|
181 | - $server = $c->getServer(); |
|
182 | - return new RecoveryController( |
|
183 | - $c->getAppName(), |
|
184 | - $server->getRequest(), |
|
185 | - $server->getConfig(), |
|
186 | - $server->getL10N($c->getAppName()), |
|
187 | - $c->query('Recovery')); |
|
188 | - }); |
|
189 | - |
|
190 | - $container->registerService('StatusController', function (IAppContainer $c) { |
|
191 | - $server = $c->getServer(); |
|
192 | - return new StatusController( |
|
193 | - $c->getAppName(), |
|
194 | - $server->getRequest(), |
|
195 | - $server->getL10N($c->getAppName()), |
|
196 | - $c->query('Session') |
|
197 | - ); |
|
198 | - }); |
|
199 | - |
|
200 | - $container->registerService('SettingsController', function (IAppContainer $c) { |
|
201 | - $server = $c->getServer(); |
|
202 | - return new SettingsController( |
|
203 | - $c->getAppName(), |
|
204 | - $server->getRequest(), |
|
205 | - $server->getL10N($c->getAppName()), |
|
206 | - $server->getUserManager(), |
|
207 | - $server->getUserSession(), |
|
208 | - $c->query('KeyManager'), |
|
209 | - $c->query('Crypt'), |
|
210 | - $c->query('Session'), |
|
211 | - $server->getSession(), |
|
212 | - $c->query('Util') |
|
213 | - ); |
|
214 | - }); |
|
215 | - |
|
216 | - $container->registerService('UserSetup', |
|
217 | - function (IAppContainer $c) { |
|
218 | - $server = $c->getServer(); |
|
219 | - return new Setup($server->getLogger(), |
|
220 | - $server->getUserSession(), |
|
221 | - $c->query('Crypt'), |
|
222 | - $c->query('KeyManager')); |
|
223 | - }); |
|
224 | - |
|
225 | - $container->registerService('Util', |
|
226 | - function (IAppContainer $c) { |
|
227 | - $server = $c->getServer(); |
|
228 | - |
|
229 | - return new Util( |
|
230 | - new View(), |
|
231 | - $c->query('Crypt'), |
|
232 | - $server->getLogger(), |
|
233 | - $server->getUserSession(), |
|
234 | - $server->getConfig(), |
|
235 | - $server->getUserManager()); |
|
236 | - }); |
|
237 | - |
|
238 | - $container->registerService('EncryptAll', |
|
239 | - function (IAppContainer $c) { |
|
240 | - $server = $c->getServer(); |
|
241 | - return new EncryptAll( |
|
242 | - $c->query('UserSetup'), |
|
243 | - $c->getServer()->getUserManager(), |
|
244 | - new View(), |
|
245 | - $c->query('KeyManager'), |
|
246 | - $c->query('Util'), |
|
247 | - $server->getConfig(), |
|
248 | - $server->getMailer(), |
|
249 | - $server->getL10N('encryption'), |
|
250 | - new QuestionHelper(), |
|
251 | - $server->getSecureRandom() |
|
252 | - ); |
|
253 | - } |
|
254 | - ); |
|
255 | - |
|
256 | - $container->registerService('DecryptAll', |
|
257 | - function (IAppContainer $c) { |
|
258 | - return new DecryptAll( |
|
259 | - $c->query('Util'), |
|
260 | - $c->query('KeyManager'), |
|
261 | - $c->query('Crypt'), |
|
262 | - $c->query('Session'), |
|
263 | - new QuestionHelper() |
|
264 | - ); |
|
265 | - } |
|
266 | - ); |
|
267 | - |
|
268 | - } |
|
51 | + /** @var IManager */ |
|
52 | + private $encryptionManager; |
|
53 | + /** @var IConfig */ |
|
54 | + private $config; |
|
55 | + |
|
56 | + /** |
|
57 | + * @param array $urlParams |
|
58 | + * @param bool $encryptionSystemReady |
|
59 | + */ |
|
60 | + public function __construct($urlParams = array(), $encryptionSystemReady = true) { |
|
61 | + parent::__construct('encryption', $urlParams); |
|
62 | + $this->encryptionManager = \OC::$server->getEncryptionManager(); |
|
63 | + $this->config = \OC::$server->getConfig(); |
|
64 | + $this->registerServices(); |
|
65 | + if($encryptionSystemReady === false) { |
|
66 | + /** @var Session $session */ |
|
67 | + $session = $this->getContainer()->query('Session'); |
|
68 | + $session->setStatus(Session::RUN_MIGRATION); |
|
69 | + } |
|
70 | + if ($this->encryptionManager->isEnabled() && $encryptionSystemReady) { |
|
71 | + /** @var Setup $setup */ |
|
72 | + $setup = $this->getContainer()->query('UserSetup'); |
|
73 | + $setup->setupSystem(); |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * register hooks |
|
79 | + */ |
|
80 | + |
|
81 | + public function registerHooks() { |
|
82 | + if (!$this->config->getSystemValue('maintenance', false)) { |
|
83 | + |
|
84 | + $container = $this->getContainer(); |
|
85 | + $server = $container->getServer(); |
|
86 | + // Register our hooks and fire them. |
|
87 | + $hookManager = new HookManager(); |
|
88 | + |
|
89 | + $hookManager->registerHook([ |
|
90 | + new UserHooks($container->query('KeyManager'), |
|
91 | + $server->getUserManager(), |
|
92 | + $server->getLogger(), |
|
93 | + $container->query('UserSetup'), |
|
94 | + $server->getUserSession(), |
|
95 | + $container->query('Util'), |
|
96 | + $container->query('Session'), |
|
97 | + $container->query('Crypt'), |
|
98 | + $container->query('Recovery')) |
|
99 | + ]); |
|
100 | + |
|
101 | + $hookManager->fireHooks(); |
|
102 | + |
|
103 | + } else { |
|
104 | + // Logout user if we are in maintenance to force re-login |
|
105 | + $this->getContainer()->getServer()->getUserSession()->logout(); |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + public function registerEncryptionModule() { |
|
110 | + $container = $this->getContainer(); |
|
111 | + |
|
112 | + |
|
113 | + $this->encryptionManager->registerEncryptionModule( |
|
114 | + Encryption::ID, |
|
115 | + Encryption::DISPLAY_NAME, |
|
116 | + function() use ($container) { |
|
117 | + |
|
118 | + return new Encryption( |
|
119 | + $container->query('Crypt'), |
|
120 | + $container->query('KeyManager'), |
|
121 | + $container->query('Util'), |
|
122 | + $container->query('Session'), |
|
123 | + $container->query('EncryptAll'), |
|
124 | + $container->query('DecryptAll'), |
|
125 | + $container->getServer()->getLogger(), |
|
126 | + $container->getServer()->getL10N($container->getAppName()) |
|
127 | + ); |
|
128 | + }); |
|
129 | + |
|
130 | + } |
|
131 | + |
|
132 | + public function registerServices() { |
|
133 | + $container = $this->getContainer(); |
|
134 | + |
|
135 | + $container->registerService('Crypt', |
|
136 | + function (IAppContainer $c) { |
|
137 | + $server = $c->getServer(); |
|
138 | + return new Crypt($server->getLogger(), |
|
139 | + $server->getUserSession(), |
|
140 | + $server->getConfig(), |
|
141 | + $server->getL10N($c->getAppName())); |
|
142 | + }); |
|
143 | + |
|
144 | + $container->registerService('Session', |
|
145 | + function (IAppContainer $c) { |
|
146 | + $server = $c->getServer(); |
|
147 | + return new Session($server->getSession()); |
|
148 | + } |
|
149 | + ); |
|
150 | + |
|
151 | + $container->registerService('KeyManager', |
|
152 | + function (IAppContainer $c) { |
|
153 | + $server = $c->getServer(); |
|
154 | + |
|
155 | + return new KeyManager($server->getEncryptionKeyStorage(), |
|
156 | + $c->query('Crypt'), |
|
157 | + $server->getConfig(), |
|
158 | + $server->getUserSession(), |
|
159 | + new Session($server->getSession()), |
|
160 | + $server->getLogger(), |
|
161 | + $c->query('Util') |
|
162 | + ); |
|
163 | + }); |
|
164 | + |
|
165 | + $container->registerService('Recovery', |
|
166 | + function (IAppContainer $c) { |
|
167 | + $server = $c->getServer(); |
|
168 | + |
|
169 | + return new Recovery( |
|
170 | + $server->getUserSession(), |
|
171 | + $c->query('Crypt'), |
|
172 | + $server->getSecureRandom(), |
|
173 | + $c->query('KeyManager'), |
|
174 | + $server->getConfig(), |
|
175 | + $server->getEncryptionKeyStorage(), |
|
176 | + $server->getEncryptionFilesHelper(), |
|
177 | + new View()); |
|
178 | + }); |
|
179 | + |
|
180 | + $container->registerService('RecoveryController', function (IAppContainer $c) { |
|
181 | + $server = $c->getServer(); |
|
182 | + return new RecoveryController( |
|
183 | + $c->getAppName(), |
|
184 | + $server->getRequest(), |
|
185 | + $server->getConfig(), |
|
186 | + $server->getL10N($c->getAppName()), |
|
187 | + $c->query('Recovery')); |
|
188 | + }); |
|
189 | + |
|
190 | + $container->registerService('StatusController', function (IAppContainer $c) { |
|
191 | + $server = $c->getServer(); |
|
192 | + return new StatusController( |
|
193 | + $c->getAppName(), |
|
194 | + $server->getRequest(), |
|
195 | + $server->getL10N($c->getAppName()), |
|
196 | + $c->query('Session') |
|
197 | + ); |
|
198 | + }); |
|
199 | + |
|
200 | + $container->registerService('SettingsController', function (IAppContainer $c) { |
|
201 | + $server = $c->getServer(); |
|
202 | + return new SettingsController( |
|
203 | + $c->getAppName(), |
|
204 | + $server->getRequest(), |
|
205 | + $server->getL10N($c->getAppName()), |
|
206 | + $server->getUserManager(), |
|
207 | + $server->getUserSession(), |
|
208 | + $c->query('KeyManager'), |
|
209 | + $c->query('Crypt'), |
|
210 | + $c->query('Session'), |
|
211 | + $server->getSession(), |
|
212 | + $c->query('Util') |
|
213 | + ); |
|
214 | + }); |
|
215 | + |
|
216 | + $container->registerService('UserSetup', |
|
217 | + function (IAppContainer $c) { |
|
218 | + $server = $c->getServer(); |
|
219 | + return new Setup($server->getLogger(), |
|
220 | + $server->getUserSession(), |
|
221 | + $c->query('Crypt'), |
|
222 | + $c->query('KeyManager')); |
|
223 | + }); |
|
224 | + |
|
225 | + $container->registerService('Util', |
|
226 | + function (IAppContainer $c) { |
|
227 | + $server = $c->getServer(); |
|
228 | + |
|
229 | + return new Util( |
|
230 | + new View(), |
|
231 | + $c->query('Crypt'), |
|
232 | + $server->getLogger(), |
|
233 | + $server->getUserSession(), |
|
234 | + $server->getConfig(), |
|
235 | + $server->getUserManager()); |
|
236 | + }); |
|
237 | + |
|
238 | + $container->registerService('EncryptAll', |
|
239 | + function (IAppContainer $c) { |
|
240 | + $server = $c->getServer(); |
|
241 | + return new EncryptAll( |
|
242 | + $c->query('UserSetup'), |
|
243 | + $c->getServer()->getUserManager(), |
|
244 | + new View(), |
|
245 | + $c->query('KeyManager'), |
|
246 | + $c->query('Util'), |
|
247 | + $server->getConfig(), |
|
248 | + $server->getMailer(), |
|
249 | + $server->getL10N('encryption'), |
|
250 | + new QuestionHelper(), |
|
251 | + $server->getSecureRandom() |
|
252 | + ); |
|
253 | + } |
|
254 | + ); |
|
255 | + |
|
256 | + $container->registerService('DecryptAll', |
|
257 | + function (IAppContainer $c) { |
|
258 | + return new DecryptAll( |
|
259 | + $c->query('Util'), |
|
260 | + $c->query('KeyManager'), |
|
261 | + $c->query('Crypt'), |
|
262 | + $c->query('Session'), |
|
263 | + new QuestionHelper() |
|
264 | + ); |
|
265 | + } |
|
266 | + ); |
|
267 | + |
|
268 | + } |
|
269 | 269 | } |
@@ -29,6 +29,6 @@ |
||
29 | 29 | |
30 | 30 | $app = new Application([], $encryptionSystemReady); |
31 | 31 | if ($encryptionSystemReady) { |
32 | - $app->registerEncryptionModule(); |
|
33 | - $app->registerHooks(); |
|
32 | + $app->registerEncryptionModule(); |
|
33 | + $app->registerHooks(); |
|
34 | 34 | } |
@@ -36,76 +36,76 @@ |
||
36 | 36 | |
37 | 37 | $application = new Application(); |
38 | 38 | $application->registerRoutes($this, [ |
39 | - 'resources' => [ |
|
40 | - 'users' => ['url' => '/settings/users/users'], |
|
41 | - 'AuthSettings' => ['url' => '/settings/personal/authtokens'], |
|
42 | - ], |
|
43 | - 'routes' => [ |
|
44 | - ['name' => 'MailSettings#setMailSettings', 'url' => '/settings/admin/mailsettings', 'verb' => 'POST'], |
|
45 | - ['name' => 'MailSettings#storeCredentials', 'url' => '/settings/admin/mailsettings/credentials', 'verb' => 'POST'], |
|
46 | - ['name' => 'MailSettings#sendTestMail', 'url' => '/settings/admin/mailtest', 'verb' => 'POST'], |
|
47 | - ['name' => 'Encryption#startMigration', 'url' => '/settings/admin/startmigration', 'verb' => 'POST'], |
|
48 | - ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET'], |
|
49 | - ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET'], |
|
50 | - ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'], |
|
51 | - ['name' => 'SecuritySettings#trustedDomains', 'url' => '/settings/admin/security/trustedDomains', 'verb' => 'POST'], |
|
52 | - ['name' => 'Users#setDisplayName', 'url' => '/settings/users/{username}/displayName', 'verb' => 'POST'], |
|
53 | - ['name' => 'Users#setEMailAddress', 'url' => '/settings/users/{id}/mailAddress', 'verb' => 'PUT'], |
|
54 | - ['name' => 'Users#setUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT'], |
|
55 | - ['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'], |
|
56 | - ['name' => 'Users#setEnabled', 'url' => '/settings/users/{id}/setEnabled', 'verb' => 'POST'], |
|
57 | - ['name' => 'Users#stats', 'url' => '/settings/users/stats', 'verb' => 'GET'], |
|
58 | - ['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'], |
|
59 | - ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'], |
|
60 | - ['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'], |
|
61 | - ['name' => 'CheckSetup#check', 'url' => '/settings/ajax/checksetup', 'verb' => 'GET'], |
|
62 | - ['name' => 'CheckSetup#getFailedIntegrityCheckFiles', 'url' => '/settings/integrity/failed', 'verb' => 'GET'], |
|
63 | - ['name' => 'CheckSetup#rescanFailedIntegrityCheck', 'url' => '/settings/integrity/rescan', 'verb' => 'GET'], |
|
64 | - ['name' => 'Certificate#addPersonalRootCertificate', 'url' => '/settings/personal/certificate', 'verb' => 'POST'], |
|
65 | - ['name' => 'Certificate#removePersonalRootCertificate', 'url' => '/settings/personal/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
66 | - ['name' => 'Certificate#addSystemRootCertificate', 'url' => '/settings/admin/certificate', 'verb' => 'POST'], |
|
67 | - ['name' => 'Certificate#removeSystemRootCertificate', 'url' => '/settings/admin/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
68 | - ['name' => 'PersonalSettings#index', 'url' => '/settings/user/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'personal-info']], |
|
69 | - ['name' => 'AdminSettings#index', 'url' => '/settings/admin/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'server']], |
|
70 | - ['name' => 'AdminSettings#form', 'url' => '/settings/admin/{section}', 'verb' => 'GET'], |
|
71 | - ['name' => 'ChangePassword#changePersonalPassword', 'url' => '/settings/personal/changepassword', 'verb' => 'POST'], |
|
72 | - ['name' => 'ChangePassword#changeUserPassword', 'url' => '/settings/users/changepassword', 'verb' => 'POST'], |
|
73 | - ['name' => 'Groups#index', 'url' => '/settings/users/groups', 'verb' => 'GET'], |
|
74 | - ['name' => 'Groups#show', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'GET'], |
|
75 | - ['name' => 'Groups#create', 'url' => '/settings/users/groups', 'verb' => 'POST'], |
|
76 | - ['name' => 'Groups#update', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'PUT'], |
|
77 | - ['name' => 'Groups#destroy', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'DELETE'], |
|
78 | - ] |
|
39 | + 'resources' => [ |
|
40 | + 'users' => ['url' => '/settings/users/users'], |
|
41 | + 'AuthSettings' => ['url' => '/settings/personal/authtokens'], |
|
42 | + ], |
|
43 | + 'routes' => [ |
|
44 | + ['name' => 'MailSettings#setMailSettings', 'url' => '/settings/admin/mailsettings', 'verb' => 'POST'], |
|
45 | + ['name' => 'MailSettings#storeCredentials', 'url' => '/settings/admin/mailsettings/credentials', 'verb' => 'POST'], |
|
46 | + ['name' => 'MailSettings#sendTestMail', 'url' => '/settings/admin/mailtest', 'verb' => 'POST'], |
|
47 | + ['name' => 'Encryption#startMigration', 'url' => '/settings/admin/startmigration', 'verb' => 'POST'], |
|
48 | + ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET'], |
|
49 | + ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET'], |
|
50 | + ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'], |
|
51 | + ['name' => 'SecuritySettings#trustedDomains', 'url' => '/settings/admin/security/trustedDomains', 'verb' => 'POST'], |
|
52 | + ['name' => 'Users#setDisplayName', 'url' => '/settings/users/{username}/displayName', 'verb' => 'POST'], |
|
53 | + ['name' => 'Users#setEMailAddress', 'url' => '/settings/users/{id}/mailAddress', 'verb' => 'PUT'], |
|
54 | + ['name' => 'Users#setUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT'], |
|
55 | + ['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'], |
|
56 | + ['name' => 'Users#setEnabled', 'url' => '/settings/users/{id}/setEnabled', 'verb' => 'POST'], |
|
57 | + ['name' => 'Users#stats', 'url' => '/settings/users/stats', 'verb' => 'GET'], |
|
58 | + ['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'], |
|
59 | + ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'], |
|
60 | + ['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'], |
|
61 | + ['name' => 'CheckSetup#check', 'url' => '/settings/ajax/checksetup', 'verb' => 'GET'], |
|
62 | + ['name' => 'CheckSetup#getFailedIntegrityCheckFiles', 'url' => '/settings/integrity/failed', 'verb' => 'GET'], |
|
63 | + ['name' => 'CheckSetup#rescanFailedIntegrityCheck', 'url' => '/settings/integrity/rescan', 'verb' => 'GET'], |
|
64 | + ['name' => 'Certificate#addPersonalRootCertificate', 'url' => '/settings/personal/certificate', 'verb' => 'POST'], |
|
65 | + ['name' => 'Certificate#removePersonalRootCertificate', 'url' => '/settings/personal/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
66 | + ['name' => 'Certificate#addSystemRootCertificate', 'url' => '/settings/admin/certificate', 'verb' => 'POST'], |
|
67 | + ['name' => 'Certificate#removeSystemRootCertificate', 'url' => '/settings/admin/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
68 | + ['name' => 'PersonalSettings#index', 'url' => '/settings/user/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'personal-info']], |
|
69 | + ['name' => 'AdminSettings#index', 'url' => '/settings/admin/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'server']], |
|
70 | + ['name' => 'AdminSettings#form', 'url' => '/settings/admin/{section}', 'verb' => 'GET'], |
|
71 | + ['name' => 'ChangePassword#changePersonalPassword', 'url' => '/settings/personal/changepassword', 'verb' => 'POST'], |
|
72 | + ['name' => 'ChangePassword#changeUserPassword', 'url' => '/settings/users/changepassword', 'verb' => 'POST'], |
|
73 | + ['name' => 'Groups#index', 'url' => '/settings/users/groups', 'verb' => 'GET'], |
|
74 | + ['name' => 'Groups#show', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'GET'], |
|
75 | + ['name' => 'Groups#create', 'url' => '/settings/users/groups', 'verb' => 'POST'], |
|
76 | + ['name' => 'Groups#update', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'PUT'], |
|
77 | + ['name' => 'Groups#destroy', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'DELETE'], |
|
78 | + ] |
|
79 | 79 | ]); |
80 | 80 | |
81 | 81 | /** @var $this \OCP\Route\IRouter */ |
82 | 82 | |
83 | 83 | // Settings pages |
84 | 84 | $this->create('settings_help', '/settings/help') |
85 | - ->actionInclude('settings/help.php'); |
|
85 | + ->actionInclude('settings/help.php'); |
|
86 | 86 | $this->create('settings_users', '/settings/users') |
87 | - ->actionInclude('settings/users.php'); |
|
87 | + ->actionInclude('settings/users.php'); |
|
88 | 88 | // Settings ajax actions |
89 | 89 | // users |
90 | 90 | $this->create('settings_ajax_setquota', '/settings/ajax/setquota.php') |
91 | - ->actionInclude('settings/ajax/setquota.php'); |
|
91 | + ->actionInclude('settings/ajax/setquota.php'); |
|
92 | 92 | $this->create('settings_ajax_togglegroups', '/settings/ajax/togglegroups.php') |
93 | - ->actionInclude('settings/ajax/togglegroups.php'); |
|
93 | + ->actionInclude('settings/ajax/togglegroups.php'); |
|
94 | 94 | $this->create('settings_ajax_togglesubadmins', '/settings/ajax/togglesubadmins.php') |
95 | - ->actionInclude('settings/ajax/togglesubadmins.php'); |
|
95 | + ->actionInclude('settings/ajax/togglesubadmins.php'); |
|
96 | 96 | $this->create('settings_ajax_changegorupname', '/settings/ajax/changegroupname.php') |
97 | - ->actionInclude('settings/ajax/changegroupname.php'); |
|
97 | + ->actionInclude('settings/ajax/changegroupname.php'); |
|
98 | 98 | // apps |
99 | 99 | $this->create('settings_ajax_enableapp', '/settings/ajax/enableapp.php') |
100 | - ->actionInclude('settings/ajax/enableapp.php'); |
|
100 | + ->actionInclude('settings/ajax/enableapp.php'); |
|
101 | 101 | $this->create('settings_ajax_disableapp', '/settings/ajax/disableapp.php') |
102 | - ->actionInclude('settings/ajax/disableapp.php'); |
|
102 | + ->actionInclude('settings/ajax/disableapp.php'); |
|
103 | 103 | $this->create('settings_ajax_updateapp', '/settings/ajax/updateapp.php') |
104 | - ->actionInclude('settings/ajax/updateapp.php'); |
|
104 | + ->actionInclude('settings/ajax/updateapp.php'); |
|
105 | 105 | $this->create('settings_ajax_uninstallapp', '/settings/ajax/uninstallapp.php') |
106 | - ->actionInclude('settings/ajax/uninstallapp.php'); |
|
106 | + ->actionInclude('settings/ajax/uninstallapp.php'); |
|
107 | 107 | $this->create('settings_ajax_navigationdetect', '/settings/ajax/navigationdetect.php') |
108 | - ->actionInclude('settings/ajax/navigationdetect.php'); |
|
108 | + ->actionInclude('settings/ajax/navigationdetect.php'); |
|
109 | 109 | // admin |
110 | 110 | $this->create('settings_ajax_excludegroups', '/settings/ajax/excludegroups.php') |
111 | - ->actionInclude('settings/ajax/excludegroups.php'); |
|
111 | + ->actionInclude('settings/ajax/excludegroups.php'); |
@@ -29,58 +29,58 @@ |
||
29 | 29 | use OCP\Settings\IIconSection; |
30 | 30 | |
31 | 31 | class PersonalSection implements IIconSection { |
32 | - /** @var IURLGenerator */ |
|
33 | - private $urlGenerator; |
|
34 | - /** @var IL10N */ |
|
35 | - private $l; |
|
32 | + /** @var IURLGenerator */ |
|
33 | + private $urlGenerator; |
|
34 | + /** @var IL10N */ |
|
35 | + private $l; |
|
36 | 36 | |
37 | - public function __construct(IURLGenerator $urlGenerator, IL10N $l) { |
|
38 | - $this->urlGenerator = $urlGenerator; |
|
39 | - $this->l = $l; |
|
40 | - } |
|
37 | + public function __construct(IURLGenerator $urlGenerator, IL10N $l) { |
|
38 | + $this->urlGenerator = $urlGenerator; |
|
39 | + $this->l = $l; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * returns the relative path to an 16*16 icon describing the section. |
|
44 | - * e.g. '/core/img/places/files.svg' |
|
45 | - * |
|
46 | - * @returns string |
|
47 | - * @since 13.0.0 |
|
48 | - */ |
|
49 | - public function getIcon() { |
|
50 | - return $this->urlGenerator->imagePath('core', 'actions/share.svg'); |
|
51 | - } |
|
42 | + /** |
|
43 | + * returns the relative path to an 16*16 icon describing the section. |
|
44 | + * e.g. '/core/img/places/files.svg' |
|
45 | + * |
|
46 | + * @returns string |
|
47 | + * @since 13.0.0 |
|
48 | + */ |
|
49 | + public function getIcon() { |
|
50 | + return $this->urlGenerator->imagePath('core', 'actions/share.svg'); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * returns the ID of the section. It is supposed to be a lower case string, |
|
55 | - * e.g. 'ldap' |
|
56 | - * |
|
57 | - * @returns string |
|
58 | - * @since 9.1 |
|
59 | - */ |
|
60 | - public function getID() { |
|
61 | - return 'sharing'; |
|
62 | - } |
|
53 | + /** |
|
54 | + * returns the ID of the section. It is supposed to be a lower case string, |
|
55 | + * e.g. 'ldap' |
|
56 | + * |
|
57 | + * @returns string |
|
58 | + * @since 9.1 |
|
59 | + */ |
|
60 | + public function getID() { |
|
61 | + return 'sharing'; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
66 | - * integration'. Use the L10N service to translate it. |
|
67 | - * |
|
68 | - * @return string |
|
69 | - * @since 9.1 |
|
70 | - */ |
|
71 | - public function getName() { |
|
72 | - return $this->l->t('Sharing'); |
|
73 | - } |
|
64 | + /** |
|
65 | + * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
66 | + * integration'. Use the L10N service to translate it. |
|
67 | + * |
|
68 | + * @return string |
|
69 | + * @since 9.1 |
|
70 | + */ |
|
71 | + public function getName() { |
|
72 | + return $this->l->t('Sharing'); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @return int whether the form should be rather on the top or bottom of |
|
77 | - * the settings navigation. The sections are arranged in ascending order of |
|
78 | - * the priority values. It is required to return a value between 0 and 99. |
|
79 | - * |
|
80 | - * E.g.: 70 |
|
81 | - * @since 9.1 |
|
82 | - */ |
|
83 | - public function getPriority() { |
|
84 | - return 15; |
|
85 | - } |
|
75 | + /** |
|
76 | + * @return int whether the form should be rather on the top or bottom of |
|
77 | + * the settings navigation. The sections are arranged in ascending order of |
|
78 | + * the priority values. It is required to return a value between 0 and 99. |
|
79 | + * |
|
80 | + * E.g.: 70 |
|
81 | + * @since 9.1 |
|
82 | + */ |
|
83 | + public function getPriority() { |
|
84 | + return 15; |
|
85 | + } |
|
86 | 86 | } |
@@ -27,99 +27,99 @@ |
||
27 | 27 | * @since 9.1 |
28 | 28 | */ |
29 | 29 | interface IManager { |
30 | - /** |
|
31 | - * @since 9.1.0 |
|
32 | - */ |
|
33 | - const KEY_ADMIN_SETTINGS = 'admin'; |
|
30 | + /** |
|
31 | + * @since 9.1.0 |
|
32 | + */ |
|
33 | + const KEY_ADMIN_SETTINGS = 'admin'; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @since 9.1.0 |
|
37 | - */ |
|
38 | - const KEY_ADMIN_SECTION = 'admin-section'; |
|
35 | + /** |
|
36 | + * @since 9.1.0 |
|
37 | + */ |
|
38 | + const KEY_ADMIN_SECTION = 'admin-section'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @since 13.0.0 |
|
42 | - */ |
|
43 | - const KEY_PERSONAL_SETTINGS = 'personal'; |
|
40 | + /** |
|
41 | + * @since 13.0.0 |
|
42 | + */ |
|
43 | + const KEY_PERSONAL_SETTINGS = 'personal'; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @since 13.0.0 |
|
47 | - */ |
|
48 | - const KEY_PERSONAL_SECTION = 'personal-section'; |
|
45 | + /** |
|
46 | + * @since 13.0.0 |
|
47 | + */ |
|
48 | + const KEY_PERSONAL_SECTION = 'personal-section'; |
|
49 | 49 | |
50 | - /** |
|
51 | - * sets up settings according to data specified by an apps info.xml, within |
|
52 | - * the <settings> element. |
|
53 | - * |
|
54 | - * @param array $settings an associative array, allowed keys are as specified |
|
55 | - * by the KEY_ constant of this interface. The value |
|
56 | - * must always be a class name, implement either |
|
57 | - * IAdmin or ISection. I.e. only one section and admin |
|
58 | - * setting can be configured per app. |
|
59 | - * @since 9.1.0 |
|
60 | - */ |
|
61 | - public function setupSettings(array $settings); |
|
50 | + /** |
|
51 | + * sets up settings according to data specified by an apps info.xml, within |
|
52 | + * the <settings> element. |
|
53 | + * |
|
54 | + * @param array $settings an associative array, allowed keys are as specified |
|
55 | + * by the KEY_ constant of this interface. The value |
|
56 | + * must always be a class name, implement either |
|
57 | + * IAdmin or ISection. I.e. only one section and admin |
|
58 | + * setting can be configured per app. |
|
59 | + * @since 9.1.0 |
|
60 | + */ |
|
61 | + public function setupSettings(array $settings); |
|
62 | 62 | |
63 | - /** |
|
64 | - * attempts to remove an apps section and/or settings entry. A listener is |
|
65 | - * added centrally making sure that this method is called ones an app was |
|
66 | - * disabled. |
|
67 | - * |
|
68 | - * What this does not help with is when applications change their settings |
|
69 | - * or section classes during their life time. New entries will be added, |
|
70 | - * but inactive ones will still reside in the database. |
|
71 | - * |
|
72 | - * @param string $appId |
|
73 | - * @since 9.1.0 |
|
74 | - */ |
|
75 | - public function onAppDisabled($appId); |
|
63 | + /** |
|
64 | + * attempts to remove an apps section and/or settings entry. A listener is |
|
65 | + * added centrally making sure that this method is called ones an app was |
|
66 | + * disabled. |
|
67 | + * |
|
68 | + * What this does not help with is when applications change their settings |
|
69 | + * or section classes during their life time. New entries will be added, |
|
70 | + * but inactive ones will still reside in the database. |
|
71 | + * |
|
72 | + * @param string $appId |
|
73 | + * @since 9.1.0 |
|
74 | + */ |
|
75 | + public function onAppDisabled($appId); |
|
76 | 76 | |
77 | - /** |
|
78 | - * The method should check all registered classes whether they are still |
|
79 | - * instantiable and remove them, if not. This method is called by a |
|
80 | - * background job once, after one or more apps were updated. |
|
81 | - * |
|
82 | - * An app`s info.xml can change during an update and make it unknown whether |
|
83 | - * a registered class name was changed or not. An old one would just stay |
|
84 | - * registered. Another case is if an admin takes a radical approach and |
|
85 | - * simply removes an app from the app folder. These unregular checks will |
|
86 | - * take care of such situations. |
|
87 | - * |
|
88 | - * @since 9.1.0 |
|
89 | - */ |
|
90 | - public function checkForOrphanedClassNames(); |
|
77 | + /** |
|
78 | + * The method should check all registered classes whether they are still |
|
79 | + * instantiable and remove them, if not. This method is called by a |
|
80 | + * background job once, after one or more apps were updated. |
|
81 | + * |
|
82 | + * An app`s info.xml can change during an update and make it unknown whether |
|
83 | + * a registered class name was changed or not. An old one would just stay |
|
84 | + * registered. Another case is if an admin takes a radical approach and |
|
85 | + * simply removes an app from the app folder. These unregular checks will |
|
86 | + * take care of such situations. |
|
87 | + * |
|
88 | + * @since 9.1.0 |
|
89 | + */ |
|
90 | + public function checkForOrphanedClassNames(); |
|
91 | 91 | |
92 | - /** |
|
93 | - * returns a list of the admin sections |
|
94 | - * |
|
95 | - * @return array array of ISection[] where key is the priority |
|
96 | - * @since 9.1.0 |
|
97 | - */ |
|
98 | - public function getAdminSections(); |
|
92 | + /** |
|
93 | + * returns a list of the admin sections |
|
94 | + * |
|
95 | + * @return array array of ISection[] where key is the priority |
|
96 | + * @since 9.1.0 |
|
97 | + */ |
|
98 | + public function getAdminSections(); |
|
99 | 99 | |
100 | - /** |
|
101 | - * returns a list of the personal sections |
|
102 | - * |
|
103 | - * @return array array of ISection[] where key is the priority |
|
104 | - * @since 13.0.0 |
|
105 | - */ |
|
106 | - public function getPersonalSections(); |
|
100 | + /** |
|
101 | + * returns a list of the personal sections |
|
102 | + * |
|
103 | + * @return array array of ISection[] where key is the priority |
|
104 | + * @since 13.0.0 |
|
105 | + */ |
|
106 | + public function getPersonalSections(); |
|
107 | 107 | |
108 | - /** |
|
109 | - * returns a list of the admin settings |
|
110 | - * |
|
111 | - * @param string $section the section id for which to load the settings |
|
112 | - * @return array array of IAdmin[] where key is the priority |
|
113 | - * @since 9.1.0 |
|
114 | - */ |
|
115 | - public function getAdminSettings($section); |
|
108 | + /** |
|
109 | + * returns a list of the admin settings |
|
110 | + * |
|
111 | + * @param string $section the section id for which to load the settings |
|
112 | + * @return array array of IAdmin[] where key is the priority |
|
113 | + * @since 9.1.0 |
|
114 | + */ |
|
115 | + public function getAdminSettings($section); |
|
116 | 116 | |
117 | - /** |
|
118 | - * returns a list of the personal settings |
|
119 | - * |
|
120 | - * @param string $section the section id for which to load the settings |
|
121 | - * @return array array of IPersonal[] where key is the priority |
|
122 | - * @since 13.0.0 |
|
123 | - */ |
|
124 | - public function getPersonalSettings($section); |
|
117 | + /** |
|
118 | + * returns a list of the personal settings |
|
119 | + * |
|
120 | + * @param string $section the section id for which to load the settings |
|
121 | + * @return array array of IPersonal[] where key is the priority |
|
122 | + * @since 13.0.0 |
|
123 | + */ |
|
124 | + public function getPersonalSettings($section); |
|
125 | 125 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @since 9.1.0 |
37 | 37 | */ |
38 | - const KEY_ADMIN_SECTION = 'admin-section'; |
|
38 | + const KEY_ADMIN_SECTION = 'admin-section'; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @since 13.0.0 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @since 13.0.0 |
47 | 47 | */ |
48 | - const KEY_PERSONAL_SECTION = 'personal-section'; |
|
48 | + const KEY_PERSONAL_SECTION = 'personal-section'; |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * sets up settings according to data specified by an apps info.xml, within |
@@ -29,63 +29,63 @@ |
||
29 | 29 | use OCP\Settings\ISettings; |
30 | 30 | |
31 | 31 | class Encryption implements ISettings { |
32 | - /** @var IManager */ |
|
33 | - private $manager; |
|
32 | + /** @var IManager */ |
|
33 | + private $manager; |
|
34 | 34 | |
35 | - /** @var IUserManager */ |
|
36 | - private $userManager; |
|
35 | + /** @var IUserManager */ |
|
36 | + private $userManager; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param IManager $manager |
|
40 | - * @param IUserManager $userManager |
|
41 | - */ |
|
42 | - public function __construct(IManager $manager, IUserManager $userManager) { |
|
43 | - $this->manager = $manager; |
|
44 | - $this->userManager = $userManager; |
|
45 | - } |
|
38 | + /** |
|
39 | + * @param IManager $manager |
|
40 | + * @param IUserManager $userManager |
|
41 | + */ |
|
42 | + public function __construct(IManager $manager, IUserManager $userManager) { |
|
43 | + $this->manager = $manager; |
|
44 | + $this->userManager = $userManager; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @return TemplateResponse |
|
49 | - */ |
|
50 | - public function getForm() { |
|
51 | - $encryptionModules = $this->manager->getEncryptionModules(); |
|
52 | - $defaultEncryptionModuleId = $this->manager->getDefaultEncryptionModuleId(); |
|
53 | - $encryptionModuleList = []; |
|
54 | - foreach ($encryptionModules as $module) { |
|
55 | - $encryptionModuleList[$module['id']]['displayName'] = $module['displayName']; |
|
56 | - $encryptionModuleList[$module['id']]['default'] = false; |
|
57 | - if ($module['id'] === $defaultEncryptionModuleId) { |
|
58 | - $encryptionModuleList[$module['id']]['default'] = true; |
|
59 | - } |
|
60 | - } |
|
47 | + /** |
|
48 | + * @return TemplateResponse |
|
49 | + */ |
|
50 | + public function getForm() { |
|
51 | + $encryptionModules = $this->manager->getEncryptionModules(); |
|
52 | + $defaultEncryptionModuleId = $this->manager->getDefaultEncryptionModuleId(); |
|
53 | + $encryptionModuleList = []; |
|
54 | + foreach ($encryptionModules as $module) { |
|
55 | + $encryptionModuleList[$module['id']]['displayName'] = $module['displayName']; |
|
56 | + $encryptionModuleList[$module['id']]['default'] = false; |
|
57 | + if ($module['id'] === $defaultEncryptionModuleId) { |
|
58 | + $encryptionModuleList[$module['id']]['default'] = true; |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - $parameters = [ |
|
63 | - // Encryption API |
|
64 | - 'encryptionEnabled' => $this->manager->isEnabled(), |
|
65 | - 'encryptionReady' => $this->manager->isReady(), |
|
66 | - 'externalBackendsEnabled' => count($this->userManager->getBackends()) > 1, |
|
67 | - // Modules |
|
68 | - 'encryptionModules' => $encryptionModuleList, |
|
69 | - ]; |
|
62 | + $parameters = [ |
|
63 | + // Encryption API |
|
64 | + 'encryptionEnabled' => $this->manager->isEnabled(), |
|
65 | + 'encryptionReady' => $this->manager->isReady(), |
|
66 | + 'externalBackendsEnabled' => count($this->userManager->getBackends()) > 1, |
|
67 | + // Modules |
|
68 | + 'encryptionModules' => $encryptionModuleList, |
|
69 | + ]; |
|
70 | 70 | |
71 | - return new TemplateResponse('settings', 'settings/admin/encryption', $parameters, ''); |
|
72 | - } |
|
71 | + return new TemplateResponse('settings', 'settings/admin/encryption', $parameters, ''); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return string the section ID, e.g. 'sharing' |
|
76 | - */ |
|
77 | - public function getSection() { |
|
78 | - return 'encryption'; |
|
79 | - } |
|
74 | + /** |
|
75 | + * @return string the section ID, e.g. 'sharing' |
|
76 | + */ |
|
77 | + public function getSection() { |
|
78 | + return 'encryption'; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return int whether the form should be rather on the top or bottom of |
|
83 | - * the admin section. The forms are arranged in ascending order of the |
|
84 | - * priority values. It is required to return a value between 0 and 100. |
|
85 | - * |
|
86 | - * E.g.: 70 |
|
87 | - */ |
|
88 | - public function getPriority() { |
|
89 | - return 0; |
|
90 | - } |
|
81 | + /** |
|
82 | + * @return int whether the form should be rather on the top or bottom of |
|
83 | + * the admin section. The forms are arranged in ascending order of the |
|
84 | + * priority values. It is required to return a value between 0 and 100. |
|
85 | + * |
|
86 | + * E.g.: 70 |
|
87 | + */ |
|
88 | + public function getPriority() { |
|
89 | + return 0; |
|
90 | + } |
|
91 | 91 | } |