diff --git a/contrib/image_hash_ban/main.php b/contrib/image_hash_ban/main.php index 2c21a023..4d0236bd 100644 --- a/contrib/image_hash_ban/main.php +++ b/contrib/image_hash_ban/main.php @@ -46,10 +46,7 @@ class Image_Hash_Ban extends Extension { if(is_a($event, 'DataUploadEvent')) { global $database; - $image = $event->image; - $tmp_hash = $image->hash; - - if ($database->db->GetOne("SELECT COUNT(*) FROM image_bans WHERE hash = ?", $tmp_hash) == 1) { + if ($database->db->GetOne("SELECT COUNT(*) FROM image_bans WHERE hash = ?", $event->hash) == 1) { $event->veto("This image has been banned!"); } } @@ -64,6 +61,15 @@ class Image_Hash_Ban extends Extension { $page->set_mode("redirect"); $page->set_redirect(make_link("admin")); } + if(isset($_POST['image_id'])) { + global $database; + $image = $database->get_image($_POST['image_id']); + if($image) { + send_event(new ImageDeletionEvent($image)); + $event->page->set_mode("redirect"); + $event->page->set_redirect(make_link("post/list")); + } + } } else if($event->get_arg(0) == "remove") { if(isset($_POST['hash'])) { @@ -90,10 +96,9 @@ class Image_Hash_Ban extends Extension { $this->remove_image_hash_ban($event->hash); } - if(is_a($event, 'DisplayingImageEvent')) { - global $user; - if($user->is_admin()) { - $this->theme->display_image_banner($event->page, $event->image->hash); + if(is_a($event, 'ImageAdminBlockBuildingEvent')) { + if($event->user->is_admin()) { + $event->add_part($this->theme->get_buttons_html($event->image)); } } } diff --git a/contrib/image_hash_ban/theme.php b/contrib/image_hash_ban/theme.php index 84494dd1..daf5d414 100644 --- a/contrib/image_hash_ban/theme.php +++ b/contrib/image_hash_ban/theme.php @@ -64,19 +64,16 @@ class ImageBanTheme extends Themelet { * * $image_id = the image to delete */ - public function display_image_banner($page, $image_hash) { - -/* I'll fix this soon - $i_image_hash = int_escape($image_hash); + public function get_buttons_html($image) { $html = " -
- - + + + +
"; - $page->add_block(new Block("Image Ban", $html, "left")); -*/ + return $html; } } -?> \ No newline at end of file +?>