X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile%2Fmentor.inc.php;h=17d9cdd67c0983c795fa6ad3cce8860f09df047c;hb=25b261b1e0c8745d1f134f1a082e428ab50bd811;hp=a9690fd053ee1012f3e2bf5845478b0aab23d534;hpb=d2100923749766ffcf61745b0145cf82a3886716;p=platal.git diff --git a/modules/profile/mentor.inc.php b/modules/profile/mentor.inc.php index a9690fd..17d9cdd 100644 --- a/modules/profile/mentor.inc.php +++ b/modules/profile/mentor.inc.php @@ -1,6 +1,6 @@ pid()); while (list($s, $ss, $ssname) = $res->next()) { if (!isset($value[$s])) { @@ -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; } @@ -56,22 +56,32 @@ class ProfileSecteurs implements ProfileSetting { XDB::execute("DELETE FROM profile_mentor_sector - WHERE uid = {?}", + WHERE pid = {?}", $page->pid()); if (!count($value)) { return; } - foreach ($value as $id=>&$sect) { - foreach ($sect as $sid=>&$name) { - XDB::execute("INSERT INTO profile_mentor_sector (uid, sectorid, subsectorid) + foreach ($value as $id => $sect) { + foreach ($sect as $sid => $name) { + XDB::execute("INSERT INTO profile_mentor_sector (pid, sectorid, subsectorid) VALUES ({?}, {?}, {?})", $page->pid(), $id, $sid); } } } + + public function getText($value) { + $sectors = array(); + foreach ($value as $sector) { + foreach ($sector as $subsector) { + $sectors[] = $subsector; + } + } + return implode(', ', $sectors); + } } -class ProfileCountry implements ProfileSetting +class ProfileSettingCountry implements ProfileSetting { public function value(ProfilePage &$page, $field, $value, &$success) { @@ -81,7 +91,7 @@ class ProfileCountry implements ProfileSetting $res = XDB::iterRow("SELECT m.country, gc.countryFR FROM profile_mentor_country AS m INNER JOIN geoloc_countries AS gc ON (m.country = gc.iso_3166_1_a2) - WHERE m.uid = {?}", + WHERE m.pid = {?}", $page->pid()); while (list($id, $name) = $res->next()) { $value[$id] = $name; @@ -99,18 +109,22 @@ class ProfileCountry implements ProfileSetting public function save(ProfilePage &$page, $field, $value) { XDB::execute("DELETE FROM profile_mentor_country - WHERE uid = {?}", + WHERE pid = {?}", $page->pid()); foreach ($value as $id=>&$name) { - XDB::execute("INSERT INTO profile_mentor_country (uid, country) + XDB::execute("INSERT INTO profile_mentor_country (pid, country) VALUES ({?}, {?})", $page->pid(), $id); } } + + public function getText($value) { + return implode(', ', $value); + } } -class ProfileMentor extends ProfilePage +class ProfileSettingMentor extends ProfilePage { protected $pg_template = 'profile/mentor.tpl'; @@ -118,15 +132,15 @@ class ProfileMentor extends ProfilePage { parent::__construct($wiz); $this->settings['expertise'] = null; - $this->settings['secteurs'] = new ProfileSecteurs(); - $this->settings['countries'] = new ProfileCountry(); + $this->settings['sectors'] = new ProfileSettingSectors(); + $this->settings['countries'] = new ProfileSettingCountry(); } protected function _fetchData() { $res = XDB::query("SELECT expertise - FROM mentor - WHERE uid = {?}", + FROM profile_mentor + WHERE pid = {?}", $this->pid()); $this->values['expertise'] = $res->fetchOneCell(); } @@ -136,12 +150,12 @@ class ProfileMentor extends ProfilePage if ($this->changed['expertise']) { $expertise = trim($this->values['expertise']); if (empty($expertise)) { - XDB::execute("DELETE FROM mentor - WHERE uid = {?}", + XDB::execute("DELETE FROM profile_mentor + WHERE pid = {?}", $this->pid()); $this->values['expertise'] = null; } else { - XDB::execute("REPLACE INTO mentor (uid, expertise) + XDB::execute("REPLACE INTO profile_mentor (pid, expertise) VALUES ({?}, {?})", $this->pid(), $expertise); $this->values['expertise'] = $expertise; @@ -151,12 +165,13 @@ 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")); + $page->assign('hrpid', $this->profile->hrpid); } }