X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile%2Fmentor.inc.php;h=d026ed0c28446c2efcd84cf2efe4f73e8d8d1a9e;hb=330ffaa012073e66a5c94a6dce3ef5c8e32f67b8;hp=4fc7b944236567b9aae4e13e7bf4d8ed8b767168;hpb=b20ef4deed1b6fa6334bc57c0166a88e2beac9e4;p=platal.git diff --git a/modules/profile/mentor.inc.php b/modules/profile/mentor.inc.php index 4fc7b94..d026ed0 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])) { $value[$s] = array($ss => $ssname); @@ -39,9 +39,9 @@ class ProfileSectors 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,16 +56,16 @@ class ProfileSectors implements ProfileSetting { XDB::execute("DELETE FROM profile_mentor_sector - WHERE uid = {?}", - S::i('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 ({?}, {?}, {?})", - S::i('uid'), $id, $sid); + $page->pid(), $id, $sid); } } } @@ -81,8 +81,8 @@ 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 = {?}", - S::i('uid')); + WHERE m.pid = {?}", + $page->pid()); while (list($id, $name) = $res->next()) { $value[$id] = $name; } @@ -99,12 +99,12 @@ class ProfileCountry implements ProfileSetting public function save(ProfilePage &$page, $field, $value) { XDB::execute("DELETE FROM profile_mentor_country - WHERE uid = {?}", - S::i('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 ({?}, {?})", - S::i('uid'), $id); + $page->pid(), $id); } } } @@ -125,9 +125,9 @@ class ProfileMentor extends ProfilePage protected function _fetchData() { $res = XDB::query("SELECT expertise - FROM mentor - WHERE uid = {?}", - S::i('uid')); + FROM profile_mentor + WHERE pid = {?}", + $this->pid()); $this->values['expertise'] = $res->fetchOneCell(); } @@ -136,14 +136,14 @@ class ProfileMentor extends ProfilePage if ($this->changed['expertise']) { $expertise = trim($this->values['expertise']); if (empty($expertise)) { - XDB::execute("DELETE FROM mentor - WHERE uid = {?}", - S::i('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 ({?}, {?})", - S::i('uid'), $expertise); + $this->pid(), $expertise); $this->values['expertise'] = $expertise; } } @@ -151,8 +151,8 @@ class ProfileMentor extends ProfilePage public function _prepare(PlPage &$page, $id) { - $page->assign('sectors', XDB::iterator("SELECT id, name - 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