closes FS#204 : nicknames
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Sat, 15 Jan 2005 12:58:26 +0000 (12:58 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:38 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-339

ChangeLog
htdocs/advanced_search.php
include/profil/assign_general.inc.php
include/profil/get_general.inc.php
include/profil/update_general.inc.php
include/user.func.inc.php
templates/fiche.tpl
templates/profil/general.tpl
templates/search.adv.form.tpl
upgrade/0.9.4/30_auth_user_quick.sql

index f7b1f94..bfe4c2e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -70,6 +70,7 @@ Bug/Wish :
        * Profile :
                - #65 : Add professionnal cellphone.                                                            -Car
                - #170 : Remove region display for french departments.                          -Car
+               - #204 : Add nicknames (searchable too).                                                        -MC
 
        * Search :
                - #249, #251, #253 : Some tweaks to be more accurate.                           -MC
index e63fbca..f932bbe 100644 (file)
@@ -71,6 +71,7 @@ if (!Env::has('rechercher')) {
         $nameField      = new NameSField('name',array('u.nom','u.epouse'),'');
         $firstnameField = new StringSField('firstname',array('u.prenom'),'');
     }
+    $nicknameField   = new StringSField('nickname',array('q.profile_nick'),'');
     
     $promo1Field     = new PromoSField('promo1','egal1',array('u.promo'),'');
     $promo2Field     = new PromoSField('promo2','egal2',array('u.promo'),'');
@@ -97,7 +98,7 @@ if (!Env::has('rechercher')) {
     $freeField       = new RefSField('free',array('u.libre'),'','','',false);
     $offset          = new NumericSField('offset');
   
-    $fields          = new SFieldGroup(true, array( $nameField, $firstnameField, $promo1Field,
+    $fields          = new SFieldGroup(true, array( $nameField, $firstnameField, $nicknameField, $promo1Field,
                 $promo2Field, $womanField, $subscriberField, $aliveField, $townField, $countryField,
                 $regionField, $entrepriseField, $posteField, $secteurField, $cvField, $natField,
                 $binetField, $groupexField, $sectionField, $schoolField, $diplomaField, $freeField)
@@ -115,7 +116,8 @@ if (!Env::has('rechercher')) {
                        '.$globals->search->result_fields.'
                        c.uid AS contact,
                        w.ni_id AS watch
-                 FROM  auth_user_md5  AS u 
+                 FROM  auth_user_md5   AS u 
+           INNER JOIN  auth_user_quick AS q USING(user_id)
             '.$fields->get_select_statement().'
             '.(Env::has('only_referent') ? ' INNER JOIN mentor AS m ON (m.uid = u.user_id)' : '').'
             LEFT JOIN  aliases        AS a ON (u.user_id = a.id AND a.type="a_vie")
index b5287ca..b690d57 100644 (file)
@@ -44,4 +44,5 @@ $page->assign('appli_type1',$appli_type1);
 $page->assign('appli_type2',$appli_type2);
 
 $page->assign('nouvellephoto', $nouvellephoto);
+$page->assign('surnom', $surnom);
 ?>
index 8a88374..a755ac5 100644 (file)
  ***************************************************************************/
 
 // on ramène les données du profil connecté (uid paramètre de session)
-$sql = "SELECT u.nom, u.prenom".
-        ", u.promo, u.epouse, FIND_IN_SET('femme',u.flags), nationalite".
-       ", mobile".
-       ", web".
-        ", libre".
-       ", a1.aid, a1.type".
-       ", a2.aid, a2.type".
-       " FROM auth_user_md5 AS u".
-       " LEFT  JOIN applis_ins AS a1 ON(a1.uid = u.user_id and a1.ordre = 0)".
-       " LEFT  JOIN applis_ins AS a2 ON(a2.uid = u.user_id and a2.ordre = 1)".
-       " WHERE user_id = {?}";
+$sql = "SELECT  u.nom, u.prenom, u.promo, u.epouse, FIND_IN_SET('femme',u.flags), u.nationalite, u.mobile, u.web, u.libre,
+                q.profile_nick,
+                a1.aid, a1.type, a2.aid, a2.type
+          FROM  auth_user_md5   AS u
+    INNER JOIN  auth_user_quick AS q  USING(user_id)
+    LEFT  JOIN  applis_ins      AS a1 ON(a1.uid = u.user_id and a1.ordre = 0)
+    LEFT  JOIN  applis_ins      AS a2 ON(a2.uid = u.user_id and a2.ordre = 1)
+        WHERE  u.user_id = {?}";
 
 $result = $globals->xdb->query($sql, Session::getInt('uid', -1));
-list($nom, $prenom,
-     $promo, $epouse, $femme, $nationalite,
-     $mobile, $web, $libre,
-     $appli_id1,$appli_type1,
-     $appli_id2,$appli_type2) = $result->fetchOneRow();
+list($nom, $prenom, $promo, $epouse, $femme,
+        $nationalite, $mobile, $web, $libre, $surnom, 
+        $appli_id1,$appli_type1, $appli_id2,$appli_type2) = $result->fetchOneRow();
 
 replace_ifset($nationalite,'nationalite');
 replace_ifset($mobile,'mobile');
@@ -47,6 +42,7 @@ replace_ifset($appli_id1,"appli_id1");
 replace_ifset($appli_id2,"appli_id2");
 replace_ifset($appli_type1,"appli_type1");
 replace_ifset($appli_type2,"appli_type2");
+replace_ifset($surnom,"surnom");
 
 if(Env::has('modifier') || Env::has('suivant')) {
     $mobile_public = Env::has('mobile_public');
index dd20297..2282592 100644 (file)
@@ -31,8 +31,7 @@ else
 
 $sql = "UPDATE auth_user_md5
           SET nationalite= {?}, web= {?}, mobile= {?}, libre= {?} WHERE user_id= {?}";
-
-
 $globals->xdb->execute($sql, $nationalite, $web, $mobile, $libre, Session::getInt('uid', -1));
+$globals->xdb->execute("UPDATE auth_user_quick SET profile_nick={?} WHERE user_id = {?}", $surnom, Session::getInt('uid', -1));
 
 ?>
index 44a25d9..9829700 100644 (file)
@@ -155,24 +155,24 @@ function get_user_forlife($data) {
 function &get_user_details($login, $from_uid = '')
 {
     global $globals;
-    $reqsql = "SELECT  u.prenom, u.nom, u.epouse,
+    $reqsql = "SELECT  u.user_id, u.promo, u.prenom, u.nom, u.epouse, u.date, u.cv, u.mobile, u.web, u.libre,
+                       u.perms IN ('admin','user') AS inscrit,  FIND_IN_SET('femme', u.flags) AS sexe, u.deces != 0 AS dcd, u.deces,
+                       q.profile_nick AS nickname,
                        IF(gp.nat='',gp.pays,gp.nat) AS nationalite, gp.a2 AS iso3166,
-                       u.user_id, a.alias AS forlife, a2.alias AS bestalias,
-                       u.matricule, u.perms IN ('admin','user') AS inscrit,
-                       FIND_IN_SET('femme', u.flags) AS sexe, u.deces != 0 AS dcd, u.deces,
-                       u.date, u.cv, sections.text AS section, u.mobile, u.web,
-                       u.libre, u.promo, c.uid IS NOT NULL AS is_contact, p.x, p.y,
-
+                       a.alias AS forlife, a2.alias AS bestalias,
+                       c.uid IS NOT NULL AS is_contact,
+                       s.text AS section, p.x, p.y,
                        m.expertise != '' AS is_referent
                        
-                 FROM  auth_user_md5  AS u
-           INNER JOIN  aliases        AS a  ON (u.user_id=a.id AND a.type='a_vie')
-           INNER JOIN  aliases        AS a2 ON (u.user_id=a2.id AND FIND_IN_SET('bestalias',a2.flags))
-            LEFT JOIN  contacts       AS c  ON (c.uid = {?} and c.contact = u.user_id)
-            LEFT JOIN  geoloc_pays    AS gp ON (gp.a2 = u.nationalite)
-           INNER JOIN  sections             ON (sections.id = u.section)
-            LEFT JOIN  photo          AS p  ON (p.uid = u.user_id) 
-            LEFT JOIN  mentor         AS m  ON (m.uid = u.user_id)
+                 FROM  auth_user_md5   AS u
+           INNER JOIN  auth_user_quick AS q  USING(user_id)
+           INNER JOIN  aliases         AS a  ON (u.user_id=a.id AND a.type='a_vie')
+           INNER JOIN  aliases         AS a2 ON (u.user_id=a2.id AND FIND_IN_SET('bestalias',a2.flags))
+            LEFT JOIN  contacts        AS c  ON (c.uid = {?} and c.contact = u.user_id)
+            LEFT JOIN  geoloc_pays     AS gp ON (gp.a2 = u.nationalite)
+           INNER JOIN  sections        AS s  ON (s.id  = u.section)
+            LEFT JOIN  photo           AS p  ON (p.uid = u.user_id) 
+            LEFT JOIN  mentor          AS m  ON (m.uid = u.user_id)
                 WHERE  a.alias = {?}";
     $res  = $globals->xdb->query($reqsql, $from_uid, $login);
     $user = $res->fetchOneAssoc();
index feefb32..6d47aa4 100644 (file)
@@ -31,7 +31,8 @@ function chgMainWinLoc( strPage ) {
     <td id="fiche_identite">
       <div class="civilite">
         {if $x.sexe}&bull;{/if}
-        {$x.prenom} {if $x.epouse eq ""}{$x.nom}{else}{$x.epouse} ({$x.nom}){/if}&nbsp;
+        {$x.prenom} {if $x.epouse eq ""}{$x.nom}{else}{$x.epouse} ({$x.nom}){/if}
+        {if $x.nickname} (aka {$x.nickname}){/if}&nbsp;
         <a href="vcard.php/{$x.forlife}.vcf?x={$x.forlife}">
           <img src="images/vcard.png" alt="Afficher la carte de visite" title="Afficher la carte de visite"/>
         </a>
index a5ea19a..1dddb8a 100644 (file)
       <td colspan="2" class="pflags">
         <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
           <tr>
+            <td class="rouge">
+              <input type="checkbox" disabled="disabled" checked="checked" />
+            </td>
+            <td class="texte">
+              privé
+            </td>
+          </tr>
+        </table>
+      </td>
+    </tr>
+    <tr>
+      <td class="colg">
+        <span class="titre">Surnom</span>
+      </td>
+      <td class="cold">
+        <input type="text" size="35" maxlength="64" name="surnom" value="{$surnom}" />
+      </td>
+    </tr>
+    <tr>
+      <td colspan="2" class="pflags">
+        <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
+          <tr>
             <td class="vert">
               <input type="checkbox" name="mobile_public" {if $mobile_public}checked="checked"{/if} />
             </td>
index b7d8662..a1de05c 100644 (file)
       </td>
     </tr>
     <tr>
+      <td>Surnom</td>
+      <td>
+        <input type="text" name="nickname" size="32" value="{$smarty.request.nickname}" />
+      </td>
+    </tr>
+    <tr>
       <td>Promotion</td>
       <td>
         <select name="egal1">
index f014697..572d274 100644 (file)
@@ -4,3 +4,6 @@ alter table auth_user_quick add column emails_alias_pub enum('public', 'private'
 alter table auth_user_quick add column profile_from_ax INT(1) not null default 0;
 alter table auth_user_quick add column core_mail_fmt enum('html', 'texte') not null default 'html';
 
+alter table auth_user_quick add column profile_nick varchar(64) not null;
+alter table auth_user_quick add index(profile_nick);
+