Editing the name of a profile update the name of the associated account
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 24 Jun 2010 16:31:59 +0000 (18:31 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 24 Jun 2010 16:31:59 +0000 (18:31 +0200)
(Closes #1105)

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
include/name.func.inc.php
modules/profile/general.inc.php

index 13d18de..272f1e4 100644 (file)
@@ -198,6 +198,16 @@ function set_profile_display(&$display_names, $pid)
                  $display_names['public_name'], $display_names['private_name'],
                  $display_names['directory_name'], $display_names['short_name'],
                  $display_names['sort_name'], $pid);
+
+    /* XXX: Inefficient, should directly take the profile as parameter */
+    $profile = Profile::get($pid);
+    $owner = $profile->owner();
+    if ($owner) {
+        XDB::execute('UPDATE  accounts
+                         SET  full_name = {?}
+                       WHERE  uid = {?}',
+                     $display_names['public_name'], $owner->id());
+    }
 }
 
 function build_sn_pub($pid)
index e80a593..13106c1 100644 (file)
@@ -568,10 +568,16 @@ class ProfileSettingGeneral extends ProfilePage
                          $this->values['photo_pub'], $this->pid());
         }
         if ($this->changed['yourself']) {
-            XDB::execute('UPDATE  accounts
-                             SET  display_name = {?}
-                           WHERE  uid = {?}',
-                         $this->values['yourself'], $this->owner->id());
+            if ($this->owner) {
+                XDB::execute('UPDATE  accounts
+                                 SET  display_name = {?}
+                               WHERE  uid = {?}',
+                             $this->values['yourself'], $this->owner->id());
+            }
+            XDB::execute('UPDATE  profile_display
+                             SET  yourself = {?}
+                           WHERE  pid = {?}', $this->values['yourself'],
+                         $this->pid());
         }
         if ($this->changed['promo_display']) {
             if ($this->values['promo_display']{0} == $this->profile->mainEducation()) {