Completed
Pull Request — master (#10027)
by Julius
35:11 queued 10:46
created
lib/private/Settings/Manager.php 1 patch
Indentation   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -49,354 +49,354 @@
 block discarded – undo
49 49
 use OCP\Util;
50 50
 
51 51
 class Manager implements IManager {
52
-	/** @var ILogger */
53
-	private $log;
54
-	/** @var IDBConnection */
55
-	private $dbc;
56
-	/** @var IL10N */
57
-	private $l;
58
-	/** @var IConfig */
59
-	private $config;
60
-	/** @var EncryptionManager */
61
-	private $encryptionManager;
62
-	/** @var IUserManager */
63
-	private $userManager;
64
-	/** @var ILockingProvider */
65
-	private $lockingProvider;
66
-	/** @var IRequest */
67
-	private $request;
68
-	/** @var IURLGenerator */
69
-	private $url;
70
-	/** @var AccountManager */
71
-	private $accountManager;
72
-	/** @var IGroupManager */
73
-	private $groupManager;
74
-	/** @var IFactory */
75
-	private $l10nFactory;
76
-	/** @var IAppManager */
77
-	private $appManager;
78
-
79
-	/**
80
-	 * @param ILogger $log
81
-	 * @param IDBConnection $dbc
82
-	 * @param IL10N $l
83
-	 * @param IConfig $config
84
-	 * @param EncryptionManager $encryptionManager
85
-	 * @param IUserManager $userManager
86
-	 * @param ILockingProvider $lockingProvider
87
-	 * @param IRequest $request
88
-	 * @param IURLGenerator $url
89
-	 * @param AccountManager $accountManager
90
-	 * @param IGroupManager $groupManager
91
-	 * @param IFactory $l10nFactory
92
-	 * @param IAppManager $appManager
93
-	 */
94
-	public function __construct(
95
-		ILogger $log,
96
-		IDBConnection $dbc,
97
-		IL10N $l,
98
-		IConfig $config,
99
-		EncryptionManager $encryptionManager,
100
-		IUserManager $userManager,
101
-		ILockingProvider $lockingProvider,
102
-		IRequest $request,
103
-		IURLGenerator $url,
104
-		AccountManager $accountManager,
105
-		IGroupManager $groupManager,
106
-		IFactory $l10nFactory,
107
-		IAppManager $appManager
108
-	) {
109
-		$this->log = $log;
110
-		$this->dbc = $dbc;
111
-		$this->l = $l;
112
-		$this->config = $config;
113
-		$this->encryptionManager = $encryptionManager;
114
-		$this->userManager = $userManager;
115
-		$this->lockingProvider = $lockingProvider;
116
-		$this->request = $request;
117
-		$this->url = $url;
118
-		$this->accountManager = $accountManager;
119
-		$this->groupManager = $groupManager;
120
-		$this->l10nFactory = $l10nFactory;
121
-		$this->appManager = $appManager;
122
-	}
123
-
124
-	/** @var array */
125
-	protected $sectionClasses = [];
126
-
127
-	/** @var array */
128
-	protected $sections = [];
129
-
130
-	/**
131
-	 * @param string $type 'admin' or 'personal'
132
-	 * @param string $section Class must implement OCP\Settings\ISection
133
-	 * @return void
134
-	 */
135
-	public function registerSection(string $type, string $section) {
136
-		$this->sectionClasses[$section] = $type;
137
-	}
138
-
139
-	/**
140
-	 * @param string $type 'admin' or 'personal'
141
-	 * @return ISection[]
142
-	 */
143
-	protected function getSections(string $type): array {
144
-		if (!isset($this->sections[$type])) {
145
-			$this->sections[$type] = [];
146
-		}
147
-
148
-		foreach ($this->sectionClasses as $class => $sectionType) {
149
-			try {
150
-				/** @var ISection $section */
151
-				$section = \OC::$server->query($class);
152
-			} catch (QueryException $e) {
153
-				$this->log->logException($e, ['level' => ILogger::INFO]);
154
-				continue;
155
-			}
156
-
157
-			if (!$section instanceof ISection) {
158
-				$this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => ILogger::INFO]);
159
-				continue;
160
-			}
161
-
162
-			$this->sections[$sectionType][$section->getID()] = $section;
163
-
164
-			unset($this->sectionClasses[$class]);
165
-		}
166
-
167
-		return $this->sections[$type];
168
-	}
169
-
170
-	/** @var array */
171
-	protected $settingClasses = [];
172
-
173
-	/** @var array */
174
-	protected $settings = [];
175
-
176
-	/**
177
-	 * @param string $type 'admin' or 'personal'
178
-	 * @param string $setting Class must implement OCP\Settings\ISetting
179
-	 * @return void
180
-	 */
181
-	public function registerSetting(string $type, string $setting) {
182
-		$this->settingClasses[$setting] = $type;
183
-	}
184
-
185
-	/**
186
-	 * @param string $type 'admin' or 'personal'
187
-	 * @param string $section
188
-	 * @return ISettings[]
189
-	 */
190
-	protected function getSettings(string $type, string $section): array {
191
-		if (!isset($this->settings[$type])) {
192
-			$this->settings[$type] = [];
193
-		}
194
-		if (!isset($this->settings[$type][$section])) {
195
-			$this->settings[$type][$section] = [];
196
-		}
197
-
198
-		foreach ($this->settingClasses as $class => $settingsType) {
199
-			try {
200
-				/** @var ISettings $setting */
201
-				$setting = \OC::$server->query($class);
202
-			} catch (QueryException $e) {
203
-				$this->log->logException($e, ['level' => ILogger::INFO]);
204
-				continue;
205
-			}
206
-
207
-			if (!$setting instanceof ISettings) {
208
-				$this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => ILogger::INFO]);
209
-				continue;
210
-			}
211
-
212
-			if (!isset($this->settings[$settingsType][$setting->getSection()])) {
213
-				$this->settings[$settingsType][$setting->getSection()] = [];
214
-			}
215
-			$this->settings[$settingsType][$setting->getSection()][] = $setting;
216
-
217
-			unset($this->settingClasses[$class]);
218
-		}
219
-
220
-		return $this->settings[$type][$section];
221
-	}
222
-
223
-	/**
224
-	 * @inheritdoc
225
-	 */
226
-	public function getAdminSections(): array {
227
-		// built-in sections
228
-		$sections = [
229
-			0 => [new Section('overview', $this->l->t('Overview'), 0, $this->url->imagePath('settings', 'admin.svg'))],
230
-			1 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
231
-			5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))],
232
-			10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))],
233
-			45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))],
234
-			50 => [new Section('groupware', $this->l->t('Groupware'), 0, $this->url->imagePath('core', 'places/contacts-dark.svg'))],
235
-			98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
236
-		];
237
-
238
-		$appSections = $this->getSections('admin');
239
-
240
-		foreach ($appSections as $section) {
241
-			/** @var ISection $section */
242
-			if (!isset($sections[$section->getPriority()])) {
243
-				$sections[$section->getPriority()] = [];
244
-			}
245
-
246
-			$sections[$section->getPriority()][] = $section;
247
-		}
248
-
249
-		ksort($sections);
250
-
251
-		return $sections;
252
-	}
253
-
254
-	/**
255
-	 * @param string $section
256
-	 * @return ISection[]
257
-	 */
258
-	private function getBuiltInAdminSettings($section): array {
259
-		$forms = [];
260
-
261
-		if ($section === 'overview') {
262
-			/** @var ISettings $form */
263
-			$form = new Admin\Overview($this->config);
264
-			$forms[$form->getPriority()] = [$form];
265
-			$form = new Admin\ServerDevNotice();
266
-			$forms[$form->getPriority()] = [$form];
267
-		}
268
-		if ($section === 'server') {
269
-			/** @var ISettings $form */
270
-			$form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l);
271
-			$forms[$form->getPriority()] = [$form];
272
-			$form = new Admin\Mail($this->config);
273
-			$forms[$form->getPriority()] = [$form];
274
-		}
275
-		if ($section === 'encryption') {
276
-			/** @var ISettings $form */
277
-			$form = new Admin\Encryption($this->encryptionManager, $this->userManager);
278
-			$forms[$form->getPriority()] = [$form];
279
-		}
280
-		if ($section === 'sharing') {
281
-			/** @var ISettings $form */
282
-			$form = new Admin\Sharing($this->config, $this->l);
283
-			$forms[$form->getPriority()] = [$form];
284
-		}
285
-
286
-		return $forms;
287
-	}
288
-
289
-	/**
290
-	 * @param string $section
291
-	 * @return ISection[]
292
-	 */
293
-	private function getBuiltInPersonalSettings($section): array {
294
-		$forms = [];
295
-
296
-		if ($section === 'personal-info') {
297
-			/** @var ISettings $form */
298
-			$form = new Personal\PersonalInfo(
299
-				$this->config,
300
-				$this->userManager,
301
-				$this->groupManager,
302
-				$this->accountManager,
303
-				$this->appManager,
304
-				$this->l10nFactory,
305
-				$this->l
306
-			);
307
-			$forms[$form->getPriority()] = [$form];
308
-		}
309
-		if($section === 'security') {
310
-			/** @var ISettings $form */
311
-			$form = new Personal\Security();
312
-			$forms[$form->getPriority()] = [$form];
313
-		}
314
-		if ($section === 'additional') {
315
-			/** @var ISettings $form */
316
-			$form = new Personal\Additional();
317
-			$forms[$form->getPriority()] = [$form];
318
-		}
319
-
320
-		return $forms;
321
-	}
322
-
323
-	/**
324
-	 * @inheritdoc
325
-	 */
326
-	public function getAdminSettings($section): array {
327
-		$settings = $this->getBuiltInAdminSettings($section);
328
-		$appSettings = $this->getSettings('admin', $section);
329
-
330
-		foreach ($appSettings as $setting) {
331
-			if (!isset($settings[$setting->getPriority()])) {
332
-				$settings[$setting->getPriority()] = [];
333
-			}
334
-			$settings[$setting->getPriority()][] = $setting;
335
-		}
336
-
337
-		ksort($settings);
338
-		return $settings;
339
-	}
340
-
341
-	/**
342
-	 * @inheritdoc
343
-	 */
344
-	public function getPersonalSections(): array {
345
-		$sections = [
346
-			0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))],
347
-			5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))],
348
-			15 => [new Section('sync-clients', $this->l->t('Mobile & desktop'), 0, $this->url->imagePath('core', 'clients/phone.svg'))],
349
-		];
350
-
351
-		$legacyForms = \OC_App::getForms('personal');
352
-		if(!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) {
353
-			$sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))];
354
-		}
355
-
356
-		$appSections = $this->getSections('personal');
357
-
358
-		foreach ($appSections as $section) {
359
-			/** @var ISection $section */
360
-			if (!isset($sections[$section->getPriority()])) {
361
-				$sections[$section->getPriority()] = [];
362
-			}
363
-
364
-			$sections[$section->getPriority()][] = $section;
365
-		}
366
-
367
-		ksort($sections);
368
-
369
-		return $sections;
370
-	}
371
-
372
-	/**
373
-	 * @param string[] $forms
374
-	 * @return bool
375
-	 */
376
-	private function hasLegacyPersonalSettingsToRender(array $forms): bool {
377
-		foreach ($forms as $form) {
378
-			if(trim($form) !== '') {
379
-				return true;
380
-			}
381
-		}
382
-		return false;
383
-	}
384
-
385
-	/**
386
-	 * @inheritdoc
387
-	 */
388
-	public function getPersonalSettings($section): array {
389
-		$settings = $this->getBuiltInPersonalSettings($section);
390
-		$appSettings = $this->getSettings('personal', $section);
391
-
392
-		foreach ($appSettings as $setting) {
393
-			if (!isset($settings[$setting->getPriority()])) {
394
-				$settings[$setting->getPriority()] = [];
395
-			}
396
-			$settings[$setting->getPriority()][] = $setting;
397
-		}
398
-
399
-		ksort($settings);
400
-		return $settings;
401
-	}
52
+    /** @var ILogger */
53
+    private $log;
54
+    /** @var IDBConnection */
55
+    private $dbc;
56
+    /** @var IL10N */
57
+    private $l;
58
+    /** @var IConfig */
59
+    private $config;
60
+    /** @var EncryptionManager */
61
+    private $encryptionManager;
62
+    /** @var IUserManager */
63
+    private $userManager;
64
+    /** @var ILockingProvider */
65
+    private $lockingProvider;
66
+    /** @var IRequest */
67
+    private $request;
68
+    /** @var IURLGenerator */
69
+    private $url;
70
+    /** @var AccountManager */
71
+    private $accountManager;
72
+    /** @var IGroupManager */
73
+    private $groupManager;
74
+    /** @var IFactory */
75
+    private $l10nFactory;
76
+    /** @var IAppManager */
77
+    private $appManager;
78
+
79
+    /**
80
+     * @param ILogger $log
81
+     * @param IDBConnection $dbc
82
+     * @param IL10N $l
83
+     * @param IConfig $config
84
+     * @param EncryptionManager $encryptionManager
85
+     * @param IUserManager $userManager
86
+     * @param ILockingProvider $lockingProvider
87
+     * @param IRequest $request
88
+     * @param IURLGenerator $url
89
+     * @param AccountManager $accountManager
90
+     * @param IGroupManager $groupManager
91
+     * @param IFactory $l10nFactory
92
+     * @param IAppManager $appManager
93
+     */
94
+    public function __construct(
95
+        ILogger $log,
96
+        IDBConnection $dbc,
97
+        IL10N $l,
98
+        IConfig $config,
99
+        EncryptionManager $encryptionManager,
100
+        IUserManager $userManager,
101
+        ILockingProvider $lockingProvider,
102
+        IRequest $request,
103
+        IURLGenerator $url,
104
+        AccountManager $accountManager,
105
+        IGroupManager $groupManager,
106
+        IFactory $l10nFactory,
107
+        IAppManager $appManager
108
+    ) {
109
+        $this->log = $log;
110
+        $this->dbc = $dbc;
111
+        $this->l = $l;
112
+        $this->config = $config;
113
+        $this->encryptionManager = $encryptionManager;
114
+        $this->userManager = $userManager;
115
+        $this->lockingProvider = $lockingProvider;
116
+        $this->request = $request;
117
+        $this->url = $url;
118
+        $this->accountManager = $accountManager;
119
+        $this->groupManager = $groupManager;
120
+        $this->l10nFactory = $l10nFactory;
121
+        $this->appManager = $appManager;
122
+    }
123
+
124
+    /** @var array */
125
+    protected $sectionClasses = [];
126
+
127
+    /** @var array */
128
+    protected $sections = [];
129
+
130
+    /**
131
+     * @param string $type 'admin' or 'personal'
132
+     * @param string $section Class must implement OCP\Settings\ISection
133
+     * @return void
134
+     */
135
+    public function registerSection(string $type, string $section) {
136
+        $this->sectionClasses[$section] = $type;
137
+    }
138
+
139
+    /**
140
+     * @param string $type 'admin' or 'personal'
141
+     * @return ISection[]
142
+     */
143
+    protected function getSections(string $type): array {
144
+        if (!isset($this->sections[$type])) {
145
+            $this->sections[$type] = [];
146
+        }
147
+
148
+        foreach ($this->sectionClasses as $class => $sectionType) {
149
+            try {
150
+                /** @var ISection $section */
151
+                $section = \OC::$server->query($class);
152
+            } catch (QueryException $e) {
153
+                $this->log->logException($e, ['level' => ILogger::INFO]);
154
+                continue;
155
+            }
156
+
157
+            if (!$section instanceof ISection) {
158
+                $this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => ILogger::INFO]);
159
+                continue;
160
+            }
161
+
162
+            $this->sections[$sectionType][$section->getID()] = $section;
163
+
164
+            unset($this->sectionClasses[$class]);
165
+        }
166
+
167
+        return $this->sections[$type];
168
+    }
169
+
170
+    /** @var array */
171
+    protected $settingClasses = [];
172
+
173
+    /** @var array */
174
+    protected $settings = [];
175
+
176
+    /**
177
+     * @param string $type 'admin' or 'personal'
178
+     * @param string $setting Class must implement OCP\Settings\ISetting
179
+     * @return void
180
+     */
181
+    public function registerSetting(string $type, string $setting) {
182
+        $this->settingClasses[$setting] = $type;
183
+    }
184
+
185
+    /**
186
+     * @param string $type 'admin' or 'personal'
187
+     * @param string $section
188
+     * @return ISettings[]
189
+     */
190
+    protected function getSettings(string $type, string $section): array {
191
+        if (!isset($this->settings[$type])) {
192
+            $this->settings[$type] = [];
193
+        }
194
+        if (!isset($this->settings[$type][$section])) {
195
+            $this->settings[$type][$section] = [];
196
+        }
197
+
198
+        foreach ($this->settingClasses as $class => $settingsType) {
199
+            try {
200
+                /** @var ISettings $setting */
201
+                $setting = \OC::$server->query($class);
202
+            } catch (QueryException $e) {
203
+                $this->log->logException($e, ['level' => ILogger::INFO]);
204
+                continue;
205
+            }
206
+
207
+            if (!$setting instanceof ISettings) {
208
+                $this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => ILogger::INFO]);
209
+                continue;
210
+            }
211
+
212
+            if (!isset($this->settings[$settingsType][$setting->getSection()])) {
213
+                $this->settings[$settingsType][$setting->getSection()] = [];
214
+            }
215
+            $this->settings[$settingsType][$setting->getSection()][] = $setting;
216
+
217
+            unset($this->settingClasses[$class]);
218
+        }
219
+
220
+        return $this->settings[$type][$section];
221
+    }
222
+
223
+    /**
224
+     * @inheritdoc
225
+     */
226
+    public function getAdminSections(): array {
227
+        // built-in sections
228
+        $sections = [
229
+            0 => [new Section('overview', $this->l->t('Overview'), 0, $this->url->imagePath('settings', 'admin.svg'))],
230
+            1 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
231
+            5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))],
232
+            10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))],
233
+            45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))],
234
+            50 => [new Section('groupware', $this->l->t('Groupware'), 0, $this->url->imagePath('core', 'places/contacts-dark.svg'))],
235
+            98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
236
+        ];
237
+
238
+        $appSections = $this->getSections('admin');
239
+
240
+        foreach ($appSections as $section) {
241
+            /** @var ISection $section */
242
+            if (!isset($sections[$section->getPriority()])) {
243
+                $sections[$section->getPriority()] = [];
244
+            }
245
+
246
+            $sections[$section->getPriority()][] = $section;
247
+        }
248
+
249
+        ksort($sections);
250
+
251
+        return $sections;
252
+    }
253
+
254
+    /**
255
+     * @param string $section
256
+     * @return ISection[]
257
+     */
258
+    private function getBuiltInAdminSettings($section): array {
259
+        $forms = [];
260
+
261
+        if ($section === 'overview') {
262
+            /** @var ISettings $form */
263
+            $form = new Admin\Overview($this->config);
264
+            $forms[$form->getPriority()] = [$form];
265
+            $form = new Admin\ServerDevNotice();
266
+            $forms[$form->getPriority()] = [$form];
267
+        }
268
+        if ($section === 'server') {
269
+            /** @var ISettings $form */
270
+            $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l);
271
+            $forms[$form->getPriority()] = [$form];
272
+            $form = new Admin\Mail($this->config);
273
+            $forms[$form->getPriority()] = [$form];
274
+        }
275
+        if ($section === 'encryption') {
276
+            /** @var ISettings $form */
277
+            $form = new Admin\Encryption($this->encryptionManager, $this->userManager);
278
+            $forms[$form->getPriority()] = [$form];
279
+        }
280
+        if ($section === 'sharing') {
281
+            /** @var ISettings $form */
282
+            $form = new Admin\Sharing($this->config, $this->l);
283
+            $forms[$form->getPriority()] = [$form];
284
+        }
285
+
286
+        return $forms;
287
+    }
288
+
289
+    /**
290
+     * @param string $section
291
+     * @return ISection[]
292
+     */
293
+    private function getBuiltInPersonalSettings($section): array {
294
+        $forms = [];
295
+
296
+        if ($section === 'personal-info') {
297
+            /** @var ISettings $form */
298
+            $form = new Personal\PersonalInfo(
299
+                $this->config,
300
+                $this->userManager,
301
+                $this->groupManager,
302
+                $this->accountManager,
303
+                $this->appManager,
304
+                $this->l10nFactory,
305
+                $this->l
306
+            );
307
+            $forms[$form->getPriority()] = [$form];
308
+        }
309
+        if($section === 'security') {
310
+            /** @var ISettings $form */
311
+            $form = new Personal\Security();
312
+            $forms[$form->getPriority()] = [$form];
313
+        }
314
+        if ($section === 'additional') {
315
+            /** @var ISettings $form */
316
+            $form = new Personal\Additional();
317
+            $forms[$form->getPriority()] = [$form];
318
+        }
319
+
320
+        return $forms;
321
+    }
322
+
323
+    /**
324
+     * @inheritdoc
325
+     */
326
+    public function getAdminSettings($section): array {
327
+        $settings = $this->getBuiltInAdminSettings($section);
328
+        $appSettings = $this->getSettings('admin', $section);
329
+
330
+        foreach ($appSettings as $setting) {
331
+            if (!isset($settings[$setting->getPriority()])) {
332
+                $settings[$setting->getPriority()] = [];
333
+            }
334
+            $settings[$setting->getPriority()][] = $setting;
335
+        }
336
+
337
+        ksort($settings);
338
+        return $settings;
339
+    }
340
+
341
+    /**
342
+     * @inheritdoc
343
+     */
344
+    public function getPersonalSections(): array {
345
+        $sections = [
346
+            0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))],
347
+            5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))],
348
+            15 => [new Section('sync-clients', $this->l->t('Mobile & desktop'), 0, $this->url->imagePath('core', 'clients/phone.svg'))],
349
+        ];
350
+
351
+        $legacyForms = \OC_App::getForms('personal');
352
+        if(!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) {
353
+            $sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))];
354
+        }
355
+
356
+        $appSections = $this->getSections('personal');
357
+
358
+        foreach ($appSections as $section) {
359
+            /** @var ISection $section */
360
+            if (!isset($sections[$section->getPriority()])) {
361
+                $sections[$section->getPriority()] = [];
362
+            }
363
+
364
+            $sections[$section->getPriority()][] = $section;
365
+        }
366
+
367
+        ksort($sections);
368
+
369
+        return $sections;
370
+    }
371
+
372
+    /**
373
+     * @param string[] $forms
374
+     * @return bool
375
+     */
376
+    private function hasLegacyPersonalSettingsToRender(array $forms): bool {
377
+        foreach ($forms as $form) {
378
+            if(trim($form) !== '') {
379
+                return true;
380
+            }
381
+        }
382
+        return false;
383
+    }
384
+
385
+    /**
386
+     * @inheritdoc
387
+     */
388
+    public function getPersonalSettings($section): array {
389
+        $settings = $this->getBuiltInPersonalSettings($section);
390
+        $appSettings = $this->getSettings('personal', $section);
391
+
392
+        foreach ($appSettings as $setting) {
393
+            if (!isset($settings[$setting->getPriority()])) {
394
+                $settings[$setting->getPriority()] = [];
395
+            }
396
+            $settings[$setting->getPriority()][] = $setting;
397
+        }
398
+
399
+        ksort($settings);
400
+        return $settings;
401
+    }
402 402
 }
Please login to merge, or discard this patch.
apps/dav/lib/Settings/CalDAVSettings.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -29,41 +29,41 @@
 block discarded – undo
29 29
 
30 30
 class CalDAVSettings implements ISettings {
31 31
 
32
-	/** @var IConfig */
33
-	private $config;
32
+    /** @var IConfig */
33
+    private $config;
34 34
 
35
-	/**
36
-	 * CalDAVSettings constructor.
37
-	 *
38
-	 * @param IConfig $config
39
-	 */
40
-	public function __construct(IConfig $config) {
41
-		$this->config = $config;
42
-	}
35
+    /**
36
+     * CalDAVSettings constructor.
37
+     *
38
+     * @param IConfig $config
39
+     */
40
+    public function __construct(IConfig $config) {
41
+        $this->config = $config;
42
+    }
43 43
 
44
-	/**
45
-	 * @return TemplateResponse
46
-	 */
47
-	public function getForm() {
48
-		$parameters = [
49
-			'send_invitations' => $this->config->getAppValue('dav', 'sendInvitations', 'yes'),
50
-			'generate_birthday_calendar' => $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'),
51
-		];
44
+    /**
45
+     * @return TemplateResponse
46
+     */
47
+    public function getForm() {
48
+        $parameters = [
49
+            'send_invitations' => $this->config->getAppValue('dav', 'sendInvitations', 'yes'),
50
+            'generate_birthday_calendar' => $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'),
51
+        ];
52 52
 
53
-		return new TemplateResponse('dav', 'settings-admin-caldav', $parameters);
54
-	}
53
+        return new TemplateResponse('dav', 'settings-admin-caldav', $parameters);
54
+    }
55 55
 
56
-	/**
57
-	 * @return string
58
-	 */
59
-	public function getSection() {
60
-		return 'groupware';
61
-	}
56
+    /**
57
+     * @return string
58
+     */
59
+    public function getSection() {
60
+        return 'groupware';
61
+    }
62 62
 
63
-	/**
64
-	 * @return int
65
-	 */
66
-	public function getPriority() {
67
-		return 10;
68
-	}
63
+    /**
64
+     * @return int
65
+     */
66
+    public function getPriority() {
67
+        return 10;
68
+    }
69 69
 }
Please login to merge, or discard this patch.