]> git.mxchange.org Git - friendica.git/commitdiff
Replace references to profile.name by user.username
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 10 Aug 2023 23:05:02 +0000 (01:05 +0200)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 20 Aug 2023 17:59:07 +0000 (13:59 -0400)
src/Model/Contact.php
src/Model/Profile.php
src/Model/User.php
src/Module/Settings/Account.php
src/Module/Settings/Profile/Index.php
view/templates/settings/profile/index.tpl
view/theme/frio/templates/settings/profile/index.tpl

index d91abe9bcdb0b3070fa579b0171be4da3b4ef6e1..35ca4e49eb8106d0ef106d566d402b4945e9425e 100644 (file)
@@ -788,10 +788,10 @@ class Contact
        /**
         * Updates the self-contact for the provided user id
         *
-        * @param int   $uid
-        * @param bool  $update_avatar Force the avatar update
+        * @param int  $uid
+        * @param bool $update_avatar Force the avatar update
         * @return bool "true" if updated
-        * @throws HTTPException\InternalServerErrorException
+        * @throws \Exception
         */
        public static function updateSelfFromUserID(int $uid, bool $update_avatar = false): bool
        {
index 0602df10aad4c33c46db3bc62c1de1934d46ec8a..c1a350673e1bafe995bcec7719491f42fa6e0f80 100644 (file)
@@ -37,6 +37,7 @@ use Friendica\DI;
 use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Network\HTTPException;
+use Friendica\Network\HTTPException\InternalServerErrorException;
 use Friendica\Protocol\Activity;
 use Friendica\Protocol\Diaspora;
 use Friendica\Security\PermissionSet\Entity\PermissionSet;
@@ -93,10 +94,11 @@ class Profile
        /**
         * Update a profile entry and distribute the changes if needed
         *
-        * @param array $fields Profile fields to update
-        * @param integer $uid User id
+        * @param array   $fields Profile fields to update
+        * @param integer $uid    User id
         *
         * @return boolean Whether update was successful
+        * @throws \Exception
         */
        public static function update(array $fields, int $uid): bool
        {
@@ -116,10 +118,6 @@ class Profile
                        return false;
                }
 
-               if ($old_owner['name'] != $owner['name']) {
-                       User::update(['username' => $owner['name']], $uid);
-               }
-
                $profile_fields = ['postal-code', 'dob', 'prv_keywords', 'homepage'];
                foreach ($profile_fields as $field) {
                        if ($old_owner[$field] != $owner[$field]) {
index 18da3e956046c2d79968de025e8a01138981aae8..af7a81a15dccc4a2ad22879d68beae7cb5eea192 100644 (file)
@@ -37,6 +37,7 @@ use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Module;
 use Friendica\Network\HTTPClient\Client\HttpClientAccept;
+use Friendica\Network\HTTPException\InternalServerErrorException;
 use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
 use Friendica\Network\HTTPException;
 use Friendica\Object\Image;
@@ -1328,33 +1329,18 @@ class User
        /**
         * Update a user entry and distribute the changes if needed
         *
-        * @param array $fields
+        * @param array   $fields
         * @param integer $uid
         * @return boolean
+        * @throws Exception
         */
        public static function update(array $fields, int $uid): bool
        {
-               $old_owner = self::getOwnerDataById($uid);
-               if (empty($old_owner)) {
-                       return false;
-               }
-
                if (!DBA::update('user', $fields, ['uid' => $uid])) {
                        return false;
                }
 
-               $update = Contact::updateSelfFromUserID($uid);
-
-               $owner = self::getOwnerDataById($uid);
-               if (empty($owner)) {
-                       return false;
-               }
-
-               if ($old_owner['name'] != $owner['name']) {
-                       Profile::update(['name' => $owner['name']], $uid);
-               }
-
-               if ($update) {
+               if (Contact::updateSelfFromUserID($uid)) {
                        Profile::publishUpdate($uid);
                }
 
index 1039b92e2ee0dcd81ec01f4f0f1ef267f5bd81b4..8ff00addb5294c7d4e4c1a0c941c6b55b0a28550 100644 (file)
@@ -573,7 +573,7 @@ class Account extends BaseSettings
                        '$delete_openid' => ['delete_openid', DI::l10n()->t('Delete OpenID URL'), false, ''],
 
                        '$h_basic'          => DI::l10n()->t('Basic Settings'),
-                       '$username'         => ['username', DI::l10n()->t('Full Name:'), $username, '', false, 'autocomplete="off"'],
+                       '$username'         => ['username', DI::l10n()->t('Display name:'), $username, '', false, 'autocomplete="off"'],
                        '$email'            => ['email', DI::l10n()->t('Email Address:'), $email, '', '', 'autocomplete="off"', 'email'],
                        '$timezone'         => ['timezone_select', DI::l10n()->t('Your Timezone:'), Temporal::getTimezoneSelect($timezone), ''],
                        '$language'         => ['language', DI::l10n()->t('Your Language:'), $language, DI::l10n()->t('Set the language we use to show you friendica interface and to send you emails'), $lang_choices],
index c18c72a4eed430f24fdc8f2b5abd0afa006b1763..38d816833f69010b943bd8f83cb7a7b519adcadb 100644 (file)
@@ -111,8 +111,8 @@ class Index extends BaseSettings
                        }
                }
 
-               $name = trim($request['name'] ?? '');
-               if (!$name) {
+               $username = trim($request['username'] ?? '');
+               if (!$username) {
                        $this->systemMessages->addNotice($this->t('Display Name is required.'));
                        return;
                }
@@ -141,9 +141,10 @@ class Index extends BaseSettings
 
                $this->profileFieldRepo->saveCollectionForUser($this->session->getLocalUserId(), $profileFieldsNew);
 
+               User::update(['username' => $username], $this->session->getLocalUserId());
+
                $result = Profile::update(
                        [
-                               'name'         => $name,
                                'about'        => $about,
                                'dob'          => $dob,
                                'address'      => $address,
@@ -279,7 +280,7 @@ class Index extends BaseSettings
                        '$profpiclink' => '/profile/' . $owner['nickname'] . '/photos',
 
                        '$nickname'      => $owner['nickname'],
-                       '$name'          => ['name', $this->t('Display name:'), $owner['name']],
+                       '$username'      => ['username', $this->t('Display name:'), $owner['name']],
                        '$about'         => ['about', $this->t('Description:'), $owner['about']],
                        '$dob'           => Temporal::getDateofBirthField($owner['dob'], $owner['timezone']),
                        '$address'       => ['address', $this->t('Street Address:'), $owner['address']],
index 6540ab3c6eef524c82fa2de33749181fc38490e5..64c9daee023a6cd05806344d6da408291cc2ed7e 100644 (file)
@@ -48,7 +48,7 @@
                        <h2><a class="section-caption js-section-toggler" href="javascript:;">{{$l10n.personal_section}} &raquo;</a></h2>
                        <div class="js-section toggle-section-content hidden">
 
-                {{include file="field_input.tpl" field=$name}}
+                {{include file="field_input.tpl" field=$username}}
 
                 {{include file="field_textarea.tpl" field=$about}}
 
index 5599bbe064d5e86791a768ee32f0c8a5394e289e..2665315b4c80281c0b02eb5c631d1a648a4dfa57 100644 (file)
@@ -60,7 +60,7 @@
                                {{* for the $detailed_profile we use bootstraps collapsable panel-groups to have expandable groups *}}
                                <div id="personal-collapse" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="personal">
                                        <div class="panel-body">
-                                               {{include file="field_input.tpl" field=$name}}
+                                               {{include file="field_input.tpl" field=$username}}
 
                                                {{include file="field_textarea.tpl" field=$about}}