From 84121edaccb61c4ae605d286fe4e029c990572c4 Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Sun, 30 Jan 2005 14:32:31 +0000 Subject: [PATCH] transfert de web, mobile et freetext de md5 a quick git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-414 --- htdocs/advanced_search.php | 2 +- htdocs/profil.php | 19 ++++--------------- include/profil/assign_general.inc.php | 11 +++++------ include/profil/get_general.inc.php | 19 +++++++++---------- include/profil/update_general.inc.php | 10 +++++++--- include/profil/verif_general.inc.php | 2 +- include/user.func.inc.php | 4 ++-- templates/fiche.tpl | 2 +- templates/profil/general.tpl | 18 ++++++++++++------ upgrade/0.9.5/10_auth_user_quick.sql | 15 +++++++++++++++ upgrade/0.9.5/update.sh | 19 +++++++++++++++++++ 11 files changed, 76 insertions(+), 45 deletions(-) create mode 100644 upgrade/0.9.5/10_auth_user_quick.sql create mode 100755 upgrade/0.9.5/update.sh diff --git a/htdocs/advanced_search.php b/htdocs/advanced_search.php index f932bbe..0e9a02c 100644 --- a/htdocs/advanced_search.php +++ b/htdocs/advanced_search.php @@ -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, diff --git a/htdocs/profil.php b/htdocs/profil.php index ef14602..1d08633 100644 --- a/htdocs/profil.php +++ b/htdocs/profil.php @@ -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: ?> diff --git a/include/profil/assign_general.inc.php b/include/profil/assign_general.inc.php index b690d57..1f6d572 100644 --- a/include/profil/assign_general.inc.php +++ b/include/profil/assign_general.inc.php @@ -19,10 +19,9 @@ * 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); ?> diff --git a/include/profil/get_general.inc.php b/include/profil/get_general.inc.php index a755ac5..21957c0 100644 --- a/include/profil/get_general.inc.php +++ b/include/profil/get_general.inc.php @@ -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 ? diff --git a/include/profil/update_general.inc.php b/include/profil/update_general.inc.php index 2282592..027fc37 100644 --- a/include/profil/update_general.inc.php +++ b/include/profil/update_general.inc.php @@ -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: ?> diff --git a/include/profil/verif_general.inc.php b/include/profil/verif_general.inc.php index 0b184fe..0df12c5 100644 --- a/include/profil/verif_general.inc.php +++ b/include/profil/verif_general.inc.php @@ -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."); } diff --git a/include/user.func.inc.php b/include/user.func.inc.php index 8410932..7ccb82c 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -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, diff --git a/templates/fiche.tpl b/templates/fiche.tpl index acdba44..16cf3b2 100644 --- a/templates/fiche.tpl +++ b/templates/fiche.tpl @@ -92,7 +92,7 @@ function chgMainWinLoc( strPage ) { {if $x.binets_join}Binet(s) : {$x.binets_join}
{/if} {if $x.gpxs_join}Groupe(s) X : {$x.gpxs_join|smarty:nodefaults}
{/if} {if $x.web}Site Web : {$x.web}{/if} - {if $x.libre}
Commentaires :
{$x.libre|nl2br}{/if} + {if $x.freetext}
Commentaires :
{$x.freetext|nl2br}{/if} {if $x.adr} diff --git a/templates/profil/general.tpl b/templates/profil/general.tpl index 1dddb8a..a30be62 100644 --- a/templates/profil/general.tpl +++ b/templates/profil/general.tpl @@ -183,7 +183,7 @@ Surnom - + @@ -191,17 +191,23 @@ + + @@ -223,7 +229,7 @@
- + site public - + transmis à l'AX + + + privé + Quelle couleur ??
- + site public @@ -249,7 +255,7 @@
- + site public @@ -267,7 +273,7 @@ Commentaire? ICQ? etc... - +
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 index 0000000..977932b --- /dev/null +++ b/upgrade/0.9.5/10_auth_user_quick.sql @@ -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 index 0000000..f351939 --- /dev/null +++ b/upgrade/0.9.5/update.sh @@ -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 + +########################################################### + -- 2.1.4