forked from leftypol/leftypol
Merge pull request #182 from nonmakina/modMassDelete
Enables mod mass deletion
This commit is contained in:
commit
e1ac470df0
2 changed files with 31 additions and 11 deletions
|
@ -2209,9 +2209,11 @@ function mod_deletebyip($boardName, $post, $global = false) {
|
||||||
|
|
||||||
@set_time_limit($config['mod']['rebuild_timelimit']);
|
@set_time_limit($config['mod']['rebuild_timelimit']);
|
||||||
|
|
||||||
|
$boards_to_rebuild = array();
|
||||||
$threads_to_rebuild = array();
|
$threads_to_rebuild = array();
|
||||||
$threads_deleted = array();
|
$threads_deleted = array();
|
||||||
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
$boards_to_rebuild[$post['board']] = true;
|
||||||
openBoard($post['board']);
|
openBoard($post['board']);
|
||||||
if ($config['autotagging']){
|
if ($config['autotagging']){
|
||||||
$query2 = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE id = :id", $post['board']));
|
$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);
|
deletePost($post['id'], false, false);
|
||||||
|
|
||||||
rebuildThemes('post-delete', $board['uri']);
|
|
||||||
|
|
||||||
buildIndex();
|
|
||||||
|
|
||||||
if ($post['thread'])
|
if ($post['thread'])
|
||||||
$threads_to_rebuild[$post['board']][$post['thread']] = true;
|
$threads_to_rebuild[$post['board']][$post['thread']] = true;
|
||||||
else
|
else
|
||||||
|
@ -2268,11 +2266,16 @@ function mod_deletebyip($boardName, $post, $global = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($threads_to_rebuild as $_board => $_threads) {
|
foreach ($threads_to_rebuild as $_board => $_threads) {
|
||||||
openBoard($_board);
|
openBoard($_board); // Set $board which is globally referenced by buildThread()
|
||||||
foreach ($_threads as $_thread => $_dummy) {
|
foreach ($_threads as $_thread => $_dummy) {
|
||||||
if ($_dummy && !isset($threads_deleted[$_board][$_thread]))
|
if ($_dummy && !isset($threads_deleted[$_board][$_thread]))
|
||||||
buildThread($_thread);
|
buildThread($_thread);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(array_keys($boards_to_rebuild) as $_board) {
|
||||||
|
openBoard($_board);
|
||||||
|
rebuildThemes('post-delete', $board['uri']);
|
||||||
buildIndex();
|
buildIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
29
post.php
29
post.php
|
@ -183,10 +183,19 @@ function handle_nntpchan() {
|
||||||
|
|
||||||
function handle_delete(){
|
function handle_delete(){
|
||||||
// Delete
|
// Delete
|
||||||
global $config,$board;
|
global $config, $board, $mod;
|
||||||
if (!isset($_POST['board'], $_POST['password']))
|
if (!isset($_POST['board'], $_POST['password']))
|
||||||
error($config['error']['bot']);
|
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'];
|
$password = &$_POST['password'];
|
||||||
|
|
||||||
if ($password == '')
|
if ($password == '')
|
||||||
|
@ -205,11 +214,15 @@ function handle_delete(){
|
||||||
if (!openBoard($_POST['board']))
|
if (!openBoard($_POST['board']))
|
||||||
error($config['error']['noboard']);
|
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
|
// Check if banned
|
||||||
checkBan($board['uri']);
|
checkBan($board['uri']);
|
||||||
|
|
||||||
// Check if deletion enabled
|
// Check if deletion is enabled
|
||||||
if (!$config['allow_delete'])
|
if (!$is_mod && !$config['allow_delete'])
|
||||||
error(_('Post deletion is not allowed!'));
|
error(_('Post deletion is not allowed!'));
|
||||||
|
|
||||||
if (empty($delete))
|
if (empty($delete))
|
||||||
|
@ -234,10 +247,14 @@ function handle_delete(){
|
||||||
error($config['error']['nodeletethread']);
|
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']);
|
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'])));
|
error(sprintf($config['error']['delete_too_soon'], until($post['time'] + $config['delete_time'])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +276,7 @@ function handle_delete(){
|
||||||
|
|
||||||
buildIndex();
|
buildIndex();
|
||||||
|
|
||||||
$is_mod = isset($_POST['mod']) && $_POST['mod'];
|
|
||||||
$root = $is_mod ? $config['root'] . $config['file_mod'] . '?/' : $config['root'];
|
$root = $is_mod ? $config['root'] . $config['file_mod'] . '?/' : $config['root'];
|
||||||
|
|
||||||
if (!isset($_POST['json_response'])) {
|
if (!isset($_POST['json_response'])) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue