mentor code is now at least 5 times faster, and 2 times smaller
authorx2000habouzit <x2000habouzit>
Tue, 31 Aug 2004 16:04:11 +0000 (16:04 +0000)
committerx2000habouzit <x2000habouzit>
Tue, 31 Aug 2004 16:04:11 +0000 (16:04 +0000)
works

htdocs/profil.php
include/geoloc.inc.php
include/profil/assign_mentor.inc.php [new file with mode: 0644]
include/profil/get_mentor.inc.php [new file with mode: 0644]
include/profil/profil_mentor.inc.php [deleted file]
include/profil/update_mentor.inc.php
include/profil/verif_general.inc.php
include/profil/verif_mentor.inc.php
include/secteur.emploi.inc.php
templates/profil/mentor.tpl

index fe2504f..ba44514 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: profil.php,v 1.7 2004-08-31 15:03:33 x2000habouzit Exp $
+        $Id: profil.php,v 1.8 2004-08-31 16:04:11 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -72,7 +72,7 @@ if (isset($_REQUEST['modifier']) || isset($_REQUEST['suivant'])) {
     require_once("profil/get_{$opened_tab}.inc.php");
     require_once("profil/verif_{$opened_tab}.inc.php");
 
-    if(isset($verif_errs)) {
+    if(!empty($errs)) {
        require_once("profil/assign_{$opened_tab}.inc.php");
        $page->assign("errs", $errs);
        $page->assign('onglet',$opened_tab);
index f9926a4..032b841 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: geoloc.inc.php,v 1.4 2004-08-31 13:59:43 x2000habouzit Exp $
+        $Id: geoloc.inc.php,v 1.5 2004-08-31 16:04:11 x2000habouzit Exp $
  ***************************************************************************/
 
 
  * @return echo
  */
 function geoloc_pays($current) {
-  $sql = "SELECT a2,pays FROM geoloc_pays ORDER BY pays";
+    global $globals;
+    $sql = "SELECT a2,pays FROM geoloc_pays ORDER BY pays";
 
-  $result = $globals->db->query($sql);
-  while (list($my_id,$my_pays) = mysql_fetch_row($result))
-    printf("<option value=\"%s\" %s>%s</option>\n",$my_id,($current==$my_id?"selected='selected'":""),$my_pays);
+    $result = $globals->db->query($sql);
+    while (list($my_id,$my_pays) = mysql_fetch_row($result))
+       printf("<option value=\"%s\" %s>%s</option>\n",$my_id,($current==$my_id?"selected='selected'":""),$my_pays);
 }
 function _geoloc_pays_smarty($params){
   if(!isset($params['pays']))
@@ -46,12 +47,13 @@ $page->register_function('geoloc_pays', '_geoloc_pays_smarty');
  * @return echo
  */
 function geoloc_region($pays,$current) {
-  $sql = "SELECT region,name FROM geoloc_region where a2='".$pays."' ORDER BY name";
-  $result = $globals->db->query($sql);
+    global $globals;
+    $sql = "SELECT region,name FROM geoloc_region where a2='".$pays."' ORDER BY name";
+    $result = $globals->db->query($sql);
   
-  echo "<option value=\"\"></option>";
-  while (list($regid,$regname) = mysql_fetch_row($result))
-    printf("<option value=\"%s\" %s>%s</option>\n",$regid,($current==$regid?"selected='selected'":""),$regname);
+    echo "<option value=\"\"></option>";
+    while (list($regid,$regname) = mysql_fetch_row($result))
+       printf("<option value=\"%s\" %s>%s</option>\n",$regid,($current==$regid?"selected='selected'":""),$regname);
 }
 function _geoloc_region_smarty($params){
   if(!isset($params['pays']))
diff --git a/include/profil/assign_mentor.inc.php b/include/profil/assign_mentor.inc.php
new file mode 100644 (file)
index 0000000..03985b4
--- /dev/null
@@ -0,0 +1,35 @@
+<?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_mentor.inc.php,v 1.1 2004-08-31 16:04:11 x2000habouzit Exp $
+ ***************************************************************************/
+
+$page->assign('mentor_secteur_id_new', $mentor_secteur_id_new);
+$page->assign('can_add_pays', $nb_mentor_pays < $max_mentor_pays);
+$page->assign('can_add_secteurs', $nb_mentor_secteurs < $max_mentor_secteurs);
+$page->assign('mentor_expertise', $mentor_expertise);
+$page->assign('mentor_pid', $mentor_pid);
+$page->assign('mentor_pays', $mentor_pays);
+$page->assign('mentor_sid', $mentor_sid);
+$page->assign('mentor_secteur', $mentor_secteur);
+$page->assign('mentor_ssid', $mentor_ssid);
+$page->assign('mentor_ss_secteur', $mentor_ss_secteur);
+
+?>
diff --git a/include/profil/get_mentor.inc.php b/include/profil/get_mentor.inc.php
new file mode 100644 (file)
index 0000000..248253d
--- /dev/null
@@ -0,0 +1,108 @@
+<?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: get_mentor.inc.php,v 1.1 2004-08-31 16:04:11 x2000habouzit Exp $
+ ***************************************************************************/
+
+require_once('geoloc.inc.php');
+require_once('secteur.emploi.inc.php');
+
+$max_mentor_pays = 10;
+$max_mentor_secteurs = 10;
+
+//recuperation de l'expertise
+$res = $globals->db->query("SELECT expertise FROM mentor WHERE uid = {$_SESSION['uid']}");
+
+if(mysql_num_rows($res) > 0) {
+    list($mentor_expertise) = mysql_fetch_row($res);
+} else {
+    $mentor_expertise = '';
+}
+$mentor_expertise_bd = $mentor_expertise;
+
+//suppression eventuelle d'un pays
+if(isset($_POST['mentor_pays_op']) && ($_POST['mentor_pays_op'] == 'retirer')) {
+    if(isset($_POST['mentor_pays_id'])) {
+        $id_supprimee = $_POST['mentor_pays_id'];
+        $globals->db->query("DELETE FROM mentor_pays WHERE uid = {$_SESSION['uid']} AND pid = '$id_supprimee' LIMIT 1");
+    }
+}
+
+//recuperation des pays
+$res = $globals->db->query("SELECT m.pid, p.pays 
+                    FROM mentor_pays AS m
+                   LEFT JOIN geoloc_pays AS p ON(m.pid = p.a2) WHERE m.uid = {$_SESSION['uid']} LIMIT $max_mentor_pays");
+$nb_mentor_pays = mysql_num_rows($res);
+$mentor_pid = $mentor_pays = Array();
+for($i = 1; $i <= $nb_mentor_pays ; $i++) list($mentor_pid[$i], $mentor_pays[$i]) = mysql_fetch_row($res);
+
+//ajout eventuel d'un pays
+if(isset($_POST['mentor_pays_op']) && ($_POST['mentor_pays_op'] == 'ajouter') && ($nb_mentor_pays < $max_mentor_pays)) {
+    if(isset($_POST['mentor_pays_id']) && ($_POST['mentor_pays_id'] != '00')) {
+       $id_ajoutee = $_POST['mentor_pays_id'];
+       $globals->db->query("INSERT INTO mentor_pays(uid, pid) VALUES('{$_SESSION['uid']}', '$id_ajoutee')");
+       $nb_mentor_pays++;
+       $mentor_pid[$nb_mentor_pays] = $id_ajoutee;
+       $mentor_pays[$nb_mentor_pays] = stripslashes($_POST['mentor_pays_name']);
+    }
+}
+
+
+
+//suppression d'un secteur / ss-secteur
+if(isset($_POST['mentor_secteur_op']) && ($_POST['mentor_secteur_op'] == 'retirer')) {
+    if(isset($_POST['mentor_secteur_id'])) {
+        $id_supprimee = $_POST['mentor_secteur_id'];
+        $globals->db->query("DELETE FROM mentor_secteurs WHERE uid = {$_SESSION['uid']} AND secteur = '$id_supprimee' LIMIT 1");
+    }
+}
+
+//recuperation des secteurs
+$res = $globals->db->query("SELECT m.secteur, s.label, m.ss_secteur, ss.label
+                    FROM mentor_secteurs AS m
+                   LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
+                   LEFT JOIN emploi_ss_secteur AS ss ON(s.id = ss.secteur AND m.ss_secteur = ss.id)
+                   WHERE m.uid = {$_SESSION['uid']}
+                   LIMIT $max_mentor_pays");
+$nb_mentor_secteurs = mysql_num_rows($res);
+$mentor_sid = $mentor_secteur = $mentor_ssid = $mentor_ss_secteur = Array();
+for($i = 1; $i <= $nb_mentor_secteurs ; $i++)
+    list($mentor_sid[$i], $mentor_secteur[$i], $mentor_ssid[$i], $mentor_ss_secteur[$i]) = mysql_fetch_row($res);
+
+//ajout d'un secteur
+$mentor_secteur_id_new = '';
+if(isset($_POST['mentor_secteur_op']) && ($_POST['mentor_secteur_op'] == 'ajouter') && ($nb_mentor_secteurs < $max_mentor_secteurs)) {
+    if(isset($_POST['mentor_secteur_id']) && ($_POST['mentor_secteur_id'] != ''))
+    {
+       $sid_ajoutee = $_POST['mentor_secteur_id'];
+       if(isset($_POST['mentor_ss_secteur_id']))
+           $ssid_ajoutee = $_POST['mentor_ss_secteur_id'];
+       $globals->db->query("INSERT INTO mentor_secteurs (uid, secteur, ss_secteur)
+                                   VALUES('{$_SESSION['uid']}', '$sid_ajoutee',".( ($ssid_ajoutee == '')?'NULL':"'$ssid_ajoutee'" ).")");
+       $nb_mentor_secteurs++;
+       $mentor_sid[$nb_mentor_secteurs] = $sid_ajoutee;
+       $mentor_secteur[$nb_mentor_secteurs] = stripslashes($_POST['mentor_secteur_name']);
+       $mentor_ssid[$nb_mentor_secteurs] = $ssid_ajoutee;
+       $mentor_ss_secteur[$nb_mentor_secteurs] = stripslashes($_POST['mentor_ss_secteur_name']);
+    }
+} elseif(isset($_POST['mentor_secteur_id_new'])){
+    $mentor_secteur_id_new = $_POST['mentor_secteur_id_new'];
+}
+?>
diff --git a/include/profil/profil_mentor.inc.php b/include/profil/profil_mentor.inc.php
deleted file mode 100644 (file)
index e00712d..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-<?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: profil_mentor.inc.php,v 1.5 2004-08-31 13:59:43 x2000habouzit Exp $
- ***************************************************************************/
-
-
-require_once('geoloc.inc.php');
-require_once('secteur.emploi.inc.php');
-function affiche_pays(){
-       global $mentor_pid, $mentor_pays, $nb_mentor_pays, $max_mentor_pays;
-       for($i = 1; $i <= $nb_mentor_pays ; $i++){
-           if ($i%2) echo '<tr class="pair">'; else echo '<tr class="impair">';
-?>
-       <td class="colg">
-       <span class="valeur"><?php htmlspecialchars($mentor_pays[$i]);?></span>
-       </td>
-       <td class="colm">
-       <span class="valeur">&nbsp;&nbsp;</span>
-       </td>
-        <td class="cold">
-         <span class="lien"><a href="javascript:mentor_pays_del('<?php echo $mentor_pid[$i]; ?>');">retirer</a></span>
-        </td>
-      </tr>
-<?php } if($nb_mentor_pays < $max_mentor_pays) {
-          if ($i%2) echo '<tr class="pair">'; else echo '<tr class="impair">';
-?>
-       <td class="colg">
-        <select name="mentor_pays_id_new">
-          <?php geoloc_pays('00');?>
-        </select>
-       </td>
-       <td class="colm">
-       </td>
-       <td class="cold">
-        <span class="lien"><a href="javascript:mentor_pays_add();">ajouter</a></span>
-       </td>
-      </tr>
-
-<?php
-       }
-}
-
-function _print_pays_smarty($params){affiche_pays();}
-$page->register_function('print_pays','_print_pays_smarty');
-
-
-$max_mentor_pays = 10;
-$max_mentor_secteurs = 10;
-
-$page->assign('max_mentor_pays', $max_mentor_pays);
-$page->assign('max_mentor_secteurs', $max_mentor_secteurs);
-
-//suppression eventuelle d'un pays
-if(isset($_POST['mentor_pays_op']) && ($_POST['mentor_pays_op'] == 'retirer'))
-{
-  if(isset($_POST['mentor_pays_id']))
-  {
-    $id_supprimee = $_POST['mentor_pays_id'];
-    $globals->db->query("DELETE FROM mentor_pays WHERE uid = {$_SESSION['uid']} AND pid = '$id_supprimee' LIMIT 1");
-  }
-}
-
-//suppression d'un secteur / ss-secteur
-if(isset($_POST['mentor_secteur_op']) && ($_POST['mentor_secteur_op'] == 'retirer'))
-{
-  if(isset($_POST['mentor_secteur_id']))
-  {
-    $id_supprimee = $_POST['mentor_secteur_id'];
-    $globals->db->query("DELETE FROM mentor_secteurs WHERE uid = {$_SESSION['uid']} AND secteur = '$id_supprimee' LIMIT 1");
-  }
-}
-
-//recuperation de l'expertise
-$res = $globals->db->query("SELECT expertise FROM mentor WHERE uid = {$_SESSION['uid']}");
-
-if(mysql_num_rows($res) > 0){
-  list($mentor_expertise) = mysql_fetch_row($res);
-}
-else{
-  $mentor_expertise = '';
-}
-$mentor_expertise_bd = $mentor_expertise;
-
-$page->assign_by_ref('mentor_expertise', $mentor_expertise);
-//recuperation des pays
-$res = $globals->db->query("SELECT m.pid, p.pays 
-                    FROM mentor_pays AS m
-                   LEFT JOIN geoloc_pays AS p ON(m.pid = p.a2) WHERE m.uid = {$_SESSION['uid']} LIMIT $max_mentor_pays");
-
-$nb_mentor_pays = mysql_num_rows($res);
-if($nb_mentor_pays > 0){
-  for($i = 1; $i <= $nb_mentor_pays ; $i++)
-    list($mentor_pid[$i], $mentor_pays[$i]) = mysql_fetch_row($res);
-}
-$page->assign_by_ref('mentor_pid', $mentor_pid);
-$page->assign_by_ref('mentor_pays', $mentor_pays);
-$page->assign_by_ref('nb_mentor_pays', $nb_mentor_pays);
-
-//recuperation des secteurs
-$res = $globals->db->query("SELECT m.secteur, s.label, m.ss_secteur, ss.label
-                    FROM mentor_secteurs AS m
-                   LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
-                   LEFT JOIN emploi_ss_secteur AS ss ON(s.id = ss.secteur AND m.ss_secteur = ss.id)
-                   WHERE m.uid = {$_SESSION['uid']}
-                   LIMIT $max_mentor_pays");
-$nb_mentor_secteurs = mysql_num_rows($res);
-if($nb_mentor_secteurs > 0){
-  for($i = 1; $i <= $nb_mentor_secteurs ; $i++)
-    list($mentor_sid[$i], $mentor_secteur[$i],
-         $mentor_ssid[$i], $mentor_ss_secteur[$i]) = mysql_fetch_row($res);
-}
-$page->assign_by_ref('mentor_sid', $mentor_sid);
-$page->assign_by_ref('mentor_secteur', $mentor_secteur);
-$page->assign_by_ref('mentor_ssid', $mentor_ssid);
-$page->assign_by_ref('mentor_ss_secteur', $mentor_ss_secteur);
-$page->assign_by_ref('nb_mentor_secteurs', $nb_mentor_secteurs);
-
-?>
index 2f43311..48de5cf 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: update_mentor.inc.php,v 1.3 2004-08-31 13:59:43 x2000habouzit Exp $
+        $Id: update_mentor.inc.php,v 1.4 2004-08-31 16:04:11 x2000habouzit Exp $
  ***************************************************************************/
 
 //mise a jour d'expertise si nécessaire
 
-if($mentor_expertise != $mentor_expertise_bd)
-{
-  $globals->db->query("REPLACE INTO mentor(uid, expertise) VALUES('{$_SESSION['uid']}', '".put_in_db($mentor_expertise)."')");
+if($mentor_expertise != $mentor_expertise_bd) {
+    $globals->db->query("REPLACE INTO mentor(uid, expertise) VALUES('{$_SESSION['uid']}', '".put_in_db($mentor_expertise)."')");
 }
 
 
index 9f04e92..e94aa7e 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: verif_general.inc.php,v 1.4 2004-08-31 15:03:33 x2000habouzit Exp $
+        $Id: verif_general.inc.php,v 1.5 2004-08-31 16:04:11 x2000habouzit Exp $
  ***************************************************************************/
 
 
 // validité du mobile
 if (strlen(strtok($mobile,"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($mobile)) {
-    $verif_errs = true;
     $errs[] = "Le champ 'Téléphone mobile' contient un caractère interdit."; 
 }
 
index 3ebed5c..4a3f1d1 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: verif_mentor.inc.php,v 1.4 2004-08-31 13:59:43 x2000habouzit Exp $
+        $Id: verif_mentor.inc.php,v 1.5 2004-08-31 16:04:11 x2000habouzit Exp $
  ***************************************************************************/
 
 
-//ajout eventuel d'un pays
-if(isset($_POST['mentor_pays_op']) && ($_POST['mentor_pays_op'] == 'ajouter') && ($nb_mentor_pays < $max_mentor_pays))
-{
-  if(isset($_POST['mentor_pays_id']) && ($_POST['mentor_pays_id'] != '00'))
-  {
-    $id_ajoutee = $_POST['mentor_pays_id'];
-    $globals->db->query("INSERT INTO mentor_pays(uid, pid)
-                 VALUES('{$_SESSION['uid']}', '$id_ajoutee')");
-    if(mysql_affected_rows() == 1){
-      $nb_mentor_pays++;
-      $mentor_pid[$nb_mentor_pays] = $id_ajoutee;
-      $mentor_pays[$nb_mentor_pays] = stripslashes($_POST['mentor_pays_name']);
-    }
-  }
-}
-
-//ajout d'un secteur
-if(isset($_POST['mentor_secteur_op']) && ($_POST['mentor_secteur_op'] == 'ajouter') && ($nb_mentor_secteurs < $max_mentor_secteurs))
-{
-  if(isset($_POST['mentor_secteur_id']) && ($_POST['mentor_secteur_id'] != ''))
-  {
-    $sid_ajoutee = $_POST['mentor_secteur_id'];
-    if(isset($_POST['mentor_ss_secteur_id']))
-      $ssid_ajoutee = $_POST['mentor_ss_secteur_id'];
-    $globals->db->query("INSERT INTO mentor_secteurs(uid, secteur, ss_secteur)
-                 VALUES('{$_SESSION['uid']}', '$sid_ajoutee',
-                ".( ($ssid_ajoutee == '')?'NULL':"'$ssid_ajoutee'" ).")");
-    if(mysql_affected_rows() == 1){
-      $nb_mentor_secteurs++;
-      $mentor_sid[$nb_mentor_secteurs] = $sid_ajoutee;
-      $mentor_secteur[$nb_mentor_secteurs] = stripslashes($_POST['mentor_secteur_name']);
-      $mentor_ssid[$nb_mentor_secteurs] = $ssid_ajoutee;
-      $mentor_ss_secteur[$nb_mentor_secteurs] = stripslashes($_POST['mentor_ss_secteur_name']);
-    }
-  }
-}
 //au cas ou le submit du formulaire vient d'un changement du nouveau secteur
-else if(isset($_POST['mentor_secteur_id_new'])){
-  $mentor_secteur_id_new = $_POST['mentor_secteur_id_new'];
-}
-else{
-  $mentor_secteur_id_new = '';
-}
-$page->assign_by_ref('mentor_secteur_id_new', $mentor_secteur_id_new);
-
 if(isset($_POST['mentor_expertise'])){
   $mentor_expertise = stripslashes($_POST['mentor_expertise']);
   if(!empty($mentor_expertise)){
       if (strlen(strtok($mentor_expertise,"<>{}~§`|%$^")) < strlen($mentor_expertise)){//TODO: affiner la liste
-           $str_error = $str_error."L'expertise contient un caractère interdit.<BR />";
+           $errs[] = "L'expertise contient un caractère interdit.";
        }
   }
 }
index b134902..9b68671 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: secteur.emploi.inc.php,v 1.4 2004-08-31 13:59:43 x2000habouzit Exp $
+        $Id: secteur.emploi.inc.php,v 1.5 2004-08-31 16:04:11 x2000habouzit Exp $
  ***************************************************************************/
 
 
 function select_secteur($secteur){
-       if($secteur == '') $secteur = -1;
-       echo "<option value=\"\" ". (($secteur == '')?"selected='selected'":"") .">&nbsp;</option>\n";
-       $res = $globals->db->query("SELECT id, label FROM emploi_secteur");
-       while(list($tmp_id, $tmp_label) = mysql_fetch_row($res)){
-               echo "<option value=\"$tmp_id\" " . (($secteur == $tmp_id)?"selected='selected'":"") . ">$tmp_label</option>\n";
-       }
-       mysql_free_result($res);
+    global $globals;
+    if($secteur == '') $secteur = -1;
+    echo "<option value=\"\" ". (($secteur == '')?"selected='selected'":"") .">&nbsp;</option>\n";
+    $res = $globals->db->query("SELECT id, label FROM emploi_secteur");
+    while(list($tmp_id, $tmp_label) = mysql_fetch_row($res)){
+       echo "<option value=\"$tmp_id\" " . (($secteur == $tmp_id)?"selected='selected'":"") . ">$tmp_label</option>\n";
+    }
+    mysql_free_result($res);
 }
 
 function select_ss_secteur($secteur,$ss_secteur){
-       if($secteur != ''){
-               echo "<option value=\"\">&nbsp;</option>\n";
-               $res = $globals->db->query("SELECT id, label FROM emploi_ss_secteur WHERE secteur = '$secteur'");
-               while(list($tmp_id, $tmp_label) = mysql_fetch_row($res)){
-                       echo "<option value=\"$tmp_id\" ". (($ss_secteur == $tmp_id)?"selected='selected'":"") .">$tmp_label</option>\n";
-               }
-               mysql_free_result($res);
-       }
-       else{
-         echo "<option value=\"\" selected='selected'>&nbsp;</option>\n";
+    global $globals;
+    if($secteur != ''){
+       echo "<option value=\"\">&nbsp;</option>\n";
+       $res = $globals->db->query("SELECT id, label FROM emploi_ss_secteur WHERE secteur = '$secteur'");
+       while(list($tmp_id, $tmp_label) = mysql_fetch_row($res)){
+           echo "<option value=\"$tmp_id\" ". (($ss_secteur == $tmp_id)?"selected='selected'":"") .">$tmp_label</option>\n";
        }
+       mysql_free_result($res);
+    }
+    else{
+       echo "<option value=\"\" selected='selected'>&nbsp;</option>\n";
+    }
 }
 
 //fonctions pour smarty
index 62b21e6..d6bad53 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: mentor.tpl,v 1.7 2004-08-31 11:25:42 x2000habouzit Exp $
+        $Id: mentor.tpl,v 1.8 2004-08-31 16:04:11 x2000habouzit Exp $
  ***************************************************************************}
 
 
 {literal}
 <script type="text/javascript">
-  <![CDATA[
+  //<![CDATA[
   function mentor_pays_add()
   {
     var selid = document.forms.prof_annu.mentor_pays_id_new.selectedIndex;
@@ -79,8 +79,7 @@ notamment internationales sur la base desquels tu seras identifiable depuis
 </p>
 
 <div class="blocunite_tab">
-  <table class="bicol" cellspacing="0" cellpadding="0" 
-    summary="Profil: Mentoring">
+  <table class="bicol" cellspacing="0" cellpadding="0" summary="Profil: Mentoring">
     <tr>
       <th colspan="3">
         Pays dont tu connais bien la culture professionnelle
@@ -114,164 +113,146 @@ notamment internationales sur la base desquels tu seras identifiable depuis
         &nbsp;
       </td>
     </tr>
-    {section name=pays loop=$nb_mentor_pays+1 start=1}
-    {assign var='i' value=$smarty.section.pays.index}
-    {if $i%2}
-    <tr class="pair">
-      {else}
-      <tr class="impair">
-        {/if}
-        <td class="colg">
-          <span class="valeur">{$mentor_pays.$i}</span>
-        </td>
-        <td class="colm">
-          <span class="valeur">&nbsp;&nbsp;</span>
-        </td>
-        <td class="cold">
-          <span class="lien"><a href="javascript:mentor_pays_del('{$mentor_pid.$i}');">retirer</a></span>
-        </td>
-      </tr>
-      {/section}
-      {if $nb_mentor_pays < $max_mentor_pays}
-      {if $i%2}
-      <tr class="pair">
-        {else}
-        <tr class="impair">
-          {/if}
-          <td class="colg">
-            <select name="mentor_pays_id_new">
-              {geoloc_pays pays='00'}
-            </select>
-          </td>
-          <td class="colm">
-          </td>
-          <td class="cold">
-            <span class="lien"><a href="javascript:mentor_pays_add();">ajouter</a></span>
-          </td>
-        </tr>
-        {/if}
-      </table>
-    </div>
+    {foreach from=$mentor_pays item=pays key=i}
+    <tr class="{cycle values="pair,impair"}">
+      <td class="colg">
+        <span class="valeur">{$pays}</span>
+      </td>
+      <td class="colm">
+        <span class="valeur">&nbsp;&nbsp;</span>
+      </td>
+      <td class="cold">
+        <span class="lien"><a href="javascript:mentor_pays_del('{$mentor_pid.$i}');">retirer</a></span>
+      </td>
+    </tr>
+    {/foreach}
+    {if $can_add_pays}
+    <tr class="{cycle values="pair,impair"}">
+      <td class="colg">
+        <select name="mentor_pays_id_new">
+          {geoloc_pays pays='00'}
+        </select>
+      </td>
+      <td class="colm">
+      </td>
+      <td class="cold">
+        <span class="lien"><a href="javascript:mentor_pays_add();">ajouter</a></span>
+      </td>
+    </tr>
+    {/if}
+  </table>
+</div>
 
-    <div class="blocunite">
-      <table class="bicol" cellspacing="0" cellpadding="0" 
-        summary="Profil: Mentoring">
-        <tr>
-          <th colspan="3">
-            Secteurs d'activité dans lesquels tu as beaucoup exercé
-            <input type="hidden" value="" name="mentor_secteur_op" />
-            <input type="hidden" value="" name="mentor_secteur_id" />
-            <input type="hidden" value="" name="mentor_secteur_name" />
-            <input type="hidden" value="" name="mentor_ss_secteur_id" />
-            <input type="hidden" value="" name="mentor_ss_secteur_name" />
-          </th>
-        </tr>
-        <tr>
-          <td colspan="3" class="pflags">
-            <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
-              <tr>
-                <td class="rouge">
-                  <input type="checkbox" name="accesX" checked="checked" disabled="disabled" />
-                </td>
-                <td class="texte">
-                  ne peut être ni public ni transmis à l'AX
-                </td>
-              </tr>
-            </table>
-          </td>
-        </tr>
-        <tr class="impair">
-          <td class="colg">
-            <span class="titre">Secteur</span>
-          </td>
-          <td class="colm">
-            <span class="titre">Sous-Secteur</span>
-          </td>
-          <td class="cold" style="width:15%">
-            &nbsp;
-          </td>
-        </tr>
-        {section name=secteur loop=$nb_mentor_secteurs+1 start=1}
-        {assign var='i' value=$smarty.section.secteur.index}
-        {if $i%2}
-        <tr class="pair">
-          {else}
-          <tr class="impair">
-            {/if}
-            <td class="colg">
-              <span class="valeur">{$mentor_secteur.$i}</span>
-            </td>
-            <td class="colm">
-              <span class="valeur">{$mentor_ss_secteur.$i}</span>
+<div class="blocunite">
+  <table class="bicol" cellspacing="0" cellpadding="0" 
+    summary="Profil: Mentoring">
+    <tr>
+      <th colspan="3">
+        Secteurs d'activité dans lesquels tu as beaucoup exercé
+        <input type="hidden" value="" name="mentor_secteur_op" />
+        <input type="hidden" value="" name="mentor_secteur_id" />
+        <input type="hidden" value="" name="mentor_secteur_name" />
+        <input type="hidden" value="" name="mentor_ss_secteur_id" />
+        <input type="hidden" value="" name="mentor_ss_secteur_name" />
+      </th>
+    </tr>
+    <tr>
+      <td colspan="3" class="pflags">
+        <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
+          <tr>
+            <td class="rouge">
+              <input type="checkbox" name="accesX" checked="checked" disabled="disabled" />
             </td>
-            <td class="cold">
-              <span class="lien"><a href="javascript:mentor_secteur_del('{$mentor_sid.$i}');">retirer</a></span>
+            <td class="texte">
+              ne peut être ni public ni transmis à l'AX
             </td>
           </tr>
-          {/section}
-          {if $nb_mentor_secteurs < $max_mentor_secteurs}
-          {if $i%2}
-          <tr class="pair">
-            {else}
-            <tr class="impair">
-              {/if}
-              <td class="colg">
-                <select name="mentor_secteur_id_new" onchange="javascript:submit()">
-                  {select_secteur secteur=$mentor_secteur_id_new}
-                </select>
-              </td>
-              <td class="colm">
-                <select name="mentor_ss_secteur_id_new">
-                  {select_ss_secteur secteur=$mentor_secteur_id_new ss_secteur=''}
-                </select>
-              </td>
-              <td class="cold">
-                <span class="lien"><a href="javascript:mentor_secteur_add();">ajouter</a></span>
-              </td>
-            </tr>
-            {/if}
-          </table>
-        </div>
+        </table>
+      </td>
+    </tr>
+    <tr class="impair">
+      <td class="colg">
+        <span class="titre">Secteur</span>
+      </td>
+      <td class="colm">
+        <span class="titre">Sous-Secteur</span>
+      </td>
+      <td class="cold" style="width:15%">
+        &nbsp;
+      </td>
+    </tr>
+    {foreach from=$mentor_secteur item=secteur key=i}
+    <tr class="{cycle values="pair,impair"}">
+      <td class="colg">
+        <span class="valeur">{$secteur}</span>
+      </td>
+      <td class="colm">
+        <span class="valeur">{$mentor_ss_secteur.$i}</span>
+      </td>
+      <td class="cold">
+        <span class="lien"><a href="javascript:mentor_secteur_del('{$mentor_sid.$i}');">retirer</a></span>
+      </td>
+    </tr>
+    {/foreach}
+    {if $can_add_secteurs}
+    <tr class="{cycle values="pair,impair"}">
+      <td class="colg">
+        <select name="mentor_secteur_id_new" onchange="javascript:submit()">
+          {select_secteur secteur=$mentor_secteur_id_new}
+        </select>
+      </td>
+      <td class="colm">
+        <select name="mentor_ss_secteur_id_new">
+          {select_ss_secteur secteur=$mentor_secteur_id_new ss_secteur=''}
+        </select>
+      </td>
+      <td class="cold">
+        <span class="lien"><a href="javascript:mentor_secteur_add();">ajouter</a></span>
+      </td>
+    </tr>
+    {/if}
+  </table>
+</div>
 
-        <div class="blocunite">
-          <table class="bicol" cellspacing="0" cellpadding="0" 
-            summary="Profil: Mentoring">
-            <tr>
-              <th colspan="3">
-                Expérience et expertises que tu acceptes de faire partager
-              </th>
-            </tr>
-            <tr>
-              <td colspan="3" class="pflags">
-                <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
-                  <tr>
-                    <td class="rouge">
-                      <input type="checkbox" name="accesX" checked="checked" disabled="disabled" />
-                    </td>
-                    <td class="texte">
-                      ne peut être ni public ni transmis à l'AX
-                    </td>
-                  </tr>
-                </table>
-              </td>
-            </tr>
-            <tr>
-              <td colspan="3">
-                Dans cette case il te faut indiquer en quelques mots ce qui t'a
-                amené à acquérir l'expérience indiquée, et dans quelle mesure tu
-                veux bien que ceux de nos camarades qui seraient intéressés par un
-                contact avec toi, en prenne l'initiative. <strong>Il est obligatoire de
-                  remplir cette dernière case pour apparaître dans la base de données
-                  des "Mentors".</strong>
-                <br />
-              </td>
-            </tr>
-            <tr>
-              <td colspan="3">
-                <textarea rows="8" cols="60" name="mentor_expertise">{$mentor_expertise}</textarea>
-              </td>
-            </tr>
-          </table>
-        </div>
+<div class="blocunite">
+  <table class="bicol" cellspacing="0" cellpadding="0" 
+    summary="Profil: Mentoring">
+    <tr>
+      <th colspan="3">
+        Expérience et expertises que tu acceptes de faire partager
+      </th>
+    </tr>
+    <tr>
+      <td colspan="3" class="pflags">
+        <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
+          <tr>
+            <td class="rouge">
+              <input type="checkbox" name="accesX" checked="checked" disabled="disabled" />
+            </td>
+            <td class="texte">
+              ne peut être ni public ni transmis à l'AX
+            </td>
+          </tr>
+        </table>
+      </td>
+    </tr>
+    <tr>
+      <td colspan="3">
+        Dans cette case il te faut indiquer en quelques mots ce qui t'a
+        amené à acquérir l'expérience indiquée, et dans quelle mesure tu
+        veux bien que ceux de nos camarades qui seraient intéressés par un
+        contact avec toi, en prenne l'initiative. <strong>Il est obligatoire de
+          remplir cette dernière case pour apparaître dans la base de données
+          des "Mentors".</strong>
+        <br />
+      </td>
+    </tr>
+    <tr>
+      <td colspan="3">
+        <textarea rows="8" cols="60" name="mentor_expertise">{$mentor_expertise}</textarea>
+      </td>
+    </tr>
+  </table>
+</div>
 
 {* vim:set et sw=2 sts=2 sws=2: *}