X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile%2Fmentor.inc.php;h=64b1de74e81707602a02c47b5f3276125c08204d;hb=6dae45b393a59fd04713b9c651ff0970aeec84d7;hp=5928acdd9c920dcf73cb84370e1c8f1c19749c73;hpb=be6ab042d1dc34d9e42557281b48dd8da400231b;p=platal.git diff --git a/modules/profile/mentor.inc.php b/modules/profile/mentor.inc.php index 5928acd..64b1de7 100644 --- a/modules/profile/mentor.inc.php +++ b/modules/profile/mentor.inc.php @@ -1,6 +1,6 @@ settings['countries'] = new ProfileCountry(); } - protected function fetchData() + 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(); + $this->values['expertise'] = $res->fetchOneCell(); } - protected function saveData() + protected function _saveData() { - parent::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) + public function _prepare(PlatalPage &$page, $id) { - parent::prepare($page); $page->assign('secteurs_sel', XDB::iterator("SELECT id, label FROM emploi_secteur")); }