diff options
-rw-r--r-- | lib/class/rating.class.php | 8 |
1 files changed, 8 insertions, 0 deletions
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) . "'"; |