transfert de web, mobile et freetext de md5 a quick
authorPascal Corpet <pascal.corpet@m4x.org>
Sun, 30 Jan 2005 14:32:31 +0000 (14:32 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:56 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-414

htdocs/advanced_search.php
htdocs/profil.php
include/profil/assign_general.inc.php
include/profil/get_general.inc.php
include/profil/update_general.inc.php
include/profil/verif_general.inc.php
include/user.func.inc.php
templates/fiche.tpl
templates/profil/general.tpl
upgrade/0.9.5/10_auth_user_quick.sql [new file with mode: 0644]
upgrade/0.9.5/update.sh [new file with mode: 0755]

index f932bbe..0e9a02c 100644 (file)
@@ -95,7 +95,7 @@ if (!Env::has('rechercher')) {
     $schoolField     = new RefSField('school',array('as.aid'),'applis_ins','`as`','u.user_id=as.uid');
     $diplomaField    = new RefSField('diploma',array('ad.type'),'applis_ins','ad','u.user_id=ad.uid');
   
-    $freeField       = new RefSField('free',array('u.libre'),'','','',false);
+    $freeField       = new RefSField('free',array('q.profile_freetext'),'','','',false);
     $offset          = new NumericSField('offset');
   
     $fields          = new SFieldGroup(true, array( $nameField, $firstnameField, $nicknameField, $promo1Field,
index ef14602..1d08633 100644 (file)
@@ -41,15 +41,13 @@ if (Env::has('old_tab') && isset($tabname_array[Env::get('old_tab')])) {
 }
 $new_tab = Env::has('suivant') ? get_next_tab($opened_tab) : $opened_tab;
 
-// pour tous les tabs, on recupere les bits car on a besoin de tous les bits pour en mettre a jour un, la date d naissance pour verifier
+// pour tous les tabs, la date de naissance pour verifier
 // quelle est bien rentree et la date.
 $res = $globals->xdb->query(
-        "SELECT  FIND_IN_SET('mobile_public', bits), FIND_IN_SET('mobile_ax', bits),
-                 FIND_IN_SET('web_public', bits), FIND_IN_SET('libre_public', bits),
-                 naissance, DATE_FORMAT(date,'%d.%m.%Y')
+        "SELECT  naissance, DATE_FORMAT(date,'%d.%m.%Y')
            FROM  auth_user_md5
           WHERE  user_id={?}", Session::getInt('uid'));
-list($mobile_public, $mobile_ax,$web_public, $libre_public, $naissance, $date_modif_profil) = $res->fetchOneRow();
+list($naissance, $date_modif_profil) = $res->fetchOneRow();
 
 // lorsqu'on n'a pas la date de naissance en base de données
 if (!$naissance)  {
@@ -93,16 +91,6 @@ if (Env::has('modifier') || Env::has('suivant')) {
     */
     $globals->xdb->execute('REPLACE INTO user_changes SET user_id={?}', Session::getInt('uid'));
 
-    //Mise a jour des bits
-    // bits : set('mobile_public','mobile_ax','web_public','libre_public')
-    $bits_reply = "";
-    if ($mobile_public) $bits_reply .= 'mobile_public,';
-    if ($mobile_ax) $bits_reply .= 'mobile_ax,';
-    if ($web_public) $bits_reply .= 'web_public,';
-    if ($libre_public) $bits_reply .= 'libre_public,';
-    if (!empty($bits_reply)) $bits_reply = substr($bits_reply, 0, -1);
-    $globals->xdb->execute('UPDATE auth_user_md5 set bits={?} WHERE user_id={?}', $bits_reply, Session::getInt('uid'));
-    
     if (!Session::has('suid')) {
        require_once('notifs.inc.php');
        register_watch_op(Session::getInt('uid'), WATCH_FICHE);
@@ -125,4 +113,5 @@ $page->assign('onglet_last',get_last_tab());
 $page->assign('onglet_tpl',"profil/$new_tab.tpl");
 $page->run();
 
+// vim:set et sws=4 sw=4 sts=4:
 ?>
index b690d57..1f6d572 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-$page->assign('mobile_public',$mobile_public);
-$page->assign('mobile_ax',$mobile_ax);
-$page->assign('libre_public',$libre_public);
-$page->assign('web_public',$web_public);
+$page->assign('mobile_pub',$mobile_pub);
+$page->assign('web_pub',$web_pub);
+$page->assign('freetext_pub',$freetext_pub);
 
 $page->assign('nom', $nom);
 $page->assign('prenom', $prenom);
@@ -36,7 +35,7 @@ $page->assign('mobile',$mobile);
 
 $page->assign('web',$web);
 
-$page->assign('libre',$libre);
+$page->assign('freetext',$freetext);
 
 $page->assign('appli_id1',$appli_id1);
 $page->assign('appli_id2',$appli_id2);
@@ -44,5 +43,5 @@ $page->assign('appli_type1',$appli_type1);
 $page->assign('appli_type2',$appli_type2);
 
 $page->assign('nouvellephoto', $nouvellephoto);
-$page->assign('surnom', $surnom);
+$page->assign('nickname', $nickname);
 ?>
index a755ac5..21957c0 100644 (file)
@@ -20,8 +20,8 @@
  ***************************************************************************/
 
 // 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), u.nationalite, u.mobile, u.web, u.libre,
-                q.profile_nick,
+$sql = "SELECT  u.nom, u.prenom, u.promo, u.epouse, FIND_IN_SET('femme',u.flags), 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
     INNER JOIN  auth_user_quick AS q  USING(user_id)
@@ -30,25 +30,24 @@ $sql = "SELECT  u.nom, u.prenom, u.promo, u.epouse, FIND_IN_SET('femme',u.flags)
         WHERE  u.user_id = {?}";
 
 $result = $globals->xdb->query($sql, Session::getInt('uid', -1));
-list($nom, $prenom, $promo, $epouse, $femme,
-        $nationalite, $mobile, $web, $libre, $surnom
+list($nom, $prenom, $promo, $epouse, $femme, $nationalite,
+       $mobile, $mobile_pub, $web, $web_pub, $freetext, $freetext_pub, $nickname
         $appli_id1,$appli_type1, $appli_id2,$appli_type2) = $result->fetchOneRow();
 
 replace_ifset($nationalite,'nationalite');
 replace_ifset($mobile,'mobile');
 replace_ifset($web,"web");
-replace_ifset($libre,"libre");
+replace_ifset($freetext,"freetext");
 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");
+replace_ifset($nickname,"nickname");
 
 if(Env::has('modifier') || Env::has('suivant')) {
-    $mobile_public = Env::has('mobile_public');
-    $mobile_ax = Env::has('mobile_ax');
-    $libre_public = Env::has('libre_public');
-    $web_public = Env::has('web_public');
+    $mobile_pub = Env::get('mobile_pub');
+    $web_pub = Env::has('web_pub')?'public':'private';
+    $freetext_pub = Env::has('freetext_pub')?'public':'private';
 }
 
 // Y a-t-il une photo en attente de confirmation ?
index 2282592..027fc37 100644 (file)
@@ -29,9 +29,13 @@ if ($appli_id2>0)
 else
      $globals->xdb->execute("DELETE FROM applis_ins WHERE uid= {?} AND ordre=1", Session::getInt('uid', -1));
 
+$globals->xdb->execute('UPDATE auth_user_quick SET profile_mobile_pub = {?}, profile_web_pub = {?}, profile_freetext_pub = {?} WHERE user_id = {?}',
+    $mobile_pub, $web_pub, $freetext_pub, Session::getInt('uid', -1));
+    
 $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));
+          SET nationalite= {?} WHERE user_id= {?}";
+$globals->xdb->execute($sql, $nationalite, Session::getInt('uid', -1));
+$globals->xdb->execute("UPDATE auth_user_quick SET profile_nick={?}, profile_mobile={?}, profile_web={?}, profile_freetext={?} WHERE user_id = {?}", $nickname, $mobile, $web, $freetext, Session::getInt('uid', -1));
 
+// vim:set et sws=4 sts=4 sw=4:
 ?>
index 0b184fe..0df12c5 100644 (file)
@@ -37,7 +37,7 @@ if ($web=="http://" or $web == '') {
 }
 
 //validité du champ libre
-if (strlen(strtok($libre,"<>")) < strlen($libre))
+if (strlen(strtok($freetext,"<>")) < strlen($freetext))
 {
     $page->trig("Le champ 'Complément libre' contient un caractère interdit.");
 }
index 8410932..7ccb82c 100644 (file)
@@ -155,9 +155,9 @@ 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, u.mobile, u.web, u.libre,
+    $reqsql = "SELECT  u.user_id, u.promo, u.prenom, u.nom, u.epouse, 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_nick AS nickname, q.profile_from_ax, q.profile_mobile AS mobile, q.profile_web AS web, q.profile_freetext AS freetext,
                        IF(gp.nat='',gp.pays,gp.nat) AS nationalite, gp.a2 AS iso3166,
                        a.alias AS forlife, a2.alias AS bestalias,
                        c.uid IS NOT NULL AS is_contact,
index acdba44..16cf3b2 100644 (file)
@@ -92,7 +92,7 @@ function chgMainWinLoc( strPage ) {
       {if $x.binets_join}<em class="intitule">Binet(s) : </em><span>{$x.binets_join}</span><br />{/if}
       {if $x.gpxs_join}<em class="intitule">Groupe(s) X : </em><span>{$x.gpxs_join|smarty:nodefaults}</span><br />{/if}
       {if $x.web}<em class="intitule">Site Web : </em><a href="{$x.web}" class='popup'>{$x.web}</a>{/if}
-      {if $x.libre}<br /><em class="intitule">Commentaires : </em><br /><span>{$x.libre|nl2br}</span>{/if}
+      {if $x.freetext}<br /><em class="intitule">Commentaires : </em><br /><span>{$x.freetext|nl2br}</span>{/if}
     </td>
   </tr>
   {if $x.adr}
index 1dddb8a..a30be62 100644 (file)
         <span class="titre">Surnom</span>
       </td>
       <td class="cold">
-        <input type="text" size="35" maxlength="64" name="surnom" value="{$surnom}" />
+        <input type="text" size="35" maxlength="64" name="nickname" value="{$nickname}" />
       </td>
     </tr>
     <tr>
         <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} />
+              <input type="radio" name="mobile_pub" {if $mobile_pub eq 'public'}checked="checked"{/if} value='public' />
             </td>
             <td class="texte">
               site public
             </td>
             <td class="orange">
-              <input type="checkbox" name="mobile_ax" {if $mobile_ax}checked="checked"{/if} />
+              <input type="radio" name="mobile_pub" {if $mobile_pub eq 'ax'}checked="checked"{/if} value='ax' />
             </td>
             <td class="texte">
               transmis à l'AX
             </td>
+            <td class="rouge">
+              <input type="radio" name="mobile_pub" {if $mobile_pub eq 'private'}checked="checked"{/if} value='private' />
+            </td>
+            <td class="texte">
+              privé
+            </td>
             <td class="texte">
               <a href="{"docs/faq.php"|url}#flags" class="popup_800x240">Quelle couleur ??</a>
             </td>
         <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
           <tr>
             <td class="vert">
-              <input type="checkbox" name="web_public" {if $web_public}checked="checked"{/if} />
+              <input type="checkbox" name="web_pub" {if $web_pub eq 'public'}checked="checked"{/if} />
             </td>
             <td class="texte">
               site public
         <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
           <tr>
             <td class="vert">
-              <input type="checkbox" name="libre_public" {if $libre_public}checked="checked"{/if} />
+              <input type="checkbox" name="freetext_pub" {if $freetext_pub eq 'public'}checked="checked"{/if} />
             </td>
             <td class="texte">
               site public
         <span class="comm">Commentaire? ICQ? etc...</span>
       </td>
       <td class="dcold">
-        <textarea name="libre" rows="3" cols="29" >{$libre}</textarea>
+        <textarea name="freetext" rows="3" cols="29" >{$freetext}</textarea>
       </td>
     </tr>
   </table>
diff --git a/upgrade/0.9.5/10_auth_user_quick.sql b/upgrade/0.9.5/10_auth_user_quick.sql
new file mode 100644 (file)
index 0000000..977932b
--- /dev/null
@@ -0,0 +1,15 @@
+ALTER TABLE auth_user_quick
+ADD profile_mobile VARCHAR(20) NOT NULL,
+ADD profile_mobile_pub ENUM('private', 'ax', 'public') DEFAULT 'private' NOT NULL,
+ADD profile_web VARCHAR(255) NOT NULL,
+ADD profile_web_pub ENUM('private', 'public') DEFAULT 'private' NOT NULL,
+ADD profile_freetext VARCHAR(255) NOT NULL,
+ADD profile_freetext_pub ENUM('private', 'public') DEFAULT 'private' NOT NULL;
+UPDATE auth_user_quick AS q INNER JOIN auth_user_md5 AS u USING(user_id) SET
+q.profile_mobile = u.mobile,
+q.profile_mobile_pub = IF(FIND_IN_SET('mobile_public', u.bits), 'public', IF(FIND_IN_SET('mobile_ax', u.bits), 'ax', 'private')),
+q.profile_web = u.web,
+q.profile_web_pub = IF(FIND_IN_SET('web_public', u.bits), 'public', 'private'),
+q.profile_freetext = u.libre,
+q.profile_freetext_pub = IF(FIND_IN_SET('libre_public', u.bits), 'public', 'private');
+ALTER TABLE auth_user_md5 DROP mobile, DROP web, DROP libre, CHANGE bits bits SET('mail_ax') NOT NULL;
diff --git a/upgrade/0.9.5/update.sh b/upgrade/0.9.5/update.sh
new file mode 100755 (executable)
index 0000000..f351939
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+. ../inc/pervasive.sh
+
+mailman_stop
+mailman_templates
+mailman_start
+
+
+###########################################################
+for sql in *.sql
+do
+    echo -n $sql
+    $MYSQL x4dat < $sql &>/dev/null || echo -n " ERROR"
+    echo .
+done
+
+###########################################################
+