From 6dae45b393a59fd04713b9c651ff0970aeec84d7 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Wed, 4 Jun 2008 21:32:56 +0200 Subject: [PATCH] Clear mentor entry of the user when is expertise is empty. (Closes #840) Signed-off-by: Florent Bruneau --- modules/profile/mentor.inc.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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; + } } } -- 2.1.4