From: x2000habouzit Date: Fri, 29 Oct 2004 01:24:20 +0000 (+0000) Subject: one table for the nationality is enough ! X-Git-Tag: xorg/old~1148 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=1c73ca408a602bd1c465e5f0d7a911b5829c2272;p=platal.git one table for the nationality is enough ! get rid of the old nationalites --- diff --git a/htdocs/advanced_search.php b/htdocs/advanced_search.php index 170505a..71b24d8 100644 --- a/htdocs/advanced_search.php +++ b/htdocs/advanced_search.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: advanced_search.php,v 1.20 2004-10-24 14:21:30 x2000bedo Exp $ + $Id: advanced_search.php,v 1.21 2004-10-29 01:24:20 x2000habouzit Exp $ ***************************************************************************/ require("auto.prepend.inc.php"); @@ -32,7 +32,7 @@ require_once("geoloc.inc.php"); function form_prepare() { global $page,$globals; $page->assign('formulaire',1); - $sql = 'SELECT id,text FROM nationalites ORDER BY text'; + $sql = 'SELECT a2 AS id,IF(nat=\'\',pays,nat) AS text FROM geoloc_pays ORDER BY text'; $page->mysql_assign($sql,'choix_nationalites'); $sql = 'SELECT id,text FROM binets_def ORDER BY text'; $page->mysql_assign($sql,'choix_binets'); diff --git a/htdocs/fiche.php b/htdocs/fiche.php index 9a515ce..a9b96ce 100644 --- a/htdocs/fiche.php +++ b/htdocs/fiche.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: fiche.php,v 1.15 2004-10-27 18:02:29 x2000coic Exp $ + $Id: fiche.php,v 1.16 2004-10-29 01:24:20 x2000habouzit Exp $ ***************************************************************************/ @@ -43,15 +43,15 @@ if (isset($_REQUEST['user'])) else $where_clause = " WHERE u.matricule = '{$_REQUEST['mat']}'"; -$reqsql = "SELECT u.prenom, u.nom, u.epouse, nationalites.text, +$reqsql = "SELECT u.prenom, u.nom, u.epouse, IF(gp.nat='',gp.pays,gp.nat) AS text u.user_id, a.alias, a2.alias, u.matricule, i.deces != 0 as dcd, i.deces, u.date, u.cv, sections.text, u.mobile, u.web, u.libre, u.promo, c.uid IS NOT NULL, p.x, p.y 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 a ON (u.user_id=a.id AND a.type='a_vie') INNER JOIN aliases AS a2 ON (u.user_id=a2.id AND (a2.type='alias' OR a2.type='epouse') AND a2.alias LIKE '%.%') - LEFT JOIN contacts AS c ON (c.uid = {$_SESSION['uid']} and c.contact = u.user_id) - INNER JOIN nationalites ON(nationalites.id = u.nationalite) + LEFT JOIN contacts AS c ON (c.uid = {$_SESSION['uid']} and c.contact = u.user_id) + INNER JOIN geoloc_pays AS gp ON (gp.a2 = u.nationalite) INNER JOIN sections ON(sections.id = u.section) INNER JOIN identification AS i ON(u.matricule = i.matricule) LEFT JOIN photo as p ON(p.uid = u.user_id)".$where_clause." diff --git a/htdocs/mescontacts.php b/htdocs/mescontacts.php index cba0fb8..a6b71de 100644 --- a/htdocs/mescontacts.php +++ b/htdocs/mescontacts.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: mescontacts.php,v 1.19 2004-10-28 20:28:41 x2000habouzit Exp $ + $Id: mescontacts.php,v 1.20 2004-10-29 01:24:20 x2000habouzit Exp $ ***************************************************************************/ require("auto.prepend.inc.php"); @@ -91,7 +91,7 @@ $sql = "SELECT contact AS id, a.*, l.alias AS forlife, i.deces != 0 AS dcd, i.deces, i.matricule_ax, FIND_IN_SET('femme', i.flags) AS sexe, e.entreprise, es.label AS secteur, ef.fonction_fr AS fonction, - n.text AS nat, n.iso3166, + IF(n.nat='',n.pays,n.nat) AS nat, n.a2 AS iso3166, 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, @@ -103,7 +103,7 @@ $sql = "SELECT contact AS id, LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = a.user_id) LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id) LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id) - LEFT JOIN nationalites AS n ON (a.nationalite = n.id) + LEFT JOIN geoloc_pays AS n ON (a.nationalite = n.a2) LEFT JOIN applis_ins AS ai0 ON (a.user_id = ai0.uid AND ai0.ordre = 0) LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid) LEFT JOIN applis_ins AS ai1 ON (a.user_id = ai1.uid AND ai1.ordre = 1) diff --git a/include/search.classes.inc.php b/include/search.classes.inc.php index 9c5d561..ba2e116 100644 --- a/include/search.classes.inc.php +++ b/include/search.classes.inc.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: search.classes.inc.php,v 1.26 2004-10-28 12:20:59 x2000habouzit Exp $ + $Id: search.classes.inc.php,v 1.27 2004-10-29 01:24:20 x2000habouzit Exp $ ***************************************************************************/ require_once("xorg.misc.inc.php"); @@ -33,7 +33,7 @@ $globals->search_result_fields = ' ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type, ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type, e.entreprise, es.label AS secteur, ef.fonction_fr AS fonction, - n.text AS nat, n.iso3166, + IF(n.nat=\'\',n.pays,n.nat) AS nat, n.a2 AS iso3166, adr.ville, gp.pays, gr.name AS region,'; $globals->search_result_where_statement = ' LEFT JOIN applis_ins AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0) @@ -43,7 +43,7 @@ $globals->search_result_where_statement = ' LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id) LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id) LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id) - LEFT JOIN nationalites AS n ON (u.nationalite = n.id) + LEFT JOIN geoloc_pays AS n ON (u.nationalite = n.a2) LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut)) LEFT JOIN geoloc_pays AS gp ON (adr.pays = gp.a2) LEFT JOIN geoloc_region AS gr ON (adr.pays = gr.a2 AND adr.region = gr.region)'; diff --git a/plugins/function.select_nat.php b/plugins/function.select_nat.php new file mode 100644 index 0000000..8fd34e4 --- /dev/null +++ b/plugins/function.select_nat.php @@ -0,0 +1,51 @@ +db->query($sql); + + $sel = ' selected="selected"'; + + // on ajoute une entree vide si $pad est vrai + $html = ""; + if ($pad) + $html.= '\n"; + while (list($my_id,$my_text) = mysql_fetch_row($result)) { + $html .= sprintf("\n",$my_id,($valeur==$my_id?$sel:""),$my_text); + } + mysql_free_result($result); + return $html; +} + +function smarty_function_select_nat($params, &$smarty) { + if(empty($params['pad']) || !($params['pad'])) + $pad = false; + else + $pad = true; + return select_nat($params['valeur'], $pad); +} + +?> diff --git a/scripts/migration/0.9.2/nationalites.sql b/scripts/migration/0.9.2/nationalites.sql index 17a5edf..395fab0 100644 --- a/scripts/migration/0.9.2/nationalites.sql +++ b/scripts/migration/0.9.2/nationalites.sql @@ -22,6 +22,8 @@ replace INTO `nationalites` VALUES (18,'Canadien','CA'); replace INTO `nationalites` VALUES (19,'Chilien','CL'); replace INTO `nationalites` VALUES (20,'Chinois','CN'); replace INTO `nationalites` VALUES (21,'Colombien','CO'); +replace INTO `nationalites` VALUES (22,'Coréen','KR'); +replace INTO `nationalites` VALUES (86,'Costaricien','CR'); replace INTO `nationalites` VALUES (80,'Croate','HR'); replace INTO `nationalites` VALUES (23,'Cubain','CU'); replace INTO `nationalites` VALUES (24,'Danois','DK'); @@ -83,3 +85,13 @@ replace INTO `nationalites` VALUES (77,'V replace INTO `nationalites` VALUES (78,'Vietnamien','VN'); replace INTO `nationalites` VALUES (79,'Yougoslave','CS'); +alter table geoloc_pays add column nat varchar(100) not null; +update geoloc_pays inner join nationalites ON iso3166=a2 set nat=text; +update auth_user_md5 set nationalite='' where nationalite='0' or nationalite='36'; +alter table auth_user_md5 change column nationalite nationalite varchar(2) not null; +update auth_user_md5 AS u + inner join nationalites AS n ON u.nationalite=n.id + inner join geoloc_pays AS g ON iso3166=a2 + set u.nationalite = a2; + +drop table nationalites; diff --git a/templates/inscription/step2.tpl b/templates/inscription/step2.tpl index 1607010..07c5598 100644 --- a/templates/inscription/step2.tpl +++ b/templates/inscription/step2.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: step2.tpl,v 1.4 2004-10-24 14:41:13 x2000habouzit Exp $ + $Id: step2.tpl,v 1.5 2004-10-29 01:24:21 x2000habouzit Exp $ ***************************************************************************} @@ -104,7 +104,7 @@ diff --git a/templates/profil/general.tpl b/templates/profil/general.tpl index 9549734..7b6b856 100644 --- a/templates/profil/general.tpl +++ b/templates/profil/general.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: general.tpl,v 1.14 2004-10-09 05:57:48 x2000habouzit Exp $ + $Id: general.tpl,v 1.15 2004-10-29 01:24:22 x2000habouzit Exp $ ***************************************************************************} @@ -70,7 +70,7 @@