Merge commit 'origin/fusionax' into account
[platal.git] / modules / profile / mentor.inc.php
index 7fae8ec..2ecb60b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -19,7 +19,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class ProfileSecteurs implements ProfileSetting
+class ProfileSectors implements ProfileSetting
 {
     public function value(ProfilePage &$page, $field, $value, &$success)
     {
@@ -39,9 +39,9 @@ class ProfileSecteurs implements ProfileSetting
                     $value[$s][$ss] = $ssname;
                 }
             }
-        } else if (!is_array($value)) {
+        } elseif (!is_array($value)) {
             $value = array();
-        } else if (count($value) > 10) {
+        } elseif (count($value) > 10) {
             Platal::page()->trigError("Le nombre de secteurs d'expertise est limité à 10.");
             $success = false;
         }
@@ -61,8 +61,8 @@ class ProfileSecteurs implements ProfileSetting
         if (!count($value)) {
             return;
         }
-        foreach ($value as $id=>&$sect) {
-            foreach ($sect as $sid=>&$name) {
+        foreach ($value as $id => $sect) {
+            foreach ($sect as $sid => $name) {
                 XDB::execute("INSERT INTO  profile_mentor_sector (uid, sectorid, subsectorid)
                                    VALUES  ({?}, {?}, {?})",
                              $page->pid(), $id, $sid);
@@ -78,9 +78,9 @@ class ProfileCountry implements ProfileSetting
         $success = true;
         if (is_null($value)) {
             $value = array();
-            $res = XDB::iterRow("SELECT  m.country, p.pays
+            $res = XDB::iterRow("SELECT  m.country, gc.countryFR
                                    FROM  profile_mentor_country AS m
-                             INNER JOIN  geoloc_pays            AS p ON (m.country = p.a2)
+                             INNER JOIN  geoloc_countries       AS gc ON (m.country = gc.iso_3166_1_a2)
                                   WHERE  m.uid = {?}",
                                 $page->pid());
             while (list($id, $name) = $res->next()) {
@@ -118,14 +118,14 @@ class ProfileMentor extends ProfilePage
     {
         parent::__construct($wiz);
         $this->settings['expertise'] = null;
-        $this->settings['secteurs'] = new ProfileSecteurs();
+        $this->settings['sectors'] = new ProfileSectors();
         $this->settings['countries'] = new ProfileCountry();
     }
 
     protected function _fetchData()
     {
         $res = XDB::query("SELECT  expertise
-                             FROM  mentor
+                             FROM  profile_mentor
                             WHERE  uid = {?}",
                           $this->pid());
         $this->values['expertise'] = $res->fetchOneCell();
@@ -136,12 +136,12 @@ class ProfileMentor extends ProfilePage
         if ($this->changed['expertise']) {
             $expertise = trim($this->values['expertise']);
             if (empty($expertise)) {
-                XDB::execute("DELETE FROM  mentor
+                XDB::execute("DELETE FROM  profile_mentor
                                     WHERE  uid = {?}",
                              $this->pid());
                 $this->values['expertise'] = null;
             } else {
-                XDB::execute("REPLACE INTO  mentor (uid, expertise)
+                XDB::execute("REPLACE INTO  profile_mentor (uid, expertise)
                                     VALUES  ({?}, {?})",
                              $this->pid(), $expertise);
                 $this->values['expertise'] = $expertise;
@@ -151,8 +151,12 @@ class ProfileMentor extends ProfilePage
 
     public function _prepare(PlPage &$page, $id)
     {
-        $page->assign('secteurs_sel', XDB::iterator("SELECT  id, name AS label
-                                                       FROM  profile_job_sector_enum"));
+        $page->assign('sectorList', XDB::iterator('SELECT  id, name
+                                                     FROM  profile_job_sector_enum'));
+
+        $page->assign('countryList', XDB::iterator("SELECT  iso_3166_1_a2, countryFR
+                                                      FROM  geoloc_countries
+                                                  ORDER BY  countryFR"));
     }
 }