update image_hash_ban to the 2.2 APIs

git-svn-id: file:///home/shish/svn/shimmie2/trunk@940 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2008-07-27 15:55:45 +00:00
parent 19ea54ad21
commit 8ac2428820
2 changed files with 20 additions and 18 deletions

View file

@ -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));
}
}
}

View file

@ -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 = "
<form action='".make_link("admin/image_hash_ban")."' method='POST'>
<input type='hidden' name='image_hash' value='$i_image_hash'>
<input type='field' name='reason'>
<form action='".make_link("image_hash_ban/add")."' method='POST'>
<input type='hidden' name='hash' value='{$image->hash}'>
<input type='hidden' name='image_id' value='{$image->id}'>
<input type='text' name='reason'>
<input type='submit' value='Ban and Delete'>
</form>
";
$page->add_block(new Block("Image Ban", $html, "left"));
*/
return $html;
}
}
?>