Mentor page
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 9 Sep 2007 17:11:06 +0000 (19:11 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 9 Sep 2007 17:11:06 +0000 (19:11 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
include/geoloc.inc.php
modules/profile/assign_mentor.inc.php [deleted file]
modules/profile/get_mentor.inc.php [deleted file]
modules/profile/mentor.inc.php [new file with mode: 0644]
modules/profile/page.inc.php
plugins/function.geoloc_country.php [moved from modules/profile/update_mentor.inc.php with 87% similarity]
plugins/function.geoloc_region.php [moved from modules/profile/verif_mentor.inc.php with 80% similarity]
templates/profile/deco.tpl
templates/profile/jobs.job.tpl
templates/profile/mentor.tpl
templates/profile/skill.tpl

index a1939b8..89ecd45 100644 (file)
@@ -42,17 +42,6 @@ function geoloc_country($current, $avail_only = false)
     return $html;
 }
 
-function _geoloc_country_smarty($params)
-{
-    echo "miqjfmeij";
-    if(!isset($params['country'])) {
-        return;
-    }
-    return geoloc_country($params['country'], @$params['available']);
-}
-
-$GLOBALS['page']->register_function('geoloc_country', '_geoloc_country_smarty');
-
 /** donne la liste deroulante des regions pour un pays
  * @param $pays le pays dont on veut afficher les regions
  * @param $current la region actuellement selectionnee
@@ -79,15 +68,6 @@ function geoloc_region($country, $current, $avail_only = false)
     }
     return $html;
 }
-
-function _geoloc_region_smarty($params, &$smarty)
-{
-    if(!isset($params['country']) || !isset($params['region'])) {
-        return;
-    }
-    return geoloc_region($params['country'], $params['region'], @$params['available']);
-}
-$GLOBALS['page']->register_function('geoloc_region', '_geoloc_region_smarty');
 // }}}
 
 // {{{ get_address_infos($txt)
diff --git a/modules/profile/assign_mentor.inc.php b/modules/profile/assign_mentor.inc.php
deleted file mode 100644 (file)
index 728a8d3..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2007 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                *
- ***************************************************************************/
-
-$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);
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/modules/profile/get_mentor.inc.php b/modules/profile/get_mentor.inc.php
deleted file mode 100644 (file)
index 53d18a6..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2007 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                *
- ***************************************************************************/
-
-require_once('geoloc.inc.php');
-require_once('secteur.emploi.inc.php');
-
-$max_mentor_pays = 10;
-$max_mentor_secteurs = 10;
-
-//recuperation de l'expertise
-$res = XDB::query("SELECT expertise FROM mentor WHERE uid = {?}", S::v('uid',-1));
-
-$mentor_expertise = $res->fetchOneCell();
-$mentor_expertise_bd = $mentor_expertise;
-
-//suppression eventuelle d'un pays
-if(Post::v('mentor_pays_op', '') == 'retirer') {
-    if(Post::has('mentor_pays_id')) {
-        $id_supprimee = Post::v('mentor_pays_id', '00');
-        XDB::execute("DELETE FROM mentor_pays WHERE uid = {?} AND pid = {?} LIMIT 1", S::v('uid', -1), $id_supprimee);
-    }
-}
-
-//recuperation des pays
-$res = XDB::iterRow("SELECT m.pid, p.pays
-                    FROM mentor_pays AS m
-                   LEFT JOIN geoloc_pays AS p ON(m.pid = p.a2) WHERE m.uid = {?} LIMIT {?}", S::v('uid', -1), $max_mentor_pays);
-$nb_mentor_pays = $res->total();
-$mentor_pid = $mentor_pays = Array();
-for($i = 1; $i <= $nb_mentor_pays ; $i++) list($mentor_pid[$i], $mentor_pays[$i]) = $res->next();
-
-//ajout eventuel d'un pays
-if((Post::v('mentor_pays_op', '') == 'ajouter') && ($nb_mentor_pays < $max_mentor_pays)) {
-    if(Post::v('mentor_pays_id', '00') != '00') {
-       $id_ajoutee = Post::v('mentor_pays_id', '00');
-       XDB::execute("INSERT INTO mentor_pays(uid, pid) VALUES({?}, {?})", S::v('uid', -1), $id_ajoutee);
-       $nb_mentor_pays++;
-       $mentor_pid[$nb_mentor_pays] = $id_ajoutee;
-       $mentor_pays[$nb_mentor_pays] = Post::v('mentor_pays_name', '');
-    }
-}
-
-
-
-//suppression d'un secteur / ss-secteur
-if(Post::v('mentor_secteur_op', '') == 'retirer') {
-    if(Post::has('mentor_secteur_id')) {
-        $id_supprimee = Post::v('mentor_secteur_id', '');
-        XDB::execute("DELETE FROM mentor_secteurs WHERE uid = {?} AND secteur = {?} LIMIT 1", S::v('uid', -1), $id_supprimee);
-    }
-}
-
-//recuperation des secteurs
-$res = XDB::iterRow("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 = {?}
-                   LIMIT {?}", S::v('uid', -1), $max_mentor_pays);
-$nb_mentor_secteurs = $res->total();
-$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]) = $res->next();
-
-//ajout d'un secteur
-$mentor_secteur_id_new = '';
-if((Post::v('mentor_secteur_op', '')== 'ajouter') && ($nb_mentor_secteurs < $max_mentor_secteurs)) {
-    if(Post::v('mentor_secteur_id', '') != '')
-    {
-       $sid_ajoutee = Post::v('mentor_secteur_id', '');
-       if(Post::has('mentor_ss_secteur_id'))
-           $ssid_ajoutee = Post::v('mentor_ss_secteur_id', '');
-       XDB::execute("INSERT INTO mentor_secteurs (uid, secteur, ss_secteur)
-                                   VALUES({?}, {?}, {?})", S::v('uid', -1), $sid_ajoutee, ($ssid_ajoutee == '')?null:$ssid_ajoutee);
-       $nb_mentor_secteurs++;
-       $mentor_sid[$nb_mentor_secteurs] = $sid_ajoutee;
-       $mentor_secteur[$nb_mentor_secteurs] = Post::v('mentor_secteur_name', '');
-       $mentor_ssid[$nb_mentor_secteurs] = $ssid_ajoutee;
-       $mentor_ss_secteur[$nb_mentor_secteurs] = Post::v('mentor_ss_secteur_name', '');
-    }
-} elseif(Post::has('mentor_secteur_id_new')){
-    $mentor_secteur_id_new = Post::v('mentor_secteur_id_new', '');
-}
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/modules/profile/mentor.inc.php b/modules/profile/mentor.inc.php
new file mode 100644 (file)
index 0000000..5928acd
--- /dev/null
@@ -0,0 +1,160 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2007 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                *
+ ***************************************************************************/
+
+class ProfileSecteurs implements ProfileSetting
+{
+    public function value(ProfilePage &$page, $field, $value, &$success)
+    {
+        $success = true;
+        if (is_null($value)) {
+            $value = array();
+            $res = XDB::iterRow("SELECT  m.secteur, m.ss_secteur, ss.label
+                                   FROM  mentor_secteurs AS m
+                             INNER JOIN  emploi_secteur  AS s ON(m.secteur = s.id)
+                             INNER JOIN  emploi_ss_secteur AS ss ON(s.id = ss.secteur AND m.ss_secteur = ss.id)
+                                  WHERE  m.uid = {?}",
+                                S::i('uid'));
+            while (list($s, $ss, $ssname) = $res->next()) {
+                if (!isset($value[$s])) {
+                    $value[$s] = array($ss => $ssname);
+                } else {
+                    $value[$s][$ss] = $ssname;
+                }
+            }
+        } else if (!is_array($value)) {
+            $value = array();
+        } else if (count($value) > 10) {
+            global $page;
+            $page->trig("Le nombre de secteurs d'expertise est limité à 10");
+            $success = false;
+        }
+        ksort($value);
+        foreach ($value as &$sss) {
+            ksort($sss);
+        }
+        return $value;
+    }
+
+    public function save(ProfilePage &$page, $field, $value)
+    {
+
+        XDB::execute("DELETE FROM  mentor_secteurs
+                            WHERE  uid = {?}",
+                     S::i('uid'));
+        if (!count($value)) {
+            return;
+        }
+        foreach ($value as $id=>&$sect) {
+            foreach ($sect as $sid=>&$name) {
+                XDB::execute("INSERT INTO  mentor_secteurs (uid, secteur, ss_secteur)
+                                   VALUES  ({?}, {?}, {?})",
+                             S::i('uid'), $id, $sid);
+            }
+        }
+    }
+}
+
+class ProfileCountry implements ProfileSetting
+{
+    public function value(ProfilePage &$page, $field, $value, &$success)
+    {
+        $success = true;
+        if (is_null($value)) {
+            $value = array();
+            $res = XDB::iterRow("SELECT  m.pid, p.pays
+                                   FROM  mentor_pays AS m
+                             INNER JOIN  geoloc_pays AS p ON(m.pid = p.a2)
+                                  WHERE  m.uid = {?}",
+                                S::i('uid'));
+            while (list($id, $name) = $res->next()) {
+                $value[$id] = $name;
+            }
+        } else if (!is_array($value)) {
+            $value = array();
+        } else if (count($value) > 10) {
+            global $page;
+            $page->trig("Le nombre de secteurs d'expertise est limité à 10");
+            $success = false;
+        }
+        ksort($value);
+        return $value;
+    }
+
+    public function save(ProfilePage &$page, $field, $value)
+    {
+        XDB::execute("DELETE FROM  mentor_pays
+                            WHERE  uid = {?}",
+                     S::i('uid'));
+        foreach ($value as $id=>&$name) {
+            XDB::execute("INSERT INTO  mentor_pays (uid, pid)
+                               VALUES  ({?}, {?})",
+                         S::i('uid'), $id);
+        }
+    }
+}
+
+
+class ProfileMentor extends ProfilePage
+{
+    protected $pg_template = 'profile/mentor.tpl';
+
+    public function __construct(PlWizard &$wiz)
+    {
+        parent::__construct($wiz);
+        $this->settings['expertise'] = null;
+        $this->settings['secteurs'] = new ProfileSecteurs();
+        $this->settings['countries'] = new ProfileCountry();
+    }
+
+    protected function fetchData()
+    {
+        if (count($this->orig) > 0) {
+            $this->values = $this->orig;
+            return;
+        }
+        $res = XDB::query("SELECT  expertise
+                             FROM  mentor
+                            WHERE  uid = {?}",
+                          S::i('uid'));
+        $this->value['expertise'] = $res->fetchOneCell();
+        parent::fetchData();
+    }
+
+    protected function saveData()
+    {
+        parent::saveData();
+        if ($this->changed['expertise']) {
+            XDB::execute("REPLACE INTO  mentor (uid, expertise)
+                                VALUES  ({?}, {?})",
+                         S::i('uid'), $this->values['expertise']);
+        }
+    }
+
+    public function prepare(PlatalPage &$page)
+    {
+        parent::prepare($page);
+        $page->assign('secteurs_sel', XDB::iterator("SELECT  id, label
+                                                       FROM  emploi_secteur"));
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
index f07ef04..e06e247 100644 (file)
@@ -289,6 +289,7 @@ require_once dirname(__FILE__) . '/groups.inc.php';
 require_once dirname(__FILE__) . '/decos.inc.php';
 require_once dirname(__FILE__) . '/jobs.inc.php';
 require_once dirname(__FILE__) . '/skills.inc.php';
+require_once dirname(__FILE__) . '/mentor.inc.php';
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
similarity index 87%
rename from modules/profile/update_mentor.inc.php
rename to plugins/function.geoloc_country.php
index a3e6df0..fee2b21 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-//mise a jour d'expertise si nécessaire
-
-if($mentor_expertise != $mentor_expertise_bd) {
-    XDB::execute("REPLACE INTO mentor(uid, expertise) VALUES({?}, {?})", S::v('uid', -1), $mentor_expertise);
+function smarty_function_geoloc_country($params, &$smarty) {
+    require_once 'geoloc.inc.php';
+    if(!isset($params['country'])) {
+        return;
+    }
+    return geoloc_country($params['country'], @$params['available']);
 }
 
-
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
similarity index 80%
rename from modules/profile/verif_mentor.inc.php
rename to plugins/function.geoloc_region.php
index b1707f3..e7a3a69 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-
-//au cas ou le submit du formulaire vient d'un changement du nouveau secteur
-if(Post::has('mentor_expertise')){
-  $mentor_expertise = Post::v('mentor_expertise');
-  if(!empty($mentor_expertise)){
-      if (strlen(strtok($mentor_expertise,"<>{}~§`|%$^")) < strlen($mentor_expertise)){//TODO: affiner la liste
-           $page->trig("L'expertise contient un caractère interdit.");
-       }
-  }
+function smarty_function_geoloc_region($params, &$smarty) {
+    require_once 'geoloc.inc.php';
+    if(!isset($params['country']) || !isset($params['region'])) {
+        return;
+    }
+    return geoloc_region($params['country'], $params['region'], @$params['available']);
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index 79d0433..b4eb62b 100644 (file)
@@ -95,7 +95,7 @@ function remove(id)
     {/foreach}
   {/if}{/foreach}
 {/foreach}
-</script>
+//]]></script>
 
 <table class="bicol">
   <tr>
index ce1e07d..bcda539 100644 (file)
@@ -86,7 +86,7 @@
     </tr>
     <tr>
       <td class="titre">Fonction occupée</td>
-      <td id=>
+      <td>
         <select name="{$jobpref}[fonction]">
           <option value="">&nbsp;</option>
           {assign var=ingroup value=false}
index bb9e1af..4817dbe 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-
+<script type="text/javascript">//<![CDATA[
 {literal}
-<script type="text/javascript">
-  //<![CDATA[
-  function mentor_pays_add()
-  {
-    var selid = document.forms.prof_annu.mentor_pays_id_new.selectedIndex;
-    document.forms.prof_annu.mentor_pays_id.value = document.forms.prof_annu.mentor_pays_id_new.options[selid].value;
-    document.forms.prof_annu.mentor_pays_name.value = document.forms.prof_annu.mentor_pays_id_new.options[selid].text;
-    document.forms.prof_annu.mentor_pays_op.value = "ajouter";
-    document.forms.prof_annu.submit();
-  } // function mentor_pays_add()
 
-  function mentor_pays_del( pid )
-  {
-    document.forms.prof_annu.mentor_pays_id.value = pid;
-    document.forms.prof_annu.mentor_pays_op.value = "retirer";
-    document.forms.prof_annu.submit();
-  } // function mentor_pays_del( pid )
+function updateCountry()
+{
+  var val = document.forms.prof_annu.countries_sel.value;
+  var show = true;
+  if (val == '') {
+    show = false;
+  }
+  if (document.getElementById('countries_' + val) != null) {
+    show = false;
+  }
+  document.getElementById('countries_add').style.display = show ? '' : 'none';
+}
+
+function addCountry()
+{
+  var cb   = document.forms.prof_annu.countries_sel;
+  var val  = cb.value;
+  var text = cb.options[cb.selectedIndex].text;
+  var html = '<div id="countries_' + val + '" style="clear: both; margin-bottom: 0.7em">'
+           + '  <div style="float: left; width: 50%">' + text + '</div>'
+           + '  <input type="hidden" name="countries[' + val + ']" value="' + text + '" />'
+           + '  <a href="javascript:removeCountry(\'' + val + '\')">'
+           + '    <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />'
+           + '  </a>'
+           + '</div>';
+  $('#countries').append(html);
+  updateCountry();
+}
+
+function removeCountry(id)
+{
+  $('#countries_' + id).remove();
+  updateCountry();
+}
+
+function updateSSecteur()
+{
+  var s  = document.forms.prof_annu.secteur_sel.value;
+  var ss = document.forms.prof_annu['jobs[-1][ss_secteur]'].value;
+  var show = true;
+  if (s == '' || ss == '') {
+    show = false;
+  }
+  if (document.getElementById('secteurs_' + s + '_' + ss) != null) {
+    show = false;
+  }
+  document.getElementById('secteurs_add').style.display = show ? 'block' : 'none';
+}
+
+function updateSecteur()
+{
+  var secteur = document.forms.prof_annu.secteur_sel.value;
+  if (secteur == '') {
+    secteur = '-1';
+  }
+  $.get(platal_baseurl + 'profile/ajax/secteur/-1/' + secteur,
+        function(data) {
+          data = '<a href="javascript:addSecteur()" style="display: none; float: right" id="secteurs_add">'
+               +  '  <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
+               +  '</a>' + data;
+          document.getElementById('ss_secteur_sel').innerHTML = data;
+          attachEvent(document.forms.prof_annu['jobs[-1][ss_secteur]'], 'change', updateSSecteur);
+        });
+}
+
+function addSecteur()
+{
+  var scb = document.forms.prof_annu.secteur_sel;
+  var s  = scb.value;
+  var st = scb.options[scb.selectedIndex].text;
 
-  function mentor_secteur_add()
-  {
-    var selid_secteur = document.forms.prof_annu.mentor_secteur_id_new.selectedIndex;
-    document.forms.prof_annu.mentor_secteur_id.value = document.forms.prof_annu.mentor_secteur_id_new.options[selid_secteur].value;
-    document.forms.prof_annu.mentor_secteur_name.value = document.forms.prof_annu.mentor_secteur_id_new.options[selid_secteur].text;
-    var selid_ss_secteur = document.forms.prof_annu.mentor_ss_secteur_id_new.selectedIndex;
-    document.forms.prof_annu.mentor_ss_secteur_id.value = document.forms.prof_annu.mentor_ss_secteur_id_new.options[selid_ss_secteur].value;
-    document.forms.prof_annu.mentor_ss_secteur_name.value = document.forms.prof_annu.mentor_ss_secteur_id_new.options[selid_ss_secteur].text;
-    document.forms.prof_annu.mentor_secteur_op.value = "ajouter";
-    document.forms.prof_annu.submit();
-  } // function mentor_secteur_add()
+  var sscb = document.forms.prof_annu['jobs[-1][ss_secteur]'];
+  var ss = sscb.value;
+  var sst = sscb.options[sscb.selectedIndex].text;
 
-  function mentor_secteur_del( sid )
-  {
-    document.forms.prof_annu.mentor_secteur_id.value = sid;
-    document.forms.prof_annu.mentor_secteur_op.value = "retirer";
-    document.forms.prof_annu.submit();
-  } // function mentor_secteur_del( sid )
+  var html = '<div id="secteurs_' + s + '_' + ss + '" style="clear: both; margin-top: 0.5em" class="titre">'
+           + '  <a href="javascript:removeSecteur(\'' + s + '\', \'' + ss + '\')" style="display: block; float: right">'
+           + '    <img src="images/icons/cross.gif" alt="" title="Supprimer ce secteur" />'
+           + '  </a>'
+           + '  <input type="hidden" name="secteurs[' + s + '][' + ss + ']" value="' + sst + '" />'
+           + '  ' + sst
+           + '</div>';
+  $('#secteurs').append(html);
+  updateSSecteur();
+}
+
+function removeSecteur(s, ss)
+{
+  $('#secteurs_' + s + '_' + ss).remove();
+  updateSSecteur();
+}
 
-  //]]>
-</script>
 {/literal}
+//]]></script>
 
 <p>
-Si tu acceptes que ceux de nos camarades qui,
+  Si tu acceptes que ceux des camarades te contactent afin de te demander
+  conseil, dans les domaines que tu connais bien, et pour lesquels tu pourrais
+  les aider, remplis cette rubrique.
+</p>
+<p>
+  Tu peux mentionner ici les domaines de compétences, les expériences
+  notamment internationales sur la base desquels tu seras identifiable depuis
+  <a href="referent/search">la page de recherche d'un conseil professionnel</a>.<br />
 </p>
+<p>Le mentoring est particulièrement important pour les camarades&nbsp;:</p>
 <ul>
   <li>encore jeunes, sont en train de bâtir leur projet professionnel,</li>
   <li>ou bien, plus âgés, souhaitent réorienter leur carrière,</li>
 </ul>
-<p>
-te contactent afin de te demander conseil, dans les domaines que tu connais
-bien, et pour lesquels tu pourrais les aider, remplis cette rubrique.<br />
-Tu peux mentionner ici les domaines de compétences, les expériences 
-notamment internationales sur la base desquels tu seras identifiable depuis
-<a href="referent/search">la page de recherche d'un conseil professionnel</a>.
-</p>
 
-<div class="blocunite_tab">
-  <table class="bicol" cellspacing="0" cellpadding="0" summary="Profil: Mentoring">
-    <tr>
-      <th colspan="3">
-        Pays dont tu connais bien la culture professionnelle
-        <input type="hidden" value="" name="mentor_pays_op" />
-        <input type="hidden" value="00" name="mentor_pays_id" />
-        <input type="hidden" value="" name="mentor_pays_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">
-              privé
-            </td>
-          </tr>
-        </table>
-      </td>
-    </tr>
-    <tr class="impair">
-      <td class="colg">
-        <span class="titre">Pays</span>
-      </td>
-      <td class="colm">
-        <span class="titre"></span>
-      </td>
-      <td class="cold" style="width:15%">
-        &nbsp;
-      </td>
-    </tr>
-    {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_country country='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>
+<table class="bicol" style="margin-bottom: 1em" summary="Profil: Mentoring">
+  <tr>
+    <th>
+      Pays dont tu connais bien la culture professionnelle
+    </th>
+  </tr>
+  <tr>
+    <td class="flags">
+      <span class="rouge"><input type="checkbox" name="accesX" checked="checked" disabled="disabled" /></span>
+      <span class="texte">privé</span>
+    </td>
+  </tr>
+  <tr class="impair">
+    <td>
+      <div style="float: left; width: 30%" class="titre">Pays</div>
+      <div id="countries_add" style="display: none; float: right">
+        <a href="javascript:addCountry()">{icon name=add title="Ajouter ce pays"}</a>
+      </div>
+      <select name="countries_sel" onchange="updateCountry()">
+        {geoloc_country country='00'}
+      </select>
+    </td>
+  </tr>
+  <tr class="pair">
+    <td id="countries">
+      {foreach from=$countries item=country key=i}
+      <div id="countries_{$i}" style="clear: both; margin-bottom: 0.7em">
+        <div style="float: left; width: 50%">{$country}</div>
+        <input type="hidden" name="countries[{$i}]" value="{$country}" />
+        <a href="javascript:removeCountry('{$i}')">{icon name=cross title="Supprimer ce pays"}</a>
+      </div>
+      {/foreach}
+    </td>
+  </tr>
+</table>
 
-<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">
-              privé
-            </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>
-    {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>
+<table class="bicol" style="margin-bottom: 1em" summary="Profil: Mentoring">
+  <tr>
+    <th>
+      Secteurs d'activité dans lesquels tu as beaucoup exercé
+    </th>
+  </tr>
+  <tr>
+    <td class="flags">
+      <span class="rouge"><input type="checkbox" name="accesX" checked="checked" disabled="disabled" /></span>
+      <span class="texte">privé</span>
+    </td>
+  </tr>
+  <tr>
+    <td id="secteur_sel">
+      <div style="float: left; width: 30%" class="titre">Secteur</div>
+      <select name="secteur_sel" onchange="updateSecteur()">
+        <option value="">&nbsp;</option>
+        {iterate from=$secteurs_sel item=secteur}
+        <option value="{$secteur.id}">{$secteur.label}</option>
+        {/iterate}
+      </select>
+    </td>
+  </tr>
+  <tr>
+    <td>
+      <div style="float: left; width: 30%" class="titre">Sous-secteur</div>
+      <span id="ss_secteur_sel"></span>
+    </td>
+  </tr>
+  <tr class="pair">
+    <td id="secteurs">
+      {if $secteurs|@count}
+      {foreach from=$secteurs item=secteur key=s}
+      {foreach from=$secteur item=ss_sect key=ss}
+      <div id="secteurs_{$s}_{$ss}" style="clear: both; margin-top: 0.5em" class="titre">
+        <a href="javascript:removeSecteur('{$s}', '{$ss}')" style="display: block; float: right">
+          {icon name=cross title="Supprimer ce secteur"}
+        </a>
+        <input type="hidden" name="secteurs[' + s + '][' + ss + ']" value="{$ss_sect}" />
+        {$ss_sect}
+      </div>
+      {/foreach}
+      {/foreach}
+      {/if}
+    </td>
+  </tr>
+</table>
 
-<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">
-              privé
-            </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 prennent 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>
+<table class="bicol" summary="Profil: Mentoring">
+  <tr>
+    <th>
+      Expérience et expertises que tu acceptes de faire partager
+    </th>
+  </tr>
+  <tr>
+    <td class="flags">
+      <span class="rouge"><input type="checkbox" name="accesX" checked="checked" disabled="disabled" /></span>
+      <span class="texte">privé</span>
+    </td>
+  </tr>
+  <tr>
+    <td>
+      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 prennent l'initiative. <strong>Il est obligatoire de
+      remplir cette dernière case pour apparaître dans la base de données
+      des "Mentors".</strong>
+    </td>
+  </tr>
+  <tr>
+    <td>
+      <textarea rows="8" cols="60" name="expertise">{$expertise}</textarea>
+    </td>
+  </tr>
+</table>
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 4bdba40..aea9c70 100644 (file)
@@ -80,6 +80,7 @@ function remove(cat, id)
           {if $comp.title}
           {if $ingroup}</optgroup>{/if}
           <optgroup label="{$comp.text_fr}">
+          {assign var=ingroup value=true}
           {/if}
           <option value="{$comp.id}">{$comp.text_fr}</option>
           {/iterate}