From: Florent Bruneau Date: Wed, 4 Jun 2008 19:32:56 +0000 (+0200) Subject: Clear mentor entry of the user when is expertise is empty. X-Git-Tag: core/1.0.0~154 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=6dae45b393a59fd04713b9c651ff0970aeec84d7;p=platal.git Clear mentor entry of the user when is expertise is empty. (Closes #840) Signed-off-by: Florent Bruneau --- diff --git a/modules/profile/mentor.inc.php b/modules/profile/mentor.inc.php index d1509a8..64b1de7 100644 --- a/modules/profile/mentor.inc.php +++ b/modules/profile/mentor.inc.php @@ -136,9 +136,18 @@ class ProfileMentor extends ProfilePage 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; + } } }