[feature/soft-delete] Add checkbox to restoring posts like on approve

PHPBB3-9567
This commit is contained in:
Joas Schilling 2012-10-15 15:19:32 +02:00
parent a92927d24c
commit b1ce8a8c13
2 changed files with 53 additions and 30 deletions

View file

@ -458,8 +458,6 @@ class mcp_queue
/** /**
* Restore Posts * Restore Posts
* *
* @todo: Add some XSS protection, or even a confirm_box()
*
* @param $post_id_list array IDs of the posts to restore * @param $post_id_list array IDs of the posts to restore
* @param $id mixed Category of the current active module * @param $id mixed Category of the current active module
* @param $mode string Active module * @param $mode string Active module
@ -476,48 +474,68 @@ class mcp_queue
} }
$redirect = request_var('redirect', build_url(array('quickmod'))); $redirect = request_var('redirect', build_url(array('quickmod')));
$redirect = reapply_sid($redirect);
$success_msg = ''; $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'); $post_info = get_post_data($post_id_list, 'm_approve');
$topic_info = array(); if (confirm_box(true))
// Group the posts by topic_id
foreach ($post_info as $post_id => $post_data)
{ {
if ($post_data['post_visibility'] == ITEM_APPROVED) $topic_info = array();
{
continue;
}
$topic_id = (int) $post_data['topic_id'];
$topic_info[$topic_id]['posts'][] = (int) $post_id; // Group the posts by topic_id
$topic_info[$topic_id]['forum_id'] = (int) $post_data['forum_id']; foreach ($post_info as $post_id => $post_data)
if ($post_id == $post_data['topic_first_post_id'])
{ {
$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) $redirect = request_var('redirect', "index.$phpEx");
{ $redirect = reapply_sid($redirect);
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';
}
if (!$success_msg) if (!$success_msg)
{ {

View file

@ -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_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_REASON' => 'Report reason',
'REPORT_TIME' => 'Report time', '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', 'RESYNC' => 'Resync',
'RETURN_MESSAGE' => '%sReturn to the message%s', 'RETURN_MESSAGE' => '%sReturn to the message%s',
'RETURN_NEW_FORUM' => '%sGo to the new forum%s', 'RETURN_NEW_FORUM' => '%sGo to the new forum%s',