From: x2000habouzit Date: Tue, 30 Nov 2004 21:11:38 +0000 (+0000) Subject: closes #154. X-Git-Tag: xorg/old~745 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=72e3b4ad2477b5eff348c3108b28d7aea15afb96;p=platal.git closes #154. for manager, DATE_DIFF is only mysql 4.1.1 :( --- diff --git a/ChangeLog b/ChangeLog index 4003e2e..1ad8c26 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,6 +37,7 @@ Bug/Wish : * Core : - #183,185 : Implement perms levels : 'pending'+'disabled'. -MC + - #154 : Birth fields are now of type DATE. -MC * Fiche : - #83,208,222 : New fiche. -MC diff --git a/htdocs/inscription/step3.php b/htdocs/inscription/step3.php index e72719a..30c909f 100644 --- a/htdocs/inscription/step3.php +++ b/htdocs/inscription/step3.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: step3.php,v 1.7 2004-11-22 20:04:41 x2000habouzit Exp $ + $Id: step3.php,v 1.8 2004-11-30 21:11:39 x2000habouzit Exp $ ***************************************************************************/ require_once("xorg.inc.php"); @@ -58,11 +58,13 @@ if (!isset($_REQUEST["appli_type1"])) $_REQUEST["appli_type1"]=0; if (!isset($_REQUEST["appli_type2"])) $_REQUEST["appli_type2"]=0; if (!isset($loginbis)) $loginbis=""; +$birth = printf("%s-%s-%s", substr($_REQUEST["naissance"],4,4), substr($_REQUEST["naissance"],2,2), substr($_REQUEST["naissance"],0,2)); + // nouvelle inscription $sql="REPLACE INTO en_cours SET ins_id='$ins_id', password='$password', matricule='$matricule', promo='$promo', nom='".addslashes($nom)."', prenom='".addslashes($prenom)."', email='{$_REQUEST['email']}', - naissance='{$_REQUEST['naissance']}', date='$date', nationalite='{$_REQUEST['nationalite']}', + naissance='$birth', date='$date', nationalite='{$_REQUEST['nationalite']}', appli_id1='{$_REQUEST['appli_id1']}', appli_type1='{$_REQUEST['appli_type1']}', appli_id2='{$_REQUEST['appli_id2']}', appli_type2='{$_REQUEST['appli_type2']}', loginbis='$mailorg', username='$forlife'"; diff --git a/htdocs/inscription/step4.php b/htdocs/inscription/step4.php index 80d4d6a..038dfe0 100644 --- a/htdocs/inscription/step4.php +++ b/htdocs/inscription/step4.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: step4.php,v 1.19 2004-11-22 20:04:41 x2000habouzit Exp $ + $Id: step4.php,v 1.20 2004-11-30 21:11:39 x2000habouzit Exp $ ***************************************************************************/ require_once("xorg.inc.php"); @@ -56,7 +56,7 @@ if (!empty($_REQUEST['ref'])) { $nom = stripslashes($nom); $prenom = stripslashes($prenom); $sql = "UPDATE auth_user_md5 SET password='$password', nationalite=$nationalite, perms='user', - date='$date', naissance=$naissance, date_ins = NULL WHERE matricule='$matricule'"; + date='$date', naissance='$naissance', date_ins = NULL WHERE matricule='$matricule'"; $globals->db->query($sql); $sql = "INSERT INTO auth_user_quick (user_id) SELECT user_id diff --git a/htdocs/login.php b/htdocs/login.php index e3bf46e..8869c90 100644 --- a/htdocs/login.php +++ b/htdocs/login.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: login.php,v 1.18 2004-11-22 20:04:35 x2000habouzit Exp $ + $Id: login.php,v 1.19 2004-11-30 21:11:39 x2000habouzit Exp $ ***************************************************************************/ require_once("xorg.inc.php"); @@ -28,7 +28,7 @@ $param=$globals->db->query("SELECT date,naissance FROM auth_user_md5 WHERE user_ list($date,$naissance) = mysql_fetch_row($param); mysql_free_result($param); -if ($naissance==0) { +if ($naissance==0 || $naissance=='0000-00-00') { $page->assign('ask_naissance', true); $page->run('ask-naissance'); exit; diff --git a/htdocs/profil.php b/htdocs/profil.php index 7c347e0..3cddc4f 100644 --- a/htdocs/profil.php +++ b/htdocs/profil.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: profil.php,v 1.16 2004-11-22 20:04:36 x2000habouzit Exp $ + $Id: profil.php,v 1.17 2004-11-30 21:11:39 x2000habouzit Exp $ ***************************************************************************/ require_once("xorg.inc.php"); @@ -56,7 +56,8 @@ if (!$naissance) { } //sinon - $globals->db->query("UPDATE auth_user_md5 SET naissance='{$_REQUEST['birth']}' WHERE user_id=".$_SESSION['uid']); + $birth = printf("%s-%s-%s", substr($_REQUEST["birth"],4,4), substr($_REQUEST["birth"],2,2), substr($_REQUEST["birth"],0,2)); + $globals->db->query("UPDATE auth_user_md5 SET naissance='$birth' WHERE user_id=".$_SESSION['uid']); $page->assign('etat_naissance','ok'); $page->run(); } else { diff --git a/htdocs/recovery.php b/htdocs/recovery.php index d5a3659..5316c0b 100644 --- a/htdocs/recovery.php +++ b/htdocs/recovery.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: recovery.php,v 1.11 2004-11-22 20:04:36 x2000habouzit Exp $ + $Id: recovery.php,v 1.12 2004-11-30 21:11:39 x2000habouzit Exp $ ***************************************************************************/ require_once("xorg.inc.php"); @@ -31,6 +31,7 @@ if (isset($_REQUEST['login']) and isset($_REQUEST['birth'])) { $page->assign('error', "Date de naissance incorrecte ou incohérente"); $page->run(); } + $birth = printf("%s-%s-%s", substr($_REQUEST["birth"],4,4), substr($_REQUEST["birth"],2,2), substr($_REQUEST["birth"],0,2)); $mailorg=strtok($_REQUEST['login'],"@"); @@ -44,13 +45,13 @@ if (isset($_REQUEST['login']) and isset($_REQUEST['birth'])) { $result=$globals->db->query($sql); if (list($uid,$naissance)=mysql_fetch_array($result)) { if((strlen($naissance))<5) { - $globals->db->query("UPDATE auth_user_md5 SET naissance={$_REQUEST['birth']} WHERE user_id=$uid"); - $naissance = $_REQUEST['birth']; + $globals->db->query("UPDATE auth_user_md5 SET naissance='$birth' WHERE user_id=$uid"); + $naissance = $birth; } } mysql_free_result($result); - if ($naissance == $_REQUEST['birth']) { + if ($naissance == $birth) { $page->assign('ok', true); $url=rand_url_id(); $stamp=date("Y-m-d H:i:s"); diff --git a/include/webservices/manageurs.server.inc.php b/include/webservices/manageurs.server.inc.php index ec02eef..df276ad 100644 --- a/include/webservices/manageurs.server.inc.php +++ b/include/webservices/manageurs.server.inc.php @@ -84,10 +84,10 @@ function get_annuaire_infos($method, $params) { if ($array) { // on a bien eu un résultat : le matricule etait bon - //on n'envoit que l'age à manageurs - $year = (int) substr($array['age'],4,4); - $month = (int) substr($array['age'],2,2); - $day = (int) substr($array['age'],4,4); + //on n'envoit que l'age à manageurs le format est YYYY-MM-DD 0123-56-89 + $year = (int) substr($array['age'],0,4); + $month = (int) substr($array['age'],5,2); + $day = (int) substr($array['age'],8,2); $age = (int) date('Y') - $year - 1; if(( $month < (int)date('m')) || (($month == (int)date('m')) && ($day >= (int)date('d')))) $age += 1; diff --git a/upgrade/0.9.3/30_auth_user_md5.sql b/upgrade/0.9.3/30_auth_user_md5.sql index 75250df..3de96e9 100644 --- a/upgrade/0.9.3/30_auth_user_md5.sql +++ b/upgrade/0.9.3/30_auth_user_md5.sql @@ -2,3 +2,15 @@ alter table auth_user_md5 change column perms perms enum('user','admin','non-ins update auth_user_md5 set perms='pending' where perms='non-inscrit'; alter table auth_user_md5 change column perms perms enum('user','admin','pending','disabled'); alter table auth_user_md5 change column comment comment varchar(64) not null; + +alter table auth_user_md5 add column foo int; +update auth_user_md5 set foo=naissance ; +alter table auth_user_md5 change column naissance naissance date not null; +update auth_user_md5 set naissance = concat(foo % 10000, '-', (foo / 10000) % 100, '-', foo / 1000000); +alter table auth_user_md5 drop column foo; + +alter table en_cours add column foo int; +update en_cours set foo=naissance ; +alter table en_cours change column naissance naissance date not null; +update en_cours set naissance = concat(foo % 10000, '-', (foo / 10000) % 100, '-', foo / 1000000); +alter table en_cours drop column foo;