Properly uses names (Closes #1192).
authorStéphane Jacob <sj@m4x.org>
Sun, 11 Jul 2010 10:56:13 +0000 (12:56 +0200)
committerStéphane Jacob <sj@m4x.org>
Mon, 12 Jul 2010 10:37:04 +0000 (12:37 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/profile.php
classes/user.php
plugins/function.profile.php
templates/admin/validation.tpl
templates/include/minifiche.tpl
templates/include/plview.trombi.entry.tpl
templates/include/trombi.tpl
templates/profile/profile.tpl

index fe929c1..0b22460 100644 (file)
@@ -850,8 +850,9 @@ class Profile
                                      IF( {?}, pn_n.name, NULL) AS nickname,
                                      IF(pn_uf.name IS NULL, pn_f.name, pn_uf.name) AS firstname_ordinary,
                                      IF(pn_ul.name IS NULL, pn_l.name, pn_ul.name) AS lastname_ordinary,
-                                     pd.yourself, pd.promo, pd.short_name, pd.directory_name AS full_name,
-                                     pd.directory_name, IF(pp.pub IN {?}, pp.display_tel, NULL) AS mobile,
+                                     pd.yourself, pd.promo, pd.short_name, pd.public_name AS full_name,
+                                     pd.directory_name, pd.public_name, pd.private_name,
+                                     IF(pp.pub IN {?}, pp.display_tel, NULL) AS mobile,
                                      (ph.pub IN {?} AND ph.attach IS NOT NULL) AS has_photo,
                                      ph.x AS photo_width, ph.y AS photo_height,
                                      p.last_change < DATE_SUB(NOW(), INTERVAL 365 DAY) AS is_old,
index b2a75f0..db0f675 100644 (file)
@@ -287,6 +287,22 @@ class User extends PlUser
         return $this->profile()->lastName();
     }
 
+    public function fullName($with_promo = false)
+    {
+        if (!$this->hasProfile()) {
+            return $this->full_name;
+        }
+        return $this->profile()->fullName($with_promo);
+    }
+
+    public function directoryName()
+    {
+        if (!$this->hasProfile()) {
+            return $this->full_name;
+        }
+        return $this->profile()->directory_name;
+    }
+
     /** Return the main profile attached with this account if any.
      */
     public function profile()
index dfc4bf3..a355f8f 100644 (file)
@@ -31,7 +31,7 @@ function smarty_function_profile($params, &$smarty)
         $user = User::getWithUID($user);
     }
 
-    $name = pl_entities($user->fullName());
+    $name = pl_entities($user->directoryName());
     if ($with_sex && $user->isFemale()) {
         $name = '&bull;' . $name;
     }
index 6f4f833..8c0cb21 100644 (file)
@@ -46,8 +46,11 @@ function toggleField(name, id, obj) {
   <tr>
     <td class="titre" style="width: 20%">Demandeur&nbsp;:</td>
     <td>
-      <a href="profile/{$valid->user->login()}" class="popup2">
-        {$valid->user->fullName()} ({$valid->user->promo()})
+      {if $valid->user->hasProfile()}
+      {assign var="profile" value=$valid->user->profile()}
+      <a href="profile/{$profile->hrpid}" class="popup2">
+      {/if}
+        {$valid->user->fullName("promo")}
       </a>
     </td>
   </tr>
index f593af7..21fc745 100644 (file)
@@ -55,7 +55,7 @@
     <div class="nom">
       {if $profile->isFemale()}&bull;{/if}
       {if !$dead && $registered}<a href="profile/{$profile->hrid()}" class="popup2">{/if}
-      {$profile->full_name}
+      {$profile->directory_name}
       {if !$dead && $registered}</a>{/if}
     </div>
 
index ea6dbcc..24e157d 100644 (file)
@@ -33,9 +33,7 @@
 {else}
 <td class="center" style="vertical-align: bottom; padding-bottom: 15px">
   <a href="profile/{$profile->hrid()}" class="popup2">
-    <span {if $profile->name_tooltip}class="hinted"
-    title="{$profile->directory_name}"{/if}>{$profile->directory_name}</span> 
-    {if $trombi_with_promo && $profile->promo()}({$profile->promo()}){/if}
+    {$profile->private_name} {if $trombi_with_promo && $profile->promo()}({$profile->promo()}){/if}
   </a>
 </td>
 {/if}
index e389a9d..f3ec1e7 100644 (file)
@@ -37,7 +37,7 @@
       {/if}
       <br />
       <a href="{if $urlmainsite}{$urlmainsite}{/if}profile/{$p.forlife}" class="popup2">
-        <span {if $p.name_tooltip}class="hinted" title="{$p.name_tooltip}"{/if}>{$p.name_display}</span>{if $trombi_show_promo} ({$p.promo_display}){/if}
+        {$p.name_display}{if $trombi_show_promo} ({$p.promo_display}){/if}
       </a>
     </td>
   {if $loop eq "3"}
index e1e8210..79abc50 100644 (file)
@@ -86,10 +86,7 @@ function chgMainWinLoc(strPage)
   <div id="fiche_identite" class="part">
     <div class="civilite">
       {if $profile->isFemale()}&bull;{/if}
-        <span {if $profile->name_tooltip neq ""}class="hinted" title="{$profile->name_tooltip}"{/if}>{$profile->shortName()}</span>
-      {if $logged}
-        {if $profile->nickname} (alias {$profile->nickname}){/if}
-      {/if}
+        {if $logged}{$profile->private_name}{else}{$profile->public_name}{/if}
 
       {if $logged}
         &nbsp;{if !$profile->isDead()}<a href="vcard/{$owner->login()}.vcf">{*