Passed
Push — master ( f8859e...b72d27 )
by Roeland
13:06
created
apps/theming/lib/Settings/Section.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -28,55 +28,55 @@
 block discarded – undo
28 28
 use OCP\Settings\IIconSection;
29 29
 
30 30
 class Section implements IIconSection {
31
-	/** @var IL10N */
32
-	private $l;
33
-	/** @var IURLGenerator */
34
-	private $url;
31
+    /** @var IL10N */
32
+    private $l;
33
+    /** @var IURLGenerator */
34
+    private $url;
35 35
 
36
-	/**
37
-	 * @param IURLGenerator $url
38
-	 * @param IL10N $l
39
-	 */
40
-	public function __construct(IURLGenerator $url, IL10N $l) {
41
-		$this->url = $url;
42
-		$this->l = $l;
43
-	}
36
+    /**
37
+     * @param IURLGenerator $url
38
+     * @param IL10N $l
39
+     */
40
+    public function __construct(IURLGenerator $url, IL10N $l) {
41
+        $this->url = $url;
42
+        $this->l = $l;
43
+    }
44 44
 
45
-	/**
46
-	 * returns the ID of the section. It is supposed to be a lower case string,
47
-	 * e.g. 'ldap'
48
-	 *
49
-	 * @returns string
50
-	 */
51
-	public function getID() {
52
-		return 'theming';
53
-	}
45
+    /**
46
+     * returns the ID of the section. It is supposed to be a lower case string,
47
+     * e.g. 'ldap'
48
+     *
49
+     * @returns string
50
+     */
51
+    public function getID() {
52
+        return 'theming';
53
+    }
54 54
 
55
-	/**
56
-	 * returns the translated name as it should be displayed, e.g. 'LDAP / AD
57
-	 * integration'. Use the L10N service to translate it.
58
-	 *
59
-	 * @return string
60
-	 */
61
-	public function getName() {
62
-		return $this->l->t('Theming');
63
-	}
55
+    /**
56
+     * returns the translated name as it should be displayed, e.g. 'LDAP / AD
57
+     * integration'. Use the L10N service to translate it.
58
+     *
59
+     * @return string
60
+     */
61
+    public function getName() {
62
+        return $this->l->t('Theming');
63
+    }
64 64
 
65
-	/**
66
-	 * @return int whether the form should be rather on the top or bottom of
67
-	 * the settings navigation. The sections are arranged in ascending order of
68
-	 * the priority values. It is required to return a value between 0 and 99.
69
-	 *
70
-	 * E.g.: 70
71
-	 */
72
-	public function getPriority() {
73
-		return 30;
74
-	}
65
+    /**
66
+     * @return int whether the form should be rather on the top or bottom of
67
+     * the settings navigation. The sections are arranged in ascending order of
68
+     * the priority values. It is required to return a value between 0 and 99.
69
+     *
70
+     * E.g.: 70
71
+     */
72
+    public function getPriority() {
73
+        return 30;
74
+    }
75 75
 
76
-	/**
77
-	 * {@inheritdoc}
78
-	 */
79
-	public function getIcon() {
80
-		return $this->url->imagePath('theming', 'app-dark.svg');
81
-	}
76
+    /**
77
+     * {@inheritdoc}
78
+     */
79
+    public function getIcon() {
80
+        return $this->url->imagePath('theming', 'app-dark.svg');
81
+    }
82 82
 }
Please login to merge, or discard this patch.
settings/templates/settings/personal/personal.info.php 2 patches
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 					</div>
70 70
 				</div>
71 71
 				<span class="icon-checkmark hidden"></span>
72
-				<?php if($_['lookupServerUploadEnabled']) { ?>
72
+				<?php if ($_['lookupServerUploadEnabled']) { ?>
73 73
 				<input type="hidden" id="avatarscope" value="<?php p($_['avatarScope']) ?>">
74 74
 				<?php } ?>
75 75
 			</form>
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
 					<p class="quotatext">
88 88
 						<?php if ($_['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED): ?>
89 89
 							<?php print_unescaped($l->t('You are using <strong>%s</strong>',
90
-								[$_['usage']]));?>
90
+								[$_['usage']])); ?>
91 91
 						<?php else: ?>
92 92
 							<?php print_unescaped($l->t('You are using <strong>%1$s</strong> of <strong>%2$s</strong> (<strong>%3$s %%</strong>)',
93
-								[$_['usage'], $_['total_space'],  $_['usage_relative']]));?>
93
+								[$_['usage'], $_['total_space'], $_['usage_relative']])); ?>
94 94
 						<?php endif ?>
95 95
 					</p>
96 96
 				</div>
97
-				<progress value="<?php p($_['usage_relative']); ?>" max="100"<?php if($_['usage_relative'] > 80): ?> class="warn" <?php endif; ?>></progress>
97
+				<progress value="<?php p($_['usage_relative']); ?>" max="100"<?php if ($_['usage_relative'] > 80): ?> class="warn" <?php endif; ?>></progress>
98 98
 			</div>
99 99
 		</div>
100 100
 	</div>
@@ -111,15 +111,15 @@  discard block
 block discarded – undo
111 111
 					</div>
112 112
 				</h3>
113 113
 				<input type="text" id="displayname" name="displayname"
114
-					<?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?>
114
+					<?php if (!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?>
115 115
 					   value="<?php p($_['displayName']) ?>"
116 116
 					   autocomplete="on" autocapitalize="none" autocorrect="off" />
117
-				<?php if(!$_['displayNameChangeSupported']) { ?>
118
-					<span><?php if(isset($_['displayName']) && !empty($_['displayName'])) { p($_['displayName']); } else { p($l->t('No display name set')); } ?></span>
117
+				<?php if (!$_['displayNameChangeSupported']) { ?>
118
+					<span><?php if (isset($_['displayName']) && !empty($_['displayName'])) { p($_['displayName']); } else { p($l->t('No display name set')); } ?></span>
119 119
 				<?php } ?>
120 120
 				<span class="icon-checkmark hidden"></span>
121 121
 				<span class="icon-error hidden" ></span>
122
-				<?php if($_['lookupServerUploadEnabled']) { ?>
122
+				<?php if ($_['lookupServerUploadEnabled']) { ?>
123 123
 					<input type="hidden" id="displaynamescope" value="<?php p($_['displayNameScope']) ?>">
124 124
 				<?php } ?>
125 125
 			</form>
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 						</span>
135 135
 					</div>
136 136
 				</h3>
137
-				<div class="verify <?php if ($_['email'] === ''  || $_['emailScope'] !== 'public') p('hidden'); ?>">
137
+				<div class="verify <?php if ($_['email'] === '' || $_['emailScope'] !== 'public') p('hidden'); ?>">
138 138
 					<img id="verify-email" title="<?php p($_['emailMessage']); ?>" data-status="<?php p($_['emailVerification']) ?>" src="
139 139
 				<?php
140
-					switch($_['emailVerification']) {
140
+					switch ($_['emailVerification']) {
141 141
 						case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
142 142
 							p(image_path('core', 'actions/verifying.svg'));
143 143
 							break;
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
 					?>">
151 151
 				</div>
152 152
 				<input type="email" name="email" id="email" value="<?php p($_['email']); ?>"
153
-					<?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?>
153
+					<?php if (!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?>
154 154
 					   placeholder="<?php p($l->t('Your email address')); ?>"
155 155
 					   autocomplete="on" autocapitalize="none" autocorrect="off" />
156 156
 			   	<span class="icon-checkmark hidden"></span>
157 157
 				<span class="icon-error hidden" ></span>
158
-				<?php if(!$_['displayNameChangeSupported']) { ?>
159
-					<span><?php if(isset($_['email']) && !empty($_['email'])) { p($_['email']); } else { p($l->t('No email address set')); }?></span>
158
+				<?php if (!$_['displayNameChangeSupported']) { ?>
159
+					<span><?php if (isset($_['email']) && !empty($_['email'])) { p($_['email']); } else { p($l->t('No email address set')); }?></span>
160 160
 				<?php } ?>
161
-				<?php if($_['displayNameChangeSupported']) { ?>
161
+				<?php if ($_['displayNameChangeSupported']) { ?>
162 162
 					<em><?php p($l->t('For password reset and notifications')); ?></em>
163 163
 				<?php } ?>
164
-				<?php if($_['lookupServerUploadEnabled']) { ?>
164
+				<?php if ($_['lookupServerUploadEnabled']) { ?>
165 165
 					<input type="hidden" id="emailscope" value="<?php p($_['emailScope']) ?>">
166 166
 				<?php } ?>
167 167
 			</form>
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
 						</span>
178 178
 					</div>
179 179
 				</h3>
180
-				<input type="tel" id="phone" name="phone" <?php if(!$_['lookupServerUploadEnabled']) print_unescaped('disabled="1"'); ?>
180
+				<input type="tel" id="phone" name="phone" <?php if (!$_['lookupServerUploadEnabled']) print_unescaped('disabled="1"'); ?>
181 181
 					   value="<?php p($_['phone']) ?>"
182 182
 					   placeholder="<?php p($l->t('Your phone number')); ?>"
183 183
 				       autocomplete="on" autocapitalize="none" autocorrect="off" />
184 184
 				<span class="icon-checkmark hidden"></span>
185
-				<?php if($_['lookupServerUploadEnabled']) { ?>
185
+				<?php if ($_['lookupServerUploadEnabled']) { ?>
186 186
 				<input type="hidden" id="phonescope" value="<?php p($_['phoneScope']) ?>">
187 187
 				<?php } ?>
188 188
 			</form>
@@ -199,12 +199,12 @@  discard block
 block discarded – undo
199 199
 						</span>
200 200
 					</div>
201 201
 				</h3>
202
-				<input type="text" id="address" name="address" <?php if(!$_['lookupServerUploadEnabled']) print_unescaped('disabled="1"');  ?>
202
+				<input type="text" id="address" name="address" <?php if (!$_['lookupServerUploadEnabled']) print_unescaped('disabled="1"'); ?>
203 203
 					   placeholder="<?php p($l->t('Your postal address')); ?>"
204 204
 					   value="<?php p($_['address']) ?>"
205 205
 					   autocomplete="on" autocapitalize="none" autocorrect="off" />
206 206
 				<span class="icon-checkmark hidden"></span>
207
-				<?php if($_['lookupServerUploadEnabled']) { ?>
207
+				<?php if ($_['lookupServerUploadEnabled']) { ?>
208 208
 				<input type="hidden" id="addressscope" value="<?php p($_['addressScope']) ?>">
209 209
 				<?php } ?>
210 210
 			</form>
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 						</span>
222 222
 					</div>
223 223
 				</h3>
224
-				<?php if($_['lookupServerUploadEnabled']) { ?>
225
-				<div class="verify <?php if ($_['website'] === ''  || $_['websiteScope'] !== 'public') p('hidden'); ?>">
224
+				<?php if ($_['lookupServerUploadEnabled']) { ?>
225
+				<div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') p('hidden'); ?>">
226 226
 					<img id="verify-website" title="<?php p($_['websiteMessage']); ?>" data-status="<?php p($_['websiteVerification']) ?>" src="
227 227
 					<?php
228
-					switch($_['websiteVerification']) {
228
+					switch ($_['websiteVerification']) {
229 229
 						case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
230 230
 							p(image_path('core', 'actions/verifying.svg'));
231 231
 							break;
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
 							p(image_path('core', 'actions/verify.svg'));
237 237
 					}
238 238
 					?>"
239
-					<?php if($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?>
239
+					<?php if ($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?>
240 240
 					>
241 241
 					<div class="verification-dialog popovermenu bubble menu">
242 242
 						<div class="verification-dialog-content">
243 243
 							<p class="explainVerification"></p>
244 244
 							<p class="verificationCode"></p>
245
-							<p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.'));?></p>
245
+							<p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.')); ?></p>
246 246
 						</div>
247 247
 					</div>
248 248
 				</div>
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 				<input type="url" name="website" id="website" value="<?php p($_['website']); ?>"
251 251
 				       placeholder="<?php p($l->t('Link https://…')); ?>"
252 252
 				       autocomplete="on" autocapitalize="none" autocorrect="off"
253
-					   <?php if(!$_['lookupServerUploadEnabled']) print_unescaped('disabled="1"');  ?>
253
+					   <?php if (!$_['lookupServerUploadEnabled']) print_unescaped('disabled="1"'); ?>
254 254
 				/>
255 255
 				<span class="icon-checkmark hidden"></span>
256
-				<?php if($_['lookupServerUploadEnabled']) { ?>
256
+				<?php if ($_['lookupServerUploadEnabled']) { ?>
257 257
 				<input type="hidden" id="websitescope" value="<?php p($_['websiteScope']) ?>">
258 258
 				<?php } ?>
259 259
 			</form>
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 						</span>
271 271
 					</div>
272 272
 				</h3>
273
-				<?php if($_['lookupServerUploadEnabled']) { ?>
274
-				<div class="verify <?php if ($_['twitter'] === ''  || $_['twitterScope'] !== 'public') p('hidden'); ?>">
273
+				<?php if ($_['lookupServerUploadEnabled']) { ?>
274
+				<div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') p('hidden'); ?>">
275 275
 					<img id="verify-twitter" title="<?php p($_['twitterMessage']); ?>" data-status="<?php p($_['twitterVerification']) ?>" src="
276 276
 					<?php
277
-					switch($_['twitterVerification']) {
277
+					switch ($_['twitterVerification']) {
278 278
 						case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
279 279
 							p(image_path('core', 'actions/verifying.svg'));
280 280
 							break;
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
 							p(image_path('core', 'actions/verify.svg'));
286 286
 					}
287 287
 					?>"
288
-					<?php if($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?>
288
+					<?php if ($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?>
289 289
 					>
290 290
 					<div class="verification-dialog popovermenu bubble menu">
291 291
 						<div class="verification-dialog-content">
292 292
 							<p class="explainVerification"></p>
293 293
 							<p class="verificationCode"></p>
294
-							<p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.'));?></p>
294
+							<p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.')); ?></p>
295 295
 						</div>
296 296
 					</div>
297 297
 				</div>
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
 				<input type="text" name="twitter" id="twitter" value="<?php p($_['twitter']); ?>"
300 300
 					   placeholder="<?php p($l->t('Twitter handle @…')); ?>"
301 301
 					   autocomplete="on" autocapitalize="none" autocorrect="off"
302
-					   <?php if(!$_['lookupServerUploadEnabled']) print_unescaped('disabled="1"');  ?>
302
+					   <?php if (!$_['lookupServerUploadEnabled']) print_unescaped('disabled="1"'); ?>
303 303
 				/>
304 304
 				<span class="icon-checkmark hidden"></span>
305
-				<?php if($_['lookupServerUploadEnabled']) { ?>
305
+				<?php if ($_['lookupServerUploadEnabled']) { ?>
306 306
 				<input type="hidden" id="twitterscope" value="<?php p($_['twitterScope']) ?>">
307 307
 				<?php } ?>
308 308
 			</form>
@@ -315,27 +315,27 @@  discard block
 block discarded – undo
315 315
 			<?php if (isset($_['activelanguage'])) { ?>
316 316
 				<form id="language" class="section">
317 317
 					<h3>
318
-						<label for="languageinput"><?php p($l->t('Language'));?></label>
318
+						<label for="languageinput"><?php p($l->t('Language')); ?></label>
319 319
 					</h3>
320
-					<select id="languageinput" name="lang" data-placeholder="<?php p($l->t('Language'));?>">
321
-						<option value="<?php p($_['activelanguage']['code']);?>">
322
-							<?php p($_['activelanguage']['name']);?>
320
+					<select id="languageinput" name="lang" data-placeholder="<?php p($l->t('Language')); ?>">
321
+						<option value="<?php p($_['activelanguage']['code']); ?>">
322
+							<?php p($_['activelanguage']['name']); ?>
323 323
 						</option>
324
-						<?php foreach($_['commonlanguages'] as $language):?>
325
-							<option value="<?php p($language['code']);?>">
326
-								<?php p($language['name']);?>
324
+						<?php foreach ($_['commonlanguages'] as $language):?>
325
+							<option value="<?php p($language['code']); ?>">
326
+								<?php p($language['name']); ?>
327 327
 							</option>
328
-						<?php endforeach;?>
328
+						<?php endforeach; ?>
329 329
 						<optgroup label="––––––––––"></optgroup>
330
-						<?php foreach($_['languages'] as $language):?>
331
-							<option value="<?php p($language['code']);?>">
332
-								<?php p($language['name']);?>
330
+						<?php foreach ($_['languages'] as $language):?>
331
+							<option value="<?php p($language['code']); ?>">
332
+								<?php p($language['name']); ?>
333 333
 							</option>
334
-						<?php endforeach;?>
334
+						<?php endforeach; ?>
335 335
 					</select>
336 336
 					<a href="https://www.transifex.com/nextcloud/nextcloud/"
337 337
 					   target="_blank" rel="noreferrer noopener">
338
-						<em><?php p($l->t('Help translate'));?></em>
338
+						<em><?php p($l->t('Help translate')); ?></em>
339 339
 					</a>
340 340
 				</form>
341 341
 			<?php } ?>
@@ -344,27 +344,27 @@  discard block
 block discarded – undo
344 344
 			<?php if (isset($_['activelocale'])) { ?>
345 345
 				<form id="locale" class="section">
346 346
 					<h3>
347
-						<label for="localeinput"><?php p($l->t('Locale'));?></label>
347
+						<label for="localeinput"><?php p($l->t('Locale')); ?></label>
348 348
 					</h3>
349
-					<select id="localeinput" name="lang" data-placeholder="<?php p($l->t('Locale'));?>">
350
-						<option value="<?php p($_['activelocale']['code']);?>">
351
-							<?php p($_['activelocale']['name']);?>
349
+					<select id="localeinput" name="lang" data-placeholder="<?php p($l->t('Locale')); ?>">
350
+						<option value="<?php p($_['activelocale']['code']); ?>">
351
+							<?php p($_['activelocale']['name']); ?>
352 352
 						</option>
353 353
 						<optgroup label="––––––––––"></optgroup>
354
-						<?php foreach($_['localesForLanguage'] as $locale):?>
355
-							<option value="<?php p($locale['code']);?>">
356
-								<?php p($locale['name']);?>
354
+						<?php foreach ($_['localesForLanguage'] as $locale):?>
355
+							<option value="<?php p($locale['code']); ?>">
356
+								<?php p($locale['name']); ?>
357 357
 							</option>
358
-						<?php endforeach;?>
358
+						<?php endforeach; ?>
359 359
 						<optgroup label="––––––––––"></optgroup>
360
-						<option value="<?php p($_['activelocale']['code']);?>">
361
-							<?php p($_['activelocale']['name']);?>
360
+						<option value="<?php p($_['activelocale']['code']); ?>">
361
+							<?php p($_['activelocale']['name']); ?>
362 362
 						</option>
363
-						<?php foreach($_['locales'] as $locale):?>
364
-							<option value="<?php p($locale['code']);?>">
365
-								<?php p($locale['name']);?>
363
+						<?php foreach ($_['locales'] as $locale):?>
364
+							<option value="<?php p($locale['code']); ?>">
365
+								<?php p($locale['name']); ?>
366 366
 							</option>
367
-						<?php endforeach;?>
367
+						<?php endforeach; ?>
368 368
 					</select>
369 369
 					<div id="localeexample" class="personal-info icon-timezone">
370 370
 						<p>
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 /** @var array $_ */
27 27
 
28 28
 script('settings', [
29
-	'usersettings',
30
-	'templates',
31
-	'federationsettingsview',
32
-	'federationscopemenu',
33
-	'settings/personalInfo',
29
+    'usersettings',
30
+    'templates',
31
+    'federationsettingsview',
32
+    'federationscopemenu',
33
+    'settings/personalInfo',
34 34
 ]);
35 35
 ?>
36 36
 
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 					<p class="quotatext">
86 86
 						<?php if ($_['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED): ?>
87 87
 							<?php print_unescaped($l->t('You are using <strong>%s</strong>',
88
-								[$_['usage']]));?>
88
+                                [$_['usage']]));?>
89 89
 						<?php else: ?>
90 90
 							<?php print_unescaped($l->t('You are using <strong>%1$s</strong> of <strong>%2$s</strong> (<strong>%3$s %%</strong>)',
91
-								[$_['usage'], $_['total_space'],  $_['usage_relative']]));?>
91
+                                [$_['usage'], $_['total_space'],  $_['usage_relative']]));?>
92 92
 						<?php endif ?>
93 93
 					</p>
94 94
 				</div>
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
 				<div class="verify <?php if ($_['email'] === ''  || $_['emailScope'] !== 'public') p('hidden'); ?>">
136 136
 					<img id="verify-email" title="<?php p($_['emailMessage']); ?>" data-status="<?php p($_['emailVerification']) ?>" src="
137 137
 				<?php
138
-					switch($_['emailVerification']) {
139
-						case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
140
-							p(image_path('core', 'actions/verifying.svg'));
141
-							break;
142
-						case \OC\Accounts\AccountManager::VERIFIED:
143
-							p(image_path('core', 'actions/verified.svg'));
144
-							break;
145
-						default:
146
-							p(image_path('core', 'actions/verify.svg'));
147
-					}
148
-					?>">
138
+                    switch($_['emailVerification']) {
139
+                        case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
140
+                            p(image_path('core', 'actions/verifying.svg'));
141
+                            break;
142
+                        case \OC\Accounts\AccountManager::VERIFIED:
143
+                            p(image_path('core', 'actions/verified.svg'));
144
+                            break;
145
+                        default:
146
+                            p(image_path('core', 'actions/verify.svg'));
147
+                    }
148
+                    ?>">
149 149
 				</div>
150 150
 				<input type="email" name="email" id="email" value="<?php p($_['email']); ?>"
151 151
 					<?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?>
@@ -223,17 +223,17 @@  discard block
 block discarded – undo
223 223
 				<div class="verify <?php if ($_['website'] === ''  || $_['websiteScope'] !== 'public') p('hidden'); ?>">
224 224
 					<img id="verify-website" title="<?php p($_['websiteMessage']); ?>" data-status="<?php p($_['websiteVerification']) ?>" src="
225 225
 					<?php
226
-					switch($_['websiteVerification']) {
227
-						case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
228
-							p(image_path('core', 'actions/verifying.svg'));
229
-							break;
230
-						case \OC\Accounts\AccountManager::VERIFIED:
231
-							p(image_path('core', 'actions/verified.svg'));
232
-							break;
233
-						default:
234
-							p(image_path('core', 'actions/verify.svg'));
235
-					}
236
-					?>"
226
+                    switch($_['websiteVerification']) {
227
+                        case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
228
+                            p(image_path('core', 'actions/verifying.svg'));
229
+                            break;
230
+                        case \OC\Accounts\AccountManager::VERIFIED:
231
+                            p(image_path('core', 'actions/verified.svg'));
232
+                            break;
233
+                        default:
234
+                            p(image_path('core', 'actions/verify.svg'));
235
+                    }
236
+                    ?>"
237 237
 					<?php if($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?>
238 238
 					>
239 239
 					<div class="verification-dialog popovermenu bubble menu">
@@ -272,17 +272,17 @@  discard block
 block discarded – undo
272 272
 				<div class="verify <?php if ($_['twitter'] === ''  || $_['twitterScope'] !== 'public') p('hidden'); ?>">
273 273
 					<img id="verify-twitter" title="<?php p($_['twitterMessage']); ?>" data-status="<?php p($_['twitterVerification']) ?>" src="
274 274
 					<?php
275
-					switch($_['twitterVerification']) {
276
-						case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
277
-							p(image_path('core', 'actions/verifying.svg'));
278
-							break;
279
-						case \OC\Accounts\AccountManager::VERIFIED:
280
-							p(image_path('core', 'actions/verified.svg'));
281
-							break;
282
-						default:
283
-							p(image_path('core', 'actions/verify.svg'));
284
-					}
285
-					?>"
275
+                    switch($_['twitterVerification']) {
276
+                        case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
277
+                            p(image_path('core', 'actions/verifying.svg'));
278
+                            break;
279
+                        case \OC\Accounts\AccountManager::VERIFIED:
280
+                            p(image_path('core', 'actions/verified.svg'));
281
+                            break;
282
+                        default:
283
+                            p(image_path('core', 'actions/verify.svg'));
284
+                    }
285
+                    ?>"
286 286
 					<?php if($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?>
287 287
 					>
288 288
 					<div class="verification-dialog popovermenu bubble menu">
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 (' . $class . ')'), ['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 (' . $class . ')'), ['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.
settings/routes.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -38,57 +38,57 @@
 block discarded – undo
38 38
 
39 39
 $application = new Application();
40 40
 $application->registerRoutes($this, [
41
-	'resources' => [
42
-		'AuthSettings' => ['url' => '/settings/personal/authtokens'],
43
-	],
44
-	'routes' => [
45
-		['name' => 'MailSettings#setMailSettings', 'url' => '/settings/admin/mailsettings', 'verb' => 'POST'],
46
-		['name' => 'MailSettings#storeCredentials', 'url' => '/settings/admin/mailsettings/credentials', 'verb' => 'POST'],
47
-		['name' => 'MailSettings#sendTestMail', 'url' => '/settings/admin/mailtest', 'verb' => 'POST'],
48
-		['name' => 'Encryption#startMigration', 'url' => '/settings/admin/startmigration', 'verb' => 'POST'],
41
+    'resources' => [
42
+        'AuthSettings' => ['url' => '/settings/personal/authtokens'],
43
+    ],
44
+    'routes' => [
45
+        ['name' => 'MailSettings#setMailSettings', 'url' => '/settings/admin/mailsettings', 'verb' => 'POST'],
46
+        ['name' => 'MailSettings#storeCredentials', 'url' => '/settings/admin/mailsettings/credentials', 'verb' => 'POST'],
47
+        ['name' => 'MailSettings#sendTestMail', 'url' => '/settings/admin/mailtest', 'verb' => 'POST'],
48
+        ['name' => 'Encryption#startMigration', 'url' => '/settings/admin/startmigration', 'verb' => 'POST'],
49 49
 
50
-		['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET'],
51
-		['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET'],
52
-		['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'],
53
-		['name' => 'AppSettings#enableApp', 'url' => '/settings/apps/enable/{appId}', 'verb' => 'GET'],
54
-		['name' => 'AppSettings#enableApp', 'url' => '/settings/apps/enable/{appId}', 'verb' => 'POST'],
55
-		['name' => 'AppSettings#enableApps', 'url' => '/settings/apps/enable', 'verb' => 'POST'],
56
-		['name' => 'AppSettings#disableApp', 'url' => '/settings/apps/disable/{appId}', 'verb' => 'GET'],
57
-		['name' => 'AppSettings#disableApps', 'url' => '/settings/apps/disable', 'verb' => 'POST'],
58
-		['name' => 'AppSettings#updateApp', 'url' => '/settings/apps/update/{appId}', 'verb' => 'GET'],
59
-		['name' => 'AppSettings#uninstallApp', 'url' => '/settings/apps/uninstall/{appId}', 'verb' => 'GET'],
60
-		['name' => 'AppSettings#viewApps', 'url' => '/settings/apps/{category}', 'verb' => 'GET', 'defaults' => ['category' => '']],
61
-		['name' => 'AppSettings#viewApps', 'url' => '/settings/apps/{category}/{id}', 'verb' => 'GET', 'defaults' => ['category' => '', 'id' => '']],
50
+        ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET'],
51
+        ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET'],
52
+        ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'],
53
+        ['name' => 'AppSettings#enableApp', 'url' => '/settings/apps/enable/{appId}', 'verb' => 'GET'],
54
+        ['name' => 'AppSettings#enableApp', 'url' => '/settings/apps/enable/{appId}', 'verb' => 'POST'],
55
+        ['name' => 'AppSettings#enableApps', 'url' => '/settings/apps/enable', 'verb' => 'POST'],
56
+        ['name' => 'AppSettings#disableApp', 'url' => '/settings/apps/disable/{appId}', 'verb' => 'GET'],
57
+        ['name' => 'AppSettings#disableApps', 'url' => '/settings/apps/disable', 'verb' => 'POST'],
58
+        ['name' => 'AppSettings#updateApp', 'url' => '/settings/apps/update/{appId}', 'verb' => 'GET'],
59
+        ['name' => 'AppSettings#uninstallApp', 'url' => '/settings/apps/uninstall/{appId}', 'verb' => 'GET'],
60
+        ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps/{category}', 'verb' => 'GET', 'defaults' => ['category' => '']],
61
+        ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps/{category}/{id}', 'verb' => 'GET', 'defaults' => ['category' => '', 'id' => '']],
62 62
 
63
-		['name' => 'Users#setDisplayName', 'url' => '/settings/users/{username}/displayName', 'verb' => 'POST'],
64
-		['name' => 'Users#setEMailAddress', 'url' => '/settings/users/{id}/mailAddress', 'verb' => 'PUT'],
65
-		['name' => 'Users#setUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT'],
66
-		['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'],
67
-		['name' => 'Users#usersList', 'url' => '/settings/users', 'verb' => 'GET'],
68
-		['name' => 'Users#usersListByGroup', 'url' => '/settings/users/{group}', 'verb' => 'GET', 'requirements' => ['group' => '.+']],
69
-		['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'],
70
-		['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'],
71
-		['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'],
72
-		['name' => 'CheckSetup#check', 'url' => '/settings/ajax/checksetup', 'verb' => 'GET'],
73
-		['name' => 'CheckSetup#getFailedIntegrityCheckFiles', 'url' => '/settings/integrity/failed', 'verb' => 'GET'],
74
-		['name' => 'CheckSetup#rescanFailedIntegrityCheck', 'url' => '/settings/integrity/rescan', 'verb' => 'GET'],
75
-		['name' => 'Certificate#addPersonalRootCertificate', 'url' => '/settings/personal/certificate', 'verb' => 'POST'],
76
-		['name' => 'Certificate#removePersonalRootCertificate', 'url' => '/settings/personal/certificate/{certificateIdentifier}', 'verb' => 'DELETE'],
77
-		['name' => 'Certificate#addSystemRootCertificate', 'url' => '/settings/admin/certificate', 'verb' => 'POST'],
78
-		['name' => 'Certificate#removeSystemRootCertificate', 'url' => '/settings/admin/certificate/{certificateIdentifier}', 'verb' => 'DELETE'],
79
-		['name' => 'PersonalSettings#index', 'url' => '/settings/user/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'personal-info']],
80
-		['name' => 'AdminSettings#index', 'url' => '/settings/admin/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'server']],
81
-		['name' => 'AdminSettings#form', 'url' => '/settings/admin/{section}', 'verb' => 'GET'],
82
-		['name' => 'ChangePassword#changePersonalPassword', 'url' => '/settings/personal/changepassword', 'verb' => 'POST'],
83
-		['name' => 'ChangePassword#changeUserPassword', 'url' => '/settings/users/changepassword', 'verb' => 'POST'],
84
-		['name' => 'TwoFactorSettings#index', 'url' => '/settings/api/admin/twofactorauth', 'verb' => 'GET'],
85
-		['name' => 'TwoFactorSettings#update', 'url' => '/settings/api/admin/twofactorauth', 'verb' => 'PUT'],
86
-	]
63
+        ['name' => 'Users#setDisplayName', 'url' => '/settings/users/{username}/displayName', 'verb' => 'POST'],
64
+        ['name' => 'Users#setEMailAddress', 'url' => '/settings/users/{id}/mailAddress', 'verb' => 'PUT'],
65
+        ['name' => 'Users#setUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT'],
66
+        ['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'],
67
+        ['name' => 'Users#usersList', 'url' => '/settings/users', 'verb' => 'GET'],
68
+        ['name' => 'Users#usersListByGroup', 'url' => '/settings/users/{group}', 'verb' => 'GET', 'requirements' => ['group' => '.+']],
69
+        ['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'],
70
+        ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'],
71
+        ['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'],
72
+        ['name' => 'CheckSetup#check', 'url' => '/settings/ajax/checksetup', 'verb' => 'GET'],
73
+        ['name' => 'CheckSetup#getFailedIntegrityCheckFiles', 'url' => '/settings/integrity/failed', 'verb' => 'GET'],
74
+        ['name' => 'CheckSetup#rescanFailedIntegrityCheck', 'url' => '/settings/integrity/rescan', 'verb' => 'GET'],
75
+        ['name' => 'Certificate#addPersonalRootCertificate', 'url' => '/settings/personal/certificate', 'verb' => 'POST'],
76
+        ['name' => 'Certificate#removePersonalRootCertificate', 'url' => '/settings/personal/certificate/{certificateIdentifier}', 'verb' => 'DELETE'],
77
+        ['name' => 'Certificate#addSystemRootCertificate', 'url' => '/settings/admin/certificate', 'verb' => 'POST'],
78
+        ['name' => 'Certificate#removeSystemRootCertificate', 'url' => '/settings/admin/certificate/{certificateIdentifier}', 'verb' => 'DELETE'],
79
+        ['name' => 'PersonalSettings#index', 'url' => '/settings/user/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'personal-info']],
80
+        ['name' => 'AdminSettings#index', 'url' => '/settings/admin/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'server']],
81
+        ['name' => 'AdminSettings#form', 'url' => '/settings/admin/{section}', 'verb' => 'GET'],
82
+        ['name' => 'ChangePassword#changePersonalPassword', 'url' => '/settings/personal/changepassword', 'verb' => 'POST'],
83
+        ['name' => 'ChangePassword#changeUserPassword', 'url' => '/settings/users/changepassword', 'verb' => 'POST'],
84
+        ['name' => 'TwoFactorSettings#index', 'url' => '/settings/api/admin/twofactorauth', 'verb' => 'GET'],
85
+        ['name' => 'TwoFactorSettings#update', 'url' => '/settings/api/admin/twofactorauth', 'verb' => 'PUT'],
86
+    ]
87 87
 ]);
88 88
 
89 89
 /** @var $this \OCP\Route\IRouter */
90 90
 
91 91
 // Settings pages
92 92
 $this->create('settings_help', '/settings/help')
93
-	->actionInclude('settings/help.php');
93
+    ->actionInclude('settings/help.php');
94 94
 
Please login to merge, or discard this patch.
lib/private/Settings/Personal/PersonalInfo.php 1 patch
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -41,240 +41,240 @@
 block discarded – undo
41 41
 
42 42
 class PersonalInfo implements ISettings {
43 43
 
44
-	/** @var IConfig */
45
-	private $config;
46
-	/** @var IUserManager */
47
-	private $userManager;
48
-	/** @var AccountManager */
49
-	private $accountManager;
50
-	/** @var IGroupManager */
51
-	private $groupManager;
52
-	/** @var IAppManager */
53
-	private $appManager;
54
-	/** @var IFactory */
55
-	private $l10nFactory;
56
-	/** @var IL10N */
57
-	private $l;
58
-
59
-	/**
60
-	 * @param IConfig $config
61
-	 * @param IUserManager $userManager
62
-	 * @param IGroupManager $groupManager
63
-	 * @param AccountManager $accountManager
64
-	 * @param IFactory $l10nFactory
65
-	 * @param IL10N $l
66
-	 */
67
-	public function __construct(
68
-		IConfig $config,
69
-		IUserManager $userManager,
70
-		IGroupManager $groupManager,
71
-		AccountManager $accountManager,
72
-		IAppManager $appManager,
73
-		IFactory $l10nFactory,
74
-		IL10N $l
75
-	) {
76
-		$this->config = $config;
77
-		$this->userManager = $userManager;
78
-		$this->accountManager = $accountManager;
79
-		$this->groupManager = $groupManager;
80
-		$this->appManager = $appManager;
81
-		$this->l10nFactory = $l10nFactory;
82
-		$this->l = $l;
83
-	}
84
-
85
-	/**
86
-	 * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
87
-	 * @since 9.1
88
-	 */
89
-	public function getForm() {
90
-		$federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
91
-		$lookupServerUploadEnabled = false;
92
-		if($federatedFileSharingEnabled) {
93
-			$federatedFileSharing = new Application();
94
-			$shareProvider = $federatedFileSharing->getFederatedShareProvider();
95
-			$lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled();
96
-		}
97
-
98
-		$uid = \OC_User::getUser();
99
-		$user = $this->userManager->get($uid);
100
-		$userData = $this->accountManager->getUser($user);
101
-
102
-		$storageInfo = \OC_Helper::getStorageInfo('/');
103
-		if ($storageInfo['quota'] === FileInfo::SPACE_UNLIMITED) {
104
-			$totalSpace = $this->l->t('Unlimited');
105
-		} else {
106
-			$totalSpace = \OC_Helper::humanFileSize($storageInfo['total']);
107
-		}
108
-
109
-		$languageParameters = $this->getLanguages($user);
110
-		$localeParameters = $this->getLocales($user);
111
-		$messageParameters = $this->getMessageParameters($userData);
112
-
113
-		$parameters = [
114
-			'total_space' => $totalSpace,
115
-			'usage' => \OC_Helper::humanFileSize($storageInfo['used']),
116
-			'usage_relative' => round($storageInfo['relative']),
117
-			'quota' => $storageInfo['quota'],
118
-			'avatarChangeSupported' => $user->canChangeAvatar(),
119
-			'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
120
-			'avatarScope' => $userData[AccountManager::PROPERTY_AVATAR]['scope'],
121
-			'displayNameChangeSupported' => $user->canChangeDisplayName(),
122
-			'displayName' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'],
123
-			'displayNameScope' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['scope'],
124
-			'email' => $userData[AccountManager::PROPERTY_EMAIL]['value'],
125
-			'emailScope' => $userData[AccountManager::PROPERTY_EMAIL]['scope'],
126
-			'emailVerification' => $userData[AccountManager::PROPERTY_EMAIL]['verified'],
127
-			'phone' => $userData[AccountManager::PROPERTY_PHONE]['value'],
128
-			'phoneScope' => $userData[AccountManager::PROPERTY_PHONE]['scope'],
129
-			'address' => $userData[AccountManager::PROPERTY_ADDRESS]['value'],
130
-			'addressScope' => $userData[AccountManager::PROPERTY_ADDRESS]['scope'],
131
-			'website' =>  $userData[AccountManager::PROPERTY_WEBSITE]['value'],
132
-			'websiteScope' =>  $userData[AccountManager::PROPERTY_WEBSITE]['scope'],
133
-			'websiteVerification' => $userData[AccountManager::PROPERTY_WEBSITE]['verified'],
134
-			'twitter' => $userData[AccountManager::PROPERTY_TWITTER]['value'],
135
-			'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'],
136
-			'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'],
137
-			'groups' => $this->getGroups($user),
138
-		] + $messageParameters + $languageParameters + $localeParameters;
139
-
140
-
141
-		return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, '');
142
-	}
143
-
144
-	/**
145
-	 * @return string the section ID, e.g. 'sharing'
146
-	 * @since 9.1
147
-	 */
148
-	public function getSection() {
149
-		return 'personal-info';
150
-	}
151
-
152
-	/**
153
-	 * @return int whether the form should be rather on the top or bottom of
154
-	 * the admin section. The forms are arranged in ascending order of the
155
-	 * priority values. It is required to return a value between 0 and 100.
156
-	 *
157
-	 * E.g.: 70
158
-	 * @since 9.1
159
-	 */
160
-	public function getPriority() {
161
-		return 10;
162
-	}
163
-
164
-	/**
165
-	 * returns a sorted list of the user's group GIDs
166
-	 *
167
-	 * @param IUser $user
168
-	 * @return array
169
-	 */
170
-	private function getGroups(IUser $user) {
171
-		$groups = array_map(
172
-			function(IGroup $group) {
173
-				return $group->getDisplayName();
174
-			},
175
-			$this->groupManager->getUserGroups($user)
176
-		);
177
-		sort($groups);
178
-
179
-		return $groups;
180
-	}
181
-
182
-	/**
183
-	 * returns the user language, common language and other languages in an
184
-	 * associative array
185
-	 *
186
-	 * @param IUser $user
187
-	 * @return array
188
-	 */
189
-	private function getLanguages(IUser $user) {
190
-		$forceLanguage = $this->config->getSystemValue('force_language', false);
191
-		if($forceLanguage !== false) {
192
-			return [];
193
-		}
194
-
195
-		$uid = $user->getUID();
196
-
197
-		$userConfLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
198
-		$languages = $this->l10nFactory->getLanguages();
199
-
200
-		// associate the user language with the proper array
201
-		$userLangIndex = array_search($userConfLang, array_column($languages['commonlanguages'], 'code'));
202
-		$userLang = $languages['commonlanguages'][$userLangIndex];
203
-		// search in the other languages
204
-		if ($userLangIndex === false) {
205
-			$userLangIndex = array_search($userConfLang, array_column($languages['languages'], 'code'));		
206
-			$userLang = $languages['languages'][$userLangIndex];
207
-		}
208
-		// if user language is not available but set somehow: show the actual code as name
209
-		if (!is_array($userLang)) {
210
-			$userLang = [
211
-				'code' => $userConfLang,
212
-				'name' => $userConfLang,
213
-			];
214
-		}
215
-
216
-		return array_merge(
217
-			array('activelanguage' => $userLang),
218
-			$languages
219
-		);
220
-	}
221
-
222
-	private function getLocales(IUser $user) {
223
-		$forceLanguage = $this->config->getSystemValue('force_locale', false);
224
-		if($forceLanguage !== false) {
225
-			return [];
226
-		}
227
-
228
-		$uid = $user->getUID();
229
-
230
-		$userLocaleString = $this->config->getUserValue($uid, 'core', 'locale', $this->l10nFactory->findLocale());
231
-
232
-		$userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
233
-
234
-		$localeCodes = $this->l10nFactory->findAvailableLocales();
235
-
236
-		$userLocale = array_filter($localeCodes, function($value) use ($userLocaleString) {
237
-			return $userLocaleString === $value['code'];
238
-		});
239
-
240
-		if (!empty($userLocale))
241
-		{
242
-			$userLocale = reset($userLocale);
243
-		}
244
-
245
-		$localesForLanguage = array_filter($localeCodes, function($localeCode) use ($userLang) {
246
-			return 0 === strpos($localeCode['code'], $userLang);
247
-		});
248
-
249
-		return [
250
-			'activelocaleLang' => $userLocaleString,
251
-			'activelocale' => $userLocale,
252
-			'locales' => $localeCodes,
253
-			'localesForLanguage' => $localesForLanguage,
254
-		];
255
-	}
256
-
257
-	/**
258
-	 * @param array $userData
259
-	 * @return array
260
-	 */
261
-	private function getMessageParameters(array $userData) {
262
-		$needVerifyMessage = [AccountManager::PROPERTY_EMAIL, AccountManager::PROPERTY_WEBSITE, AccountManager::PROPERTY_TWITTER];
263
-		$messageParameters = [];
264
-		foreach ($needVerifyMessage as $property) {
265
-			switch ($userData[$property]['verified']) {
266
-				case AccountManager::VERIFIED:
267
-					$message = $this->l->t('Verifying');
268
-					break;
269
-				case AccountManager::VERIFICATION_IN_PROGRESS:
270
-					$message = $this->l->t('Verifying …');
271
-					break;
272
-				default:
273
-					$message = $this->l->t('Verify');
274
-			}
275
-			$messageParameters[$property . 'Message'] = $message;
276
-		}
277
-		return $messageParameters;
278
-	}
44
+    /** @var IConfig */
45
+    private $config;
46
+    /** @var IUserManager */
47
+    private $userManager;
48
+    /** @var AccountManager */
49
+    private $accountManager;
50
+    /** @var IGroupManager */
51
+    private $groupManager;
52
+    /** @var IAppManager */
53
+    private $appManager;
54
+    /** @var IFactory */
55
+    private $l10nFactory;
56
+    /** @var IL10N */
57
+    private $l;
58
+
59
+    /**
60
+     * @param IConfig $config
61
+     * @param IUserManager $userManager
62
+     * @param IGroupManager $groupManager
63
+     * @param AccountManager $accountManager
64
+     * @param IFactory $l10nFactory
65
+     * @param IL10N $l
66
+     */
67
+    public function __construct(
68
+        IConfig $config,
69
+        IUserManager $userManager,
70
+        IGroupManager $groupManager,
71
+        AccountManager $accountManager,
72
+        IAppManager $appManager,
73
+        IFactory $l10nFactory,
74
+        IL10N $l
75
+    ) {
76
+        $this->config = $config;
77
+        $this->userManager = $userManager;
78
+        $this->accountManager = $accountManager;
79
+        $this->groupManager = $groupManager;
80
+        $this->appManager = $appManager;
81
+        $this->l10nFactory = $l10nFactory;
82
+        $this->l = $l;
83
+    }
84
+
85
+    /**
86
+     * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
87
+     * @since 9.1
88
+     */
89
+    public function getForm() {
90
+        $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
91
+        $lookupServerUploadEnabled = false;
92
+        if($federatedFileSharingEnabled) {
93
+            $federatedFileSharing = new Application();
94
+            $shareProvider = $federatedFileSharing->getFederatedShareProvider();
95
+            $lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled();
96
+        }
97
+
98
+        $uid = \OC_User::getUser();
99
+        $user = $this->userManager->get($uid);
100
+        $userData = $this->accountManager->getUser($user);
101
+
102
+        $storageInfo = \OC_Helper::getStorageInfo('/');
103
+        if ($storageInfo['quota'] === FileInfo::SPACE_UNLIMITED) {
104
+            $totalSpace = $this->l->t('Unlimited');
105
+        } else {
106
+            $totalSpace = \OC_Helper::humanFileSize($storageInfo['total']);
107
+        }
108
+
109
+        $languageParameters = $this->getLanguages($user);
110
+        $localeParameters = $this->getLocales($user);
111
+        $messageParameters = $this->getMessageParameters($userData);
112
+
113
+        $parameters = [
114
+            'total_space' => $totalSpace,
115
+            'usage' => \OC_Helper::humanFileSize($storageInfo['used']),
116
+            'usage_relative' => round($storageInfo['relative']),
117
+            'quota' => $storageInfo['quota'],
118
+            'avatarChangeSupported' => $user->canChangeAvatar(),
119
+            'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
120
+            'avatarScope' => $userData[AccountManager::PROPERTY_AVATAR]['scope'],
121
+            'displayNameChangeSupported' => $user->canChangeDisplayName(),
122
+            'displayName' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'],
123
+            'displayNameScope' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['scope'],
124
+            'email' => $userData[AccountManager::PROPERTY_EMAIL]['value'],
125
+            'emailScope' => $userData[AccountManager::PROPERTY_EMAIL]['scope'],
126
+            'emailVerification' => $userData[AccountManager::PROPERTY_EMAIL]['verified'],
127
+            'phone' => $userData[AccountManager::PROPERTY_PHONE]['value'],
128
+            'phoneScope' => $userData[AccountManager::PROPERTY_PHONE]['scope'],
129
+            'address' => $userData[AccountManager::PROPERTY_ADDRESS]['value'],
130
+            'addressScope' => $userData[AccountManager::PROPERTY_ADDRESS]['scope'],
131
+            'website' =>  $userData[AccountManager::PROPERTY_WEBSITE]['value'],
132
+            'websiteScope' =>  $userData[AccountManager::PROPERTY_WEBSITE]['scope'],
133
+            'websiteVerification' => $userData[AccountManager::PROPERTY_WEBSITE]['verified'],
134
+            'twitter' => $userData[AccountManager::PROPERTY_TWITTER]['value'],
135
+            'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'],
136
+            'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'],
137
+            'groups' => $this->getGroups($user),
138
+        ] + $messageParameters + $languageParameters + $localeParameters;
139
+
140
+
141
+        return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, '');
142
+    }
143
+
144
+    /**
145
+     * @return string the section ID, e.g. 'sharing'
146
+     * @since 9.1
147
+     */
148
+    public function getSection() {
149
+        return 'personal-info';
150
+    }
151
+
152
+    /**
153
+     * @return int whether the form should be rather on the top or bottom of
154
+     * the admin section. The forms are arranged in ascending order of the
155
+     * priority values. It is required to return a value between 0 and 100.
156
+     *
157
+     * E.g.: 70
158
+     * @since 9.1
159
+     */
160
+    public function getPriority() {
161
+        return 10;
162
+    }
163
+
164
+    /**
165
+     * returns a sorted list of the user's group GIDs
166
+     *
167
+     * @param IUser $user
168
+     * @return array
169
+     */
170
+    private function getGroups(IUser $user) {
171
+        $groups = array_map(
172
+            function(IGroup $group) {
173
+                return $group->getDisplayName();
174
+            },
175
+            $this->groupManager->getUserGroups($user)
176
+        );
177
+        sort($groups);
178
+
179
+        return $groups;
180
+    }
181
+
182
+    /**
183
+     * returns the user language, common language and other languages in an
184
+     * associative array
185
+     *
186
+     * @param IUser $user
187
+     * @return array
188
+     */
189
+    private function getLanguages(IUser $user) {
190
+        $forceLanguage = $this->config->getSystemValue('force_language', false);
191
+        if($forceLanguage !== false) {
192
+            return [];
193
+        }
194
+
195
+        $uid = $user->getUID();
196
+
197
+        $userConfLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
198
+        $languages = $this->l10nFactory->getLanguages();
199
+
200
+        // associate the user language with the proper array
201
+        $userLangIndex = array_search($userConfLang, array_column($languages['commonlanguages'], 'code'));
202
+        $userLang = $languages['commonlanguages'][$userLangIndex];
203
+        // search in the other languages
204
+        if ($userLangIndex === false) {
205
+            $userLangIndex = array_search($userConfLang, array_column($languages['languages'], 'code'));		
206
+            $userLang = $languages['languages'][$userLangIndex];
207
+        }
208
+        // if user language is not available but set somehow: show the actual code as name
209
+        if (!is_array($userLang)) {
210
+            $userLang = [
211
+                'code' => $userConfLang,
212
+                'name' => $userConfLang,
213
+            ];
214
+        }
215
+
216
+        return array_merge(
217
+            array('activelanguage' => $userLang),
218
+            $languages
219
+        );
220
+    }
221
+
222
+    private function getLocales(IUser $user) {
223
+        $forceLanguage = $this->config->getSystemValue('force_locale', false);
224
+        if($forceLanguage !== false) {
225
+            return [];
226
+        }
227
+
228
+        $uid = $user->getUID();
229
+
230
+        $userLocaleString = $this->config->getUserValue($uid, 'core', 'locale', $this->l10nFactory->findLocale());
231
+
232
+        $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
233
+
234
+        $localeCodes = $this->l10nFactory->findAvailableLocales();
235
+
236
+        $userLocale = array_filter($localeCodes, function($value) use ($userLocaleString) {
237
+            return $userLocaleString === $value['code'];
238
+        });
239
+
240
+        if (!empty($userLocale))
241
+        {
242
+            $userLocale = reset($userLocale);
243
+        }
244
+
245
+        $localesForLanguage = array_filter($localeCodes, function($localeCode) use ($userLang) {
246
+            return 0 === strpos($localeCode['code'], $userLang);
247
+        });
248
+
249
+        return [
250
+            'activelocaleLang' => $userLocaleString,
251
+            'activelocale' => $userLocale,
252
+            'locales' => $localeCodes,
253
+            'localesForLanguage' => $localesForLanguage,
254
+        ];
255
+    }
256
+
257
+    /**
258
+     * @param array $userData
259
+     * @return array
260
+     */
261
+    private function getMessageParameters(array $userData) {
262
+        $needVerifyMessage = [AccountManager::PROPERTY_EMAIL, AccountManager::PROPERTY_WEBSITE, AccountManager::PROPERTY_TWITTER];
263
+        $messageParameters = [];
264
+        foreach ($needVerifyMessage as $property) {
265
+            switch ($userData[$property]['verified']) {
266
+                case AccountManager::VERIFIED:
267
+                    $message = $this->l->t('Verifying');
268
+                    break;
269
+                case AccountManager::VERIFICATION_IN_PROGRESS:
270
+                    $message = $this->l->t('Verifying …');
271
+                    break;
272
+                default:
273
+                    $message = $this->l->t('Verify');
274
+            }
275
+            $messageParameters[$property . 'Message'] = $message;
276
+        }
277
+        return $messageParameters;
278
+    }
279 279
 
280 280
 }
Please login to merge, or discard this patch.