Adjusted admin delete by query to bypass trash

This commit is contained in:
Matthew Barbour 2019-06-27 14:37:05 -05:00 committed by Shish
parent 558d154e85
commit 4116bda066
2 changed files with 9 additions and 4 deletions

View file

@ -137,6 +137,7 @@ class AdminPage extends Extension
global $page; global $page;
$query = $_POST['query']; $query = $_POST['query'];
$reason = @$_POST['reason']; $reason = @$_POST['reason'];
assert(strlen($query) > 1); assert(strlen($query) > 1);
$images = Image::find_images(0, 1000000, Tag::explode($query)); $images = Image::find_images(0, 1000000, Tag::explode($query));
@ -146,7 +147,7 @@ class AdminPage extends Extension
if ($reason && class_exists("ImageBan")) { if ($reason && class_exists("ImageBan")) {
send_event(new AddImageHashBanEvent($image->hash, $reason)); send_event(new AddImageHashBanEvent($image->hash, $reason));
} }
send_event(new ImageDeletionEvent($image)); send_event(new ImageDeletionEvent($image, true));
} }
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);

View file

@ -55,16 +55,18 @@ class AdminPageTheme extends Themelet
$html .= "<input type='submit' value='Set Tag Case'>"; $html .= "<input type='submit' value='Set Tag Case'>";
$html .= "</form>\n"; $html .= "</form>\n";
$page->add_block(new Block("Set Tag Case", $html)); $page->add_block(new Block("Set Tag Case", $html));
} }
public function dbq_html($terms) public function dbq_html($terms)
{ {
$h_terms = html_escape($terms); if(ext_is_live("Trash")) {
$h_reason = ""; $warning = "This delete method will bypass the trash<br/>";
}
if (class_exists("ImageBan")) { if (class_exists("ImageBan")) {
$h_reason = "<input type='text' name='reason' placeholder='Ban reason (leave blank to not ban)'>"; $h_reason = "<input type='text' name='reason' placeholder='Ban reason (leave blank to not ban)'>";
} }
$html = make_form(make_link("admin/delete_by_query"), "POST") . " $html = $warning.make_form(make_link("admin/delete_by_query"), "POST") . "
<input type='button' class='shm-unlocker' data-unlock-sel='#dbqsubmit' value='Unlock'> <input type='button' class='shm-unlocker' data-unlock-sel='#dbqsubmit' value='Unlock'>
<input type='hidden' name='query' value='$h_terms'> <input type='hidden' name='query' value='$h_terms'>
$h_reason $h_reason
@ -73,4 +75,6 @@ class AdminPageTheme extends Themelet
"; ";
return $html; return $html;
} }
} }