From 7cdf1e980d294085fd1053a1c50cede127bf1352 Mon Sep 17 00:00:00 2001 From: flashk Date: Sun, 30 Dec 2007 00:41:53 +0000 Subject: Removing rating of object will actually remove it from rating table --- lib/class/rating.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/class') diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php index ff7b940d..f981fc4e 100644 --- a/lib/class/rating.class.php +++ b/lib/class/rating.class.php @@ -117,6 +117,14 @@ class Rating { $score = Dba::escape($score); + // If score is -1, then remove rating + if ($score == '-1') { + $sql = "DELETE FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type' " . + "AND `user`='" . Dba::escape($GLOBALS['user']->id) . "'"; + $db_results = Dba::query($sql); + return true; + } + /* Check if it exists */ $sql = "SELECT `id` FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type' " . "AND `user`='" . Dba::escape($GLOBALS['user']->id) . "'"; -- cgit