extension du nom d'epouse a un nom d'usage
authorPascal Corpet <pascal.corpet@m4x.org>
Fri, 25 Mar 2005 10:28:06 +0000 (10:28 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:28:20 +0000 (23:28 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-517

35 files changed:
ChangeLog
bin/cron/checkdb.php
bin/cron/recherche.sql
bin/newsletter.send.php
htdocs/admin/synchro_ax.php
htdocs/admin/utilisateurs.php
htdocs/advanced_search.php
htdocs/carnet/mescontacts.php
htdocs/emails.php
htdocs/emails/redirect.php
htdocs/fiche.php
htdocs/listes/trombi.php
htdocs/nomusage.php [moved from htdocs/epouse.php with 73% similarity]
include/contacts.pdf.inc.php
include/emails.inc.php
include/homonymes.inc.php
include/lists.inc.php
include/notifs.inc.php
include/profil/assign_general.inc.php
include/profil/get_general.inc.php
include/profil/get_poly.inc.php
include/search/classes.inc.php
include/synchro_ax.inc.php
include/user.func.inc.php
include/validations/nomusage.inc.php [moved from include/validations/epouses.inc.php with 62% similarity]
scripts/webredirect.php
templates/epouse.tpl [deleted file]
templates/fiche.tpl
templates/include/form.valid.nomusage.tpl [moved from templates/include/form.valid.epouses.tpl with 96% similarity]
templates/include/minifiche.tpl
templates/nomusage.tpl [new file with mode: 0644]
templates/profil/general.tpl
templates/vcard.tpl
upgrade/0.9.5/50_aliases.sql [new file with mode: 0644]
upgrade/0.9.5/60_auth_user_md5.sql [new file with mode: 0644]

index d0134bf..884b0fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@ New :
        * Profile :
                - One can choose precisely which fields appear on his public fiche.     -Car
                - Accents and special chars in name and first name                                      -Car
+               - Spouse name extended to usage name                                                            -Car
 
        * Register :
                - Already subscribed members now have a warning.                                        -MC
index f271527..d14af8a 100755 (executable)
@@ -84,7 +84,7 @@ check("select uid, cid from competences_ins group by uid having count(cid) > 20"
 check("SELECT a.*
         FROM aliases       AS a
         LEFT JOIN auth_user_md5 AS u ON u.user_id=a.id
-        WHERE (a.type='alias' OR a.type='epouse' OR a.type='a_vie') AND u.prenom is null");
+        WHERE (a.type='alias' OR a.type='a_vie') AND u.prenom is null");
 
 /* validite de applis_ins */
 check("select a.* from applis_ins as a left join auth_user_md5 as u on u.user_id=a.uid where u.prenom is null");
@@ -131,7 +131,7 @@ info("SELECT  a1.alias, a2.alias, e1.email, e2.flags
         INNER JOIN  aliases       AS a2 ON(a2.id=e2.uid AND a2.type='a_vie')
         INNER JOIN  auth_user_md5 AS u1 ON(a1.id=u1.user_id)
         INNER JOIN  auth_user_md5 AS u2 ON(a2.id=u2.user_id)
-        WHERE  FIND_IN_SET(e1.flags,'active') AND u1.nom!=u2.epouse AND u2.nom!=u1.epouse
+        WHERE  FIND_IN_SET(e1.flags,'active') AND u1.nom!=u2.nom_usage AND u2.nom!=u1.nom_usage
         ORDER BY  a1.alias",
         "donne la liste des emails qui apparaissent 2 fois dans la table emails pour des personnes différentes");
 
index 35ad285..f4007e4 100644 (file)
@@ -1,7 +1,7 @@
 USE x4dat;
 DROP TABLE IF EXISTS recherche;
 CREATE TABLE recherche SELECT matricule AS matricule,LOWER(REPLACE(nom_ini,'-',' ')) AS nom1,
-LOWER(REPLACE(nom,'-',' ')) AS nom2, LOWER(REPLACE(epouse,'-',' ')) AS nom3,
+LOWER(REPLACE(nom,'-',' ')) AS nom2, LOWER(REPLACE(nom_usage,'-',' ')) AS nom3,
 LOWER(REPLACE(prenom_ini,'-',' ')) AS prenom1, LOWER(REPLACE(prenom,'-',' ')) AS prenom2, promo AS
 promo FROM auth_user_md5;
 DROP TABLE IF EXISTS recherche_soundex;
index cab9ffb..3897469 100755 (executable)
@@ -40,7 +40,7 @@ $nl->setSent();
 while(true) {
     $res = $globals->xdb->iterRow(
             "SELECT  ni.user_id, a.alias,
-                     u.prenom, IF(u.epouse='', u.nom, u.epouse),
+                     u.prenom, IF(u.nom_usage='', u.nom, u.nom_usage),
                      FIND_IN_SET('femme', u.flags),
                     q.core_mail_fmt AS pref
                FROM  newsletter_ins  AS ni
index 9bc3332..efc418d 100644 (file)
@@ -77,7 +77,7 @@ if ($login) {
             }
         }
 
-        import_from_ax($userax, Env::has('epouse'), Env::has('mobile'), $adr_dels, $adr_adds, $pro_dels, $pro_adds, Env::has('nationalite'));
+        import_from_ax($userax, Env::has('nom_usage'), Env::has('mobile'), $adr_dels, $adr_adds, $pro_dels, $pro_adds, Env::has('nationalite'));
 
     }
 
@@ -87,10 +87,10 @@ if ($login) {
         $user['matricule_ax'] = $userax['matricule_ax'];
         unset($userax['matricule_ax']);
         $user['nom'] = ucwords(strtolower($user['nom']));
-        $user['epouse'] = ucwords(strtolower($user['epouse']));
+        $user['nom_usage'] = ucwords(strtolower($user['nom_usage']));
     }
 
-    $page->assign('watch_champs',array('nom', 'epouse', 'prenom', 'nationalite', 'mobile'));
+    $page->assign('watch_champs',array('nom', 'nom_usage', 'prenom', 'nationalite', 'mobile'));
     $page->assign('modifiables', array(0,1,0,1,1));
 
     $page->assign('x', $user);
index 8684076..ea98cf3 100644 (file)
@@ -96,10 +96,11 @@ if ($login) {
                break;
 
            case "best":
-               $globals->xdb->execute("UPDATE  aliases SET flags='' WHERE flags='bestalias' AND id={?}", $mr['user_id']);
-               $globals->xdb->execute("UPDATE  aliases SET flags='epouse' WHERE flags='epouse,bestalias' AND id={?}", $mr['user_id']);
+                // 'bestalias' is the first bit of the set : 1
+                // 255 is the max for flags (8 sets max)
+               $globals->xdb->execute("UPDATE  aliases SET flags= flags & (255 - 1) WHERE id={?}", $mr['user_id']);
                $globals->xdb->execute("UPDATE  aliases
-                                           SET  flags=CONCAT(flags,',','bestalias')
+                                           SET  flags= flags | 1
                                         WHERE  id={?} AND alias={?}", $mr['user_id'], $val);
                break;
 
index 11e094a..57a865f 100644 (file)
@@ -71,7 +71,7 @@ if (!Env::has('rechercher')) {
             $nameField      = new RefWithSoundexSField('name',array('rn.nom1_soundex','rn.nom2_soundex','rn.nom3_soundex'),'recherche_soundex','rn','u.matricule = rn.matricule');
             $firstnameField = new RefWithSoundexSField('firstname',array('rp.prenom1_soundex','rp.prenom2_soundex'),'recherche_soundex','rp','u.matricule = rp.matricule');
         } else {
-            $nameField      = new NameSField('name',array('u.nom','u.epouse'),'');
+            $nameField      = new NameSField('name',array('u.nom','u.nom_usage'),'');
             $firstnameField = new StringSField('firstname',array('u.prenom'),'');
         }
         $nicknameField   = new StringSField('nickname',array('q.profile_nick'),'');
index 79b8ed9..2ad376e 100644 (file)
@@ -81,7 +81,7 @@ if(Get::get('trombi')) {
             $order = str_replace(" DESC,", ",", $order);
             
        $res   = $globals->xdb->query("
-               SELECT  u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom, a.alias AS forlife, u.promo
+               SELECT  u.prenom, IF(u.nom_usage='',u.nom,u.nom_usage) AS nom, a.alias AS forlife, u.promo
                  FROM  contacts       AS c
            INNER JOIN  auth_user_md5  AS u   ON (u.user_id = c.contact)
            INNER JOIN  aliases        AS a   ON (u.user_id = a.id AND a.type='a_vie')
@@ -127,7 +127,7 @@ if(Get::get('trombi')) {
                    ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type,
                    ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
                    adr.ville, gp.a2, gp.pays, gr.name AS region,
-                   IF(a.epouse<>'',a.epouse,a.nom) AS sortkey
+                   IF(a.nom_usage<>'',a.nom_usage,a.nom) AS sortkey
              FROM  contacts       AS c
         INNER JOIN  auth_user_md5  AS a   ON (a.user_id = c.contact)
         INNER JOIN  aliases        AS l   ON (a.user_id = l.id AND l.type='a_vie')
index 0c38190..9ae78bf 100644 (file)
@@ -25,9 +25,10 @@ new_skinned_page('emails.tpl',AUTH_COOKIE);
 $uid = Session::getInt('uid');
 
 if (Post::has('best')) {
-    $globals->xdb->execute("UPDATE  aliases SET flags='' WHERE flags='bestalias' AND id={?}", $uid);
-    $globals->xdb->execute("UPDATE  aliases SET flags='epouse' WHERE flags='epouse,bestalias' AND id={?}", $uid);
-    $globals->xdb->execute("UPDATE  aliases SET flags=CONCAT(flags,',','bestalias') WHERE id={?} AND alias={?}", $uid, Post::get('best'));
+    // bestalias is the first bit : 1
+    // there will be maximum 8 bits in flags : 255
+    $globals->xdb->execute("UPDATE  aliases SET flags=flags & (255 - 1) WHERE id={?}", $uid);
+    $globals->xdb->execute("UPDATE  aliases SET flags=flags | 1 WHERE id={?} AND alias={?}", $uid, Post::get('best'));
 }
 
 // on regarde si on a affaire à un homonyme
index 7ef579f..cff20d9 100644 (file)
@@ -57,7 +57,7 @@ $res = $globals->xdb->query(
         "SELECT  alias,expire
            FROM  aliases
           WHERE  id={?} AND (type='a_vie' OR type='alias')
-       ORDER BY  !FIND_IN_SET('epouse',flags), LENGTH(alias)", $uid);
+       ORDER BY  !FIND_IN_SET('usage',flags), LENGTH(alias)", $uid);
 $page->assign('alias', $res->fetchAllAssoc());
 $page->assign('emails',$redirect->emails);
 
index 968b242..a7a1bdf 100644 (file)
@@ -49,7 +49,7 @@ if (Env::has('mat')) {
 
 $new   = Env::get('modif') == 'new';
 $user  = get_user_details($login, Session::getInt('uid'));
-$title = $user['prenom'] . ' ' . empty($user['epouse']) ? $user['nom'] : $user['epouse'];
+$title = $user['prenom'] . ' ' . empty($user['nom_usage']) ? $user['nom'] : $user['nom_usage'];
 $page->assign('xorg_title', $title);
 
 // photo
index e3af66c..97638fe 100644 (file)
@@ -47,7 +47,7 @@ function getList($offset,$limit)
     $membres = Array();
     foreach ($members as $member) {
         list($m) = split('@',$member[1]);
-        $res = $globals->xdb->query("SELECT  prenom,IF(epouse='', nom, epouse) AS nom, promo, a.alias AS forlife
+        $res = $globals->xdb->query("SELECT  prenom,IF(nom_usage='', nom, nom_usage) AS nom, promo, a.alias AS forlife
                                        FROM  auth_user_md5 AS u
                                  INNER JOIN  aliases AS a ON u.user_id = a.id
                                       WHERE  a.alias = {?}", $m);
similarity index 73%
rename from htdocs/epouse.php
rename to htdocs/nomusage.php
index 28176c3..cdf8eaa 100644 (file)
@@ -23,35 +23,34 @@ require_once("xorg.inc.php");
 require_once("validations.inc.php");
 require_once("xorg.misc.inc.php");
 
-new_skinned_page('epouse.tpl', AUTH_MDP);
+new_skinned_page('nomusage.tpl', AUTH_MDP);
 
 $res = $globals->xdb->query(
-        "SELECT  u.nom,u.epouse,u.flags,e.alias
+        "SELECT  u.nom,u.nom_usage,u.flags,e.alias
            FROM  auth_user_md5  AS u
       LEFT JOIN  aliases        AS e ON(u.user_id = e.id)
-          WHERE  user_id={?}", Session::getInt('uid'));
+          WHERE  user_id={?} AND FIND_IN_SET('usage', e.flags)", Session::getInt('uid'));
 
-list($nom,$epouse_old,$flags,$alias_old) = $res->fetchOneRow();
+list($nom,$usage_old,$flags,$alias_old) = $res->fetchOneRow();
 $flags = new flagset($flags);
-$page->assign('is_femme',   $flags->hasflag("femme"));
-$page->assign('epouse_old', $epouse_old);
+$page->assign('usage_old', $usage_old);
 $page->assign('alias_old',  $alias_old);
 
-$epouse = replace_accent(trim(Env::get('epouse'))); 
-$epouse = strtoupper($epouse);
-$page->assign('epouse_req', $epouse);
+$nom_usage = replace_accent(trim(Env::get('nom_usage'))); 
+$nom_usage = strtoupper($nom_usage);
+$page->assign('usage_req', $nom_usage);
 
-if (Env::has('submit') && ($epouse != $epouse_old)) {
-    // on vient de recevoir une requete, differente de l'ancien nom de mariage
-    if ($epouse == $nom) {
+if (Env::has('submit') && ($nom_usage != $usage_old)) {
+    // on vient de recevoir une requete, differente de l'ancien nom d'usage
+    if ($nom_usage == $nom) {
         $page->assign('same', true);
     } else { // le nom de mariage est distinct du nom à l'X
         // on calcule l'alias pour l'afficher
-        $myepouse = new EpouseReq(Session::getInt('uid'), $epouse);
-        $myepouse->submit();
-        $page->assign('myepouse', $myepouse);
+        $myusage = new UsageReq(Session::getInt('uid'), $nom_usage);
+        $myusage->submit();
+        $page->assign('myusage', $myusage);
     }
 }
 
-$page->run($flags->hasflag('femme') ? '' : 'not_femme');
+$page->run();
 ?>
index 4dc8be0..e1b67c2 100644 (file)
@@ -267,7 +267,7 @@ class ContactsPDF extends FPDF
         $this->SetFillColor(245, 248, 252);
         $this->SetLineWidth(0.4);
 
-        $nom = $x['prenom'].' '.($x['epouse'] ? "{$x['epouse']} - née {$x['nom']}" : $x['nom'])." ({$x['promo']})";
+        $nom = $x['prenom'].' '.($x['nom_usage'] ? "{$x['nom_usage']} ({$x['nom']})" : $x['nom'])." ({$x['promo']})";
         $ok  = false;
 
         if ($wp) {
index b7bb6eb..ab54a40 100644 (file)
@@ -41,7 +41,7 @@ function fix_bestalias($uid)
     $globals->xdb->execute("UPDATE  aliases
                                SET  flags=CONCAT(flags,',','bestalias')
                             WHERE  id={?} AND type!='homonyme'
-                         ORDER BY  !FIND_IN_SET('epouse',flags),alias LIKE '%.%', LENGTH(alias)
+                         ORDER BY  !FIND_IN_SET('usage',flags),alias LIKE '%.%', LENGTH(alias)
                             LIMIT  1", $uid);
 }
 
index 1323af3..79c11e4 100644 (file)
@@ -66,7 +66,7 @@ function switch_bestalias($uid, $loginbis) {
     $res = $globals->xdb->query("SELECT alias FROM aliases WHERE id = {?} AND alias != {?} AND expire IS NULL ORDER BY LENGTH(alias) LIMIT 1", $uid, $loginbis);
     $newbest = $res->fetchOneCell();
     // change the bestalias flag
-    $globals->xdb->execute("UPDATE aliases SET flags = CONCAT(IF(FIND_IN_SET('epouse', flags), 'epouse', ''), ',' , IF(alias = {?}, 'bestalias', '')) WHERE id = {?}", $newbest, $uid);
+    $globals->xdb->execute("UPDATE aliases SET flags = (flags & (255 - 1)) | IF(alias = {?}, 1, 0) WHERE id = {?}", $newbest, $uid);
 
     return $newbest;
 }
index 689774f..1f3eea2 100644 (file)
@@ -47,7 +47,7 @@ function list_sort_owners(&$members, $tri_promo = true) {
     foreach($members as $mem) {
         list($m, $dom) = split('@',$mem);
         if ($dom == $globals->mail->domain || $dom == $globals->mail->domain2) {
-            $res = $globals->xdb->query('SELECT  prenom,IF(epouse="", nom, epouse), promo
+            $res = $globals->xdb->query('SELECT  prenom,IF(nom_usage="", nom, nom_udage), promo
                                            FROM  auth_user_md5 AS u
                                      INNER JOIN  aliases AS a ON u.user_id = a.id
                                           WHERE  a.alias = {?}', $m);
index 16e135d..1205a21 100644 (file)
@@ -77,14 +77,14 @@ function _select_notifs_base($table, $mail, $where)
     $our   = $cases[$table];
     $sql = "
         (
-          SELECT  u.promo, u.prenom, IF(u.epouse='',u.nom,u.epouse) AS nom,
+          SELECT  u.promo, u.prenom, IF(u.nom_usage='',u.nom,u.nom_usage) AS nom,
                   a.alias AS bestalias,
                   wo.*,
                   {$our['contact_sql']} AS contact,
                   (u.perms IN('admin','user')) AS inscrit";
     if ($mail) {
         $sql.=",
-                  w.uid AS aid, v.prenom AS aprenom, IF(v.epouse='',v.nom,v.prenom) AS anom,
+                  w.uid AS aid, v.prenom AS aprenom, IF(v.nom_usage='',v.nom,v.nom_usage) AS anom,
                   b.alias AS abestalias, (v.flags='femme') AS sexe, q.core_mail_fmt AS mail_fmt"; 
     }
 
@@ -383,7 +383,7 @@ class NoninsNotifs {
     function NoninsNotifs($uid) {
        global $globals;
        $this->_uid = $uid;
-       $res = $globals->xdb->iterator("SELECT  u.prenom,IF(u.epouse='',u.nom,u.epouse) AS nom, u.promo, u.user_id
+       $res = $globals->xdb->iterator("SELECT  u.prenom,IF(u.nom_usage='',u.nom,u.nom_usage) AS nom, u.promo, u.user_id
                                           FROM  watch_nonins  AS w
                                     INNER JOIN  auth_user_md5 AS u ON (u.user_id = w.ni_id)
                                          WHERE  w.uid = {?}
@@ -402,7 +402,7 @@ class NoninsNotifs {
     function add($p) {
        global $globals;
        $globals->xdb->execute('INSERT INTO watch_nonins (uid,ni_id) VALUES({?},{?})', $this->_uid, $p);
-       $res = $globals->xdb->query('SELECT  prenom,IF(epouse="",nom,epouse) AS nom,promo,user_id
+       $res = $globals->xdb->query('SELECT  prenom,IF(nom_usage="",nom,nom_usage) AS nom,promo,user_id
                                        FROM  auth_user_md5
                                       WHERE  user_id={?}', $p);
        $this->_data["$p"] = $res->fetchOneAssoc();
index f01379a..8f14bc5 100644 (file)
@@ -26,8 +26,7 @@ $page->assign('freetext_pub',$freetext_pub);
 $page->assign('nom', $nom);
 $page->assign('prenom', $prenom);
 $page->assign('promo', $promo);
-$page->assign('epouse', $epouse);
-$page->assign('femme', $femme);
+$page->assign('nom_usage', $nom_usage);
 
 $page->assign('nationalite',$nationalite);
 
index 865cb7a..3200775 100644 (file)
@@ -20,7 +20,7 @@
  ***************************************************************************/
 
 // on ramène les données du profil connecté (uid paramètre de session)
-$sql = "SELECT  u.nom, u.prenom, u.nom_ini, u.prenom_ini, u.promo, u.epouse, FIND_IN_SET('femme',u.flags), u.nationalite,
+$sql = "SELECT  u.nom, u.prenom, u.nom_ini, u.prenom_ini, u.promo, u.nom_usage, u.nationalite,
                q.profile_mobile, q.profile_mobile_pub, q.profile_web, q.profile_web_pub, q.profile_freetext, q.profile_freetext_pub, q.profile_nick,
                 a1.aid, a1.type, a2.aid, a2.type
           FROM  auth_user_md5   AS u
@@ -30,7 +30,7 @@ $sql = "SELECT  u.nom, u.prenom, u.nom_ini, u.prenom_ini, u.promo, u.epouse, FIN
         WHERE  u.user_id = {?}";
 
 $result = $globals->xdb->query($sql, Session::getInt('uid', -1));
-list($nom, $prenom, $nom_ini, $prenom_ini, $promo, $epouse, $femme, $nationalite,
+list($nom, $prenom, $nom_ini, $prenom_ini, $promo, $nom_usage, $nationalite,
        $mobile, $mobile_pub, $web, $web_pub, $freetext, $freetext_pub, $nickname, 
         $appli_id1,$appli_type1, $appli_id2,$appli_type2) = $result->fetchOneRow();
 
index c38e662..7f699fc 100644 (file)
 
 //declaration des fonctions msarty pour les binets et groupex
 
-$sql = "SELECT u.nom, u.prenom".
-    ", u.promo, epouse, u.flags, section".
+$sql = "SELECT section".
     " FROM auth_user_md5 AS u".
     " WHERE user_id = {?}";
 
 $result = $globals->xdb->query($sql, Session::getInt('uid', -1));
-list($nom, $prenom, $promo, $epouse, $flags, $section) = $result->fetchOneRow();
+$section = $result->fetchOneCell();
 
 replace_ifset($section,'section');
 
index f6e41f7..dffb6c2 100644 (file)
@@ -25,8 +25,8 @@ require_once("xorg.misc.inc.php");
 
 $globals->search->result_fields = '
                 u.user_id, u.promo, u.matricule, u.matricule_ax,
-               if(u.epouse=\'\', u.nom, u.epouse) AS NomSortKey,
-                u.epouse,u.date,
+               if(u.nom_usage=\'\', u.nom, u.nom_usage) AS NomSortKey,
+                u.nom_usage,u.date,
                 u.deces!=0 AS dcd,u.deces,
                u.perms IN (\'admin\',\'user\') AS inscrit,
                u.perms != \'pending\' AS wasinscrit,
@@ -264,7 +264,7 @@ class QuickSearch extends SField
        foreach ($this->strings as $s) {
            $t = '%'.str_replace('*', '%', $s).'%';
            $t = str_replace('%%', '%', $t);
-           $where[] = "(u.nom LIKE '$t' OR u.epouse LIKE '$t' OR u.prenom LIKE '$t')";
+           $where[] = "(u.nom LIKE '$t' OR u.nom_usage LIKE '$t' OR u.prenom LIKE '$t')";
        }
        
        $wherep = Array();
@@ -298,8 +298,8 @@ class QuickSearch extends SField
        $order = "0";
         $sep   = "[ \\'\\-]";
        foreach ($this->strings as $s) {
-           $order .= " + ( (u.nom='$s' OR u.epouse='$s') + (CONCAT(' ',u.nom,' ',u.epouse,' ') RLIKE '$sep{$s}$sep') )*1000
-                        + ( CONCAT(' ',u.nom,' ',u.epouse,' ') RLIKE '$sep{$s}' )*100
+           $order .= " + ( (u.nom='$s' OR u.nom_usage='$s') + (CONCAT(' ',u.nom,' ',u.nom_usage,' ') RLIKE '$sep{$s}$sep') )*1000
+                        + ( CONCAT(' ',u.nom,' ',u.nom_usage,' ') RLIKE '$sep{$s}' )*100
                         + ( (u.prenom = '$s') + (CONCAT(' ',u.prenom,' ') RLIKE '$sep{$s}$sep') )*10
                         + ( u.prenom RLIKE '(^|$sep){$s}' )";
        }
index 880f01b..5c7876e 100644 (file)
@@ -46,7 +46,7 @@ function get_user_ax($uid, $raw=false)
     $ancien = $array['dump']['ancien'];
     $userax['nom'] = $ancien[0];
     // ancien1 = ?
-    $userax['epouse'] = ($ancien[2] != $ancien[0])?$ancien[2]:"";
+    $userax['nom_usage'] = ($ancien[2] != $ancien[0])?$ancien[2]:"";
     // ancien3 = ?
     $userax['prenom'] = $ancien[4];
     $userax['sexe'] = ($ancien[5] != 'M')?1:0;
@@ -129,12 +129,12 @@ function get_user_ax($uid, $raw=false)
     return $userax;
 }
 
-function import_from_ax($userax, $epouse=false, $mobile=false, $del_address=null, $add_address=null, $del_pro=null, $add_pro=null, $nationalite=false)
+function import_from_ax($userax, $nom_usage=false, $mobile=false, $del_address=null, $add_address=null, $del_pro=null, $add_pro=null, $nationalite=false)
 { 
     global $globals;
 
-    if ($epouse) {
-        $globals->xdb->execute("UPDATE auth_user_md5 SET epouse = {?} WHERE user_id = {?}", strtoupper($userax['epouse']), $userax['uid']);
+    if ($nom_usage) {
+        $globals->xdb->execute("UPDATE auth_user_md5 SET nom_usage = {?} WHERE user_id = {?}", strtoupper($userax['nom_usage']), $userax['uid']);
     }
     
     if ($mobile) {
index 3c0c114..b9350fa 100644 (file)
@@ -155,7 +155,7 @@ function get_user_forlife($data) {
 function &get_user_details($login, $from_uid = '')
 {
     global $globals;
-    $reqsql = "SELECT  u.user_id, u.promo, u.prenom, u.nom, u.epouse, u.date, u.cv,
+    $reqsql = "SELECT  u.user_id, u.promo, u.prenom, u.nom, u.nom_usage, u.date, u.cv,
                        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, q.profile_from_ax, q.profile_mobile AS mobile, q.profile_web AS web, q.profile_freetext AS freetext,
                        q.profile_mobile_pub AS mobile_pub, q.profile_web_pub AS web_pub, q.profile_freetext_pub AS freetext_pub,
similarity index 62%
rename from include/validations/epouses.inc.php
rename to include/validations/nomusage.inc.php
index 0ee56f4..a61841a 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-// {{{ class EpouseReq
+// {{{ class UsageReq
 
-class EpouseReq extends Validate
+class UsageReq extends Validate
 {
     // {{{ properties
 
     var $unique = true;
 
-    var $epouse;
+    var $nom_usage;
     var $alias = '';
 
-    var $oldepouse;
+    var $oldusage;
     var $oldalias;
 
     var $homonyme;
     
     var $rules = "Refuser 
     tout ce qui n'est visiblement pas un nom de famille (ce qui est 
-    extrmement rare car à peu près n'importe quoi peut être un nom de 
+    extremement rare car à peu près n'importe quoi peut être un nom de 
     famille...)";
 
     // }}}
     // {{{ constructor
 
-    function EpouseReq($_uid, $_epouse)
+    function UsageReq($_uid, $_usage)
     {
         global $globals;
-        $this->Validate($_uid, true, 'epouse');
-        $this->epouse  = $_epouse;
-        $this->alias   = make_username($this->prenom, $this->epouse);
+        $this->Validate($_uid, true, 'usage');
+        $this->nom_usage  = $_usage;
+        $this->alias   = make_username($this->prenom, $this->nom_usage);
+        if (!$this->nom_usage) $this->alias = "";
 
         $res = $globals->xdb->query("
-                SELECT  e.alias, u.epouse, a.id
+                SELECT  e.alias, u.nom_usage, a.id
                   FROM  auth_user_md5 as u
-             LEFT JOIN  aliases       as e ON(e.type='alias' AND FIND_IN_SET('epouse',e.flags) AND e.id = u.user_id)
+             LEFT JOIN  aliases       as e ON(e.type='alias' AND FIND_IN_SET('usage',e.flags) AND e.id = u.user_id)
              LEFT JOIN  aliases       as a ON(a.alias = {?} AND a.id != u.user_id)
                  WHERE  u.user_id = {?}", $this->alias, $this->uid);
-        list($this->oldalias, $this->oldepouse, $this->homonyme) = $res->fetchOneRow();
+        list($this->oldalias, $this->oldusage, $this->homonyme) = $res->fetchOneRow();
     }
 
     // }}}
@@ -64,21 +65,21 @@ class EpouseReq extends Validate
 
     function get_request($uid)
     {
-        return parent::get_request($uid,'epouse');
+        return parent::get_request($uid,'usage');
     }
 
     // }}}
     // {{{ function formu()
 
     function formu()
-    { return 'include/form.valid.epouses.tpl'; }
+    { return 'include/form.valid.nomusage.tpl'; }
 
     // }}}
     // {{{ function _mail_subj()
 
     function _mail_subj()
     {
-        return "[Polytechnique.org/EPOUSE] Changement de nom de mariage";
+        return "[Polytechnique.org/USAGE] Changement de nom d'usage";
     }
 
     // }}}
@@ -88,14 +89,16 @@ class EpouseReq extends Validate
     {
         global $globals;
         if ($isok) {
-            $res = "  La demande de changement de nom de mariage que tu as demandée vient d'être effectuée.";
+            $res = "  La demande de changement de nom d'usage que tu as demandée vient d'être effectuée.";
             if ($this->oldalias) {
                 $res .= "\n\n  Les alias {$this->oldalias}@{$globals->mail->domain} et @{$globals->mail->domain2} ont été supprimés.";
             }
-            $res .= "\n\n  Les alias {$this->alias}@{$globals->mail->domain} et @{$globals->mail->domain2} sont maintenant à ta disposition !";
+            if ($nom_usage) {
+                $res .= "\n\n  Les alias {$this->alias}@{$globals->mail->domain} et @{$globals->mail->domain2} sont maintenant à ta disposition !";
+            }
             return $res;
         } else {
-            return "  La demande de changement de nom de mariage que tu avais faite a été refusée.";
+            return "  La demande de changement de nom d'usage que tu avais faite a été refusée.";
         }
     }
 
@@ -106,11 +109,17 @@ class EpouseReq extends Validate
     {
         global $globals;
 
-        $globals->xdb->execute("UPDATE auth_user_md5 set epouse={?} WHERE user_id={?}",$this->epouse ,$this->uid);
-        $globals->xdb->execute("DELETE FROM aliases WHERE FIND_IN_SET('epouse',flags) AND id={?}", $this->uid);
-        $globals->xdb->execute("UPDATE aliases SET flags='' WHERE flags='bestalias' AND id={?}", $this->uid);
-        $globals->xdb->execute("INSERT INTO aliases VALUES({?}, 'alias', 'epouse,bestalias', {?}, null)",
+        $globals->xdb->execute("UPDATE auth_user_md5 set nom_usage={?} WHERE user_id={?}",$this->nom_usage ,$this->uid);
+        $globals->xdb->execute("DELETE FROM aliases WHERE FIND_IN_SET('usage',flags) AND id={?}", $this->uid);
+        if ($this->alias) {
+            $globals->xdb->execute("UPDATE aliases SET flags=flags & 255-1 WHERE id={?}", $this->uid);
+            $globals->xdb->execute("INSERT INTO aliases VALUES({?}, 'alias', 'usage,bestalias', {?}, null)",
                 $this->alias, $this->uid);
+        }
+        $r = $globals->xdb->query("SELECT alias FROM aliases WHERE FIND_IN_SET('bestalias', flags) AND id = {?}", $this->uid);
+        if ($r->fetchOneCell() == "") {
+            $globals->xdb->execute("UPDATE aliases SET flags = 1 | flags WHERE id = {?} LIMIT 1", $this->uid);
+        }
         $f = fopen("/tmp/flag_recherche","w");
         fputs($f,"1");
         fclose($f);
index 13f81d1..6c1c2c6 100644 (file)
@@ -29,7 +29,7 @@ list($username, $path) = preg_split('/\//', $_SERVER["REQUEST_URI"], 2, PREG_SPL
 $res = $globals->xdb->query(
         "SELECT  redirecturl
            FROM  auth_user_quick AS a
-     INNER JOIN  aliases         AS al ON (al.id = a.user_id AND (al.type='a_vie' OR al.type='alias' OR al.type='epouse'))
+     INNER JOIN  aliases         AS al ON (al.id = a.user_id AND (al.type='a_vie' OR al.type='alias'))
           WHERE  al.alias = {?}", $username);
 
 if ($url = $res->fetchOneCell()) {
diff --git a/templates/epouse.tpl b/templates/epouse.tpl
deleted file mode 100644 (file)
index d493cae..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-{***************************************************************************
- *  Copyright (C) 2003-2004 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************}
-
-
-<h1>
-  Nom de mariage
-</h1>
-
-{if !$is_femme}
-
-<p class="erreur">
-  Tu n'es pas autorisé à avoir accès à cette page !
-</p>
-
-{else}
-
-  {if $same}
-  <p class="erreur">
-      Si ton nom de mariage est identique à ton nom à l'X, il n'est pas
-      nécessaire de le saisir ici!
-  </p>
-  {else}
-    {if $myepouse}
-    {if $epouse_old}
-    <p>
-      Ta demande de suppression de ton nom de mariage ainsi que de tes
-      alias {$alias_old}@polytechnique.org et
-      {$alias_old}@m4x.org a bien été enregistrée. 
-    </p>
-    {/if}
-
-    {if $myepouse->alias}
-    <p>
-      Ta demande d'ajout de ton nom de mariage a bien été enregistrée. Sa
-      validation engendrera la création des alias
-      <strong>{$myepouse->alias}@polytechnique.org</strong> et
-      <strong>{$myepouse->alias}@m4x.org</strong>.
-    </p>
-    {/if}
-    
-    <p>
-      Tu recevras un mail dès que les changements demandés auront été effectués. 
-      Encore merci de nous faire confiance pour tes e-mails !
-    </p>
-
-    {else}
-
-    <p>
-    Afin d'être joignable à la fois sous ton nom à l'X et sous ton nom de mariage, tu peux
-    saisir ici ce dernier. Il apparaîtra alors dans l'annuaire et tu disposeras
-    des adresses correspondantes @m4x.org et @polytechnique.org, en plus de
-    celles que tu possèdes déjà.
-    </p>
-
-    <br />
-
-    <form action="{$smarty.server.PHP_SELF}" method="post">
-      <table class="bicol" cellpadding="4" summary="Nom d'epouse">
-        <tr>
-          <th>Nom de mariage</th>
-        </tr>
-        <tr>
-          <td class="center"><input type="text" name="epouse" value="{$epouse_old}" /></td>
-        </tr>
-        <tr>
-          <td class="center"><input type="submit" name="submit" value="Envoyer" /></td>
-        </tr>
-      </table>
-    </form>
-    {/if}
-  {/if}
-{/if}
-  
-
-{* vim:set et sw=2 sts=2 sws=2: *}
index 18e30c9..c16e8fa 100644 (file)
@@ -31,7 +31,7 @@ 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}
+        {$x.prenom} {if $x.nom_usage eq ""}{$x.nom}{else}{$x.nom_usage} ({$x.nom}){/if}
         {min_auth level="cookie"}
         {if $x.nickname} (aka {$x.nickname}){/if}&nbsp;
         <a href="vcard.php/{$x.forlife}.vcf?x={$x.forlife}">
similarity index 96%
rename from templates/include/form.valid.epouses.tpl
rename to templates/include/form.valid.nomusage.tpl
index 7f4555c..489d6d8 100644 (file)
@@ -20,8 +20,8 @@
 
 
 <tr class="impair">
-  <td class="titre">Épouse&nbsp;:</td>
-  <td>{$valid->epouse}</td>
+  <td class="titre">Nom d'usage&nbsp;:</td>
+  <td>{$valid->nom_usage}</td>
 </tr>
 <tr class="impair">
   <td class="titre">Nouvel&nbsp;alias&nbsp;:</td>
index 0cdccd8..11e098d 100644 (file)
@@ -30,7 +30,7 @@
     {only_public}
     {if !$c.dcd && $c.inscrit}<a href="{"fiche.php"|url}?user={$c.user_id}" class="popup2">{/if}
     {/only_public}
-    {if $c.epouse}{$c.epouse} {$c.prenom}<br />(née {$c.nom}){else}{$c.nom} {$c.prenom}{/if}
+    {if $c.nom_usage}{$c.nom_usage} {$c.prenom}<br />({$c.nom}){else}{$c.nom} {$c.prenom}{/if}
     {if !$c.dcd && $c.inscrit}</a>{/if}
   </div>
 
diff --git a/templates/nomusage.tpl b/templates/nomusage.tpl
new file mode 100644 (file)
index 0000000..a23d867
--- /dev/null
@@ -0,0 +1,83 @@
+{***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************}
+
+
+<h1>
+  Nom d'usage
+</h1>
+
+{if $same}
+<p class="erreur">
+    Si ton nom d'usage est identique à ton nom à l'X, il n'est pas
+    nécessaire de le saisir ici!
+</p>
+{else}
+  {if $myusage}
+  {if $usage_old}
+  <p>
+    Ta demande de suppression de ton nom d'usage ainsi que de tes
+    alias {$alias_old}@polytechnique.org et
+    {$alias_old}@m4x.org a bien été enregistrée. 
+  </p>
+  {/if}
+
+  {if $myusage->alias}
+  <p>
+    Ta demande d'ajout de ton nom d'usage a bien été enregistrée. Sa
+    validation engendrera la création des alias
+    <strong>{$myusage->alias}@polytechnique.org</strong> et
+    <strong>{$myusage->alias}@m4x.org</strong>.
+  </p>
+  {/if}
+  
+  <p>
+    Tu recevras un mail dès que les changements demandés auront été effectués. 
+    Encore merci de nous faire confiance pour tes e-mails !
+  </p>
+
+{else}
+
+  <p>
+  Afin d'être joignable à la fois sous ton nom à l'X et sous ton nom d'usage, tu peux
+  saisir ici ce dernier. Il apparaîtra alors dans l'annuaire et tu disposeras
+  des adresses correspondantes @m4x.org et @polytechnique.org, en plus de
+  celles que tu possèdes déjà.
+  </p>
+
+  <br />
+
+  <form action="{$smarty.server.PHP_SELF}" method="post">
+    <table class="bicol" cellpadding="4" summary="Nom d'usage">
+      <tr>
+        <th>Nom d'usage</th>
+      </tr>
+      <tr>
+        <td class="center"><input type="text" name="nom_usage" value="{$usage_old}" /></td>
+      </tr>
+      <tr>
+        <td class="center"><input type="submit" name="submit" value="Envoyer" /></td>
+      </tr>
+    </table>
+  </form>
+  {/if}
+{/if}
+
+
+{* vim:set et sw=2 sts=2 sws=2: *}
index 7f75266..acf508c 100644 (file)
         <span class="nom">X{$promo}</span>
       </td>
     </tr>     
-    {if $femme}
     <tr>
       <td class="colg">
-        <span class="titre">Nom de mariage</span><br />
+        <span class="titre">Nom d'usage</span><br />
         <span class="comm">(si différent de {$nom} seulement)</span>
       </td>
       <td class="cold">
-        <span class="nom">{$epouse|default:"Aucun"}</span>
-        <span class="lien"><a href="epouse.php">modifier</a></span>
+        <span class="nom">{$nom_usage|default:"Aucun"}</span>
+        <span class="lien"><a href="nomusage.php">modifier</a></span>
       </td>
     </tr>
-    {/if}
     <tr>
       <td class="colg">
         <span class="titre">Nationalité</span>
index c84d9e3..c1409a8 100644 (file)
  ***************************************************************************}
 BEGIN:VCARD
 VERSION:3.0
-{if $vcard.epouse}
-FN;ENCODING=QUOTED-PRINTABLE:{"`$vcard.prenom` `$vcard.epouse` (`$vcard.nom`)"|qp_enc}
+{if $vcard.nom_usage}
+FN;ENCODING=QUOTED-PRINTABLE:{"`$vcard.prenom` `$vcard.nom_usage` (`$vcard.nom`)"|qp_enc}
 {else}
 FN;ENCODING=QUOTED-PRINTABLE:{"`$vcard.prenom` `$vcard.nom`"|qp_enc}
 {/if}
-N;ENCODING=QUOTED-PRINTABLE:{$vcard.nom|qp_enc};{$vcard.prenom|qp_enc};{$vcard.epouse|qp_enc};;
+N;ENCODING=QUOTED-PRINTABLE:{$vcard.nom|qp_enc};{$vcard.prenom|qp_enc};{$vcard.nom_usage|qp_enc};;
 EMAIL;TYPE=internet:{$vcard.bestalias}@polytechnique.org
 {if $vcard.bestalias neq $vcard.forlife}
 EMAIL;TYPE=internet:{$vcard.forlife}@polytechnique.org
diff --git a/upgrade/0.9.5/50_aliases.sql b/upgrade/0.9.5/50_aliases.sql
new file mode 100644 (file)
index 0000000..baac2a4
--- /dev/null
@@ -0,0 +1,4 @@
+ALTER TABLE aliases CHANGE flags flags SET('bestalias','usage','epouse') NOT NULL;
+UPDATE aliases SET flags = 'usage,epouse' WHERE flags='epouse';
+UPDATE aliases SET flags = 'usage,epouse,bestalias' WHERE flags='epouse,bestalias';
+
diff --git a/upgrade/0.9.5/60_auth_user_md5.sql b/upgrade/0.9.5/60_auth_user_md5.sql
new file mode 100644 (file)
index 0000000..f5272cc
--- /dev/null
@@ -0,0 +1,2 @@
+ALTER TABLE auth_user_md5 CHANGE epouse nom_usage VARCHAR(255) NOT NULL;
+