Directly passes profile to set_profile_display.
authorStéphane Jacob <sj@m4x.org>
Sat, 17 Jul 2010 16:04:24 +0000 (18:04 +0200)
committerStéphane Jacob <sj@m4x.org>
Sat, 17 Jul 2010 16:04:24 +0000 (18:04 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
include/name.func.inc.php
include/validations/names.inc.php
modules/profile/general.inc.php

index 272f1e4..2698650 100644 (file)
@@ -189,7 +189,7 @@ function build_sort_name(&$search_names, &$sn_types)
     return $name;
 }
 
-function set_profile_display(&$display_names, $pid)
+function set_profile_display(&$display_names, Profile $profile)
 {
     XDB::execute("UPDATE  profile_display
                      SET  public_name = {?}, private_name = {?},
@@ -197,10 +197,8 @@ function set_profile_display(&$display_names, $pid)
                    WHERE  pid = {?}",
                  $display_names['public_name'], $display_names['private_name'],
                  $display_names['directory_name'], $display_names['short_name'],
-                 $display_names['sort_name'], $pid);
+                 $display_names['sort_name'], $profile->id());
 
-    /* XXX: Inefficient, should directly take the profile as parameter */
-    $profile = Profile::get($pid);
     $owner = $profile->owner();
     if ($owner) {
         XDB::execute('UPDATE  accounts
index 712f4e1..2893d65 100644 (file)
@@ -130,7 +130,7 @@ class NamesReq extends ProfileValidate
     {
         require_once 'name.func.inc.php';
 
-        set_profile_display($this->display_names, $this->profile->id());
+        set_profile_display($this->display_names, $this->profile);
 
         if (!is_null($this->profileOwner)) {
             set_alias_names($this->sn_new, $this->sn_old, $this->profile->id(),
index 362c5eb..c89c11c 100644 (file)
@@ -231,7 +231,7 @@ class ProfileSettingSearchNames implements ProfileSetting
             $display_names = array();
             build_display_names($display_names, $this->search_names,
                                 $page->profile->isFemale(), $this->private_name_end);
-            set_profile_display($display_names, $page->pid());
+            set_profile_display($display_names, $page->profile);
         }
     }