general done THE RIGHT WAY ;p
authorx2000habouzit <x2000habouzit>
Tue, 31 Aug 2004 15:03:33 +0000 (15:03 +0000)
committerx2000habouzit <x2000habouzit>
Tue, 31 Aug 2004 15:03:33 +0000 (15:03 +0000)
now have to convert every one else

htdocs/profil.php
include/profil/assign_general.inc.php [new file with mode: 0644]
include/profil/get_general.inc.php [moved from include/profil/profil_general.inc.php with 76% similarity]
include/profil/verif_general.inc.php
templates/profil.tpl

index a1a18c3..fe2504f 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: profil.php,v 1.6 2004-08-31 14:48:56 x2000habouzit Exp $
+        $Id: profil.php,v 1.7 2004-08-31 15:03:33 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -65,11 +65,22 @@ if (!$naissance)  {
     $page->run();//on affiche le formulaire pour naissance
 }
 
+$errs=Array();
+
 //doit-on faire un update ?
 if (isset($_REQUEST['modifier']) || isset($_REQUEST['suivant'])) {
-    require_once("profil/profil_{$opened_tab}.inc.php");
+    require_once("profil/get_{$opened_tab}.inc.php");
     require_once("profil/verif_{$opened_tab}.inc.php");
 
+    if(isset($verif_errs)) {
+       require_once("profil/assign_{$opened_tab}.inc.php");
+       $page->assign("errs", $errs);
+       $page->assign('onglet',$opened_tab);
+       $page->assign('onglet_last',get_last_tab());
+       $page->assign('onglet_tpl',"profil/$opened_tab.tpl");
+       $page->run();
+    }
+
     $date=date("Y-m-j");//nouvelle date de mise a jour
 
     //On sauvegarde l'uid pour l'AX
@@ -102,9 +113,11 @@ if (isset($_REQUEST['modifier']) || isset($_REQUEST['suivant'])) {
     $page->assign('etat_update','ok');
 }
 
-require_once("profil/profil_{$new_tab}.inc.php");
+require_once("profil/get_{$new_tab}.inc.php");
 require_once("profil/verif_{$new_tab}.inc.php");
+require_once("profil/assign_{$new_tab}.inc.php");
 
+$page->assign("errs", $errs);
 $page->assign('onglet',$new_tab);
 $page->assign('onglet_last',get_last_tab());
 $page->assign('onglet_tpl',"profil/$new_tab.tpl");
diff --git a/include/profil/assign_general.inc.php b/include/profil/assign_general.inc.php
new file mode 100644 (file)
index 0000000..50ab041
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************
+        $Id: assign_general.inc.php,v 1.1 2004-08-31 15:03:33 x2000habouzit Exp $
+ ***************************************************************************/
+
+$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('nom', $nom);
+$page->assign('prenom', $prenom);
+$page->assign('promo', $promo);
+$page->assign('epouse', $epouse);
+$page->assign('femme', $femme);
+$page->assign('alias', $alias);
+
+$page->assign('nationalite',$nationalite);
+
+$page->assign('mobile',$mobile);
+
+$page->assign('web',$web);
+
+$page->assign('libre',$libre);
+
+$page->assign('appli_id1',$appli_id1);
+$page->assign('appli_id2',$appli_id2);
+$page->assign('appli_type1',$appli_type1);
+$page->assign('appli_type2',$appli_type2);
+
+?>
similarity index 76%
rename from include/profil/profil_general.inc.php
rename to include/profil/get_general.inc.php
index e398fee..d7396fb 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: profil_general.inc.php,v 1.4 2004-08-31 14:48:57 x2000habouzit Exp $
+        $Id: get_general.inc.php,v 1.1 2004-08-31 15:03:33 x2000habouzit Exp $
  ***************************************************************************/
 
 // on ramène les données du profil connecté (uid paramètre de session)
@@ -43,41 +43,23 @@ list($nom, $prenom,
      $libre, $alias,
      $appli_id1,$appli_type1,
      $appli_id2,$appli_type2) = mysql_fetch_row($result);
-if(mysql_errno($conn) !=0) echo mysql_errno($conn).": ".mysql_error($conn);
 
 mysql_free_result($result);
 
-$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('nom', $nom);
-$page->assign('prenom', $prenom);
-$page->assign('promo', $promo);
-$page->assign('epouse', $epouse);
-$page->assign('femme', $femme);
-$page->assign('alias', $alias);
-
 replace_ifset($nationalite,'nationalite');
-$page->assign('nationalite',$nationalite);
-
 replace_ifset($mobile,'mobile');
-$page->assign('mobile',$mobile);
-
 replace_ifset($web,"web");
-$page->assign('web',$web);
-
 replace_ifset($libre,"libre");
-$page->assign('libre',$libre);
-
 replace_ifset($appli_id1,"appli_id1");
 replace_ifset($appli_id2,"appli_id2");
-$page->assign('appli_id1',$appli_id1);
-$page->assign('appli_id2',$appli_id2);
 replace_ifset($appli_type1,"appli_type1");
 replace_ifset($appli_type2,"appli_type2");
-$page->assign('appli_type1',$appli_type1);
-$page->assign('appli_type2',$appli_type2);
+
+if(isset($_REQUEST['modifier']) || isset($_REQUEST['suivant'])) {
+    $mobile_public = (isset($_REQUEST['mobile_public']));
+    $mobile_ax = (isset($_REQUEST['mobile_ax']));
+    $libre_public = (isset($_REQUEST['libre_public']));
+    $web_public = (isset($_REQUEST['web_public']));
+}
 
 ?>
index 3a555d3..9f04e92 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: verif_general.inc.php,v 1.3 2004-08-31 14:48:57 x2000habouzit Exp $
+        $Id: verif_general.inc.php,v 1.4 2004-08-31 15:03:33 x2000habouzit Exp $
  ***************************************************************************/
 
 
 // validité du mobile
-if (strlen(strtok($mobile,"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($mobile))
-{
-  $str_error = $str_error."Le champ 'Téléphone mobile' contient un caractère interdit.<BR />"; 
+if (strlen(strtok($mobile,"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($mobile)) {
+    $verif_errs = true;
+    $errs[] = "Le champ 'Téléphone mobile' contient un caractère interdit."; 
 }
 
 // correction du champ web si vide
 if ($web=="http://" or $web == '') {
-  $web='';
+    $web='';
 } elseif (!preg_match("{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i", $web)) {
-  // validité de l'url donnée dans web
-  $str_error = $str_error."URL incorrecte dans le champ 'Page web perso', une url doit commencer par http:// ou https:// ou ftp:// et ne pas contenir de caractères interdits<BR />";
+    // validité de l'url donnée dans web
+    $errs[] = "URL incorrecte dans le champ 'Page web perso', une url doit commencer par http:// ou https:// ou ftp:// et ne pas contenir de caractères interdits";
 } else {
-  $web = str_replace('&', '&amp;', $web);
+    $web = str_replace('&', '&amp;', $web);
 }
 
 //validité du champ libre
 if (strlen(strtok($libre,"<>")) < strlen($libre))
 {
-  $str_error = $str_error."Le champ 'Complément libre' contient un caractère interdit.<BR />";
+    $errs[] = "Le champ 'Complément libre' contient un caractère interdit.";
 }
 
-$mobile_public = (isset($_REQUEST['mobile_public']));
-$mobile_ax = (isset($_REQUEST['mobile_ax']));
-$libre_public = (isset($_REQUEST['libre_public']));
-$web_public = (isset($_REQUEST['web_public']));
-
 ?>
index be7030f..e64ab95 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: profil.tpl,v 1.8 2004-08-31 13:59:44 x2000habouzit Exp $
+        $Id: profil.tpl,v 1.9 2004-08-31 15:03:33 x2000habouzit Exp $
  ***************************************************************************}
 
 
 {/if}
 {if $etat_naissance == '' || $etat_naissance == 'ok'}
 
+{foreach from=$errs item=e}
+<p class="erreur">{$e}</p>
+{/foreach}
+
 <p>Tu peux consulter <a href="javascript:x()" onclick="popWin('fiche.php?user={$smarty.session.username}','_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=620,height=370')">l'état actuel de ta fiche</a> tel qu'elle apparaîtra pour un camarade.</p>
 
 <form action="{$smarty.server.PHP_SELF}" method="post" id="prof_annu">