mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[feature/soft-delete] Add checkbox to restoring posts like on approve
PHPBB3-9567
This commit is contained in:
parent
a92927d24c
commit
b1ce8a8c13
2 changed files with 53 additions and 30 deletions
|
@ -458,8 +458,6 @@ class mcp_queue
|
|||
/**
|
||||
* Restore Posts
|
||||
*
|
||||
* @todo: Add some XSS protection, or even a confirm_box()
|
||||
*
|
||||
* @param $post_id_list array IDs of the posts to restore
|
||||
* @param $id mixed Category of the current active module
|
||||
* @param $mode string Active module
|
||||
|
@ -476,48 +474,68 @@ class mcp_queue
|
|||
}
|
||||
|
||||
$redirect = request_var('redirect', build_url(array('quickmod')));
|
||||
$redirect = reapply_sid($redirect);
|
||||
$success_msg = '';
|
||||
|
||||
$s_hidden_fields = build_hidden_fields(array(
|
||||
'i' => $id,
|
||||
'mode' => $mode,
|
||||
'post_id_list' => $post_id_list,
|
||||
'action' => 'approve',
|
||||
'redirect' => $redirect)
|
||||
);
|
||||
|
||||
$post_info = get_post_data($post_id_list, 'm_approve');
|
||||
|
||||
$topic_info = array();
|
||||
|
||||
// Group the posts by topic_id
|
||||
foreach ($post_info as $post_id => $post_data)
|
||||
if (confirm_box(true))
|
||||
{
|
||||
if ($post_data['post_visibility'] == ITEM_APPROVED)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$topic_id = (int) $post_data['topic_id'];
|
||||
$topic_info = array();
|
||||
|
||||
$topic_info[$topic_id]['posts'][] = (int) $post_id;
|
||||
$topic_info[$topic_id]['forum_id'] = (int) $post_data['forum_id'];
|
||||
|
||||
if ($post_id == $post_data['topic_first_post_id'])
|
||||
// Group the posts by topic_id
|
||||
foreach ($post_info as $post_id => $post_data)
|
||||
{
|
||||
$topic_info[$topic_id]['first_post'] = true;
|
||||
if ($post_data['post_visibility'] == ITEM_APPROVED)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$topic_id = (int) $post_data['topic_id'];
|
||||
|
||||
$topic_info[$topic_id]['posts'][] = (int) $post_id;
|
||||
$topic_info[$topic_id]['forum_id'] = (int) $post_data['forum_id'];
|
||||
|
||||
if ($post_id == $post_data['topic_first_post_id'])
|
||||
{
|
||||
$topic_info[$topic_id]['first_post'] = true;
|
||||
}
|
||||
|
||||
if ($post_id == $post_data['topic_last_post_id'])
|
||||
{
|
||||
$topic_info[$topic_id]['last_post'] = true;
|
||||
}
|
||||
|
||||
$post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$post_data['forum_id']}&t={$post_data['topic_id']}&p={$post_data['post_id']}") . '#p' . $post_data['post_id'];
|
||||
}
|
||||
|
||||
if ($post_id == $post_data['topic_last_post_id'])
|
||||
foreach ($topic_info as $topic_id => $topic_data)
|
||||
{
|
||||
$topic_info[$topic_id]['last_post'] = true;
|
||||
phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), '', isset($topic_data['first_post']), isset($topic_data['last_post']));
|
||||
}
|
||||
|
||||
$post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$post_data['forum_id']}&t={$post_data['topic_id']}&p={$post_data['post_id']}") . '#p' . $post_data['post_id'];
|
||||
if (sizeof($post_info) >= 1)
|
||||
{
|
||||
$success_msg = (sizeof($post_info) == 1) ? 'POST_RESTORED_SUCCESS' : 'POSTS_RESTORED_SUCCESS';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_APPROVE' => true,
|
||||
));
|
||||
|
||||
confirm_box(false, 'RESTORE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html');
|
||||
}
|
||||
|
||||
foreach ($topic_info as $topic_id => $topic_data)
|
||||
{
|
||||
phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), '', isset($topic_data['first_post']), isset($topic_data['last_post']));
|
||||
}
|
||||
|
||||
$success_msg = '';
|
||||
if (sizeof($post_info) >= 1)
|
||||
{
|
||||
$success_msg = (sizeof($post_info) == 1) ? 'POST_RESTORED_SUCCESS' : 'POSTS_RESTORED_SUCCESS';
|
||||
}
|
||||
$redirect = request_var('redirect', "index.$phpEx");
|
||||
$redirect = reapply_sid($redirect);
|
||||
|
||||
if (!$success_msg)
|
||||
{
|
||||
|
|
|
@ -306,6 +306,11 @@ $lang = array_merge($lang, array(
|
|||
'REPORT_POST_EXPLAIN' => 'Use this form to report the selected post to the forum moderators and board administrators. Reporting should generally be used only if the post breaks forum rules.',
|
||||
'REPORT_REASON' => 'Report reason',
|
||||
'REPORT_TIME' => 'Report time',
|
||||
'RESTORE' => 'Restore',
|
||||
'RESTORE_POST' => 'Restore post',
|
||||
'RESTORE_POST_CONFIRM' => 'Are you sure you want to restore this post?',
|
||||
'RESTORE_POSTS' => 'Restore posts',
|
||||
'RESTORE_POSTS_CONFIRM' => 'Are you sure you want to restore the selected posts?',
|
||||
'RESYNC' => 'Resync',
|
||||
'RETURN_MESSAGE' => '%sReturn to the message%s',
|
||||
'RETURN_NEW_FORUM' => '%sGo to the new forum%s',
|
||||
|
|
Loading…
Add table
Reference in a new issue