Completed
Push — master ( 7971ba...bae3ba )
by Morris
14:40
created
lib/private/Settings/Admin/Security.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -31,63 +31,63 @@
 block discarded – undo
31 31
 use OCP\Settings\ISettings;
32 32
 
33 33
 class Security implements ISettings {
34
-	/** @var IManager */
35
-	private $manager;
34
+    /** @var IManager */
35
+    private $manager;
36 36
 
37
-	/** @var IUserManager */
38
-	private $userManager;
37
+    /** @var IUserManager */
38
+    private $userManager;
39 39
 
40
-	/**
41
-	 * @param IManager $manager
42
-	 * @param IUserManager $userManager
43
-	 */
44
-	public function __construct(IManager $manager, IUserManager $userManager) {
45
-		$this->manager = $manager;
46
-		$this->userManager = $userManager;
47
-	}
40
+    /**
41
+     * @param IManager $manager
42
+     * @param IUserManager $userManager
43
+     */
44
+    public function __construct(IManager $manager, IUserManager $userManager) {
45
+        $this->manager = $manager;
46
+        $this->userManager = $userManager;
47
+    }
48 48
 
49
-	/**
50
-	 * @return TemplateResponse
51
-	 */
52
-	public function getForm() {
53
-		$encryptionModules = $this->manager->getEncryptionModules();
54
-		$defaultEncryptionModuleId = $this->manager->getDefaultEncryptionModuleId();
55
-		$encryptionModuleList = [];
56
-		foreach ($encryptionModules as $module) {
57
-			$encryptionModuleList[$module['id']]['displayName'] = $module['displayName'];
58
-			$encryptionModuleList[$module['id']]['default'] = false;
59
-			if ($module['id'] === $defaultEncryptionModuleId) {
60
-				$encryptionModuleList[$module['id']]['default'] = true;
61
-			}
62
-		}
49
+    /**
50
+     * @return TemplateResponse
51
+     */
52
+    public function getForm() {
53
+        $encryptionModules = $this->manager->getEncryptionModules();
54
+        $defaultEncryptionModuleId = $this->manager->getDefaultEncryptionModuleId();
55
+        $encryptionModuleList = [];
56
+        foreach ($encryptionModules as $module) {
57
+            $encryptionModuleList[$module['id']]['displayName'] = $module['displayName'];
58
+            $encryptionModuleList[$module['id']]['default'] = false;
59
+            if ($module['id'] === $defaultEncryptionModuleId) {
60
+                $encryptionModuleList[$module['id']]['default'] = true;
61
+            }
62
+        }
63 63
 
64
-		$parameters = [
65
-			// Encryption API
66
-			'encryptionEnabled'       => $this->manager->isEnabled(),
67
-			'encryptionReady'         => $this->manager->isReady(),
68
-			'externalBackendsEnabled' => count($this->userManager->getBackends()) > 1,
69
-			// Modules
70
-			'encryptionModules'       => $encryptionModuleList,
71
-		];
64
+        $parameters = [
65
+            // Encryption API
66
+            'encryptionEnabled'       => $this->manager->isEnabled(),
67
+            'encryptionReady'         => $this->manager->isReady(),
68
+            'externalBackendsEnabled' => count($this->userManager->getBackends()) > 1,
69
+            // Modules
70
+            'encryptionModules'       => $encryptionModuleList,
71
+        ];
72 72
 
73
-		return new TemplateResponse('settings', 'settings/admin/security', $parameters, '');
74
-	}
73
+        return new TemplateResponse('settings', 'settings/admin/security', $parameters, '');
74
+    }
75 75
 
76
-	/**
77
-	 * @return string the section ID, e.g. 'sharing'
78
-	 */
79
-	public function getSection() {
80
-		return 'security';
81
-	}
76
+    /**
77
+     * @return string the section ID, e.g. 'sharing'
78
+     */
79
+    public function getSection() {
80
+        return 'security';
81
+    }
82 82
 
83
-	/**
84
-	 * @return int whether the form should be rather on the top or bottom of
85
-	 * the admin section. The forms are arranged in ascending order of the
86
-	 * priority values. It is required to return a value between 0 and 100.
87
-	 *
88
-	 * E.g.: 70
89
-	 */
90
-	public function getPriority() {
91
-		return 10;
92
-	}
83
+    /**
84
+     * @return int whether the form should be rather on the top or bottom of
85
+     * the admin section. The forms are arranged in ascending order of the
86
+     * priority values. It is required to return a value between 0 and 100.
87
+     *
88
+     * E.g.: 70
89
+     */
90
+    public function getPriority() {
91
+        return 10;
92
+    }
93 93
 }
Please login to merge, or discard this patch.
lib/private/Settings/Manager.php 1 patch
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -40,319 +40,319 @@
 block discarded – undo
40 40
 
41 41
 class Manager implements IManager {
42 42
 
43
-	/** @var ILogger */
44
-	private $log;
45
-
46
-	/** @var IL10N */
47
-	private $l;
48
-
49
-	/** @var IURLGenerator */
50
-	private $url;
51
-
52
-	/** @var IServerContainer */
53
-	private $container;
54
-
55
-	public function __construct(
56
-		ILogger $log,
57
-		IL10N $l10n,
58
-		IURLGenerator $url,
59
-		IServerContainer $container
60
-	) {
61
-		$this->log = $log;
62
-		$this->l = $l10n;
63
-		$this->url = $url;
64
-		$this->container = $container;
65
-	}
66
-
67
-	/** @var array */
68
-	protected $sectionClasses = [];
69
-
70
-	/** @var array */
71
-	protected $sections = [];
72
-
73
-	/**
74
-	 * @param string $type 'admin' or 'personal'
75
-	 * @param string $section Class must implement OCP\Settings\ISection
76
-	 *
77
-	 * @return void
78
-	 */
79
-	public function registerSection(string $type, string $section) {
80
-		if (!isset($this->sectionClasses[$type])) {
81
-			$this->sectionClasses[$type] = [];
82
-		}
83
-
84
-		$this->sectionClasses[$type][] = $section;
85
-	}
86
-
87
-	/**
88
-	 * @param string $type 'admin' or 'personal'
89
-	 *
90
-	 * @return ISection[]
91
-	 */
92
-	protected function getSections(string $type): array {
93
-		if (!isset($this->sections[$type])) {
94
-			$this->sections[$type] = [];
95
-		}
96
-
97
-		if (!isset($this->sectionClasses[$type])) {
98
-			return $this->sections[$type];
99
-		}
100
-
101
-		foreach ($this->sectionClasses[$type] as $index => $class) {
102
-			try {
103
-				/** @var ISection $section */
104
-				$section = \OC::$server->query($class);
105
-			} catch (QueryException $e) {
106
-				$this->log->logException($e, ['level' => ILogger::INFO]);
107
-				continue;
108
-			}
109
-
110
-			if (!$section instanceof ISection) {
111
-				$this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => ILogger::INFO]);
112
-				continue;
113
-			}
114
-
115
-			$sectionID = $section->getID();
116
-
117
-			if (isset($this->sections[$type][$sectionID])) {
118
-				$this->log->logException(new \InvalidArgumentException('Section with the same ID already registered'), ['level' => ILogger::INFO]);
119
-				continue;
120
-			}
121
-
122
-			$this->sections[$type][$sectionID] = $section;
123
-
124
-			unset($this->sectionClasses[$type][$index]);
125
-		}
126
-
127
-		return $this->sections[$type];
128
-	}
129
-
130
-	/** @var array */
131
-	protected $settingClasses = [];
132
-
133
-	/** @var array */
134
-	protected $settings = [];
135
-
136
-	/**
137
-	 * @param string $type 'admin' or 'personal'
138
-	 * @param string $setting Class must implement OCP\Settings\ISetting
139
-	 *
140
-	 * @return void
141
-	 */
142
-	public function registerSetting(string $type, string $setting) {
143
-		$this->settingClasses[$setting] = $type;
144
-	}
145
-
146
-	/**
147
-	 * @param string $type 'admin' or 'personal'
148
-	 * @param string $section
149
-	 *
150
-	 * @return ISettings[]
151
-	 */
152
-	protected function getSettings(string $type, string $section): array {
153
-		if (!isset($this->settings[$type])) {
154
-			$this->settings[$type] = [];
155
-		}
156
-		if (!isset($this->settings[$type][$section])) {
157
-			$this->settings[$type][$section] = [];
158
-		}
159
-
160
-		foreach ($this->settingClasses as $class => $settingsType) {
161
-			try {
162
-				/** @var ISettings $setting */
163
-				$setting = \OC::$server->query($class);
164
-			} catch (QueryException $e) {
165
-				$this->log->logException($e, ['level' => ILogger::INFO]);
166
-				continue;
167
-			}
168
-
169
-			if (!$setting instanceof ISettings) {
170
-				$this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => ILogger::INFO]);
171
-				continue;
172
-			}
173
-
174
-			if (!isset($this->settings[$settingsType][$setting->getSection()])) {
175
-				$this->settings[$settingsType][$setting->getSection()] = [];
176
-			}
177
-			$this->settings[$settingsType][$setting->getSection()][] = $setting;
178
-
179
-			unset($this->settingClasses[$class]);
180
-		}
181
-
182
-		return $this->settings[$type][$section];
183
-	}
184
-
185
-	/**
186
-	 * @inheritdoc
187
-	 */
188
-	public function getAdminSections(): array {
189
-		// built-in sections
190
-		$sections = [
191
-			0 => [new Section('overview', $this->l->t('Overview'), 0, $this->url->imagePath('settings', 'admin.svg'))],
192
-			1 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
193
-			5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))],
194
-			10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))],
195
-			50 => [new Section('groupware', $this->l->t('Groupware'), 0, $this->url->imagePath('core', 'places/contacts.svg'))],
196
-			98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
197
-		];
198
-
199
-		$appSections = $this->getSections('admin');
200
-
201
-		foreach ($appSections as $section) {
202
-			/** @var ISection $section */
203
-			if (!isset($sections[$section->getPriority()])) {
204
-				$sections[$section->getPriority()] = [];
205
-			}
206
-
207
-			$sections[$section->getPriority()][] = $section;
208
-		}
209
-
210
-		ksort($sections);
211
-
212
-		return $sections;
213
-	}
214
-
215
-	/**
216
-	 * @param string $section
217
-	 *
218
-	 * @return ISection[]
219
-	 */
220
-	private function getBuiltInAdminSettings($section): array {
221
-		$forms = [];
222
-
223
-		if ($section === 'overview') {
224
-			/** @var ISettings $form */
225
-			$form = $this->container->query(Admin\Overview::class);
226
-			$forms[$form->getPriority()] = [$form];
227
-		}
228
-		if ($section === 'server') {
229
-			/** @var ISettings $form */
230
-			$form = $this->container->query(Admin\Server::class);
231
-			$forms[$form->getPriority()] = [$form];
232
-			$form = $this->container->query(Admin\Mail::class);
233
-			$forms[$form->getPriority()] = [$form];
234
-		}
235
-		if ($section === 'security') {
236
-			/** @var ISettings $form */
237
-			$form = $this->container->query(Admin\Security::class);
238
-			$forms[$form->getPriority()] = [$form];
239
-		}
240
-		if ($section === 'sharing') {
241
-			/** @var ISettings $form */
242
-			$form = $this->container->query(Admin\Sharing::class);
243
-			$forms[$form->getPriority()] = [$form];
244
-		}
245
-
246
-		return $forms;
247
-	}
248
-
249
-	/**
250
-	 * @param string $section
251
-	 *
252
-	 * @return ISection[]
253
-	 */
254
-	private function getBuiltInPersonalSettings($section): array {
255
-		$forms = [];
256
-
257
-		if ($section === 'personal-info') {
258
-			/** @var ISettings $form */
259
-			$form = $this->container->query(Personal\PersonalInfo::class);
260
-			$forms[$form->getPriority()] = [$form];
261
-			$form = new Personal\ServerDevNotice();
262
-			$forms[$form->getPriority()] = [$form];
263
-		}
264
-		if ($section === 'security') {
265
-			/** @var ISettings $form */
266
-			$form = $this->container->query(Personal\Security::class);
267
-			$forms[$form->getPriority()] = [$form];
268
-		}
269
-		if ($section === 'additional') {
270
-			/** @var ISettings $form */
271
-			$form = $this->container->query(Personal\Additional::class);
272
-			$forms[$form->getPriority()] = [$form];
273
-		}
274
-
275
-		return $forms;
276
-	}
277
-
278
-	/**
279
-	 * @inheritdoc
280
-	 */
281
-	public function getAdminSettings($section): array {
282
-		$settings = $this->getBuiltInAdminSettings($section);
283
-		$appSettings = $this->getSettings('admin', $section);
284
-
285
-		foreach ($appSettings as $setting) {
286
-			if (!isset($settings[$setting->getPriority()])) {
287
-				$settings[$setting->getPriority()] = [];
288
-			}
289
-			$settings[$setting->getPriority()][] = $setting;
290
-		}
291
-
292
-		ksort($settings);
293
-		return $settings;
294
-	}
295
-
296
-	/**
297
-	 * @inheritdoc
298
-	 */
299
-	public function getPersonalSections(): array {
300
-		$sections = [
301
-			0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))],
302
-			5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))],
303
-			15 => [new Section('sync-clients', $this->l->t('Mobile & desktop'), 0, $this->url->imagePath('core', 'clients/phone.svg'))],
304
-		];
305
-
306
-		$legacyForms = \OC_App::getForms('personal');
307
-		if (!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) {
308
-			$sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))];
309
-		}
310
-
311
-		$appSections = $this->getSections('personal');
312
-
313
-		foreach ($appSections as $section) {
314
-			/** @var ISection $section */
315
-			if (!isset($sections[$section->getPriority()])) {
316
-				$sections[$section->getPriority()] = [];
317
-			}
318
-
319
-			$sections[$section->getPriority()][] = $section;
320
-		}
321
-
322
-		ksort($sections);
323
-
324
-		return $sections;
325
-	}
326
-
327
-	/**
328
-	 * @param string[] $forms
329
-	 *
330
-	 * @return bool
331
-	 */
332
-	private function hasLegacyPersonalSettingsToRender(array $forms): bool {
333
-		foreach ($forms as $form) {
334
-			if (trim($form) !== '') {
335
-				return true;
336
-			}
337
-		}
338
-		return false;
339
-	}
340
-
341
-	/**
342
-	 * @inheritdoc
343
-	 */
344
-	public function getPersonalSettings($section): array {
345
-		$settings = $this->getBuiltInPersonalSettings($section);
346
-		$appSettings = $this->getSettings('personal', $section);
347
-
348
-		foreach ($appSettings as $setting) {
349
-			if (!isset($settings[$setting->getPriority()])) {
350
-				$settings[$setting->getPriority()] = [];
351
-			}
352
-			$settings[$setting->getPriority()][] = $setting;
353
-		}
354
-
355
-		ksort($settings);
356
-		return $settings;
357
-	}
43
+    /** @var ILogger */
44
+    private $log;
45
+
46
+    /** @var IL10N */
47
+    private $l;
48
+
49
+    /** @var IURLGenerator */
50
+    private $url;
51
+
52
+    /** @var IServerContainer */
53
+    private $container;
54
+
55
+    public function __construct(
56
+        ILogger $log,
57
+        IL10N $l10n,
58
+        IURLGenerator $url,
59
+        IServerContainer $container
60
+    ) {
61
+        $this->log = $log;
62
+        $this->l = $l10n;
63
+        $this->url = $url;
64
+        $this->container = $container;
65
+    }
66
+
67
+    /** @var array */
68
+    protected $sectionClasses = [];
69
+
70
+    /** @var array */
71
+    protected $sections = [];
72
+
73
+    /**
74
+     * @param string $type 'admin' or 'personal'
75
+     * @param string $section Class must implement OCP\Settings\ISection
76
+     *
77
+     * @return void
78
+     */
79
+    public function registerSection(string $type, string $section) {
80
+        if (!isset($this->sectionClasses[$type])) {
81
+            $this->sectionClasses[$type] = [];
82
+        }
83
+
84
+        $this->sectionClasses[$type][] = $section;
85
+    }
86
+
87
+    /**
88
+     * @param string $type 'admin' or 'personal'
89
+     *
90
+     * @return ISection[]
91
+     */
92
+    protected function getSections(string $type): array {
93
+        if (!isset($this->sections[$type])) {
94
+            $this->sections[$type] = [];
95
+        }
96
+
97
+        if (!isset($this->sectionClasses[$type])) {
98
+            return $this->sections[$type];
99
+        }
100
+
101
+        foreach ($this->sectionClasses[$type] as $index => $class) {
102
+            try {
103
+                /** @var ISection $section */
104
+                $section = \OC::$server->query($class);
105
+            } catch (QueryException $e) {
106
+                $this->log->logException($e, ['level' => ILogger::INFO]);
107
+                continue;
108
+            }
109
+
110
+            if (!$section instanceof ISection) {
111
+                $this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => ILogger::INFO]);
112
+                continue;
113
+            }
114
+
115
+            $sectionID = $section->getID();
116
+
117
+            if (isset($this->sections[$type][$sectionID])) {
118
+                $this->log->logException(new \InvalidArgumentException('Section with the same ID already registered'), ['level' => ILogger::INFO]);
119
+                continue;
120
+            }
121
+
122
+            $this->sections[$type][$sectionID] = $section;
123
+
124
+            unset($this->sectionClasses[$type][$index]);
125
+        }
126
+
127
+        return $this->sections[$type];
128
+    }
129
+
130
+    /** @var array */
131
+    protected $settingClasses = [];
132
+
133
+    /** @var array */
134
+    protected $settings = [];
135
+
136
+    /**
137
+     * @param string $type 'admin' or 'personal'
138
+     * @param string $setting Class must implement OCP\Settings\ISetting
139
+     *
140
+     * @return void
141
+     */
142
+    public function registerSetting(string $type, string $setting) {
143
+        $this->settingClasses[$setting] = $type;
144
+    }
145
+
146
+    /**
147
+     * @param string $type 'admin' or 'personal'
148
+     * @param string $section
149
+     *
150
+     * @return ISettings[]
151
+     */
152
+    protected function getSettings(string $type, string $section): array {
153
+        if (!isset($this->settings[$type])) {
154
+            $this->settings[$type] = [];
155
+        }
156
+        if (!isset($this->settings[$type][$section])) {
157
+            $this->settings[$type][$section] = [];
158
+        }
159
+
160
+        foreach ($this->settingClasses as $class => $settingsType) {
161
+            try {
162
+                /** @var ISettings $setting */
163
+                $setting = \OC::$server->query($class);
164
+            } catch (QueryException $e) {
165
+                $this->log->logException($e, ['level' => ILogger::INFO]);
166
+                continue;
167
+            }
168
+
169
+            if (!$setting instanceof ISettings) {
170
+                $this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => ILogger::INFO]);
171
+                continue;
172
+            }
173
+
174
+            if (!isset($this->settings[$settingsType][$setting->getSection()])) {
175
+                $this->settings[$settingsType][$setting->getSection()] = [];
176
+            }
177
+            $this->settings[$settingsType][$setting->getSection()][] = $setting;
178
+
179
+            unset($this->settingClasses[$class]);
180
+        }
181
+
182
+        return $this->settings[$type][$section];
183
+    }
184
+
185
+    /**
186
+     * @inheritdoc
187
+     */
188
+    public function getAdminSections(): array {
189
+        // built-in sections
190
+        $sections = [
191
+            0 => [new Section('overview', $this->l->t('Overview'), 0, $this->url->imagePath('settings', 'admin.svg'))],
192
+            1 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
193
+            5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))],
194
+            10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))],
195
+            50 => [new Section('groupware', $this->l->t('Groupware'), 0, $this->url->imagePath('core', 'places/contacts.svg'))],
196
+            98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
197
+        ];
198
+
199
+        $appSections = $this->getSections('admin');
200
+
201
+        foreach ($appSections as $section) {
202
+            /** @var ISection $section */
203
+            if (!isset($sections[$section->getPriority()])) {
204
+                $sections[$section->getPriority()] = [];
205
+            }
206
+
207
+            $sections[$section->getPriority()][] = $section;
208
+        }
209
+
210
+        ksort($sections);
211
+
212
+        return $sections;
213
+    }
214
+
215
+    /**
216
+     * @param string $section
217
+     *
218
+     * @return ISection[]
219
+     */
220
+    private function getBuiltInAdminSettings($section): array {
221
+        $forms = [];
222
+
223
+        if ($section === 'overview') {
224
+            /** @var ISettings $form */
225
+            $form = $this->container->query(Admin\Overview::class);
226
+            $forms[$form->getPriority()] = [$form];
227
+        }
228
+        if ($section === 'server') {
229
+            /** @var ISettings $form */
230
+            $form = $this->container->query(Admin\Server::class);
231
+            $forms[$form->getPriority()] = [$form];
232
+            $form = $this->container->query(Admin\Mail::class);
233
+            $forms[$form->getPriority()] = [$form];
234
+        }
235
+        if ($section === 'security') {
236
+            /** @var ISettings $form */
237
+            $form = $this->container->query(Admin\Security::class);
238
+            $forms[$form->getPriority()] = [$form];
239
+        }
240
+        if ($section === 'sharing') {
241
+            /** @var ISettings $form */
242
+            $form = $this->container->query(Admin\Sharing::class);
243
+            $forms[$form->getPriority()] = [$form];
244
+        }
245
+
246
+        return $forms;
247
+    }
248
+
249
+    /**
250
+     * @param string $section
251
+     *
252
+     * @return ISection[]
253
+     */
254
+    private function getBuiltInPersonalSettings($section): array {
255
+        $forms = [];
256
+
257
+        if ($section === 'personal-info') {
258
+            /** @var ISettings $form */
259
+            $form = $this->container->query(Personal\PersonalInfo::class);
260
+            $forms[$form->getPriority()] = [$form];
261
+            $form = new Personal\ServerDevNotice();
262
+            $forms[$form->getPriority()] = [$form];
263
+        }
264
+        if ($section === 'security') {
265
+            /** @var ISettings $form */
266
+            $form = $this->container->query(Personal\Security::class);
267
+            $forms[$form->getPriority()] = [$form];
268
+        }
269
+        if ($section === 'additional') {
270
+            /** @var ISettings $form */
271
+            $form = $this->container->query(Personal\Additional::class);
272
+            $forms[$form->getPriority()] = [$form];
273
+        }
274
+
275
+        return $forms;
276
+    }
277
+
278
+    /**
279
+     * @inheritdoc
280
+     */
281
+    public function getAdminSettings($section): array {
282
+        $settings = $this->getBuiltInAdminSettings($section);
283
+        $appSettings = $this->getSettings('admin', $section);
284
+
285
+        foreach ($appSettings as $setting) {
286
+            if (!isset($settings[$setting->getPriority()])) {
287
+                $settings[$setting->getPriority()] = [];
288
+            }
289
+            $settings[$setting->getPriority()][] = $setting;
290
+        }
291
+
292
+        ksort($settings);
293
+        return $settings;
294
+    }
295
+
296
+    /**
297
+     * @inheritdoc
298
+     */
299
+    public function getPersonalSections(): array {
300
+        $sections = [
301
+            0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))],
302
+            5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))],
303
+            15 => [new Section('sync-clients', $this->l->t('Mobile & desktop'), 0, $this->url->imagePath('core', 'clients/phone.svg'))],
304
+        ];
305
+
306
+        $legacyForms = \OC_App::getForms('personal');
307
+        if (!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) {
308
+            $sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))];
309
+        }
310
+
311
+        $appSections = $this->getSections('personal');
312
+
313
+        foreach ($appSections as $section) {
314
+            /** @var ISection $section */
315
+            if (!isset($sections[$section->getPriority()])) {
316
+                $sections[$section->getPriority()] = [];
317
+            }
318
+
319
+            $sections[$section->getPriority()][] = $section;
320
+        }
321
+
322
+        ksort($sections);
323
+
324
+        return $sections;
325
+    }
326
+
327
+    /**
328
+     * @param string[] $forms
329
+     *
330
+     * @return bool
331
+     */
332
+    private function hasLegacyPersonalSettingsToRender(array $forms): bool {
333
+        foreach ($forms as $form) {
334
+            if (trim($form) !== '') {
335
+                return true;
336
+            }
337
+        }
338
+        return false;
339
+    }
340
+
341
+    /**
342
+     * @inheritdoc
343
+     */
344
+    public function getPersonalSettings($section): array {
345
+        $settings = $this->getBuiltInPersonalSettings($section);
346
+        $appSettings = $this->getSettings('personal', $section);
347
+
348
+        foreach ($appSettings as $setting) {
349
+            if (!isset($settings[$setting->getPriority()])) {
350
+                $settings[$setting->getPriority()] = [];
351
+            }
352
+            $settings[$setting->getPriority()][] = $setting;
353
+        }
354
+
355
+        ksort($settings);
356
+        return $settings;
357
+    }
358 358
 }
Please login to merge, or discard this patch.