From 2c43a4f42025a050d8555e1cfa32ca076a23b659 Mon Sep 17 00:00:00 2001 From: shish Date: Sun, 21 Oct 2007 23:12:49 +0000 Subject: [PATCH] clean up votes when images are deleted git-svn-id: file:///home/shish/svn/shimmie2/trunk@547 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/numeric_score/main.php | 5 +++++ contrib/text_score/main.php | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/contrib/numeric_score/main.php b/contrib/numeric_score/main.php index 4eb5973d..a1228b97 100644 --- a/contrib/numeric_score/main.php +++ b/contrib/numeric_score/main.php @@ -58,6 +58,11 @@ class NumericScore extends Extension { } } + if(is_a($event, 'ImageDeletionEvent')) { + global $database; + $database->execute("DELETE FROM numeric_score_votes WHERE image_id=?", array($event->image->id)); + } + if(is_a($event, 'SetupBuildingEvent')) { $sb = new SetupBlock("Numeric Score"); $sb->add_bool_option("numeric_score_anon", "Allow anonymous votes: "); diff --git a/contrib/text_score/main.php b/contrib/text_score/main.php index d706ef87..a96850b1 100644 --- a/contrib/text_score/main.php +++ b/contrib/text_score/main.php @@ -32,7 +32,7 @@ class TextScore extends Extension { } if(is_a($event, 'PageRequestEvent') && $event->page_name == "text_score" && - $event->get_arg(0) == "vote" + $event->get_arg(0) == "vote" && isset($_POST['score']) && isset($_POST['image_id'])) { $i_score = int_escape($_POST['score']); $i_image_id = int_escape($_POST['image_id']); @@ -58,6 +58,11 @@ class TextScore extends Extension { } } + if(is_a($event, 'ImageDeletionEvent')) { + global $database; + $database->execute("DELETE FROM text_score_votes WHERE image_id=?", array($event->image->id)); + } + if(is_a($event, 'SetupBuildingEvent')) { $sb = new SetupBlock("Text Score"); $sb->add_bool_option("text_score_anon", "Allow anonymous votes: ");