@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | /** @var array $_ */ |
27 | 27 | |
28 | 28 | script('settings', [ |
29 | - 'usersettings', |
|
30 | - 'templates', |
|
31 | - 'federationsettingsview', |
|
32 | - 'federationscopemenu', |
|
33 | - 'settings/personalInfo', |
|
34 | - 'vue-settings-personal-info', |
|
29 | + 'usersettings', |
|
30 | + 'templates', |
|
31 | + 'federationsettingsview', |
|
32 | + 'federationscopemenu', |
|
33 | + 'settings/personalInfo', |
|
34 | + 'vue-settings-personal-info', |
|
35 | 35 | ]); |
36 | 36 | ?> |
37 | 37 | |
@@ -85,10 +85,10 @@ discard block |
||
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> |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | </h3> |
111 | 111 | <input type="text" id="displayname" name="displayname" |
112 | 112 | <?php if (!$_['displayNameChangeSupported']) { |
113 | - print_unescaped('class="hidden"'); |
|
114 | - } ?> |
|
113 | + print_unescaped('class="hidden"'); |
|
114 | + } ?> |
|
115 | 115 | value="<?php p($_['displayName']) ?>" |
116 | 116 | autocomplete="on" autocapitalize="none" autocorrect="off" /> |
117 | 117 | <?php if (!$_['displayNameChangeSupported']) { ?> |
118 | 118 | <span><?php if (isset($_['displayName']) && !empty($_['displayName'])) { |
119 | - p($_['displayName']); |
|
120 | - } else { |
|
121 | - p($l->t('No display name set')); |
|
122 | - } ?></span> |
|
119 | + p($_['displayName']); |
|
120 | + } else { |
|
121 | + p($l->t('No display name set')); |
|
122 | + } ?></span> |
|
123 | 123 | <?php } ?> |
124 | 124 | <span class="icon-checkmark hidden"></span> |
125 | 125 | <span class="icon-error hidden" ></span> |
@@ -179,24 +179,24 @@ discard block |
||
179 | 179 | </h3> |
180 | 180 | <?php if ($_['lookupServerUploadEnabled']) { ?> |
181 | 181 | <div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') { |
182 | - p('hidden'); |
|
183 | - } ?>"> |
|
182 | + p('hidden'); |
|
183 | + } ?>"> |
|
184 | 184 | <img id="verify-website" title="<?php p($_['websiteMessage']); ?>" data-status="<?php p($_['websiteVerification']) ?>" src=" |
185 | 185 | <?php |
186 | - switch ($_['websiteVerification']) { |
|
187 | - case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
188 | - p(image_path('core', 'actions/verifying.svg')); |
|
189 | - break; |
|
190 | - case \OC\Accounts\AccountManager::VERIFIED: |
|
191 | - p(image_path('core', 'actions/verified.svg')); |
|
192 | - break; |
|
193 | - default: |
|
194 | - p(image_path('core', 'actions/verify.svg')); |
|
195 | - } |
|
196 | - ?>" |
|
186 | + switch ($_['websiteVerification']) { |
|
187 | + case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
188 | + p(image_path('core', 'actions/verifying.svg')); |
|
189 | + break; |
|
190 | + case \OC\Accounts\AccountManager::VERIFIED: |
|
191 | + p(image_path('core', 'actions/verified.svg')); |
|
192 | + break; |
|
193 | + default: |
|
194 | + p(image_path('core', 'actions/verify.svg')); |
|
195 | + } |
|
196 | + ?>" |
|
197 | 197 | <?php if ($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) { |
198 | - print_unescaped(' class="verify-action"'); |
|
199 | - } ?> |
|
198 | + print_unescaped(' class="verify-action"'); |
|
199 | + } ?> |
|
200 | 200 | > |
201 | 201 | <div class="verification-dialog popovermenu bubble menu"> |
202 | 202 | <div class="verification-dialog-content"> |
@@ -228,24 +228,24 @@ discard block |
||
228 | 228 | </h3> |
229 | 229 | <?php if ($_['lookupServerUploadEnabled']) { ?> |
230 | 230 | <div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') { |
231 | - p('hidden'); |
|
232 | - } ?>"> |
|
231 | + p('hidden'); |
|
232 | + } ?>"> |
|
233 | 233 | <img id="verify-twitter" title="<?php p($_['twitterMessage']); ?>" data-status="<?php p($_['twitterVerification']) ?>" src=" |
234 | 234 | <?php |
235 | - switch ($_['twitterVerification']) { |
|
236 | - case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
237 | - p(image_path('core', 'actions/verifying.svg')); |
|
238 | - break; |
|
239 | - case \OC\Accounts\AccountManager::VERIFIED: |
|
240 | - p(image_path('core', 'actions/verified.svg')); |
|
241 | - break; |
|
242 | - default: |
|
243 | - p(image_path('core', 'actions/verify.svg')); |
|
244 | - } |
|
245 | - ?>" |
|
235 | + switch ($_['twitterVerification']) { |
|
236 | + case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS: |
|
237 | + p(image_path('core', 'actions/verifying.svg')); |
|
238 | + break; |
|
239 | + case \OC\Accounts\AccountManager::VERIFIED: |
|
240 | + p(image_path('core', 'actions/verified.svg')); |
|
241 | + break; |
|
242 | + default: |
|
243 | + p(image_path('core', 'actions/verify.svg')); |
|
244 | + } |
|
245 | + ?>" |
|
246 | 246 | <?php if ($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) { |
247 | - print_unescaped(' class="verify-action"'); |
|
248 | - } ?> |
|
247 | + print_unescaped(' class="verify-action"'); |
|
248 | + } ?> |
|
249 | 249 | > |
250 | 250 | <div class="verification-dialog popovermenu bubble menu"> |
251 | 251 | <div class="verification-dialog-content"> |
@@ -54,281 +54,281 @@ |
||
54 | 54 | |
55 | 55 | class PersonalInfo implements ISettings { |
56 | 56 | |
57 | - /** @var IConfig */ |
|
58 | - private $config; |
|
59 | - /** @var IUserManager */ |
|
60 | - private $userManager; |
|
61 | - /** @var IAccountManager */ |
|
62 | - private $accountManager; |
|
63 | - /** @var IGroupManager */ |
|
64 | - private $groupManager; |
|
65 | - /** @var IAppManager */ |
|
66 | - private $appManager; |
|
67 | - /** @var IFactory */ |
|
68 | - private $l10nFactory; |
|
69 | - /** @var IL10N */ |
|
70 | - private $l; |
|
71 | - /** @var IInitialState */ |
|
72 | - private $initialStateService; |
|
73 | - |
|
74 | - public function __construct( |
|
75 | - IConfig $config, |
|
76 | - IUserManager $userManager, |
|
77 | - IGroupManager $groupManager, |
|
78 | - IAccountManager $accountManager, |
|
79 | - IAppManager $appManager, |
|
80 | - IFactory $l10nFactory, |
|
81 | - IL10N $l, |
|
82 | - IInitialState $initialStateService |
|
83 | - ) { |
|
84 | - $this->config = $config; |
|
85 | - $this->userManager = $userManager; |
|
86 | - $this->accountManager = $accountManager; |
|
87 | - $this->groupManager = $groupManager; |
|
88 | - $this->appManager = $appManager; |
|
89 | - $this->l10nFactory = $l10nFactory; |
|
90 | - $this->l = $l; |
|
91 | - $this->initialStateService = $initialStateService; |
|
92 | - } |
|
93 | - |
|
94 | - public function getForm(): TemplateResponse { |
|
95 | - $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing'); |
|
96 | - $lookupServerUploadEnabled = false; |
|
97 | - if ($federatedFileSharingEnabled) { |
|
98 | - /** @var FederatedShareProvider $shareProvider */ |
|
99 | - $shareProvider = \OC::$server->query(FederatedShareProvider::class); |
|
100 | - $lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled(); |
|
101 | - } |
|
102 | - |
|
103 | - $uid = \OC_User::getUser(); |
|
104 | - $user = $this->userManager->get($uid); |
|
105 | - $account = $this->accountManager->getAccount($user); |
|
106 | - |
|
107 | - // make sure FS is setup before querying storage related stuff... |
|
108 | - \OC_Util::setupFS($user->getUID()); |
|
109 | - |
|
110 | - $storageInfo = \OC_Helper::getStorageInfo('/'); |
|
111 | - if ($storageInfo['quota'] === FileInfo::SPACE_UNLIMITED) { |
|
112 | - $totalSpace = $this->l->t('Unlimited'); |
|
113 | - } else { |
|
114 | - $totalSpace = \OC_Helper::humanFileSize($storageInfo['total']); |
|
115 | - } |
|
116 | - |
|
117 | - $languageParameters = $this->getLanguages($user); |
|
118 | - $localeParameters = $this->getLocales($user); |
|
119 | - $messageParameters = $this->getMessageParameters($account); |
|
120 | - |
|
121 | - $parameters = [ |
|
122 | - 'total_space' => $totalSpace, |
|
123 | - 'usage' => \OC_Helper::humanFileSize($storageInfo['used']), |
|
124 | - 'usage_relative' => round($storageInfo['relative']), |
|
125 | - 'quota' => $storageInfo['quota'], |
|
126 | - 'avatarChangeSupported' => $user->canChangeAvatar(), |
|
127 | - 'lookupServerUploadEnabled' => $lookupServerUploadEnabled, |
|
128 | - 'avatarScope' => $account->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope(), |
|
129 | - 'displayNameChangeSupported' => $user->canChangeDisplayName(), |
|
130 | - 'displayName' => $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME)->getValue(), |
|
131 | - 'displayNameScope' => $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME)->getScope(), |
|
132 | - 'email' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue(), |
|
133 | - 'emailScope' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getScope(), |
|
134 | - 'emailVerification' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getVerified(), |
|
135 | - 'phone' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getValue(), |
|
136 | - 'phoneScope' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getScope(), |
|
137 | - 'address' => $account->getProperty(IAccountManager::PROPERTY_ADDRESS)->getValue(), |
|
138 | - 'addressScope' => $account->getProperty(IAccountManager::PROPERTY_ADDRESS)->getScope(), |
|
139 | - 'website' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getValue(), |
|
140 | - 'websiteScope' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getScope(), |
|
141 | - 'websiteVerification' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getVerified(), |
|
142 | - 'twitter' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getValue(), |
|
143 | - 'twitterScope' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getScope(), |
|
144 | - 'twitterVerification' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getVerified(), |
|
145 | - 'groups' => $this->getGroups($user), |
|
146 | - ] + $messageParameters + $languageParameters + $localeParameters; |
|
147 | - |
|
148 | - $emails = $this->getEmails($account); |
|
149 | - |
|
150 | - $accountParameters = [ |
|
151 | - 'displayNameChangeSupported' => $user->canChangeDisplayName(), |
|
152 | - ]; |
|
153 | - |
|
154 | - $this->initialStateService->provideInitialState('emails', $emails); |
|
155 | - $this->initialStateService->provideInitialState('accountParameters', $accountParameters); |
|
156 | - |
|
157 | - return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, ''); |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * @return string the section ID, e.g. 'sharing' |
|
162 | - * @since 9.1 |
|
163 | - */ |
|
164 | - public function getSection(): string { |
|
165 | - return 'personal-info'; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * @return int whether the form should be rather on the top or bottom of |
|
170 | - * the admin section. The forms are arranged in ascending order of the |
|
171 | - * priority values. It is required to return a value between 0 and 100. |
|
172 | - * |
|
173 | - * E.g.: 70 |
|
174 | - * @since 9.1 |
|
175 | - */ |
|
176 | - public function getPriority(): int { |
|
177 | - return 10; |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * returns a sorted list of the user's group GIDs |
|
182 | - * |
|
183 | - * @param IUser $user |
|
184 | - * @return array |
|
185 | - */ |
|
186 | - private function getGroups(IUser $user): array { |
|
187 | - $groups = array_map( |
|
188 | - static function (IGroup $group) { |
|
189 | - return $group->getDisplayName(); |
|
190 | - }, |
|
191 | - $this->groupManager->getUserGroups($user) |
|
192 | - ); |
|
193 | - sort($groups); |
|
194 | - |
|
195 | - return $groups; |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * returns the primary email and additional emails in an |
|
200 | - * associative array |
|
201 | - * |
|
202 | - * @param IAccount $account |
|
203 | - * @return array |
|
204 | - */ |
|
205 | - private function getEmails(IAccount $account): array { |
|
206 | - $primaryEmail = [ |
|
207 | - 'value' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue(), |
|
208 | - 'scope' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getScope(), |
|
209 | - 'verified' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getVerified(), |
|
210 | - ]; |
|
211 | - |
|
212 | - $additionalEmails = array_map( |
|
213 | - function (IAccountProperty $property) { |
|
214 | - return [ |
|
215 | - 'value' => $property->getValue(), |
|
216 | - 'scope' => $property->getScope(), |
|
217 | - 'verified' => $property->getVerified(), |
|
218 | - ]; |
|
219 | - }, |
|
220 | - $account->getPropertyCollection(IAccountManager::COLLECTION_EMAIL)->getProperties() |
|
221 | - ); |
|
222 | - |
|
223 | - $emails = [ |
|
224 | - 'primaryEmail' => $primaryEmail, |
|
225 | - 'additionalEmails' => $additionalEmails, |
|
226 | - ]; |
|
227 | - |
|
228 | - return $emails; |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * returns the user language, common language and other languages in an |
|
233 | - * associative array |
|
234 | - * |
|
235 | - * @param IUser $user |
|
236 | - * @return array |
|
237 | - */ |
|
238 | - private function getLanguages(IUser $user): array { |
|
239 | - $forceLanguage = $this->config->getSystemValue('force_language', false); |
|
240 | - if ($forceLanguage !== false) { |
|
241 | - return []; |
|
242 | - } |
|
243 | - |
|
244 | - $uid = $user->getUID(); |
|
245 | - |
|
246 | - $userConfLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); |
|
247 | - $languages = $this->l10nFactory->getLanguages(); |
|
248 | - |
|
249 | - // associate the user language with the proper array |
|
250 | - $userLangIndex = array_search($userConfLang, array_column($languages['commonlanguages'], 'code')); |
|
251 | - $userLang = $languages['commonlanguages'][$userLangIndex]; |
|
252 | - // search in the other languages |
|
253 | - if ($userLangIndex === false) { |
|
254 | - $userLangIndex = array_search($userConfLang, array_column($languages['languages'], 'code')); |
|
255 | - $userLang = $languages['languages'][$userLangIndex]; |
|
256 | - } |
|
257 | - // if user language is not available but set somehow: show the actual code as name |
|
258 | - if (!is_array($userLang)) { |
|
259 | - $userLang = [ |
|
260 | - 'code' => $userConfLang, |
|
261 | - 'name' => $userConfLang, |
|
262 | - ]; |
|
263 | - } |
|
264 | - |
|
265 | - return array_merge( |
|
266 | - ['activelanguage' => $userLang], |
|
267 | - $languages |
|
268 | - ); |
|
269 | - } |
|
270 | - |
|
271 | - private function getLocales(IUser $user): array { |
|
272 | - $forceLanguage = $this->config->getSystemValue('force_locale', false); |
|
273 | - if ($forceLanguage !== false) { |
|
274 | - return []; |
|
275 | - } |
|
276 | - |
|
277 | - $uid = $user->getUID(); |
|
278 | - |
|
279 | - $userLocaleString = $this->config->getUserValue($uid, 'core', 'locale', $this->l10nFactory->findLocale()); |
|
280 | - |
|
281 | - $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); |
|
282 | - |
|
283 | - $localeCodes = $this->l10nFactory->findAvailableLocales(); |
|
284 | - |
|
285 | - $userLocale = array_filter($localeCodes, function ($value) use ($userLocaleString) { |
|
286 | - return $userLocaleString === $value['code']; |
|
287 | - }); |
|
288 | - |
|
289 | - if (!empty($userLocale)) { |
|
290 | - $userLocale = reset($userLocale); |
|
291 | - } |
|
292 | - |
|
293 | - $localesForLanguage = array_filter($localeCodes, function ($localeCode) use ($userLang) { |
|
294 | - return 0 === strpos($localeCode['code'], $userLang); |
|
295 | - }); |
|
296 | - |
|
297 | - if (!$userLocale) { |
|
298 | - $userLocale = [ |
|
299 | - 'code' => 'en', |
|
300 | - 'name' => 'English' |
|
301 | - ]; |
|
302 | - } |
|
303 | - |
|
304 | - return [ |
|
305 | - 'activelocaleLang' => $userLocaleString, |
|
306 | - 'activelocale' => $userLocale, |
|
307 | - 'locales' => $localeCodes, |
|
308 | - 'localesForLanguage' => $localesForLanguage, |
|
309 | - ]; |
|
310 | - } |
|
311 | - |
|
312 | - /** |
|
313 | - * @param IAccount $account |
|
314 | - * @return array |
|
315 | - */ |
|
316 | - private function getMessageParameters(IAccount $account): array { |
|
317 | - $needVerifyMessage = [IAccountManager::PROPERTY_EMAIL, IAccountManager::PROPERTY_WEBSITE, IAccountManager::PROPERTY_TWITTER]; |
|
318 | - $messageParameters = []; |
|
319 | - foreach ($needVerifyMessage as $property) { |
|
320 | - switch ($account->getProperty($property)->getVerified()) { |
|
321 | - case IAccountManager::VERIFIED: |
|
322 | - $message = $this->l->t('Verifying'); |
|
323 | - break; |
|
324 | - case IAccountManager::VERIFICATION_IN_PROGRESS: |
|
325 | - $message = $this->l->t('Verifying …'); |
|
326 | - break; |
|
327 | - default: |
|
328 | - $message = $this->l->t('Verify'); |
|
329 | - } |
|
330 | - $messageParameters[$property . 'Message'] = $message; |
|
331 | - } |
|
332 | - return $messageParameters; |
|
333 | - } |
|
57 | + /** @var IConfig */ |
|
58 | + private $config; |
|
59 | + /** @var IUserManager */ |
|
60 | + private $userManager; |
|
61 | + /** @var IAccountManager */ |
|
62 | + private $accountManager; |
|
63 | + /** @var IGroupManager */ |
|
64 | + private $groupManager; |
|
65 | + /** @var IAppManager */ |
|
66 | + private $appManager; |
|
67 | + /** @var IFactory */ |
|
68 | + private $l10nFactory; |
|
69 | + /** @var IL10N */ |
|
70 | + private $l; |
|
71 | + /** @var IInitialState */ |
|
72 | + private $initialStateService; |
|
73 | + |
|
74 | + public function __construct( |
|
75 | + IConfig $config, |
|
76 | + IUserManager $userManager, |
|
77 | + IGroupManager $groupManager, |
|
78 | + IAccountManager $accountManager, |
|
79 | + IAppManager $appManager, |
|
80 | + IFactory $l10nFactory, |
|
81 | + IL10N $l, |
|
82 | + IInitialState $initialStateService |
|
83 | + ) { |
|
84 | + $this->config = $config; |
|
85 | + $this->userManager = $userManager; |
|
86 | + $this->accountManager = $accountManager; |
|
87 | + $this->groupManager = $groupManager; |
|
88 | + $this->appManager = $appManager; |
|
89 | + $this->l10nFactory = $l10nFactory; |
|
90 | + $this->l = $l; |
|
91 | + $this->initialStateService = $initialStateService; |
|
92 | + } |
|
93 | + |
|
94 | + public function getForm(): TemplateResponse { |
|
95 | + $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing'); |
|
96 | + $lookupServerUploadEnabled = false; |
|
97 | + if ($federatedFileSharingEnabled) { |
|
98 | + /** @var FederatedShareProvider $shareProvider */ |
|
99 | + $shareProvider = \OC::$server->query(FederatedShareProvider::class); |
|
100 | + $lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled(); |
|
101 | + } |
|
102 | + |
|
103 | + $uid = \OC_User::getUser(); |
|
104 | + $user = $this->userManager->get($uid); |
|
105 | + $account = $this->accountManager->getAccount($user); |
|
106 | + |
|
107 | + // make sure FS is setup before querying storage related stuff... |
|
108 | + \OC_Util::setupFS($user->getUID()); |
|
109 | + |
|
110 | + $storageInfo = \OC_Helper::getStorageInfo('/'); |
|
111 | + if ($storageInfo['quota'] === FileInfo::SPACE_UNLIMITED) { |
|
112 | + $totalSpace = $this->l->t('Unlimited'); |
|
113 | + } else { |
|
114 | + $totalSpace = \OC_Helper::humanFileSize($storageInfo['total']); |
|
115 | + } |
|
116 | + |
|
117 | + $languageParameters = $this->getLanguages($user); |
|
118 | + $localeParameters = $this->getLocales($user); |
|
119 | + $messageParameters = $this->getMessageParameters($account); |
|
120 | + |
|
121 | + $parameters = [ |
|
122 | + 'total_space' => $totalSpace, |
|
123 | + 'usage' => \OC_Helper::humanFileSize($storageInfo['used']), |
|
124 | + 'usage_relative' => round($storageInfo['relative']), |
|
125 | + 'quota' => $storageInfo['quota'], |
|
126 | + 'avatarChangeSupported' => $user->canChangeAvatar(), |
|
127 | + 'lookupServerUploadEnabled' => $lookupServerUploadEnabled, |
|
128 | + 'avatarScope' => $account->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope(), |
|
129 | + 'displayNameChangeSupported' => $user->canChangeDisplayName(), |
|
130 | + 'displayName' => $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME)->getValue(), |
|
131 | + 'displayNameScope' => $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME)->getScope(), |
|
132 | + 'email' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue(), |
|
133 | + 'emailScope' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getScope(), |
|
134 | + 'emailVerification' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getVerified(), |
|
135 | + 'phone' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getValue(), |
|
136 | + 'phoneScope' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getScope(), |
|
137 | + 'address' => $account->getProperty(IAccountManager::PROPERTY_ADDRESS)->getValue(), |
|
138 | + 'addressScope' => $account->getProperty(IAccountManager::PROPERTY_ADDRESS)->getScope(), |
|
139 | + 'website' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getValue(), |
|
140 | + 'websiteScope' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getScope(), |
|
141 | + 'websiteVerification' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getVerified(), |
|
142 | + 'twitter' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getValue(), |
|
143 | + 'twitterScope' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getScope(), |
|
144 | + 'twitterVerification' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getVerified(), |
|
145 | + 'groups' => $this->getGroups($user), |
|
146 | + ] + $messageParameters + $languageParameters + $localeParameters; |
|
147 | + |
|
148 | + $emails = $this->getEmails($account); |
|
149 | + |
|
150 | + $accountParameters = [ |
|
151 | + 'displayNameChangeSupported' => $user->canChangeDisplayName(), |
|
152 | + ]; |
|
153 | + |
|
154 | + $this->initialStateService->provideInitialState('emails', $emails); |
|
155 | + $this->initialStateService->provideInitialState('accountParameters', $accountParameters); |
|
156 | + |
|
157 | + return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, ''); |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * @return string the section ID, e.g. 'sharing' |
|
162 | + * @since 9.1 |
|
163 | + */ |
|
164 | + public function getSection(): string { |
|
165 | + return 'personal-info'; |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * @return int whether the form should be rather on the top or bottom of |
|
170 | + * the admin section. The forms are arranged in ascending order of the |
|
171 | + * priority values. It is required to return a value between 0 and 100. |
|
172 | + * |
|
173 | + * E.g.: 70 |
|
174 | + * @since 9.1 |
|
175 | + */ |
|
176 | + public function getPriority(): int { |
|
177 | + return 10; |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * returns a sorted list of the user's group GIDs |
|
182 | + * |
|
183 | + * @param IUser $user |
|
184 | + * @return array |
|
185 | + */ |
|
186 | + private function getGroups(IUser $user): array { |
|
187 | + $groups = array_map( |
|
188 | + static function (IGroup $group) { |
|
189 | + return $group->getDisplayName(); |
|
190 | + }, |
|
191 | + $this->groupManager->getUserGroups($user) |
|
192 | + ); |
|
193 | + sort($groups); |
|
194 | + |
|
195 | + return $groups; |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * returns the primary email and additional emails in an |
|
200 | + * associative array |
|
201 | + * |
|
202 | + * @param IAccount $account |
|
203 | + * @return array |
|
204 | + */ |
|
205 | + private function getEmails(IAccount $account): array { |
|
206 | + $primaryEmail = [ |
|
207 | + 'value' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue(), |
|
208 | + 'scope' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getScope(), |
|
209 | + 'verified' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getVerified(), |
|
210 | + ]; |
|
211 | + |
|
212 | + $additionalEmails = array_map( |
|
213 | + function (IAccountProperty $property) { |
|
214 | + return [ |
|
215 | + 'value' => $property->getValue(), |
|
216 | + 'scope' => $property->getScope(), |
|
217 | + 'verified' => $property->getVerified(), |
|
218 | + ]; |
|
219 | + }, |
|
220 | + $account->getPropertyCollection(IAccountManager::COLLECTION_EMAIL)->getProperties() |
|
221 | + ); |
|
222 | + |
|
223 | + $emails = [ |
|
224 | + 'primaryEmail' => $primaryEmail, |
|
225 | + 'additionalEmails' => $additionalEmails, |
|
226 | + ]; |
|
227 | + |
|
228 | + return $emails; |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * returns the user language, common language and other languages in an |
|
233 | + * associative array |
|
234 | + * |
|
235 | + * @param IUser $user |
|
236 | + * @return array |
|
237 | + */ |
|
238 | + private function getLanguages(IUser $user): array { |
|
239 | + $forceLanguage = $this->config->getSystemValue('force_language', false); |
|
240 | + if ($forceLanguage !== false) { |
|
241 | + return []; |
|
242 | + } |
|
243 | + |
|
244 | + $uid = $user->getUID(); |
|
245 | + |
|
246 | + $userConfLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); |
|
247 | + $languages = $this->l10nFactory->getLanguages(); |
|
248 | + |
|
249 | + // associate the user language with the proper array |
|
250 | + $userLangIndex = array_search($userConfLang, array_column($languages['commonlanguages'], 'code')); |
|
251 | + $userLang = $languages['commonlanguages'][$userLangIndex]; |
|
252 | + // search in the other languages |
|
253 | + if ($userLangIndex === false) { |
|
254 | + $userLangIndex = array_search($userConfLang, array_column($languages['languages'], 'code')); |
|
255 | + $userLang = $languages['languages'][$userLangIndex]; |
|
256 | + } |
|
257 | + // if user language is not available but set somehow: show the actual code as name |
|
258 | + if (!is_array($userLang)) { |
|
259 | + $userLang = [ |
|
260 | + 'code' => $userConfLang, |
|
261 | + 'name' => $userConfLang, |
|
262 | + ]; |
|
263 | + } |
|
264 | + |
|
265 | + return array_merge( |
|
266 | + ['activelanguage' => $userLang], |
|
267 | + $languages |
|
268 | + ); |
|
269 | + } |
|
270 | + |
|
271 | + private function getLocales(IUser $user): array { |
|
272 | + $forceLanguage = $this->config->getSystemValue('force_locale', false); |
|
273 | + if ($forceLanguage !== false) { |
|
274 | + return []; |
|
275 | + } |
|
276 | + |
|
277 | + $uid = $user->getUID(); |
|
278 | + |
|
279 | + $userLocaleString = $this->config->getUserValue($uid, 'core', 'locale', $this->l10nFactory->findLocale()); |
|
280 | + |
|
281 | + $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); |
|
282 | + |
|
283 | + $localeCodes = $this->l10nFactory->findAvailableLocales(); |
|
284 | + |
|
285 | + $userLocale = array_filter($localeCodes, function ($value) use ($userLocaleString) { |
|
286 | + return $userLocaleString === $value['code']; |
|
287 | + }); |
|
288 | + |
|
289 | + if (!empty($userLocale)) { |
|
290 | + $userLocale = reset($userLocale); |
|
291 | + } |
|
292 | + |
|
293 | + $localesForLanguage = array_filter($localeCodes, function ($localeCode) use ($userLang) { |
|
294 | + return 0 === strpos($localeCode['code'], $userLang); |
|
295 | + }); |
|
296 | + |
|
297 | + if (!$userLocale) { |
|
298 | + $userLocale = [ |
|
299 | + 'code' => 'en', |
|
300 | + 'name' => 'English' |
|
301 | + ]; |
|
302 | + } |
|
303 | + |
|
304 | + return [ |
|
305 | + 'activelocaleLang' => $userLocaleString, |
|
306 | + 'activelocale' => $userLocale, |
|
307 | + 'locales' => $localeCodes, |
|
308 | + 'localesForLanguage' => $localesForLanguage, |
|
309 | + ]; |
|
310 | + } |
|
311 | + |
|
312 | + /** |
|
313 | + * @param IAccount $account |
|
314 | + * @return array |
|
315 | + */ |
|
316 | + private function getMessageParameters(IAccount $account): array { |
|
317 | + $needVerifyMessage = [IAccountManager::PROPERTY_EMAIL, IAccountManager::PROPERTY_WEBSITE, IAccountManager::PROPERTY_TWITTER]; |
|
318 | + $messageParameters = []; |
|
319 | + foreach ($needVerifyMessage as $property) { |
|
320 | + switch ($account->getProperty($property)->getVerified()) { |
|
321 | + case IAccountManager::VERIFIED: |
|
322 | + $message = $this->l->t('Verifying'); |
|
323 | + break; |
|
324 | + case IAccountManager::VERIFICATION_IN_PROGRESS: |
|
325 | + $message = $this->l->t('Verifying …'); |
|
326 | + break; |
|
327 | + default: |
|
328 | + $message = $this->l->t('Verify'); |
|
329 | + } |
|
330 | + $messageParameters[$property . 'Message'] = $message; |
|
331 | + } |
|
332 | + return $messageParameters; |
|
333 | + } |
|
334 | 334 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | private function getGroups(IUser $user): array { |
187 | 187 | $groups = array_map( |
188 | - static function (IGroup $group) { |
|
188 | + static function(IGroup $group) { |
|
189 | 189 | return $group->getDisplayName(); |
190 | 190 | }, |
191 | 191 | $this->groupManager->getUserGroups($user) |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | ]; |
211 | 211 | |
212 | 212 | $additionalEmails = array_map( |
213 | - function (IAccountProperty $property) { |
|
213 | + function(IAccountProperty $property) { |
|
214 | 214 | return [ |
215 | 215 | 'value' => $property->getValue(), |
216 | 216 | 'scope' => $property->getScope(), |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | $localeCodes = $this->l10nFactory->findAvailableLocales(); |
284 | 284 | |
285 | - $userLocale = array_filter($localeCodes, function ($value) use ($userLocaleString) { |
|
285 | + $userLocale = array_filter($localeCodes, function($value) use ($userLocaleString) { |
|
286 | 286 | return $userLocaleString === $value['code']; |
287 | 287 | }); |
288 | 288 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $userLocale = reset($userLocale); |
291 | 291 | } |
292 | 292 | |
293 | - $localesForLanguage = array_filter($localeCodes, function ($localeCode) use ($userLang) { |
|
293 | + $localesForLanguage = array_filter($localeCodes, function($localeCode) use ($userLang) { |
|
294 | 294 | return 0 === strpos($localeCode['code'], $userLang); |
295 | 295 | }); |
296 | 296 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | default: |
328 | 328 | $message = $this->l->t('Verify'); |
329 | 329 | } |
330 | - $messageParameters[$property . 'Message'] = $message; |
|
330 | + $messageParameters[$property.'Message'] = $message; |
|
331 | 331 | } |
332 | 332 | return $messageParameters; |
333 | 333 | } |