]> source.dussan.org Git - nextcloud-server.git/commitdiff
Provide initial state
authorChristopher Ng <chrng8@gmail.com>
Thu, 22 Jul 2021 00:03:33 +0000 (00:03 +0000)
committerChristopher Ng <chrng8@gmail.com>
Mon, 23 Aug 2021 21:29:47 +0000 (21:29 +0000)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/settings/lib/Settings/Personal/PersonalInfo.php

index 387843c552258714a8fb816372d14afaf69cd87e..d69d4b33b4c3ce23e940745072e1ffb5604bef56 100644 (file)
@@ -145,14 +145,17 @@ class PersonalInfo implements ISettings {
                        'groups' => $this->getGroups($user),
                ] + $messageParameters + $languageParameters + $localeParameters;
 
-               $emails = $this->getEmails($account);
+               $personalInfoParameters = [
+                       'displayNames' => $this->getDisplayNames($account),
+                       'emails' => $this->getEmails($account),
+               ];
 
                $accountParameters = [
                        'displayNameChangeSupported' => $user->canChangeDisplayName(),
                        'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
                ];
 
-               $this->initialStateService->provideInitialState('emails', $emails);
+               $this->initialStateService->provideInitialState('personalInfoParameters', $personalInfoParameters);
                $this->initialStateService->provideInitialState('accountParameters', $accountParameters);
 
                return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, '');
@@ -196,6 +199,29 @@ class PersonalInfo implements ISettings {
                return $groups;
        }
 
+       /**
+        * returns the primary display name in an
+        * associative array
+        *
+        * NOTE may be extended to provide additional display names (i.e. aliases) in the future
+        *
+        * @param IAccount $account
+        * @return array
+        */
+       private function getDisplayNames(IAccount $account): array {
+               $primaryDisplayName = [
+                       'value' => $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME)->getValue(),
+                       'scope' => $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME)->getScope(),
+                       'verified' => $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME)->getVerified(),
+               ];
+
+               $displayNames = [
+                       'primaryDisplayName' => $primaryDisplayName,
+               ];
+
+               return $displayNames;
+       }
+
        /**
         * returns the primary email and additional emails in an
         * associative array