Browse Source

Merge pull request #182 from nonmakina/modMassDelete

Enables mod mass deletion
pull/40/head
nonmakina 3 years ago
committed by GitHub
parent
commit
563091ba00
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      inc/mod/pages.php
  2. 29
      post.php

13
inc/mod/pages.php

@ -2209,9 +2209,11 @@ function mod_deletebyip($boardName, $post, $global = false) {
@set_time_limit($config['mod']['rebuild_timelimit']);
$boards_to_rebuild = array();
$threads_to_rebuild = array();
$threads_deleted = array();
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
$boards_to_rebuild[$post['board']] = true;
openBoard($post['board']);
if ($config['autotagging']){
$query2 = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE id = :id", $post['board']));
@ -2257,10 +2259,6 @@ function mod_deletebyip($boardName, $post, $global = false) {
deletePost($post['id'], false, false);
rebuildThemes('post-delete', $board['uri']);
buildIndex();
if ($post['thread'])
$threads_to_rebuild[$post['board']][$post['thread']] = true;
else
@ -2268,11 +2266,16 @@ function mod_deletebyip($boardName, $post, $global = false) {
}
foreach ($threads_to_rebuild as $_board => $_threads) {
openBoard($_board);
openBoard($_board); // Set $board which is globally referenced by buildThread()
foreach ($_threads as $_thread => $_dummy) {
if ($_dummy && !isset($threads_deleted[$_board][$_thread]))
buildThread($_thread);
}
}
foreach(array_keys($boards_to_rebuild) as $_board) {
openBoard($_board);
rebuildThemes('post-delete', $board['uri']);
buildIndex();
}

29
post.php

@ -183,9 +183,18 @@ function handle_nntpchan() {
function handle_delete(){
// Delete
global $config,$board;
global $config, $board, $mod;
if (!isset($_POST['board'], $_POST['password']))
error($config['error']['bot']);
check_login(false);
$is_mod = !!$mod;
if (isset($_POST['mod']) && $_POST['mod'] && !$mod) {
// Mismatched claims. (As stated below "Liar, you are not a mod.")
error($config['error']['notamod']);
}
$password = &$_POST['password'];
@ -204,12 +213,16 @@ function handle_delete(){
// Check if board exists
if (!openBoard($_POST['board']))
error($config['error']['noboard']);
// Check if mod has permission to delete posts in this board
if ($is_mod && !hasPermission($config['mod']['delete'], $board))
error($config['error']['noaccess']);
// Check if banned
checkBan($board['uri']);
// Check if deletion enabled
if (!$config['allow_delete'])
// Check if deletion is enabled
if (!$is_mod && !$config['allow_delete'])
error(_('Post deletion is not allowed!'));
if (empty($delete))
@ -234,10 +247,14 @@ function handle_delete(){
error($config['error']['nodeletethread']);
}
if ($password != '' && $post['password'] != $password && (!$thread || $thread['password'] != $password))
if ($password != ''
&& $post['password'] != $password
&& (!$thread || $thread['password'] != $password)
&& !$is_mod) {
error($config['error']['invalidpassword']);
}
if ($post['time'] > time() - $config['delete_time'] && (!$thread || $thread['password'] != $password)) {
if ($post['time'] > time() - $config['delete_time']) {
error(sprintf($config['error']['delete_too_soon'], until($post['time'] + $config['delete_time'])));
}
@ -259,7 +276,7 @@ function handle_delete(){
buildIndex();
$is_mod = isset($_POST['mod']) && $_POST['mod'];
$root = $is_mod ? $config['root'] . $config['file_mod'] . '?/' : $config['root'];
if (!isset($_POST['json_response'])) {

Loading…
Cancel
Save