closes #154.
authorx2000habouzit <x2000habouzit>
Tue, 30 Nov 2004 21:11:38 +0000 (21:11 +0000)
committerx2000habouzit <x2000habouzit>
Tue, 30 Nov 2004 21:11:38 +0000 (21:11 +0000)
for manager, DATE_DIFF is only mysql 4.1.1 :(

ChangeLog
htdocs/inscription/step3.php
htdocs/inscription/step4.php
htdocs/login.php
htdocs/profil.php
htdocs/recovery.php
include/webservices/manageurs.server.inc.php
upgrade/0.9.3/30_auth_user_md5.sql

index 4003e2e..1ad8c26 100644 (file)
--- 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
index e72719a..30c909f 100644 (file)
@@ -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'";
index 80d4d6a..038dfe0 100644 (file)
@@ -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
index e3bf46e..8869c90 100644 (file)
@@ -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;
index 7c347e0..3cddc4f 100644 (file)
@@ -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 {
index d5a3659..5316c0b 100644 (file)
@@ -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");
index ec02eef..df276ad 100644 (file)
@@ -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;
index 75250df..3de96e9 100644 (file)
@@ -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;