mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-16 13:52:03 +02:00
[feature/soft-delete] Allow soft deleting/restoring topics via quickmoderation
PHPBB3-9567
This commit is contained in:
parent
7b3d794cad
commit
4a8d38aab1
@ -33,7 +33,7 @@ class mcp_main
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $auth, $db, $user, $template, $action;
|
||||
global $config, $phpbb_root_path, $phpEx;
|
||||
global $config, $phpbb_root_path, $phpEx, $request;
|
||||
|
||||
$quickmod = ($mode == 'quickmod') ? true : false;
|
||||
|
||||
@ -108,14 +108,18 @@ class mcp_main
|
||||
case 'delete_topic':
|
||||
$user->add_lang('viewtopic');
|
||||
|
||||
// f parameter is not reliable for permission usage, however we just use it to decide
|
||||
// which permission we will check later on. So if it is manipulated, we will still catch it later on.
|
||||
$forum_id = request_var('f', 0);
|
||||
$topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
|
||||
$soft_delete = (($auth->acl_get('m_softdelete', $forum_id) && $request->is_set_post('soft_delete')) || !$auth->acl_get('m_delete', $forum_id)) ? true : false;
|
||||
|
||||
if (!sizeof($topic_ids))
|
||||
{
|
||||
trigger_error('NO_TOPIC_SELECTED');
|
||||
}
|
||||
|
||||
mcp_delete_topic($topic_ids);
|
||||
mcp_delete_topic($topic_ids, $soft_delete, ($soft_delete) ? request_var('delete_reason', '', true) : '');
|
||||
break;
|
||||
|
||||
case 'delete_post':
|
||||
@ -130,6 +134,19 @@ class mcp_main
|
||||
|
||||
mcp_delete_post($post_ids);
|
||||
break;
|
||||
|
||||
case 'restore_topic':
|
||||
$user->add_lang('posting');
|
||||
|
||||
$topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
|
||||
|
||||
if (!sizeof($topic_ids))
|
||||
{
|
||||
trigger_error('NO_TOPIC_SELECTED');
|
||||
}
|
||||
|
||||
mcp_restore_topic($topic_ids);
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($mode)
|
||||
@ -628,10 +645,82 @@ function mcp_move_topic($topic_ids)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore Topics
|
||||
*/
|
||||
function mcp_restore_topic($topic_ids)
|
||||
{
|
||||
global $auth, $user, $db, $phpEx, $phpbb_root_path;
|
||||
|
||||
if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_approve')))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$redirect = request_var('redirect', build_url(array('action', 'quickmod')));
|
||||
$forum_id = request_var('f', 0);
|
||||
|
||||
$s_hidden_fields = build_hidden_fields(array(
|
||||
'topic_id_list' => $topic_ids,
|
||||
'f' => $forum_id,
|
||||
'action' => 'restore_topic',
|
||||
'redirect' => $redirect,
|
||||
));
|
||||
$success_msg = '';
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
$success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_RESTORED_SUCCESS' : 'TOPICS_RESTORED_SUCCESS';
|
||||
|
||||
$data = get_topic_data($topic_ids);
|
||||
|
||||
foreach ($data as $topic_id => $row)
|
||||
{
|
||||
$return = phpbb_content_visibility::set_topic_visibility(ITEM_APPROVED, $topic_id, $row['forum_id'], $user->data['user_id'], time(), '');
|
||||
if (!empty($return))
|
||||
{
|
||||
add_log('mod', $row['forum_id'], $topic_id, 'LOG_RESTORE_TOPIC', $row['topic_title'], $row['topic_first_poster_name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm_box(false, (sizeof($topic_ids) == 1) ? 'RESTORE_TOPIC' : 'RESTORE_TOPICS', $s_hidden_fields);
|
||||
}
|
||||
|
||||
$topic_id = request_var('t', 0);
|
||||
if (!isset($_REQUEST['quickmod']))
|
||||
{
|
||||
$redirect = request_var('redirect', "index.$phpEx");
|
||||
$redirect = reapply_sid($redirect);
|
||||
$redirect_message = 'PAGE';
|
||||
}
|
||||
else if ($topic_id)
|
||||
{
|
||||
$redirect = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id);
|
||||
$redirect_message = 'TOPIC';
|
||||
}
|
||||
else
|
||||
{
|
||||
$redirect = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id);
|
||||
$redirect_message = 'FORUM';
|
||||
}
|
||||
|
||||
if (!$success_msg)
|
||||
{
|
||||
redirect($redirect);
|
||||
}
|
||||
else
|
||||
{
|
||||
meta_refresh(3, $redirect);
|
||||
trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_' . $redirect_message], '<a href="' . $redirect . '">', '</a>'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Topics
|
||||
*/
|
||||
function mcp_delete_topic($topic_ids)
|
||||
function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = '')
|
||||
{
|
||||
global $auth, $user, $db, $phpEx, $phpbb_root_path;
|
||||
|
||||
@ -647,8 +736,8 @@ function mcp_delete_topic($topic_ids)
|
||||
'topic_id_list' => $topic_ids,
|
||||
'f' => $forum_id,
|
||||
'action' => 'delete_topic',
|
||||
'redirect' => $redirect)
|
||||
);
|
||||
'redirect' => $redirect,
|
||||
));
|
||||
$success_msg = '';
|
||||
|
||||
if (confirm_box(true))
|
||||
@ -665,23 +754,55 @@ function mcp_delete_topic($topic_ids)
|
||||
}
|
||||
else
|
||||
{
|
||||
add_log('mod', $row['forum_id'], $topic_id, 'LOG_DELETE_TOPIC', $row['topic_title'], $row['topic_first_poster_name']);
|
||||
// Only soft delete non-shadow topics
|
||||
if ($is_soft)
|
||||
{
|
||||
$return = phpbb_content_visibility::set_topic_visibility(ITEM_DELETED, $topic_id, $row['forum_id'], $user->data['user_id'], time(), $soft_delete_reason);
|
||||
if (!empty($return))
|
||||
{
|
||||
add_log('mod', $row['forum_id'], $topic_id, 'LOG_SOFTDELETE_TOPIC', $row['topic_title'], $row['topic_first_poster_name']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
add_log('mod', $row['forum_id'], $topic_id, 'LOG_DELETE_TOPIC', $row['topic_title'], $row['topic_first_poster_name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$return = delete_topics('topic_id', $topic_ids);
|
||||
if (!$is_soft)
|
||||
{
|
||||
$return = delete_topics('topic_id', $topic_ids);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm_box(false, (sizeof($topic_ids) == 1) ? 'DELETE_TOPIC' : 'DELETE_TOPICS', $s_hidden_fields);
|
||||
global $template;
|
||||
|
||||
$user->add_lang('posting');
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_TOPIC_MODE' => true,
|
||||
'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id),
|
||||
'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id),
|
||||
'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id),
|
||||
));
|
||||
|
||||
confirm_box(false, (sizeof($topic_ids) == 1) ? 'DELETE_TOPIC' : 'DELETE_TOPICS', $s_hidden_fields, 'posting_delete_post_body.html');
|
||||
}
|
||||
|
||||
$topic_id = request_var('t', 0);
|
||||
if (!isset($_REQUEST['quickmod']))
|
||||
{
|
||||
$redirect = request_var('redirect', "index.$phpEx");
|
||||
$redirect = reapply_sid($redirect);
|
||||
$redirect_message = 'PAGE';
|
||||
}
|
||||
else if ($is_soft && $topic_id)
|
||||
{
|
||||
$redirect = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id);
|
||||
$redirect_message = 'TOPIC';
|
||||
}
|
||||
else
|
||||
{
|
||||
$redirect = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id);
|
||||
|
@ -554,9 +554,12 @@ $lang = array_merge($lang, array(
|
||||
'LOG_POST_APPROVED' => '<strong>Approved post</strong><br />» %s',
|
||||
'LOG_POST_DISAPPROVED' => '<strong>Disapproved post “%1$s” with the following reason</strong><br />» %2$s',
|
||||
'LOG_POST_EDITED' => '<strong>Edited post “%1$s” written by</strong><br />» %2$s',
|
||||
'LOG_POST_RESTORED' => '<strong>Restored post</strong><br />» %s',
|
||||
'LOG_POST_RESTORED' => '<strong>Restored post</strong><br />» %s',
|
||||
'LOG_REPORT_CLOSED' => '<strong>Closed report</strong><br />» %s',
|
||||
'LOG_REPORT_DELETED' => '<strong>Deleted report</strong><br />» %s',
|
||||
'LOG_RESTORE_TOPIC' => '<strong>Restored topic “%1$s” written by</strong><br />» %2$s',
|
||||
'LOG_SOFTDELETE_POST' => '<strong>Soft deleted post “%1$s” written by</strong><br />» %2$s',
|
||||
'LOG_SOFTDELETE_TOPIC' => '<strong>Soft deleted topic “%1$s” written by</strong><br />» %2$s',
|
||||
'LOG_SPLIT_DESTINATION' => '<strong>Moved split posts</strong><br />» to %s',
|
||||
'LOG_SPLIT_SOURCE' => '<strong>Split posts</strong><br />» from %s',
|
||||
|
||||
|
@ -82,6 +82,8 @@ $lang = array_merge($lang, array(
|
||||
'DELETE_POST_SOFT_EXP' => 'Soft deleted posts can be recovered by a moderator',
|
||||
'DELETE_POST_REASON' => 'Soft delete reason',
|
||||
'DELETE_POST_WARN' => 'Once deleted the post cannot be recovered',
|
||||
'DELETE_TOPIC_SOFT' => 'Soft delete topic',
|
||||
'DELETE_TOPIC_SOFT_EXP' => 'Soft deleted topics can be recovered by a moderator',
|
||||
'DISABLE_BBCODE' => 'Disable BBCode',
|
||||
'DISABLE_MAGIC_URL' => 'Do not automatically parse URLs',
|
||||
'DISABLE_SMILIES' => 'Disable smilies',
|
||||
|
@ -98,7 +98,8 @@ $lang = array_merge($lang, array(
|
||||
'QUOTE' => 'Quote',
|
||||
|
||||
'REPLY_TO_TOPIC' => 'Reply to topic',
|
||||
'RESTORE' => 'Restore',
|
||||
'RESTORE' => 'Restore',
|
||||
'RESTORE_TOPIC' => 'Restore topic',
|
||||
'RETURN_POST' => '%sReturn to the post%s',
|
||||
|
||||
'SUBMIT_VOTE' => 'Submit vote',
|
||||
|
@ -158,6 +158,7 @@ if ($quickmod)
|
||||
case 'move':
|
||||
case 'delete_post':
|
||||
case 'delete_topic':
|
||||
case 'restore_topic':
|
||||
$module->load('mcp', 'main', 'quickmod');
|
||||
return;
|
||||
break;
|
||||
|
@ -1565,14 +1565,14 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof
|
||||
|
||||
if ($next_post_id === false)
|
||||
{
|
||||
add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_TOPIC', $post_data['topic_title'], $post_username);
|
||||
add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_TOPIC' : 'LOG_DELETE_TOPIC'), $post_data['topic_title'], $post_username);
|
||||
|
||||
$meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id");
|
||||
$message = $user->lang['POST_DELETED'];
|
||||
}
|
||||
else
|
||||
{
|
||||
add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_POST', $post_data['post_subject'], $post_username);
|
||||
add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), $post_data['post_subject'], $post_username);
|
||||
|
||||
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id";
|
||||
$message = $user->lang['POST_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $meta_info . '">', '</a>');
|
||||
|
@ -9,7 +9,12 @@
|
||||
|
||||
<!-- IF S_DELETE_REASON or (S_ALLOWED_DELETE and S_ALLOWED_SOFTDELETE) -->
|
||||
<fieldset class="fields1">
|
||||
<!-- IF S_ALLOWED_DELETE and S_ALLOWED_SOFTDELETE -->
|
||||
<!-- IF S_TOPIC_MODE and S_ALLOWED_DELETE and S_ALLOWED_SOFTDELETE -->
|
||||
<dl>
|
||||
<dt><label for="soft_delete">{L_DELETE_TOPIC_SOFT}:</label></dt>
|
||||
<dd><label for="soft_delete"><input id="soft_delete" name="soft_delete" type="checkbox" checked="checked" value="1" /> {L_DELETE_TOPIC_SOFT_EXP}</label></dd>
|
||||
</dl>
|
||||
<!-- ELSE IF S_ALLOWED_DELETE and S_ALLOWED_SOFTDELETE -->
|
||||
<dl>
|
||||
<dt><label for="soft_delete">{L_DELETE_POST_SOFT}:</label></dt>
|
||||
<dd><label for="soft_delete"><input id="soft_delete" name="soft_delete" type="checkbox" checked="checked" value="1" /> {L_DELETE_POST_SOFT_EXP}</label></dd>
|
||||
|
@ -532,6 +532,7 @@ $quickmod_array = array(
|
||||
'lock' => array('LOCK_TOPIC', ($topic_data['topic_status'] == ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))),
|
||||
'unlock' => array('UNLOCK_TOPIC', ($topic_data['topic_status'] != ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))),
|
||||
'delete_topic' => array('DELETE_TOPIC', $auth->acl_get('m_delete', $forum_id)),
|
||||
'restore_topic' => array('RESTORE_TOPIC', (($topic_data['topic_visibility'] == ITEM_DELETED) && $auth->acl_get('m_approve', $forum_id))),
|
||||
'move' => array('MOVE_TOPIC', $auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED),
|
||||
'split' => array('SPLIT_TOPIC', $auth->acl_get('m_split', $forum_id)),
|
||||
'merge' => array('MERGE_POSTS', $auth->acl_get('m_merge', $forum_id)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user