X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fprofile%2Fmentor.inc.php;h=06b1ac9482224659c31bde6d21ffb47a2b87609a;hb=9f5bd98e936d8cef7ca9f774eeef64dbb8a1b079;hp=928987899f7ccc2661e86a0e001b3ed09705cee8;hpb=179afa7fa79902e11498314d37fe4dbf452b3617;p=platal.git diff --git a/modules/profile/mentor.inc.php b/modules/profile/mentor.inc.php index 9289878..06b1ac9 100644 --- a/modules/profile/mentor.inc.php +++ b/modules/profile/mentor.inc.php @@ -1,6 +1,6 @@ 10) { - global $page; - $page->trig("Le nombre de secteurs d'expertise est limité à 10"); + Platal::page()->trigError("Le nombre de secteurs d'expertise est limité à 10"); $success = false; } ksort($value); @@ -90,8 +89,7 @@ class ProfileCountry implements ProfileSetting } 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"); + Platal::page()->trigError("Le nombre de secteurs d'expertise est limité à 10"); $success = false; } ksort($value); @@ -130,19 +128,28 @@ class ProfileMentor extends ProfilePage FROM mentor WHERE uid = {?}", S::i('uid')); - $this->value['expertise'] = $res->fetchOneCell(); + $this->values['expertise'] = $res->fetchOneCell(); } protected function _saveData() { if ($this->changed['expertise']) { - XDB::execute("REPLACE INTO mentor (uid, expertise) - VALUES ({?}, {?})", - S::i('uid'), $this->values['expertise']); + $expertise = trim($this->values['expertise']); + if (empty($expertise)) { + XDB::execute("DELETE FROM mentor + WHERE uid = {?}", + S::i('uid')); + $this->values['expertise'] = null; + } else { + XDB::execute("REPLACE INTO mentor (uid, expertise) + VALUES ({?}, {?})", + S::i('uid'), $expertise); + $this->values['expertise'] = $expertise; + } } } - public function _prepare(PlatalPage &$page, $id) + public function _prepare(PlPage &$page, $id) { $page->assign('secteurs_sel', XDB::iterator("SELECT id, label FROM emploi_secteur"));