[feature/soft-delete] Fix restoring/approving posts with mcp moderation

PHPBB3-9567
This commit is contained in:
Joas Schilling 2012-10-31 14:09:23 +01:00
parent f0e2d21f8c
commit 18dec1026a
3 changed files with 21 additions and 14 deletions

View file

@ -25,12 +25,12 @@ class mcp_queue
var $p_master; var $p_master;
var $u_action; var $u_action;
function mcp_queue(&$p_master) public function mcp_queue(&$p_master)
{ {
$this->p_master = &$p_master; $this->p_master = &$p_master;
} }
function main($id, $mode) public function main($id, $mode)
{ {
global $auth, $db, $user, $template, $cache; global $auth, $db, $user, $template, $cache;
global $config, $phpbb_root_path, $phpEx, $action; global $config, $phpbb_root_path, $phpEx, $action;
@ -56,11 +56,11 @@ class mcp_queue
{ {
if (!empty($post_id_list)) if (!empty($post_id_list))
{ {
$this->approve_posts($action, $post_id_list, 'queue', $mode); self::approve_posts($action, $post_id_list, 'queue', $mode);
} }
else if (!empty($topic_id_list)) else if (!empty($topic_id_list))
{ {
$this->approve_topics($action, $topic_id_list, 'queue', $mode); self::approve_topics($action, $topic_id_list, 'queue', $mode);
} }
else else
{ {
@ -87,7 +87,7 @@ class mcp_queue
if (!empty($post_id_list)) if (!empty($post_id_list))
{ {
$this->disapprove_posts($post_id_list, 'queue', $mode); self::disapprove_posts($post_id_list, 'queue', $mode);
} }
else else
{ {
@ -493,7 +493,7 @@ class mcp_queue
* @param $mode string Active module * @param $mode string Active module
* @return void * @return void
*/ */
function approve_posts($action, $post_id_list, $id, $mode) static public function approve_posts($action, $post_id_list, $id, $mode)
{ {
global $db, $template, $user, $config; global $db, $template, $user, $config;
global $phpEx, $phpbb_root_path, $request; global $phpEx, $phpbb_root_path, $request;
@ -686,7 +686,7 @@ class mcp_queue
* @param $mode string Active module * @param $mode string Active module
* @return void * @return void
*/ */
function approve_topics($action, $topic_id_list, $id, $mode) static public function approve_topics($action, $topic_id_list, $id, $mode)
{ {
global $db, $template, $user, $config; global $db, $template, $user, $config;
global $phpEx, $phpbb_root_path, $request; global $phpEx, $phpbb_root_path, $request;
@ -849,7 +849,7 @@ class mcp_queue
* @param $mode string Active module * @param $mode string Active module
* @return void * @return void
*/ */
function disapprove_posts($post_id_list, $id, $mode) static public function disapprove_posts($post_id_list, $id, $mode)
{ {
global $db, $template, $user, $config; global $db, $template, $user, $config;
global $phpEx, $phpbb_root_path; global $phpEx, $phpbb_root_path;

View file

@ -84,8 +84,8 @@ function mcp_topic_view($id, $mode, $action)
$subject = $topic_info['topic_title']; $subject = $topic_info['topic_title'];
} }
// Approve posts? // Restore or pprove posts?
if ($action == 'approve' && $auth->acl_get('m_approve', $topic_info['forum_id'])) if (($action == 'restore' || $action == 'approve') && $auth->acl_get('m_approve', $topic_info['forum_id']))
{ {
include($phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx); include($phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
@ -98,7 +98,7 @@ function mcp_topic_view($id, $mode, $action)
if (!$sort) if (!$sort)
{ {
approve_post($post_id_list, $id, $mode); mcp_queue::approve_posts($action, $post_id_list, $id, $mode);
} }
} }
@ -175,7 +175,7 @@ function mcp_topic_view($id, $mode, $action)
$topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id); $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id);
} }
$has_unapproved_posts = false; $has_unapproved_posts = $has_deleted_posts = false;
// Grab extensions // Grab extensions
$extensions = $attachments = array(); $extensions = $attachments = array();
@ -225,6 +225,11 @@ function mcp_topic_view($id, $mode, $action)
$has_unapproved_posts = true; $has_unapproved_posts = true;
} }
if ($row['post_visibility'] == ITEM_DELETED)
{
$has_deleted_posts = true;
}
$post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false; $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
$template->assign_block_vars('postrow', array( $template->assign_block_vars('postrow', array(
@ -328,6 +333,7 @@ function mcp_topic_view($id, $mode, $action)
'S_CAN_MERGE' => ($auth->acl_get('m_merge', $topic_info['forum_id'])) ? true : false, 'S_CAN_MERGE' => ($auth->acl_get('m_merge', $topic_info['forum_id'])) ? true : false,
'S_CAN_DELETE' => ($auth->acl_get('m_delete', $topic_info['forum_id'])) ? true : false, 'S_CAN_DELETE' => ($auth->acl_get('m_delete', $topic_info['forum_id'])) ? true : false,
'S_CAN_APPROVE' => ($has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false, 'S_CAN_APPROVE' => ($has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false,
'S_CAN_RESTORE' => ($has_deleted_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false,
'S_CAN_LOCK' => ($auth->acl_get('m_lock', $topic_info['forum_id'])) ? true : false, 'S_CAN_LOCK' => ($auth->acl_get('m_lock', $topic_info['forum_id'])) ? true : false,
'S_CAN_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? true : false, 'S_CAN_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? true : false,
'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']),

View file

@ -160,6 +160,7 @@ onload_functions.push('subPanels()');
<!-- IF S_CAN_APPROVE --><option value="approve">{L_APPROVE_POSTS}</option><!-- ENDIF --> <!-- IF S_CAN_APPROVE --><option value="approve">{L_APPROVE_POSTS}</option><!-- ENDIF -->
<!-- IF S_CAN_LOCK --><option value="lock_post">{L_LOCK_POST_POSTS} [ {L_LOCK_POST_EXPLAIN} ]</option><option value="unlock_post">{L_UNLOCK_POST_POSTS}</option><!-- ENDIF --> <!-- IF S_CAN_LOCK --><option value="lock_post">{L_LOCK_POST_POSTS} [ {L_LOCK_POST_EXPLAIN} ]</option><option value="unlock_post">{L_UNLOCK_POST_POSTS}</option><!-- ENDIF -->
<!-- IF S_CAN_DELETE --><option value="delete_post">{L_DELETE_POSTS}</option><!-- ENDIF --> <!-- IF S_CAN_DELETE --><option value="delete_post">{L_DELETE_POSTS}</option><!-- ENDIF -->
<!-- IF S_CAN_RESTORE --><option value="restore">{L_RESTORE_POSTS}</option><!-- ENDIF -->
<!-- IF S_CAN_MERGE --><option value="merge_posts"<!-- IF S_MERGE_VIEW --> selected="selected"<!-- ENDIF -->>{L_MERGE_POSTS}</option><!-- ENDIF --> <!-- IF S_CAN_MERGE --><option value="merge_posts"<!-- IF S_MERGE_VIEW --> selected="selected"<!-- ENDIF -->>{L_MERGE_POSTS}</option><!-- ENDIF -->
<!-- IF S_CAN_SPLIT --><option value="split_all"<!-- IF S_SPLIT_VIEW --> selected="selected"<!-- ENDIF -->>{L_SPLIT_POSTS}</option><option value="split_beyond">{L_SPLIT_AFTER}</option><!-- ENDIF --> <!-- IF S_CAN_SPLIT --><option value="split_all"<!-- IF S_SPLIT_VIEW --> selected="selected"<!-- ENDIF -->>{L_SPLIT_POSTS}</option><option value="split_beyond">{L_SPLIT_AFTER}</option><!-- ENDIF -->
<!-- IF S_CAN_SYNC --><option value="resync">{L_RESYNC}</option><!-- ENDIF --> <!-- IF S_CAN_SYNC --><option value="resync">{L_RESYNC}</option><!-- ENDIF -->