From b8c55291ed7ed86565be2bc651bf20eb1a9ed4dd Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Thu, 17 Jun 2010 23:58:18 -0500 Subject: [feature/soft-delete] Lay the groundwork for a soft-delete feature So far, I've added no new functionality. The biggest change here is adjusting the DB column names to "visibility" rather than "approved". Some things here are pretty likely to change, for example the name and location of the topic_visibility class. Happy birthday phpBB :) PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index b44685b8a3..833f924efc 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -183,7 +183,7 @@ class mcp_queue 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p=$post_id&f=$forum_id"), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], - 'S_POST_UNAPPROVED' => !$post_info['post_approved'], + 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED) , 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, @@ -309,7 +309,7 @@ class mcp_queue $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' - AND p.post_approved = 0 + AND p.post_visibility = ' . ITEM_UNAPPROVED . ' ' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " AND t.topic_id = p.topic_id @@ -361,7 +361,7 @@ class mcp_queue $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_attachment AS post_attachment, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour FROM ' . TOPICS_TABLE . " t WHERE " . $db->sql_in_set('forum_id', $forum_list) . " - AND topic_approved = 0 + AND topic_visibility = " . ITEM_UNAPPROVED . " $limit_time_sql ORDER BY $sort_order_sql"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); @@ -484,7 +484,7 @@ function approve_post($post_id_list, $id, $mode) foreach ($post_info as $post_id => $post_data) { - if ($post_data['post_approved']) + if ($post_data['post_visibility'] == ITEM_APPROVED) { $post_approved_list[] = $post_id; continue; @@ -544,7 +544,7 @@ function approve_post($post_id_list, $id, $mode) if (sizeof($topic_approve_sql)) { $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_approved = 1 + SET topic_visibility = ' . ITEM_APPROVED . ' WHERE ' . $db->sql_in_set('topic_id', $topic_approve_sql); $db->sql_query($sql); } @@ -552,7 +552,7 @@ function approve_post($post_id_list, $id, $mode) if (sizeof($post_approve_sql)) { $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_approved = 1 + SET post_visibility = ' . ITEM_APPROVED . ' WHERE ' . $db->sql_in_set('post_id', $post_approve_sql); $db->sql_query($sql); } -- cgit v1.2.1 From fb13ab83e476d2afbc7bb181f7ab90df98f996da Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Sun, 27 Jun 2010 14:22:36 -0500 Subject: [feature/soft-delete] Implement the ability to soft-delete and restore posts The soft delete feature seems to work. Tests are pending. A real icon is pending. Add the permissions and the interface to soft-delete posts. Also able to restore posts via the MCP queue PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 152 +++++++-------------------------------- 1 file changed, 25 insertions(+), 127 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 833f924efc..c19fb9b2b6 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -46,6 +46,7 @@ class mcp_queue { case 'approve': case 'disapprove': + case 'restore': include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); $post_id_list = request_var('post_id_list', array(0)); @@ -59,6 +60,10 @@ class mcp_queue { approve_post($post_id_list, 'queue', $mode); } + else if ($action == 'restore') + { +// do something + } else { disapprove_post($post_id_list, 'queue', $mode); @@ -224,6 +229,16 @@ class mcp_queue case 'unapproved_topics': case 'unapproved_posts': + case 'deleted_posts': + if ($mode == 'deleted_posts') + { + $m_perm = 'm_restore'; + } + else + { + $m_perm = 'm_approve'; + } + $user->add_lang(array('viewtopic', 'viewforum')); $topic_id = request_var('t', 0); @@ -242,7 +257,7 @@ class mcp_queue $forum_id = $topic_info['forum_id']; } - $forum_list_approve = get_forum_list('m_approve', false, true); + $forum_list_approve = get_forum_list($m_perm, false, true); $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs // Remove forums we cannot read @@ -277,7 +292,7 @@ class mcp_queue } else { - $forum_info = get_forum_data(array($forum_id), 'm_approve'); + $forum_info = get_forum_data(array($forum_id), $m_perm); if (!sizeof($forum_info)) { @@ -304,8 +319,10 @@ class mcp_queue $forum_names = array(); - if ($mode == 'unapproved_posts') + if ($mode == 'unapproved_posts' || $mode == 'deleted_posts') { + $visibility_const = ($mode == 'unapproved_posts') ? ITEM_UNAPPROVED : ITEM_DELETED; + $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' @@ -425,13 +442,14 @@ class mcp_queue // Now display the page $template->assign_vars(array( 'L_DISPLAY_ITEMS' => ($mode == 'unapproved_posts') ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], - 'L_EXPLAIN' => ($mode == 'unapproved_posts') ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS_EXPLAIN'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS_EXPLAIN'], - 'L_TITLE' => ($mode == 'unapproved_posts') ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS'], + 'L_EXPLAIN' => $user->lang['MCP_QUEUE_' . strtoupper($mode) . '_EXPLAIN'], + 'L_TITLE' => $user->lang['MCP_QUEUE_' . strtoupper($mode)], 'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_FORUM_OPTIONS' => $forum_options, 'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')), - 'S_TOPICS' => ($mode == 'unapproved_posts') ? false : true, + 'S_TOPICS' => ($mode == 'unapproved_topics') ? true : false, + 'S_RESTORE' => ($mode == 'deleted_posts') ? true : false, 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, @@ -475,127 +493,7 @@ function approve_post($post_id_list, $id, $mode) { $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; - // If Topic -> total_topics = total_topics+1, total_posts = total_posts+1, forum_topics = forum_topics+1, forum_posts = forum_posts+1 - // If Post -> total_posts = total_posts+1, forum_posts = forum_posts+1, topic_replies = topic_replies+1 - - $total_topics = $total_posts = 0; - $topic_approve_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array(); - $user_posts_sql = $post_approved_list = array(); - - foreach ($post_info as $post_id => $post_data) - { - if ($post_data['post_visibility'] == ITEM_APPROVED) - { - $post_approved_list[] = $post_id; - continue; - } - - $topic_id_list[$post_data['topic_id']] = 1; - $forum_id_list[$post_data['forum_id']] = 1; - - // User post update (we do not care about topic or post, since user posts are strictly connected to posts) - // But we care about forums where post counts get not increased. ;) - if ($post_data['post_postcount']) - { - $user_posts_sql[$post_data['poster_id']] = (empty($user_posts_sql[$post_data['poster_id']])) ? 1 : $user_posts_sql[$post_data['poster_id']] + 1; - } - - // Topic or Post. ;) - if ($post_data['topic_first_post_id'] == $post_id) - { - $total_topics++; - $topic_approve_sql[] = $post_data['topic_id']; - - $approve_log[] = array( - 'type' => 'topic', - 'post_subject' => $post_data['post_subject'], - 'forum_id' => $post_data['forum_id'], - 'topic_id' => $post_data['topic_id'], - ); - } - else - { - $approve_log[] = array( - 'type' => 'post', - 'post_subject' => $post_data['post_subject'], - 'forum_id' => $post_data['forum_id'], - 'topic_id' => $post_data['topic_id'], - ); - } - - $total_posts++; - - // Increment by topic_replies if we approve a topic... - // This works because we do not adjust the topic_replies when re-approving a topic after an edit. - if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies']) - { - $total_posts += $post_data['topic_replies']; - } - - $post_approve_sql[] = $post_id; - } - - $post_id_list = array_values(array_diff($post_id_list, $post_approved_list)); - for ($i = 0, $size = sizeof($post_approved_list); $i < $size; $i++) - { - unset($post_info[$post_approved_list[$i]]); - } - - if (sizeof($topic_approve_sql)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_visibility = ' . ITEM_APPROVED . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_approve_sql); - $db->sql_query($sql); - } - - if (sizeof($post_approve_sql)) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_visibility = ' . ITEM_APPROVED . ' - WHERE ' . $db->sql_in_set('post_id', $post_approve_sql); - $db->sql_query($sql); - } - - unset($topic_approve_sql, $post_approve_sql); - - foreach ($approve_log as $log_data) - { - add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_APPROVED' : 'LOG_POST_APPROVED', $log_data['post_subject']); - } - - if (sizeof($user_posts_sql)) - { - // Try to minimize the query count by merging users with the same post count additions - $user_posts_update = array(); - - foreach ($user_posts_sql as $user_id => $user_posts) - { - $user_posts_update[$user_posts][] = $user_id; - } - - foreach ($user_posts_update as $user_posts => $user_id_ary) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts + ' . $user_posts . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - } - } - - if ($total_topics) - { - set_config_count('num_topics', $total_topics, true); - } - - if ($total_posts) - { - set_config_count('num_posts', $total_posts, true); - } - - sync('topic', 'topic_id', array_keys($topic_id_list), true); - sync('forum', 'forum_id', array_keys($forum_id_list), true, true); - unset($topic_id_list, $forum_id_list); + phpbb_visibility::unhide_posts_topics('approve', $post_info, $post_id_list); $messenger = new messenger(); -- cgit v1.2.1 From a80cfafdd91a384ba810a8ee0d43406bba955faa Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Wed, 30 Jun 2010 13:38:49 -0500 Subject: [feature/soft-delete] Rename phpbb_visibility class to phpbb_content_visibility Rename the class to more accurately reflect what it does. PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index c19fb9b2b6..221dfffebc 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -493,7 +493,7 @@ function approve_post($post_id_list, $id, $mode) { $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; - phpbb_visibility::unhide_posts_topics('approve', $post_info, $post_id_list); + phpbb_content_visibility::unhide_posts_topics('approve', $post_info, $post_id_list); $messenger = new messenger(); -- cgit v1.2.1 From f570558a8da65596b0ca2700e2e7829548d2393a Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Mon, 5 Jul 2010 21:58:20 -0500 Subject: [feature/soft-delete] Add a processor for action == restore in mcp_queue.php Restoring a post within mcp_queue.php didn't do anything before this commit. Now it does, by way of a function which is very similar to approve_post. PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 45 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 221dfffebc..597be855b7 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -62,7 +62,7 @@ class mcp_queue } else if ($action == 'restore') { -// do something + restore_post($post_id_list, 'queue', $mode); } else { @@ -462,6 +462,47 @@ class mcp_queue } } + +/** +* Approve Post/Topic +*/ +function restore_post($post_id_list, $id, $mode) +{ + global $db, $template, $user, $config; + global $phpEx, $phpbb_root_path; + + if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_restore'))) + { + trigger_error('NOT_AUTHORISED'); + } + + $redirect = request_var('redirect', build_url(array('quickmod'))); + $redirect = reapply_sid($redirect); + $success_msg = ''; + + $post_info = get_post_data($post_id_list, 'm_restore'); + + phpbb_content_visibility::unhide_posts_topics('restore', $post_info, $post_id_list); + + if (!$success_msg) + { + redirect($redirect); + } + else + { + meta_refresh(3, $redirect); + + // If approving one post, also give links back to post... + $add_message = ''; + if (sizeof($post_id_list) == 1 && !empty($post_url)) + { + $add_message = '

' . sprintf($user->lang['RETURN_POST'], '', ''); + } + + trigger_error($user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message); + } +} + /** * Approve Post/Topic */ @@ -493,7 +534,7 @@ function approve_post($post_id_list, $id, $mode) { $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; - phpbb_content_visibility::unhide_posts_topics('approve', $post_info, $post_id_list); + phpbb_content_visibility::unhide_posts_topics('approve', $post_info, $post_id_list); $messenger = new messenger(); -- cgit v1.2.1 From 1ab41f8dc6ec81f2aaf152229d5f0275de796c85 Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Sat, 17 Jul 2010 14:34:36 -0500 Subject: [feature/soft-delete] Fix some small bugs To wit: using non-existing constant POST_DELETED in posting.php; first test post was initially unapproved; soft delete checkbox appeared at post time Links pointing to the wrong place. PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 597be855b7..6c36084e68 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -322,6 +322,7 @@ class mcp_queue if ($mode == 'unapproved_posts' || $mode == 'deleted_posts') { $visibility_const = ($mode == 'unapproved_posts') ? ITEM_UNAPPROVED : ITEM_DELETED; + $starter_sql = ($mode == 'unapproved_posts') ? 'AND t.topic_first_post_id <> p.post_id' : ''; $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . ' @@ -330,7 +331,7 @@ class mcp_queue ' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " AND t.topic_id = p.topic_id - AND t.topic_first_post_id <> p.post_id + $starter_sql $limit_time_sql ORDER BY $sort_order_sql"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); -- cgit v1.2.1 From b774c09c7f25e3119eeffe7363c91c7b9fd6dbf7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 28 Aug 2012 23:01:38 +0200 Subject: [feature/soft-delete] Use the variable which holds the correct item status PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 6c36084e68..a20ce10aa6 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -327,7 +327,7 @@ class mcp_queue $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' - AND p.post_visibility = ' . ITEM_UNAPPROVED . ' + AND p.post_visibility = ' . $visibility_const . ' ' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " AND t.topic_id = p.topic_id -- cgit v1.2.1 From 8a036fa3e4e1fc51a3eb7fded346ccbd84a291b5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 29 Aug 2012 18:42:14 +0200 Subject: [feature/soft-delete] Update restoring feature to use ajax if requested. Also fixes the mcp as a hole: - displayes a success message - gives a link to the post, if only one was restored PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index a20ce10aa6..cbf0ff0089 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -470,7 +470,7 @@ class mcp_queue function restore_post($post_id_list, $id, $mode) { global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path; + global $phpEx, $phpbb_root_path, $request; if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_restore'))) { @@ -483,7 +483,7 @@ function restore_post($post_id_list, $id, $mode) $post_info = get_post_data($post_id_list, 'm_restore'); - phpbb_content_visibility::unhide_posts_topics('restore', $post_info, $post_id_list); + $success_msg = phpbb_content_visibility::unhide_posts_topics('restore', $post_info, $post_id_list); if (!$success_msg) { @@ -500,7 +500,20 @@ function restore_post($post_id_list, $id, $mode) $add_message = '

' . sprintf($user->lang['RETURN_POST'], '', ''); } - trigger_error($user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message); + $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $message, + 'REFRESH_DATA' => null, + 'visible' => true, + )); + } + + trigger_error($message); } } @@ -659,7 +672,7 @@ function approve_post($post_id_list, $id, $mode) 'MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $message, 'REFRESH_DATA' => null, - 'approved' => true + 'visible' => true, )); } @@ -931,7 +944,7 @@ function disapprove_post($post_id_list, $id, $mode) 'MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $message, 'REFRESH_DATA' => null, - 'approved' => false + 'visible' => false, )); } -- cgit v1.2.1 From c03d692a98fafa921a832e063c76a3d844632ca7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 30 Aug 2012 22:57:00 +0200 Subject: [feature/soft-delete] Fix some more usages of _approved column names PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index cbf0ff0089..3b18b7f0e7 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -548,7 +548,7 @@ function approve_post($post_id_list, $id, $mode) { $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; - phpbb_content_visibility::unhide_posts_topics('approve', $post_info, $post_id_list); + $success_msg = phpbb_content_visibility::unhide_posts_topics('approve', $post_info, $post_id_list); $messenger = new messenger(); @@ -607,15 +607,6 @@ function approve_post($post_id_list, $id, $mode) $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']; } unset($post_info); - - if ($total_topics) - { - $success_msg = ($total_topics == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS'; - } - else - { - $success_msg = (sizeof($post_id_list) + sizeof($post_approved_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS'; - } } else { -- cgit v1.2.1 From 1943de36f32609b37230da32aa679466043702fe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 1 Oct 2012 16:25:05 +0200 Subject: [feature/soft-delete] Comment out user_posts update for the moment It should rely on the permissions of the post not the current user. PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 3b18b7f0e7..b1b4ea99aa 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -465,7 +465,7 @@ class mcp_queue /** -* Approve Post/Topic +* Restore Post/Topic */ function restore_post($post_id_list, $id, $mode) { -- cgit v1.2.1 From 4bf922fa03ae80533c726bd10aeab1f0bad0d179 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Oct 2012 19:00:08 +0200 Subject: [feature/soft-delete] Fix restoring posts via MCP PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 60 +++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 13 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index b1b4ea99aa..184959dfb6 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -230,14 +230,7 @@ class mcp_queue case 'unapproved_topics': case 'unapproved_posts': case 'deleted_posts': - if ($mode == 'deleted_posts') - { - $m_perm = 'm_restore'; - } - else - { - $m_perm = 'm_approve'; - } + $m_perm = 'm_approve'; $user->add_lang(array('viewtopic', 'viewforum')); @@ -472,7 +465,7 @@ function restore_post($post_id_list, $id, $mode) global $db, $template, $user, $config; global $phpEx, $phpbb_root_path, $request; - if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_restore'))) + if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) { trigger_error('NOT_AUTHORISED'); } @@ -481,9 +474,51 @@ function restore_post($post_id_list, $id, $mode) $redirect = reapply_sid($redirect); $success_msg = ''; - $post_info = get_post_data($post_id_list, 'm_restore'); + $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 ($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; + } + } + + 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 = phpbb_content_visibility::unhide_posts_topics('restore', $post_info, $post_id_list); + $success_msg = ''; + /** + * Currently only works for approving posts + if (sizeof($topic_info) > 1) + { + $success_msg = ((sizeof($post_info) == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS'; + } + else + */ + if (sizeof($post_info) >= 1) + { + $success_msg = (sizeof($post_info) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS'; + } if (!$success_msg) { @@ -491,8 +526,6 @@ function restore_post($post_id_list, $id, $mode) } else { - meta_refresh(3, $redirect); - // If approving one post, also give links back to post... $add_message = ''; if (sizeof($post_id_list) == 1 && !empty($post_url)) @@ -513,6 +546,7 @@ function restore_post($post_id_list, $id, $mode) )); } + meta_refresh(3, $redirect); trigger_error($message); } } -- cgit v1.2.1 From 7c2cc9cfeface2ea4267dca204f56f794e3418af Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 15 Oct 2012 14:02:16 +0200 Subject: [feature/soft-delete] Turn restore_post() into a method and add the docs PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 153 ++++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 76 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 184959dfb6..31a5e09582 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -62,7 +62,7 @@ class mcp_queue } else if ($action == 'restore') { - restore_post($post_id_list, 'queue', $mode); + $this->restore_posts($post_id_list, 'queue', $mode); } else { @@ -443,7 +443,7 @@ class mcp_queue 'S_FORUM_OPTIONS' => $forum_options, 'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')), 'S_TOPICS' => ($mode == 'unapproved_topics') ? true : false, - 'S_RESTORE' => ($mode == 'deleted_posts') ? true : false, + 'S_RESTORE' => ($mode == 'deleted_posts') ? true : false, 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, @@ -454,103 +454,104 @@ class mcp_queue break; } } -} - - -/** -* Restore Post/Topic -*/ -function restore_post($post_id_list, $id, $mode) -{ - global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path, $request; - if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) + /** + * 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 + * @return void + */ + function restore_posts($post_id_list, $id, $mode) { - trigger_error('NOT_AUTHORISED'); - } + global $db, $template, $user, $config; + global $phpEx, $phpbb_root_path, $request; - $redirect = request_var('redirect', build_url(array('quickmod'))); - $redirect = reapply_sid($redirect); - $success_msg = ''; + if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) + { + trigger_error('NOT_AUTHORISED'); + } - $post_info = get_post_data($post_id_list, 'm_approve'); + $redirect = request_var('redirect', build_url(array('quickmod'))); + $redirect = reapply_sid($redirect); + $success_msg = ''; - $topic_info = array(); + $post_info = get_post_data($post_id_list, 'm_approve'); - // Group the posts by topic_id - foreach ($post_info as $post_id => $post_data) - { - if ($post_data['post_visibility'] == ITEM_APPROVED) + $topic_info = array(); + + // Group the posts by topic_id + foreach ($post_info as $post_id => $post_data) { - continue; - } - $topic_id = (int) $post_data['topic_id']; + 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']; + $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_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'])); } - } - - 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 = ''; - /** - * Currently only works for approving posts - if (sizeof($topic_info) > 1) - { - $success_msg = ((sizeof($post_info) == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS'; - } - else - */ - if (sizeof($post_info) >= 1) - { - $success_msg = (sizeof($post_info) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS'; - } - - if (!$success_msg) - { - redirect($redirect); - } - else - { - // If approving one post, also give links back to post... - $add_message = ''; - if (sizeof($post_id_list) == 1 && !empty($post_url)) + $success_msg = ''; + if (sizeof($post_info) >= 1) { - $add_message = '

' . sprintf($user->lang['RETURN_POST'], '', ''); + $success_msg = (sizeof($post_info) == 1) ? 'POST_RESTORED_SUCCESS' : 'POSTS_RESTORED_SUCCESS'; } - $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; - - if ($request->is_ajax()) + if (!$success_msg) { - $json_response = new phpbb_json_response; - $json_response->send(array( - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $message, - 'REFRESH_DATA' => null, - 'visible' => true, - )); + redirect($redirect); } + else + { + // If restoring one post, also give links back to post... + $add_message = ''; + if (sizeof($post_id_list) == 1 && !empty($post_url)) + { + $add_message = '

' . sprintf($user->lang['RETURN_POST'], '', ''); + } - meta_refresh(3, $redirect); - trigger_error($message); + $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $message, + 'REFRESH_DATA' => null, + 'visible' => true, + )); + } + + meta_refresh(3, $redirect); + trigger_error($message); + } } } + /** * Approve Post/Topic */ -- cgit v1.2.1 From a92927d24cace3b3444cb3502de765c6e8e16fa9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 15 Oct 2012 15:05:02 +0200 Subject: [feature/soft-delete] Turn other functions into methods as well PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 637 +++++++++++++++++++-------------------- 1 file changed, 318 insertions(+), 319 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 31a5e09582..99c4a6eccb 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -58,7 +58,7 @@ class mcp_queue if ($action == 'approve') { - approve_post($post_id_list, 'queue', $mode); + $this->approve_posts($post_id_list, 'queue', $mode); } else if ($action == 'restore') { @@ -66,7 +66,7 @@ class mcp_queue } else { - disapprove_post($post_id_list, 'queue', $mode); + $this->disapprove_posts($post_id_list, 'queue', $mode); } break; @@ -549,432 +549,431 @@ class mcp_queue trigger_error($message); } } -} - -/** -* Approve Post/Topic -*/ -function approve_post($post_id_list, $id, $mode) -{ - global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path; - global $request; - - if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) + /** + * Approve Post/Topic + */ + function approve_posts($post_id_list, $id, $mode) { - trigger_error('NOT_AUTHORISED'); - } + global $db, $template, $user, $config; + global $phpEx, $phpbb_root_path; + global $request; + + if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) + { + trigger_error('NOT_AUTHORISED'); + } - $redirect = request_var('redirect', build_url(array('quickmod'))); - $success_msg = ''; + $redirect = request_var('redirect', build_url(array('quickmod'))); + $success_msg = ''; - $s_hidden_fields = build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'post_id_list' => $post_id_list, - 'action' => 'approve', - 'redirect' => $redirect) - ); + $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'); - if (confirm_box(true)) - { - $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; + if (confirm_box(true)) + { + $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; - $success_msg = phpbb_content_visibility::unhide_posts_topics('approve', $post_info, $post_id_list); + $success_msg = phpbb_content_visibility::unhide_posts_topics('approve', $post_info, $post_id_list); - $messenger = new messenger(); + $messenger = new messenger(); - // Notify Poster? - if ($notify_poster) - { - foreach ($post_info as $post_id => $post_data) + // Notify Poster? + if ($notify_poster) { - if ($post_data['poster_id'] == ANONYMOUS) + foreach ($post_info as $post_id => $post_data) { - continue; - } + if ($post_data['poster_id'] == ANONYMOUS) + { + continue; + } - $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_approved' : 'post_approved'; + $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_approved' : 'post_approved'; - $messenger->template($email_template, $post_data['user_lang']); + $messenger->template($email_template, $post_data['user_lang']); - $messenger->to($post_data['user_email'], $post_data['username']); - $messenger->im($post_data['user_jabber'], $post_data['username']); + $messenger->to($post_data['user_email'], $post_data['username']); + $messenger->im($post_data['user_jabber'], $post_data['username']); - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($post_data['username']), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])), + $messenger->assign_vars(array( + 'USERNAME' => htmlspecialchars_decode($post_data['username']), + 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), + 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])), - 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&e=0", - 'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&p=$post_id&e=$post_id") - ); + 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&e=0", + 'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&p=$post_id&e=$post_id") + ); - $messenger->send($post_data['user_notify_type']); + $messenger->send($post_data['user_notify_type']); + } } - } - $messenger->save_queue(); + $messenger->save_queue(); - // Send out normal user notifications - $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); + // Send out normal user notifications + $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); - foreach ($post_info as $post_id => $post_data) - { - if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id']) + foreach ($post_info as $post_id => $post_data) { - // Forum Notifications - user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); + if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id']) + { + // Forum Notifications + user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); + } + else + { + // Topic Notifications + user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); + } } - else + + if (sizeof($post_id_list) == 1) { - // Topic Notifications - user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); + $post_data = $post_info[$post_id_list[0]]; + $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']; } + unset($post_info); } - - if (sizeof($post_id_list) == 1) + else { - $post_data = $post_info[$post_id_list[0]]; - $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']; - } - unset($post_info); - } - else - { - $show_notify = false; + $show_notify = false; - if ($config['email_enable'] || $config['jab_enable']) - { - foreach ($post_info as $post_data) + if ($config['email_enable'] || $config['jab_enable']) { - if ($post_data['poster_id'] == ANONYMOUS) + foreach ($post_info as $post_data) { - continue; - } - else - { - $show_notify = true; - break; + if ($post_data['poster_id'] == ANONYMOUS) + { + continue; + } + else + { + $show_notify = true; + break; + } } } - } - $template->assign_vars(array( - 'S_NOTIFY_POSTER' => $show_notify, - 'S_APPROVE' => true) - ); - - confirm_box(false, 'APPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); - } - - $redirect = request_var('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - - if (!$success_msg) - { - redirect($redirect); - } - else - { - meta_refresh(3, $redirect); + $template->assign_vars(array( + 'S_NOTIFY_POSTER' => $show_notify, + 'S_APPROVE' => true) + ); - // If approving one post, also give links back to post... - $add_message = ''; - if (sizeof($post_id_list) == 1 && !empty($post_url)) - { - $add_message = '

' . sprintf($user->lang['RETURN_POST'], '', ''); + confirm_box(false, 'APPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); } - $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; + $redirect = request_var('redirect', "index.$phpEx"); + $redirect = reapply_sid($redirect); - if ($request->is_ajax()) + if (!$success_msg) { - $json_response = new phpbb_json_response; - $json_response->send(array( - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $message, - 'REFRESH_DATA' => null, - 'visible' => true, - )); + redirect($redirect); } + else + { + meta_refresh(3, $redirect); - trigger_error($message); - } -} + // If approving one post, also give links back to post... + $add_message = ''; + if (sizeof($post_id_list) == 1 && !empty($post_url)) + { + $add_message = '

' . sprintf($user->lang['RETURN_POST'], '', ''); + } -/** -* Disapprove Post/Topic -*/ -function disapprove_post($post_id_list, $id, $mode) -{ - global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path; - global $request; + $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; - if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) - { - trigger_error('NOT_AUTHORISED'); + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $message, + 'REFRESH_DATA' => null, + 'visible' => true, + )); + } + + trigger_error($message); + } } - $redirect = request_var('redirect', build_url(array('t', 'mode', 'quickmod')) . "&mode=$mode"); - $reason = utf8_normalize_nfc(request_var('reason', '', true)); - $reason_id = request_var('reason_id', 0); - $success_msg = $additional_msg = ''; + /** + * Disapprove Post/Topic + */ + function disapprove_posts($post_id_list, $id, $mode) + { + global $db, $template, $user, $config; + global $phpEx, $phpbb_root_path; + global $request; - $s_hidden_fields = build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'post_id_list' => $post_id_list, - 'action' => 'disapprove', - 'redirect' => $redirect) - ); + if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) + { + trigger_error('NOT_AUTHORISED'); + } - $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; - $disapprove_reason = ''; + $redirect = request_var('redirect', build_url(array('t', 'mode', 'quickmod')) . "&mode=$mode"); + $reason = utf8_normalize_nfc(request_var('reason', '', true)); + $reason_id = request_var('reason_id', 0); + $success_msg = $additional_msg = ''; + + $s_hidden_fields = build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'post_id_list' => $post_id_list, + 'action' => 'disapprove', + 'redirect' => $redirect) + ); - if ($reason_id) - { - $sql = 'SELECT reason_title, reason_description - FROM ' . REPORTS_REASONS_TABLE . " - WHERE reason_id = $reason_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row || (!$reason && strtolower($row['reason_title']) == 'other')) - { - $additional_msg = $user->lang['NO_REASON_DISAPPROVAL']; + $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; + $disapprove_reason = ''; - $request->overwrite('confirm', null, phpbb_request_interface::POST); - $request->overwrite('confirm_key', null, phpbb_request_interface::POST); - $request->overwrite('confirm_key', null, phpbb_request_interface::REQUEST); - } - else + if ($reason_id) { - // If the reason is defined within the language file, we will use the localized version, else just use the database entry... - $disapprove_reason = (strtolower($row['reason_title']) != 'other') ? ((isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description']) : ''; - $disapprove_reason .= ($reason) ? "\n\n" . $reason : ''; - - if (isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) + $sql = 'SELECT reason_title, reason_description + FROM ' . REPORTS_REASONS_TABLE . " + WHERE reason_id = $reason_id"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row || (!$reason && strtolower($row['reason_title']) == 'other')) { - $disapprove_reason_lang = strtoupper($row['reason_title']); + $additional_msg = $user->lang['NO_REASON_DISAPPROVAL']; + + $request->overwrite('confirm', null, phpbb_request_interface::POST); + $request->overwrite('confirm_key', null, phpbb_request_interface::POST); + $request->overwrite('confirm_key', null, phpbb_request_interface::REQUEST); } + else + { + // If the reason is defined within the language file, we will use the localized version, else just use the database entry... + $disapprove_reason = (strtolower($row['reason_title']) != 'other') ? ((isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description']) : ''; + $disapprove_reason .= ($reason) ? "\n\n" . $reason : ''; - $email_disapprove_reason = $disapprove_reason; - } - } + if (isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) + { + $disapprove_reason_lang = strtoupper($row['reason_title']); + } - $post_info = get_post_data($post_id_list, 'm_approve'); + $email_disapprove_reason = $disapprove_reason; + } + } - if (confirm_box(true)) - { - $disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array(); - $topic_replies_real = $post_disapprove_list = array(); + $post_info = get_post_data($post_id_list, 'm_approve'); - // Build a list of posts to be unapproved and get the related topics real replies count - foreach ($post_info as $post_id => $post_data) + if (confirm_box(true)) { - $post_disapprove_list[$post_id] = $post_data['topic_id']; - if (!isset($topic_replies_real[$post_data['topic_id']])) + $disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array(); + $topic_replies_real = $post_disapprove_list = array(); + + // Build a list of posts to be unapproved and get the related topics real replies count + foreach ($post_info as $post_id => $post_data) { - $topic_replies_real[$post_data['topic_id']] = $post_data['topic_replies_real']; + $post_disapprove_list[$post_id] = $post_data['topic_id']; + if (!isset($topic_replies_real[$post_data['topic_id']])) + { + $topic_replies_real[$post_data['topic_id']] = $post_data['topic_replies_real']; + } } - } - // Now we build the log array - foreach ($post_disapprove_list as $post_id => $topic_id) - { - // If the count of disapproved posts for the topic is greater - // than topic's real replies count, the whole topic is disapproved/deleted - if (sizeof(array_keys($post_disapprove_list, $topic_id)) > $topic_replies_real[$topic_id]) + // Now we build the log array + foreach ($post_disapprove_list as $post_id => $topic_id) { - // Don't write the log more than once for every topic - if (!isset($disapprove_log_topics[$topic_id])) + // If the count of disapproved posts for the topic is greater + // than topic's real replies count, the whole topic is disapproved/deleted + if (sizeof(array_keys($post_disapprove_list, $topic_id)) > $topic_replies_real[$topic_id]) + { + // Don't write the log more than once for every topic + if (!isset($disapprove_log_topics[$topic_id])) + { + // Build disapproved topics log + $disapprove_log_topics[$topic_id] = array( + 'type' => 'topic', + 'post_subject' => $post_info[$post_id]['topic_title'], + 'forum_id' => $post_info[$post_id]['forum_id'], + 'topic_id' => 0, // useless to log a topic id, as it will be deleted + ); + } + } + else { - // Build disapproved topics log - $disapprove_log_topics[$topic_id] = array( - 'type' => 'topic', - 'post_subject' => $post_info[$post_id]['topic_title'], + // Build disapproved posts log + $disapprove_log_posts[] = array( + 'type' => 'post', + 'post_subject' => $post_info[$post_id]['post_subject'], 'forum_id' => $post_info[$post_id]['forum_id'], - 'topic_id' => 0, // useless to log a topic id, as it will be deleted + 'topic_id' => $post_info[$post_id]['topic_id'], ); - } - } - else - { - // Build disapproved posts log - $disapprove_log_posts[] = array( - 'type' => 'post', - 'post_subject' => $post_info[$post_id]['post_subject'], - 'forum_id' => $post_info[$post_id]['forum_id'], - 'topic_id' => $post_info[$post_id]['topic_id'], - ); + } } - } - // Get disapproved posts/topics counts separately - $num_disapproved_topics = sizeof($disapprove_log_topics); - $num_disapproved_posts = sizeof($disapprove_log_posts); + // Get disapproved posts/topics counts separately + $num_disapproved_topics = sizeof($disapprove_log_topics); + $num_disapproved_posts = sizeof($disapprove_log_posts); - // Build the whole log - $disapprove_log = array_merge($disapprove_log_topics, $disapprove_log_posts); + // Build the whole log + $disapprove_log = array_merge($disapprove_log_topics, $disapprove_log_posts); - // Unset unneeded arrays - unset($post_data, $disapprove_log_topics, $disapprove_log_posts); + // Unset unneeded arrays + unset($post_data, $disapprove_log_topics, $disapprove_log_posts); - // Let's do the job - delete disapproved posts - if (sizeof($post_disapprove_list)) - { - if (!function_exists('delete_posts')) + // Let's do the job - delete disapproved posts + if (sizeof($post_disapprove_list)) { - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } + if (!function_exists('delete_posts')) + { + include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + } - // We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts - // Note: function delete_posts triggers related forums/topics sync, - // so we don't need to call update_post_information later and to adjust real topic replies or forum topics count manually - delete_posts('post_id', array_keys($post_disapprove_list)); + // We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts + // Note: function delete_posts triggers related forums/topics sync, + // so we don't need to call update_post_information later and to adjust real topic replies or forum topics count manually + delete_posts('post_id', array_keys($post_disapprove_list)); - foreach ($disapprove_log as $log_data) - { - add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED', $log_data['post_subject'], $disapprove_reason); + foreach ($disapprove_log as $log_data) + { + add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED', $log_data['post_subject'], $disapprove_reason); + } } - } - - $messenger = new messenger(); - // Notify Poster? - if ($notify_poster) - { - $lang_reasons = array(); + $messenger = new messenger(); - foreach ($post_info as $post_id => $post_data) + // Notify Poster? + if ($notify_poster) { - if ($post_data['poster_id'] == ANONYMOUS) - { - continue; - } + $lang_reasons = array(); - if (isset($disapprove_reason_lang)) + foreach ($post_info as $post_id => $post_data) { - // Okay we need to get the reason from the posters language - if (!isset($lang_reasons[$post_data['user_lang']])) + if ($post_data['poster_id'] == ANONYMOUS) { - // Assign the current users translation as the default, this is not ideal but getting the board default adds another layer of complexity. - $lang_reasons[$post_data['user_lang']] = $user->lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]; + continue; + } - // Only load up the language pack if the language is different to the current one - if ($post_data['user_lang'] != $user->lang_name && file_exists($phpbb_root_path . '/language/' . $post_data['user_lang'] . '/mcp.' . $phpEx)) + if (isset($disapprove_reason_lang)) + { + // Okay we need to get the reason from the posters language + if (!isset($lang_reasons[$post_data['user_lang']])) { - // Load up the language pack - $lang = array(); - @include($phpbb_root_path . '/language/' . basename($post_data['user_lang']) . '/mcp.' . $phpEx); + // Assign the current users translation as the default, this is not ideal but getting the board default adds another layer of complexity. + $lang_reasons[$post_data['user_lang']] = $user->lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]; - // If we find the reason in this language pack use it - if (isset($lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang])) + // Only load up the language pack if the language is different to the current one + if ($post_data['user_lang'] != $user->lang_name && file_exists($phpbb_root_path . '/language/' . $post_data['user_lang'] . '/mcp.' . $phpEx)) { - $lang_reasons[$post_data['user_lang']] = $lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]; - } + // Load up the language pack + $lang = array(); + @include($phpbb_root_path . '/language/' . basename($post_data['user_lang']) . '/mcp.' . $phpEx); - unset($lang); // Free memory + // If we find the reason in this language pack use it + if (isset($lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang])) + { + $lang_reasons[$post_data['user_lang']] = $lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]; + } + + unset($lang); // Free memory + } } + + $email_disapprove_reason = $lang_reasons[$post_data['user_lang']]; + $email_disapprove_reason .= ($reason) ? "\n\n" . $reason : ''; } - $email_disapprove_reason = $lang_reasons[$post_data['user_lang']]; - $email_disapprove_reason .= ($reason) ? "\n\n" . $reason : ''; - } + $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_disapproved' : 'post_disapproved'; - $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_disapproved' : 'post_disapproved'; + $messenger->template($email_template, $post_data['user_lang']); - $messenger->template($email_template, $post_data['user_lang']); + $messenger->to($post_data['user_email'], $post_data['username']); + $messenger->im($post_data['user_jabber'], $post_data['username']); - $messenger->to($post_data['user_email'], $post_data['username']); - $messenger->im($post_data['user_jabber'], $post_data['username']); + $messenger->assign_vars(array( + 'USERNAME' => htmlspecialchars_decode($post_data['username']), + 'REASON' => htmlspecialchars_decode($email_disapprove_reason), + 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), + 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title']))) + ); - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($post_data['username']), - 'REASON' => htmlspecialchars_decode($email_disapprove_reason), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title']))) - ); + $messenger->send($post_data['user_notify_type']); + } - $messenger->send($post_data['user_notify_type']); + unset($lang_reasons); } + unset($post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang); - unset($lang_reasons); - } - unset($post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang); + $messenger->save_queue(); - $messenger->save_queue(); - - if ($num_disapproved_topics) - { - $success_msg = ($num_disapproved_topics == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS'; + if ($num_disapproved_topics) + { + $success_msg = ($num_disapproved_topics == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS'; + } + else + { + $success_msg = ($num_disapproved_posts == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS'; + } } else { - $success_msg = ($num_disapproved_posts == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS'; - } - } - else - { - include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); + include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); - display_reasons($reason_id); + display_reasons($reason_id); - $show_notify = false; + $show_notify = false; - foreach ($post_info as $post_data) - { - if ($post_data['poster_id'] == ANONYMOUS) - { - continue; - } - else + foreach ($post_info as $post_data) { - $show_notify = true; - break; + if ($post_data['poster_id'] == ANONYMOUS) + { + continue; + } + else + { + $show_notify = true; + break; + } } - } - $template->assign_vars(array( - 'S_NOTIFY_POSTER' => $show_notify, - 'S_APPROVE' => false, - 'REASON' => $reason, - 'ADDITIONAL_MSG' => $additional_msg) - ); + $template->assign_vars(array( + 'S_NOTIFY_POSTER' => $show_notify, + 'S_APPROVE' => false, + 'REASON' => $reason, + 'ADDITIONAL_MSG' => $additional_msg) + ); - confirm_box(false, 'DISAPPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); - } - - $redirect = request_var('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); + confirm_box(false, 'DISAPPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); + } - if (!$success_msg) - { - redirect($redirect); - } - else - { - $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", ''); + $redirect = request_var('redirect', "index.$phpEx"); + $redirect = reapply_sid($redirect); - if ($request->is_ajax()) + if (!$success_msg) { - $json_response = new phpbb_json_response; - $json_response->send(array( - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $message, - 'REFRESH_DATA' => null, - 'visible' => false, - )); + redirect($redirect); } + else + { + $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", ''); - meta_refresh(3, $redirect); - trigger_error($message); + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $message, + 'REFRESH_DATA' => null, + 'visible' => false, + )); + } + + meta_refresh(3, $redirect); + trigger_error($message); + } } } -- cgit v1.2.1 From b1ce8a8c13eca920abf3659fcbfec267684071bb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 15 Oct 2012 15:19:32 +0200 Subject: [feature/soft-delete] Add checkbox to restoring posts like on approve PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 72 +++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 27 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 99c4a6eccb..a56d4ac898 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -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,49 +474,69 @@ class mcp_queue } $redirect = request_var('redirect', build_url(array('quickmod'))); - $redirect = reapply_sid($redirect); $success_msg = ''; - $post_info = get_post_data($post_id_list, 'm_approve'); + $s_hidden_fields = build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'post_id_list' => $post_id_list, + 'action' => 'approve', + 'redirect' => $redirect) + ); - $topic_info = array(); + $post_info = get_post_data($post_id_list, 'm_approve'); - // 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) + $topic_info = array(); + + // Group the posts by topic_id + foreach ($post_info as $post_id => $post_data) { - continue; - } - $topic_id = (int) $post_data['topic_id']; + 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']; + $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_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'; + } } - - foreach ($topic_info as $topic_id => $topic_data) + else { - 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'])); - } + $template->assign_vars(array( + 'S_APPROVE' => true, + )); - $success_msg = ''; - if (sizeof($post_info) >= 1) - { - $success_msg = (sizeof($post_info) == 1) ? 'POST_RESTORED_SUCCESS' : 'POSTS_RESTORED_SUCCESS'; + confirm_box(false, 'RESTORE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); } + $redirect = request_var('redirect', "index.$phpEx"); + $redirect = reapply_sid($redirect); + if (!$success_msg) { redirect($redirect); -- cgit v1.2.1 From 33073fafbe53cb103e9e00bceb249a0879a2eb9c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 15 Oct 2012 15:53:32 +0200 Subject: [feature/soft-delete] Add module for soft deleted topics Unapproved/soft deleted posts are posts, that have a different visibility than the topic. All others will be hidden from the posts list and can be managed with the topic modules. PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 120 +++++++++++++++++++++++++++++++++------ 1 file changed, 104 insertions(+), 16 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index a56d4ac898..d61c5fa5ef 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -229,8 +229,12 @@ class mcp_queue case 'unapproved_topics': case 'unapproved_posts': + case 'deleted_topics': case 'deleted_posts': $m_perm = 'm_approve'; + $is_topics = ($mode == 'unapproved_topics' || $mode == 'deleted_topics') ? true : false; + $is_restore = ($mode == 'deleted_posts' || $mode == 'deleted_topics') ? true : false; + $visibility_const = (!$is_restore) ? ITEM_UNAPPROVED : ITEM_DELETED; $user->add_lang(array('viewtopic', 'viewforum')); @@ -312,11 +316,8 @@ class mcp_queue $forum_names = array(); - if ($mode == 'unapproved_posts' || $mode == 'deleted_posts') + if (!$is_topics) { - $visibility_const = ($mode == 'unapproved_posts') ? ITEM_UNAPPROVED : ITEM_DELETED; - $starter_sql = ($mode == 'unapproved_posts') ? 'AND t.topic_first_post_id <> p.post_id' : ''; - $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' @@ -324,7 +325,7 @@ class mcp_queue ' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " AND t.topic_id = p.topic_id - $starter_sql + AND t.topic_visibility <> p.post_visibility $limit_time_sql ORDER BY $sort_order_sql"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); @@ -370,9 +371,9 @@ class mcp_queue else { $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_attachment AS post_attachment, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour - FROM ' . TOPICS_TABLE . " t - WHERE " . $db->sql_in_set('forum_id', $forum_list) . " - AND topic_visibility = " . ITEM_UNAPPROVED . " + FROM ' . TOPICS_TABLE . ' t + WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' + AND topic_visibility = ' . $visibility_const . " $limit_time_sql ORDER BY $sort_order_sql"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); @@ -432,22 +433,22 @@ class mcp_queue $base_url = $this->u_action . "&f=$forum_id&st=$sort_days&sk=$sort_key&sd=$sort_dir"; phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); - + // Now display the page $template->assign_vars(array( - 'L_DISPLAY_ITEMS' => ($mode == 'unapproved_posts') ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], + 'L_DISPLAY_ITEMS' => (!$is_topics) ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], 'L_EXPLAIN' => $user->lang['MCP_QUEUE_' . strtoupper($mode) . '_EXPLAIN'], 'L_TITLE' => $user->lang['MCP_QUEUE_' . strtoupper($mode)], 'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_FORUM_OPTIONS' => $forum_options, 'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')), - 'S_TOPICS' => ($mode == 'unapproved_topics') ? true : false, - 'S_RESTORE' => ($mode == 'deleted_posts') ? true : false, + 'S_TOPICS' => $is_topics, + 'S_RESTORE' => $is_restore, 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, - 'TOTAL' => $user->lang((($mode == 'unapproved_posts') ? 'VIEW_TOPIC_POSTS' : 'VIEW_FORUM_TOPICS'), (int) $total), + 'TOTAL' => $user->lang(((!$is_topics) ? 'VIEW_TOPIC_POSTS' : 'VIEW_FORUM_TOPICS'), (int) $total), )); $this->tpl_name = 'mcp_queue'; @@ -480,9 +481,9 @@ class mcp_queue 'i' => $id, 'mode' => $mode, 'post_id_list' => $post_id_list, - 'action' => 'approve', - 'redirect' => $redirect) - ); + 'action' => 'restore', + 'redirect' => $redirect, + )); $post_info = get_post_data($post_id_list, 'm_approve'); @@ -568,6 +569,93 @@ class mcp_queue } } + /** + * Restore topics + * + * @param $topic_id_list array IDs of the topics to restore + * @param $id mixed Category of the current active module + * @param $mode string Active module + * @return void + */ + function restore_topics($topic_id_list, $id, $mode) + { + global $db, $template, $user, $config; + global $phpEx, $phpbb_root_path, $request; + + if (!check_ids($topic_id_list, TOPICS_TABLE, 'topic_id', array('m_approve'))) + { + trigger_error('NOT_AUTHORISED'); + } + + $redirect = request_var('redirect', build_url(array('quickmod'))); + $success_msg = ''; + + $s_hidden_fields = build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'topic_id_list' => $topic_id_list, + 'action' => 'restore', + 'redirect' => $redirect, + )); + + $topic_info = get_topic_data($topic_id_list, 'm_approve'); + + if (confirm_box(true)) + { + foreach ($topic_info as $topic_id => $topic_data) + { + phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); + $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_data['forum_id']}&t={$topic_id}"); + } + + if (sizeof($topic_info) >= 1) + { + $success_msg = 'TOPIC' . ((sizeof($topic_info) == 1) ? '' : 'S') . '_RESTORED_SUCCESS'; + } + } + else + { + $template->assign_vars(array( + 'S_APPROVE' => true, + )); + + confirm_box(false, 'RESTORE_TOPIC' . ((sizeof($topic_info) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); + } + + $redirect = request_var('redirect', "index.$phpEx"); + $redirect = reapply_sid($redirect); + + if (!$success_msg) + { + redirect($redirect); + } + else + { + // If restoring one topic, also give links back to topic... + $add_message = ''; + if (sizeof($topic_info) == 1 && !empty($topic_url)) + { + $add_message = '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); + } + + $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $message, + 'REFRESH_DATA' => null, + 'visible' => true, + )); + } + + meta_refresh(3, $redirect); + trigger_error($message); + } + } + /** * Approve Post/Topic */ -- cgit v1.2.1 From 51d54109e0ad159a521be57192b6547bebc02fe3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 16 Oct 2012 13:55:22 +0200 Subject: [feature/soft-delete] Merge approving and restoring posts into one function PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 189 +++++++++++++++++++++++++-------------- 1 file changed, 124 insertions(+), 65 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index d61c5fa5ef..26e6ad574f 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -50,23 +50,33 @@ class mcp_queue include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); $post_id_list = request_var('post_id_list', array(0)); + $topic_id_list = request_var('topic_id_list', array(0)); - if (!sizeof($post_id_list)) + if (!empty($post_id_list)) { - trigger_error('NO_POST_SELECTED'); - } - - if ($action == 'approve') - { - $this->approve_posts($post_id_list, 'queue', $mode); + if ($action != 'disapprove') + { + $this->approve_posts($action, $post_id_list, 'queue', $mode); + } + else + { + $this->disapprove_posts($post_id_list, 'queue', $mode); + } } - else if ($action == 'restore') + else if (!empty($topic_id_list)) { - $this->restore_posts($post_id_list, 'queue', $mode); + if ($action != 'disapprove') + { + $this->approve_topics($action, $post_id_list, 'queue', $mode); + } + else + { + $this->disapprove_posts($post_id_list, 'queue', $mode); + } } else { - $this->disapprove_posts($post_id_list, 'queue', $mode); + trigger_error('NO_POST_SELECTED'); } break; @@ -657,13 +667,18 @@ class mcp_queue } /** - * Approve Post/Topic + * Approve/Restore posts + * + * @param $action string Action we perform on the posts ('approve' or 'restore') + * @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 + * @return void */ - function approve_posts($post_id_list, $id, $mode) + function approve_posts($action, $post_id_list, $id, $mode) { global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path; - global $request; + global $phpEx, $phpbb_root_path, $request; if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) { @@ -671,87 +686,131 @@ class mcp_queue } $redirect = request_var('redirect', build_url(array('quickmod'))); - $success_msg = ''; + $success_msg = $post_url = ''; + $approve_log = array(); $s_hidden_fields = build_hidden_fields(array( 'i' => $id, 'mode' => $mode, 'post_id_list' => $post_id_list, - 'action' => 'approve', - 'redirect' => $redirect) - ); + 'action' => $action, + 'redirect' => $redirect, + )); $post_info = get_post_data($post_id_list, 'm_approve'); if (confirm_box(true)) { - $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; - - $success_msg = phpbb_content_visibility::unhide_posts_topics('approve', $post_info, $post_id_list); + $notify_poster = ($action == 'approve' && isset($_REQUEST['notify_poster'])) ? true : false; - $messenger = new messenger(); + $topic_info = array(); - // Notify Poster? - if ($notify_poster) + // Group the posts by topic_id + foreach ($post_info as $post_id => $post_data) { - foreach ($post_info as $post_id => $post_data) + if ($post_data['post_visibility'] == ITEM_APPROVED) { - if ($post_data['poster_id'] == ANONYMOUS) - { - continue; - } + continue; + } + $topic_id = (int) $post_data['topic_id']; - $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_approved' : 'post_approved'; + $topic_info[$topic_id]['posts'][] = (int) $post_id; + $topic_info[$topic_id]['forum_id'] = (int) $post_data['forum_id']; - $messenger->template($email_template, $post_data['user_lang']); + if ($post_id == $post_data['topic_first_post_id']) + { + $topic_info[$topic_id]['first_post'] = true; + } - $messenger->to($post_data['user_email'], $post_data['username']); - $messenger->im($post_data['user_jabber'], $post_data['username']); + if ($post_id == $post_data['topic_last_post_id']) + { + $topic_info[$topic_id]['last_post'] = true; + } - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($post_data['username']), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])), + $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']; - 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&e=0", - 'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&p=$post_id&e=$post_id") - ); + $approve_log[] = array( + 'forum_id' => $post_data['forum_id'], + 'topic_id' => $post_data['topic_id'], + 'post_subject' => $post_data['post_subject'], + ); + } - $messenger->send($post_data['user_notify_type']); - } + 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'])); } - $messenger->save_queue(); + if (sizeof($post_info) >= 1) + { + $success_msg = (sizeof($post_info) == 1) ? 'POST_' . strtoupper($action) . 'D_SUCCESS' : 'POSTS_' . strtoupper($action) . 'D_SUCCESS'; + } - // Send out normal user notifications - $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); + foreach ($approve_log as $log_data) + { + add_log('mod', $log_data['forum_id'], $log_data['topic_id'], 'LOG_POST_' . strtoupper($action) . 'D', $log_data['post_subject']); + } - foreach ($post_info as $post_id => $post_data) + // Only send out the mails, when the posts are being approved + if ($action == 'approve') { - if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id']) + $messenger = new messenger(); + + // Notify Poster? + if ($notify_poster) { - // Forum Notifications - user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); + foreach ($post_info as $post_id => $post_data) + { + if ($post_data['poster_id'] == ANONYMOUS) + { + continue; + } + + $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_approved' : 'post_approved'; + + $messenger->template($email_template, $post_data['user_lang']); + + $messenger->to($post_data['user_email'], $post_data['username']); + $messenger->im($post_data['user_jabber'], $post_data['username']); + + $messenger->assign_vars(array( + 'USERNAME' => htmlspecialchars_decode($post_data['username']), + 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), + 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])), + + 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&e=0", + 'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&p=$post_id&e=$post_id") + ); + + $messenger->send($post_data['user_notify_type']); + } } - else + + $messenger->save_queue(); + + // Send out normal user notifications + $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); + + foreach ($post_info as $post_id => $post_data) { - // Topic Notifications - user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); + if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id']) + { + // Forum Notifications + user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); + } + else + { + // Topic Notifications + user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); + } } } - - if (sizeof($post_id_list) == 1) - { - $post_data = $post_info[$post_id_list[0]]; - $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']; - } - unset($post_info); } else { $show_notify = false; - if ($config['email_enable'] || $config['jab_enable']) + if ($action == 'approve' && ($config['email_enable'] || $config['jab_enable'])) { foreach ($post_info as $post_data) { @@ -768,11 +827,11 @@ class mcp_queue } $template->assign_vars(array( - 'S_NOTIFY_POSTER' => $show_notify, - 'S_APPROVE' => true) - ); + 'S_NOTIFY_POSTER' => $show_notify, + 'S_' . strtoupper($action) => true, + )); - confirm_box(false, 'APPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); + confirm_box(false, strtoupper($action) . '_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); } $redirect = request_var('redirect', "index.$phpEx"); @@ -788,7 +847,7 @@ class mcp_queue // If approving one post, also give links back to post... $add_message = ''; - if (sizeof($post_id_list) == 1 && !empty($post_url)) + if (sizeof($post_info) == 1 && $post_url) { $add_message = '

' . sprintf($user->lang['RETURN_POST'], '', ''); } -- cgit v1.2.1 From 722835a4baad13e6886ffd724f92ffaf61990b90 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 16 Oct 2012 14:18:56 +0200 Subject: [feature/soft-delete] Merge approving and restoring topics into one function PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 187 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 173 insertions(+), 14 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 26e6ad574f..f4a78525c8 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -670,7 +670,7 @@ class mcp_queue * Approve/Restore posts * * @param $action string Action we perform on the posts ('approve' or 'restore') - * @param $post_id_list array IDs of the posts to restore + * @param $post_id_list array IDs of the posts to approve/restore * @param $id mixed Category of the current active module * @param $mode string Active module * @return void @@ -766,9 +766,7 @@ class mcp_queue continue; } - $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_approved' : 'post_approved'; - - $messenger->template($email_template, $post_data['user_lang']); + $messenger->template('post_approved', $post_data['user_lang']); $messenger->to($post_data['user_email'], $post_data['username']); $messenger->im($post_data['user_jabber'], $post_data['username']); @@ -793,16 +791,8 @@ class mcp_queue foreach ($post_info as $post_id => $post_data) { - if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id']) - { - // Forum Notifications - user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); - } - else - { - // Topic Notifications - user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); - } + // Topic Notifications + user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); } } } @@ -869,6 +859,175 @@ class mcp_queue } } + /** + * Approve/Restore topics + * + * @param $action string Action we perform on the posts ('approve' or 'restore') + * @param $topic_id_list array IDs of the topics to approve/restore + * @param $id mixed Category of the current active module + * @param $mode string Active module + * @return void + */ + function approve_topics($action, $topic_id_list, $id, $mode) + { + global $db, $template, $user, $config; + global $phpEx, $phpbb_root_path, $request; + + if (!check_ids($topic_id_list, TOPICS_TABLE, 'topic_id', array('m_approve'))) + { + trigger_error('NOT_AUTHORISED'); + } + + $redirect = request_var('redirect', build_url(array('quickmod'))); + $success_msg = $topic_url = ''; + $approve_log = array(); + + $s_hidden_fields = build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'topic_id_list' => $topic_id_list, + 'action' => $action, + 'redirect' => $redirect, + )); + + $topic_info = get_topic_data($topic_id_list, 'm_approve'); + + if (confirm_box(true)) + { + $notify_poster = ($action == 'approve' && isset($_REQUEST['notify_poster'])) ? true : false; + + foreach ($topic_info as $topic_id => $topic_data) + { + phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); + + $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_data['forum_id']}&t={$topic_id}"); + + $approve_log[] = array( + 'forum_id' => $topic_data['forum_id'], + 'topic_id' => $topic_data['topic_id'], + 'topic_title' => $topic_data['topic_title'], + ); + } + + foreach ($topic_info as $topic_id => $topic_data) + { + phpbb_content_visibility::set_topic_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); + } + + if (sizeof($topic_info) >= 1) + { + $success_msg = (sizeof($topic_info) == 1) ? 'TOPIC_' . strtoupper($action) . 'D_SUCCESS' : 'TOPICS_' . strtoupper($action) . 'D_SUCCESS'; + } + + foreach ($approve_log as $log_data) + { + add_log('mod', $log_data['forum_id'], $log_data['topic_id'], 'LOG_TOPIC_' . strtoupper($action) . 'D', $log_data['topic_title']); + } + + // Only send out the mails, when the posts are being approved + if ($action == 'approve') + { + $messenger = new messenger(); + + // Notify Poster? + if ($notify_poster) + { + foreach ($topic_info as $topic_id => $topic_data) + { + if ($topic_data['topic_poster'] == ANONYMOUS) + { + continue; + } + + $messenger->template('topic_approved', $topic_data['user_lang']); + $messenger->to($topic_data['user_email'], $topic_data['username']); + $messenger->im($topic_data['user_jabber'], $topic_data['username']); + + $messenger->assign_vars(array( + 'USERNAME' => htmlspecialchars_decode($topic_data['username']), + 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($topic_data['topic_title'])), + 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$topic_data['forum_id']}&t={$topic_data['topic_id']}&e=0", + ); + + $messenger->send($topic_data['user_notify_type']); + } + } + + $messenger->save_queue(); + + // Send out normal user notifications + $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); + + foreach ($topic_info as $topic_id => $topic_data) + { + // Forum Notifications + user_notification('post', $topic_data['topic_title'], $topic_data['topic_title'], $topic_data['forum_name'], $topic_data['forum_id'], $topic_data['topic_id'], 0); + } + } + } + else + { + $show_notify = false; + + if ($action == 'approve' && ($config['email_enable'] || $config['jab_enable'])) + { + foreach ($topic_info as $topic_data) + { + if ($topic_data['topic_poster'] == ANONYMOUS) + { + continue; + } + else + { + $show_notify = true; + break; + } + } + } + + $template->assign_vars(array( + 'S_NOTIFY_POSTER' => $show_notify, + 'S_' . strtoupper($action) => true, + )); + + confirm_box(false, strtoupper($action) . '_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); + } + + $redirect = request_var('redirect', "index.$phpEx"); + $redirect = reapply_sid($redirect); + + if (!$success_msg) + { + redirect($redirect); + } + else + { + meta_refresh(3, $redirect); + + // If approving one topic, also give links back to topic... + $add_message = ''; + if (sizeof($topic_info) == 1 && $topic_url) + { + $add_message = '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); + } + + $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $message, + 'REFRESH_DATA' => null, + 'visible' => true, + )); + } + + trigger_error($message); + } + } + /** * Disapprove Post/Topic */ -- cgit v1.2.1 From 43d041bdecb5e564ad48efdf4702cad3714c7837 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 16 Oct 2012 14:20:23 +0200 Subject: [feature/soft-delete] Removed unused old functions PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 200 --------------------------------------- 1 file changed, 200 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index f4a78525c8..5e7c53c8de 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -466,206 +466,6 @@ class mcp_queue } } - /** - * Restore Posts - * - * @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 - * @return void - */ - function restore_posts($post_id_list, $id, $mode) - { - global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path, $request; - - if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) - { - trigger_error('NOT_AUTHORISED'); - } - - $redirect = request_var('redirect', build_url(array('quickmod'))); - $success_msg = ''; - - $s_hidden_fields = build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'post_id_list' => $post_id_list, - 'action' => 'restore', - 'redirect' => $redirect, - )); - - $post_info = get_post_data($post_id_list, 'm_approve'); - - if (confirm_box(true)) - { - $topic_info = array(); - - // Group the posts by topic_id - foreach ($post_info as $post_id => $post_data) - { - 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']; - } - - 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'])); - } - - 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'); - } - - $redirect = request_var('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - - if (!$success_msg) - { - redirect($redirect); - } - else - { - // If restoring one post, also give links back to post... - $add_message = ''; - if (sizeof($post_id_list) == 1 && !empty($post_url)) - { - $add_message = '

' . sprintf($user->lang['RETURN_POST'], '', ''); - } - - $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; - - if ($request->is_ajax()) - { - $json_response = new phpbb_json_response; - $json_response->send(array( - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $message, - 'REFRESH_DATA' => null, - 'visible' => true, - )); - } - - meta_refresh(3, $redirect); - trigger_error($message); - } - } - - /** - * Restore topics - * - * @param $topic_id_list array IDs of the topics to restore - * @param $id mixed Category of the current active module - * @param $mode string Active module - * @return void - */ - function restore_topics($topic_id_list, $id, $mode) - { - global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path, $request; - - if (!check_ids($topic_id_list, TOPICS_TABLE, 'topic_id', array('m_approve'))) - { - trigger_error('NOT_AUTHORISED'); - } - - $redirect = request_var('redirect', build_url(array('quickmod'))); - $success_msg = ''; - - $s_hidden_fields = build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'topic_id_list' => $topic_id_list, - 'action' => 'restore', - 'redirect' => $redirect, - )); - - $topic_info = get_topic_data($topic_id_list, 'm_approve'); - - if (confirm_box(true)) - { - foreach ($topic_info as $topic_id => $topic_data) - { - phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); - $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_data['forum_id']}&t={$topic_id}"); - } - - if (sizeof($topic_info) >= 1) - { - $success_msg = 'TOPIC' . ((sizeof($topic_info) == 1) ? '' : 'S') . '_RESTORED_SUCCESS'; - } - } - else - { - $template->assign_vars(array( - 'S_APPROVE' => true, - )); - - confirm_box(false, 'RESTORE_TOPIC' . ((sizeof($topic_info) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); - } - - $redirect = request_var('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - - if (!$success_msg) - { - redirect($redirect); - } - else - { - // If restoring one topic, also give links back to topic... - $add_message = ''; - if (sizeof($topic_info) == 1 && !empty($topic_url)) - { - $add_message = '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); - } - - $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; - - if ($request->is_ajax()) - { - $json_response = new phpbb_json_response; - $json_response->send(array( - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $message, - 'REFRESH_DATA' => null, - 'visible' => true, - )); - } - - meta_refresh(3, $redirect); - trigger_error($message); - } - } - /** * Approve/Restore posts * -- cgit v1.2.1 From 2adb37049e8c7eab5fa762a8968605a8f608aaa8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Oct 2012 15:23:16 +0200 Subject: [feature/soft-delete] Display guest username in topic list instead of "Guest" PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 5e7c53c8de..bf34c7c53c 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -417,7 +417,7 @@ class mcp_queue { if (empty($row['post_username'])) { - $row['post_username'] = $user->lang['GUEST']; + $row['post_username'] = $row['username'] ?: $user->lang['GUEST']; } $template->assign_block_vars('postrow', array( @@ -747,7 +747,7 @@ class mcp_queue 'USERNAME' => htmlspecialchars_decode($topic_data['username']), 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($topic_data['topic_title'])), 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$topic_data['forum_id']}&t={$topic_data['topic_id']}&e=0", - ); + )); $messenger->send($topic_data['user_notify_type']); } -- cgit v1.2.1 From 0822d2bb61dda3b887911d6686a8c6db05131c47 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Oct 2012 15:32:57 +0200 Subject: [feature/soft-delete] Split unapproved/soft deleted posts from topics If a topic is soft deleted through a moderator, the topic_delete_user is set. If it is passively soft deleted (f.e. while the only approved post is deleted) the topic_delete_user is not set. This way, we can distinguish between these two cases. The same also applies to unapproved posts. So we need to set the topic_delete_user when an unapproved topic is posted. Topics that were soft deleted/unapproved by a user (rather then passive) are going to be displayed in the Topics modules, while all others are in the posts modules of the MCP queue. PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index bf34c7c53c..554a7c080b 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -335,7 +335,8 @@ class mcp_queue ' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " AND t.topic_id = p.topic_id - AND t.topic_visibility <> p.post_visibility + AND (t.topic_visibility <> p.post_visibility + OR t.topic_delete_user = 0) $limit_time_sql ORDER BY $sort_order_sql"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); @@ -384,6 +385,7 @@ class mcp_queue FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND topic_visibility = ' . $visibility_const . " + AND topic_delete_user <> 0 $limit_time_sql ORDER BY $sort_order_sql"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); -- cgit v1.2.1 From e7a137820bf6ca341df5c0c503e2767451f57c5e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 21 Oct 2012 22:30:20 +0200 Subject: [feature/soft-delete] Use correct language when restoring topics in MCP PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 554a7c080b..3d36229ee7 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -67,11 +67,11 @@ class mcp_queue { if ($action != 'disapprove') { - $this->approve_topics($action, $post_id_list, 'queue', $mode); + $this->approve_topics($action, $topic_id_list, 'queue', $mode); } else { - $this->disapprove_posts($post_id_list, 'queue', $mode); + //@todo: $this->disapprove_posts($post_id_list, 'queue', $mode); } } else @@ -434,6 +434,7 @@ class mcp_queue 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_ID' => $row['post_id'], + 'TOPIC_ID' => $row['topic_id'], 'FORUM_NAME' => $forum_names[$row['forum_id']], 'POST_SUBJECT' => ($row['post_subject'] != '') ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'TOPIC_TITLE' => $row['topic_title'], @@ -700,7 +701,7 @@ class mcp_queue foreach ($topic_info as $topic_id => $topic_data) { - phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); + phpbb_content_visibility::set_topic_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_data['forum_id']}&t={$topic_id}"); @@ -711,11 +712,6 @@ class mcp_queue ); } - foreach ($topic_info as $topic_id => $topic_data) - { - phpbb_content_visibility::set_topic_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); - } - if (sizeof($topic_info) >= 1) { $success_msg = (sizeof($topic_info) == 1) ? 'TOPIC_' . strtoupper($action) . 'D_SUCCESS' : 'TOPICS_' . strtoupper($action) . 'D_SUCCESS'; @@ -792,7 +788,7 @@ class mcp_queue 'S_' . strtoupper($action) => true, )); - confirm_box(false, strtoupper($action) . '_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); + confirm_box(false, strtoupper($action) . '_TOPIC' . ((sizeof($topic_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); } $redirect = request_var('redirect', "index.$phpEx"); -- cgit v1.2.1 From 43e6b3a921d45150cd5c2a931e3e14758081f321 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 23 Oct 2012 15:30:52 +0200 Subject: [feature/soft-delete] Fix some more topic/post count handling Only disapproving in queue is missing. PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 3d36229ee7..c954edacb2 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -895,7 +895,7 @@ class mcp_queue $disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array(); $topic_replies_real = $post_disapprove_list = array(); - // Build a list of posts to be unapproved and get the related topics real replies count + // Build a list of posts to be disapproved and get the related topics real replies count foreach ($post_info as $post_id => $post_data) { $post_disapprove_list[$post_id] = $post_data['topic_id']; -- cgit v1.2.1 From 727759c4d8bda3f1534b1e3366ce0eeeb27c887f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 23 Oct 2012 22:47:57 +0200 Subject: [feature/soft-delete] Fix disapproving posts/topics in queue PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 63 ++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 19 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index c954edacb2..cc6a90390a 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -52,33 +52,48 @@ class mcp_queue $post_id_list = request_var('post_id_list', array(0)); $topic_id_list = request_var('topic_id_list', array(0)); - if (!empty($post_id_list)) + if ($action != 'disapprove') { - if ($action != 'disapprove') + if (!empty($post_id_list)) { $this->approve_posts($action, $post_id_list, 'queue', $mode); } + else if (!empty($topic_id_list)) + { + $this->approve_topics($action, $topic_id_list, 'queue', $mode); + } else { - $this->disapprove_posts($post_id_list, 'queue', $mode); + trigger_error('NO_POST_SELECTED'); } } - else if (!empty($topic_id_list)) + else { - if ($action != 'disapprove') + if (!empty($topic_id_list)) { - $this->approve_topics($action, $topic_id_list, 'queue', $mode); + $sql = 'SELECT post_id + FROM ' . POSTS_TABLE . ' + WHERE post_visibility = ' . ITEM_UNAPPROVED . ' + AND ' . $db->sql_in_set('topic_id', $topic_id_list); + $result = $db->sql_query($sql); + + $post_id_list = array(); + while ($row = $db->sql_fetchrow($result)) + { + $post_id_list[] = (int) $row['post_id']; + } + $db->sql_freeresult($result); + } + + if (!empty($post_id_list)) + { + $this->disapprove_posts($post_id_list, 'queue', $mode); } else { - //@todo: $this->disapprove_posts($post_id_list, 'queue', $mode); + trigger_error('NO_POST_SELECTED'); } } - else - { - trigger_error('NO_POST_SELECTED'); - } - break; } @@ -827,7 +842,12 @@ class mcp_queue } /** - * Disapprove Post/Topic + * Disapprove Post + * + * @param $post_id_list array IDs of the posts to approve/restore + * @param $id mixed Category of the current active module + * @param $mode string Active module + * @return void */ function disapprove_posts($post_id_list, $id, $mode) { @@ -893,24 +913,29 @@ class mcp_queue if (confirm_box(true)) { $disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array(); - $topic_replies_real = $post_disapprove_list = array(); + $topic_posts_unapproved = $post_disapprove_list = $topic_information = array(); // Build a list of posts to be disapproved and get the related topics real replies count foreach ($post_info as $post_id => $post_data) { $post_disapprove_list[$post_id] = $post_data['topic_id']; - if (!isset($topic_replies_real[$post_data['topic_id']])) + if (!isset($topic_posts_unapproved[$post_data['topic_id']])) { - $topic_replies_real[$post_data['topic_id']] = $post_data['topic_replies_real']; + $topic_information[$post_data['topic_id']] = $post_data; + $topic_posts_unapproved[$post_data['topic_id']] = 0; } + $topic_posts_unapproved[$post_data['topic_id']]++; } // Now we build the log array foreach ($post_disapprove_list as $post_id => $topic_id) { - // If the count of disapproved posts for the topic is greater - // than topic's real replies count, the whole topic is disapproved/deleted - if (sizeof(array_keys($post_disapprove_list, $topic_id)) > $topic_replies_real[$topic_id]) + // If the count of disapproved posts for the topic is equal + // to the number of unapproved posts in the topic, and there are no different + // posts, we disapprove the hole topic + if ($topic_information[$topic_id]['topic_posts'] == 0 && + $topic_information[$topic_id]['topic_posts_softdeleted'] == 0 && + $topic_information[$topic_id]['topic_posts_unapproved'] == $topic_posts_unapproved[$topic_id]) { // Don't write the log more than once for every topic if (!isset($disapprove_log_topics[$topic_id])) -- cgit v1.2.1 From 18dec1026ad8cc5dea6117ca1336ca9eba41aa2a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 31 Oct 2012 14:09:23 +0100 Subject: [feature/soft-delete] Fix restoring/approving posts with mcp moderation PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index cc6a90390a..5fe09a2524 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -25,12 +25,12 @@ class mcp_queue var $p_master; var $u_action; - function mcp_queue(&$p_master) + public function mcp_queue(&$p_master) { $this->p_master = &$p_master; } - function main($id, $mode) + public function main($id, $mode) { global $auth, $db, $user, $template, $cache; global $config, $phpbb_root_path, $phpEx, $action; @@ -56,11 +56,11 @@ class mcp_queue { 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)) { - $this->approve_topics($action, $topic_id_list, 'queue', $mode); + self::approve_topics($action, $topic_id_list, 'queue', $mode); } else { @@ -87,7 +87,7 @@ class mcp_queue if (!empty($post_id_list)) { - $this->disapprove_posts($post_id_list, 'queue', $mode); + self::disapprove_posts($post_id_list, 'queue', $mode); } else { @@ -493,7 +493,7 @@ class mcp_queue * @param $mode string Active module * @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 $phpEx, $phpbb_root_path, $request; @@ -686,7 +686,7 @@ class mcp_queue * @param $mode string Active module * @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 $phpEx, $phpbb_root_path, $request; @@ -849,7 +849,7 @@ class mcp_queue * @param $mode string Active module * @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 $phpEx, $phpbb_root_path; -- cgit v1.2.1 From 8512543cf490e06e3b3ca95d0ae9be3ee8fb850d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 9 Nov 2012 12:32:27 +0100 Subject: [feature/soft-delete] Use request object instead of direct access PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 5fe09a2524..b6a36f184a 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -32,7 +32,7 @@ class mcp_queue public function main($id, $mode) { - global $auth, $db, $user, $template, $cache; + global $auth, $db, $user, $template, $cache, $request; global $config, $phpbb_root_path, $phpEx, $action; include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); @@ -49,8 +49,8 @@ class mcp_queue case 'restore': include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - $post_id_list = request_var('post_id_list', array(0)); - $topic_id_list = request_var('topic_id_list', array(0)); + $post_id_list = $request->variable('post_id_list', array(0)); + $topic_id_list = $request->variable('topic_id_list', array(0)); if ($action != 'disapprove') { @@ -213,7 +213,7 @@ class mcp_queue 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p=$post_id&f=$forum_id"), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], - 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED) , + 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED), 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, @@ -263,7 +263,7 @@ class mcp_queue $user->add_lang(array('viewtopic', 'viewforum')); - $topic_id = request_var('t', 0); + $topic_id = $request->variable('t', 0); $forum_info = array(); if ($topic_id) @@ -503,7 +503,7 @@ class mcp_queue trigger_error('NOT_AUTHORISED'); } - $redirect = request_var('redirect', build_url(array('quickmod'))); + $redirect = $request->variable('redirect', build_url(array('quickmod'))); $success_msg = $post_url = ''; $approve_log = array(); @@ -519,7 +519,7 @@ class mcp_queue if (confirm_box(true)) { - $notify_poster = ($action == 'approve' && isset($_REQUEST['notify_poster'])) ? true : false; + $notify_poster = ($action == 'approve' && isset($_REQUEST['notify_poster'])); $topic_info = array(); @@ -642,7 +642,7 @@ class mcp_queue confirm_box(false, strtoupper($action) . '_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); } - $redirect = request_var('redirect', "index.$phpEx"); + $redirect = $request->variable('redirect', "index.$phpEx"); $redirect = reapply_sid($redirect); if (!$success_msg) @@ -696,7 +696,7 @@ class mcp_queue trigger_error('NOT_AUTHORISED'); } - $redirect = request_var('redirect', build_url(array('quickmod'))); + $redirect = $request->variable('redirect', build_url(array('quickmod'))); $success_msg = $topic_url = ''; $approve_log = array(); @@ -806,7 +806,7 @@ class mcp_queue confirm_box(false, strtoupper($action) . '_TOPIC' . ((sizeof($topic_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); } - $redirect = request_var('redirect', "index.$phpEx"); + $redirect = $request->variable('redirect', "index.$phpEx"); $redirect = reapply_sid($redirect); if (!$success_msg) @@ -852,17 +852,16 @@ class mcp_queue static public function disapprove_posts($post_id_list, $id, $mode) { global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path; - global $request; + global $phpEx, $phpbb_root_path, $request; if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) { trigger_error('NOT_AUTHORISED'); } - $redirect = request_var('redirect', build_url(array('t', 'mode', 'quickmod')) . "&mode=$mode"); - $reason = utf8_normalize_nfc(request_var('reason', '', true)); - $reason_id = request_var('reason_id', 0); + $redirect = $request->variable('redirect', build_url(array('t', 'mode', 'quickmod')) . "&mode=$mode"); + $reason = $request->variable('reason', '', true); + $reason_id = $request->variable('reason_id', 0); $success_msg = $additional_msg = ''; $s_hidden_fields = build_hidden_fields(array( @@ -1097,7 +1096,7 @@ class mcp_queue confirm_box(false, 'DISAPPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); } - $redirect = request_var('redirect', "index.$phpEx"); + $redirect = $request->variable('redirect', "index.$phpEx"); $redirect = reapply_sid($redirect); if (!$success_msg) -- cgit v1.2.1 From 9c2a58eff4c2bd164ee3bdb2ec66729d4562963d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 9 Nov 2012 13:37:53 +0100 Subject: [feature/soft-delete] Append _approved to *_posts and *_topics column names PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index b6a36f184a..ab2d5124af 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -932,7 +932,7 @@ class mcp_queue // If the count of disapproved posts for the topic is equal // to the number of unapproved posts in the topic, and there are no different // posts, we disapprove the hole topic - if ($topic_information[$topic_id]['topic_posts'] == 0 && + if ($topic_information[$topic_id]['topic_posts_approved'] == 0 && $topic_information[$topic_id]['topic_posts_softdeleted'] == 0 && $topic_information[$topic_id]['topic_posts_unapproved'] == $topic_posts_unapproved[$topic_id]) { -- cgit v1.2.1 From f77a6eaab5485329a3b13922649fb8902e6e397f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 10 Nov 2012 11:24:52 +0100 Subject: [feature/soft-delete] Fix the rest of *_approved and the delete_post unit test PHPBB3-9567 --- phpBB/includes/mcp/mcp_queue.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index ab2d5124af..e56aa17ee8 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -305,11 +305,11 @@ class mcp_queue trigger_error('NOT_MODERATOR'); } - $sql = 'SELECT SUM(forum_topics) as sum_forum_topics + $sql = 'SELECT SUM(forum_topics_approved) as sum_forum_topics FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list); $result = $db->sql_query($sql); - $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); + $forum_info['forum_topics_approved'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); } else @@ -336,7 +336,7 @@ class mcp_queue $sort_by_sql = $sort_order_sql = array(); mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); - $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total; + $forum_topics = ($total == -1) ? $forum_info['forum_topics_approved'] : $total; $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; $forum_names = array(); -- cgit v1.2.1 From 63f3cd45bb30354b4707b542e54e7dad0f99e15c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 18 Dec 2012 15:08:05 +0100 Subject: [feature/soft-delete] Add delete information to approve deatils page PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index e56aa17ee8..4180b5b08f 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -205,6 +205,33 @@ class mcp_queue } } + // Deleting information + if ($post_info['post_visibility'] == ITEM_DELETED && $post_info['post_delete_user']) + { + // User having deleted the post also being the post author? + if (!$post_info['post_delete_user'] || $post_info['post_delete_user'] == $post_info['poster_id']) + { + $display_username = get_username_string('full', $post_info['poster_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']); + } + else + { + $sql = 'SELECT u.user_id, u.username, u.user_colour + FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u + WHERE p.post_id = ' . $post_info['post_id'] . ' + AND p.post_delete_user = u.user_id'; + $result = $db->sql_query($sql); + $post_delete_userinfo = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + $display_username = get_username_string('full', $post_info['post_delete_user'], $post_delete_userinfo['username'], $post_delete_userinfo['user_colour']); + } + + $l_deleted_by = $user->lang('DELETED_INFORMATION', $display_username, $user->format_date($post_info['post_delete_time'], false, true)); + } + else + { + $l_deleted_by = ''; + } + $post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']); $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']); @@ -216,6 +243,9 @@ class mcp_queue 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED), 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, + 'S_POST_DELETED' => ($post_info['post_visibility'] == ITEM_DELETED), + 'DELETED_MESSAGE' => $l_deleted_by, + 'DELETE_REASON' => $post_info['post_delete_reason'], 'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), @@ -227,6 +257,7 @@ class mcp_queue 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), + 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '", ''), 'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '', ''), 'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '', ''), -- cgit v1.2.1 From 6435b481c571dd44494f07b970339b104a8ffdd6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 18 Dec 2012 15:32:13 +0100 Subject: [feature/soft-delete] Fix a problem with "delete topics" in mcp PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 4180b5b08f..8b7b4ffda8 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -71,9 +71,10 @@ class mcp_queue { if (!empty($topic_id_list)) { + $post_visibility = ($mode == 'deleted_topics') ? ITEM_DELETED : ITEM_UNAPPROVED; $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' - WHERE post_visibility = ' . ITEM_UNAPPROVED . ' + WHERE post_visibility = ' . $post_visibility . ' AND ' . $db->sql_in_set('topic_id', $topic_id_list); $result = $db->sql_query($sql); -- cgit v1.2.1 From 24e1881ea1fd4da0bdf6de8f58cf8527b9087270 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 20 Dec 2012 15:23:29 +0100 Subject: [feature/soft-delete] Split up on the initial switch instead of a second one Also fixing some documentation issues PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 71 +++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 41 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 8b7b4ffda8..dd3321e4e5 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -45,55 +45,44 @@ class mcp_queue switch ($action) { case 'approve': - case 'disapprove': case 'restore': include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); $post_id_list = $request->variable('post_id_list', array(0)); $topic_id_list = $request->variable('topic_id_list', array(0)); - if ($action != 'disapprove') + if (!empty($post_id_list)) { - if (!empty($post_id_list)) - { - self::approve_posts($action, $post_id_list, 'queue', $mode); - } - else if (!empty($topic_id_list)) - { - self::approve_topics($action, $topic_id_list, 'queue', $mode); - } - else - { - trigger_error('NO_POST_SELECTED'); - } + self::approve_posts($action, $post_id_list, 'queue', $mode); + } + else if (!empty($topic_id_list)) + { + self::approve_topics($action, $topic_id_list, 'queue', $mode); } else { - if (!empty($topic_id_list)) - { - $post_visibility = ($mode == 'deleted_topics') ? ITEM_DELETED : ITEM_UNAPPROVED; - $sql = 'SELECT post_id - FROM ' . POSTS_TABLE . ' - WHERE post_visibility = ' . $post_visibility . ' - AND ' . $db->sql_in_set('topic_id', $topic_id_list); - $result = $db->sql_query($sql); + trigger_error('NO_POST_SELECTED'); + } + break; - $post_id_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - $post_id_list[] = (int) $row['post_id']; - } - $db->sql_freeresult($result); - } + case 'delete': + case 'disapprove': + include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - if (!empty($post_id_list)) - { - self::disapprove_posts($post_id_list, 'queue', $mode); - } - else - { - trigger_error('NO_POST_SELECTED'); - } + $post_id_list = $request->variable('post_id_list', array(0)); + $topic_id_list = $request->variable('topic_id_list', array(0)); + + if (!empty($post_id_list)) + { + self::disapprove_posts($post_id_list, 'queue', $mode); + } + else if (!empty($topic_id_list)) + { + self::disapprove_topics($action, $topic_id_list, 'queue', $mode); + } + else + { + trigger_error('NO_POST_SELECTED'); } break; } @@ -523,7 +512,7 @@ class mcp_queue * @param $post_id_list array IDs of the posts to approve/restore * @param $id mixed Category of the current active module * @param $mode string Active module - * @return void + * @return null */ static public function approve_posts($action, $post_id_list, $id, $mode) { @@ -716,7 +705,7 @@ class mcp_queue * @param $topic_id_list array IDs of the topics to approve/restore * @param $id mixed Category of the current active module * @param $mode string Active module - * @return void + * @return null */ static public function approve_topics($action, $topic_id_list, $id, $mode) { @@ -876,10 +865,10 @@ class mcp_queue /** * Disapprove Post * - * @param $post_id_list array IDs of the posts to approve/restore + * @param $post_id_list array IDs of the posts to disapprove/delete * @param $id mixed Category of the current active module * @param $mode string Active module - * @return void + * @return null */ static public function disapprove_posts($post_id_list, $id, $mode) { -- cgit v1.2.1 From 4498c5aaebb1122b783b52a66f78d56e0ff2c63c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 20 Dec 2012 19:23:26 +0100 Subject: [feature/soft-delete] Split deleting soft-deleted posts from unapproving posts PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 63 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index dd3321e4e5..d9ec10e6da 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -66,19 +66,70 @@ class mcp_queue break; case 'delete': - case 'disapprove': - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - $post_id_list = $request->variable('post_id_list', array(0)); $topic_id_list = $request->variable('topic_id_list', array(0)); if (!empty($post_id_list)) { - self::disapprove_posts($post_id_list, 'queue', $mode); + if (!function_exists('mcp_delete_post')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx); + } + mcp_delete_post($post_id_list, false, '', $action); } else if (!empty($topic_id_list)) { - self::disapprove_topics($action, $topic_id_list, 'queue', $mode); + if (!function_exists('mcp_delete_topic')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx); + } + mcp_delete_topic($topic_id_list, false, '', $action); + } + else + { + trigger_error('NO_POST_SELECTED'); + } + break; + + case 'disapprove': + $post_id_list = $request->variable('post_id_list', array(0)); + $topic_id_list = $request->variable('topic_id_list', array(0)); + + if (!empty($topic_id_list) && $mode == 'deleted_topics') + { + if (!function_exists('mcp_delete_topics')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx); + } + mcp_delete_topic($topic_id_list, false, '', 'disapprove'); + return; + } + + include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); + + if (!empty($topic_id_list)) + { + $post_visibility = ($mode == 'deleted_topics') ? ITEM_DELETED : ITEM_UNAPPROVED; + $sql = 'SELECT post_id + FROM ' . POSTS_TABLE . ' + WHERE post_visibility = ' . $post_visibility . ' + AND ' . $db->sql_in_set('topic_id', $topic_id_list); + $result = $db->sql_query($sql); + + $post_id_list = array(); + while ($row = $db->sql_fetchrow($result)) + { + $post_id_list[] = (int) $row['post_id']; + } + $db->sql_freeresult($result); + } + + if (!empty($post_id_list)) + { + self::disapprove_posts($post_id_list, 'queue', $mode); } else { @@ -893,7 +944,7 @@ class mcp_queue 'redirect' => $redirect) ); - $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; + $notify_poster = $request->is_set('notify_poster'); $disapprove_reason = ''; if ($reason_id) -- cgit v1.2.1 From a21de6e3f845f56026757e370b0bae8a02997bad Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 5 Mar 2013 17:09:33 +0100 Subject: [ticket/9657] Rebuild notifications in mcp_queue.php PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 157 ++++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 85 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 6f9f16bde4..01abdc82d8 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -650,46 +650,39 @@ class mcp_queue // Only send out the mails, when the posts are being approved if ($action == 'approve') { - $messenger = new messenger(); + $phpbb_notifications = $phpbb_container->get('notification_manager'); - // Notify Poster? - if ($notify_poster) + // Send out normal user notifications + $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); + + // Handle notifications + foreach ($post_info as $post_id => $post_data) { - foreach ($post_info as $post_id => $post_data) + $phpbb_notifications->delete_notifications('post_in_queue', $post_id); + + $phpbb_notifications->add_notifications(array( + 'quote', + 'bookmark', + 'post', + ), $post_data); + + $phpbb_notifications->mark_notifications_read(array( + 'quote', + 'bookmark', + 'post', + ), $post_data['post_id'], $user->data['user_id']); + + // Notify Poster? + if ($notify_poster) { if ($post_data['poster_id'] == ANONYMOUS) { continue; } - $messenger->template('post_approved', $post_data['user_lang']); - - $messenger->to($post_data['user_email'], $post_data['username']); - $messenger->im($post_data['user_jabber'], $post_data['username']); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($post_data['username']), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])), - - 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&e=0", - 'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&p=$post_id&e=$post_id") - ); - - $messenger->send($post_data['user_notify_type']); + $phpbb_notifications->add_notifications('approve_post', $post_data); } } - - $messenger->save_queue(); - - // Send out normal user notifications - $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); - - foreach ($post_info as $post_id => $post_data) - { - // Topic Notifications - user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); - } } } else @@ -818,41 +811,27 @@ class mcp_queue // Only send out the mails, when the posts are being approved if ($action == 'approve') { - $messenger = new messenger(); - - // Notify Poster? - if ($notify_poster) - { - foreach ($topic_info as $topic_id => $topic_data) - { - if ($topic_data['topic_poster'] == ANONYMOUS) - { - continue; - } - - $messenger->template('topic_approved', $topic_data['user_lang']); - $messenger->to($topic_data['user_email'], $topic_data['username']); - $messenger->im($topic_data['user_jabber'], $topic_data['username']); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($topic_data['username']), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($topic_data['topic_title'])), - 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$topic_data['forum_id']}&t={$topic_data['topic_id']}&e=0", - )); - - $messenger->send($topic_data['user_notify_type']); - } - } - - $messenger->save_queue(); - // Send out normal user notifications $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); + // Handle notifications + $phpbb_notifications = $phpbb_container->get('notification_manager'); + foreach ($topic_info as $topic_id => $topic_data) { - // Forum Notifications - user_notification('post', $topic_data['topic_title'], $topic_data['topic_title'], $topic_data['forum_name'], $topic_data['forum_id'], $topic_data['topic_id'], 0); + $phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']); + $phpbb_notifications->add_notifications(array( + 'quote', + 'topic', + ), $post_data); + + $phpbb_notifications->mark_notifications_read('quote', $post_data['post_id'], $user->data['user_id']); + $phpbb_notifications->mark_notifications_read('topic', $post_data['topic_id'], $user->data['user_id']); + + if ($notify_poster) + { + $phpbb_notifications->add_notifications('approve_topic', $post_data); + } } } } @@ -1068,20 +1047,33 @@ class mcp_queue } } - $messenger = new messenger(); + $phpbb_notifications = $phpbb_container->get('notification_manager'); - // Notify Poster? - if ($notify_poster) + $lang_reasons = array(); + + foreach ($post_info as $post_id => $post_data) { - $lang_reasons = array(); + $disapprove_all_posts_in_topic = $topic_information[$topic_id]['topic_posts_approved'] == 0 && + $topic_information[$topic_id]['topic_posts_softdeleted'] == 0 && + $topic_information[$topic_id]['topic_posts_unapproved'] == $topic_posts_unapproved[$topic_id]; - foreach ($post_info as $post_id => $post_data) + $phpbb_notifications->delete_notifications('post_in_queue', $post_id); + + // Do we disapprove the whole topic? Remove potential notifications + if ($disapprove_all_posts_in_topic) + { + $phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']); + } + + // Notify Poster? + if ($notify_poster) { if ($post_data['poster_id'] == ANONYMOUS) { continue; } + $post_data['disapprove_reason'] = ''; if (isset($disapprove_reason_lang)) { // Okay we need to get the reason from the posters language @@ -1107,32 +1099,27 @@ class mcp_queue } } - $email_disapprove_reason = $lang_reasons[$post_data['user_lang']]; - $email_disapprove_reason .= ($reason) ? "\n\n" . $reason : ''; + $post_data['disapprove_reason'] = $lang_reasons[$post_data['user_lang']]; + $post_data['disapprove_reason'] .= ($reason) ? "\n\n" . $reason : ''; } - $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_disapproved' : 'post_disapproved'; - - $messenger->template($email_template, $post_data['user_lang']); - $messenger->to($post_data['user_email'], $post_data['username']); - $messenger->im($post_data['user_jabber'], $post_data['username']); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($post_data['username']), - 'REASON' => htmlspecialchars_decode($email_disapprove_reason), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title']))) - ); - - $messenger->send($post_data['user_notify_type']); + if ($disapprove_all_posts_in_topic && $topic_information[$topic_id]['topic_posts_unapproved'] == 1) + { + // If there is only 1 post when disapproving the topic, + // we send the user a "disapprove topic" notification... + $phpbb_notifications->add_notifications('disapprove_topic', $post_data); + } + else + { + // ... otherwise there are multiple unapproved posts and + // all of them are disapproved as posts. + $phpbb_notifications->add_notifications('disapprove_post', $post_data); + } } - - unset($lang_reasons); } - unset($post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang); - $messenger->save_queue(); + unset($lang_reasons,$post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang); if ($num_disapproved_topics) { -- cgit v1.2.1 From e1f5e98fbca5c3f989a829fa763a471e04082e64 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 6 Mar 2013 12:26:43 +0100 Subject: [ticket/9657] Correctly state when to refresh last/first post info on approving PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 01abdc82d8..0e835b0aa9 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -613,12 +613,14 @@ class mcp_queue $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']) + // Refresh the first post, if the time or id is older then the current one + if ($post_id <= $post_data['topic_first_post_id'] || $post_data['post_time'] <= $post_data['topic_time']) { $topic_info[$topic_id]['first_post'] = true; } - if ($post_id == $post_data['topic_last_post_id']) + // Refresh the last post, if the time or id is newer then the current one + if ($post_id >= $post_data['topic_last_post_id'] || $post_data['post_time'] >= $post_data['topic_last_post_time']) { $topic_info[$topic_id]['last_post'] = true; } -- cgit v1.2.1 From 1a498524138a7a3192ad14ad10f714b34488321f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Mar 2013 14:15:14 +0100 Subject: [ticket/9657] Remove unused email variables PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 0e835b0aa9..4383c5d571 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -654,9 +654,6 @@ class mcp_queue { $phpbb_notifications = $phpbb_container->get('notification_manager'); - // Send out normal user notifications - $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); - // Handle notifications foreach ($post_info as $post_id => $post_data) { @@ -813,9 +810,6 @@ class mcp_queue // Only send out the mails, when the posts are being approved if ($action == 'approve') { - // Send out normal user notifications - $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); - // Handle notifications $phpbb_notifications = $phpbb_container->get('notification_manager'); @@ -961,8 +955,6 @@ class mcp_queue { $disapprove_reason_lang = strtoupper($row['reason_title']); } - - $email_disapprove_reason = $disapprove_reason; } } @@ -1121,7 +1113,7 @@ class mcp_queue } } - unset($lang_reasons,$post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang); + unset($lang_reasons, $post_info, $disapprove_reason, $disapprove_reason_lang); if ($num_disapproved_topics) { -- cgit v1.2.1 From f6dd688e7266ccbd4fda5bb5091cbb9056ebcf20 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 11 Mar 2013 12:40:33 +0100 Subject: [ticket/9657] Fix missing global $phpbb_container PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 4383c5d571..835f19555f 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -904,7 +904,7 @@ class mcp_queue */ static public function disapprove_posts($post_id_list, $id, $mode) { - global $db, $template, $user, $config; + global $db, $template, $user, $config, $phpbb_container; global $phpEx, $phpbb_root_path, $request; if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) -- cgit v1.2.1 From b727e1eedaab27c99a733b94bcdddbc55cc929d9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 11 Mar 2013 16:37:43 +0100 Subject: [ticket/9657] Correctly split disapproving from perma deleting posts PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 63 ++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 9 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 835f19555f..29c0375e6c 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -960,6 +960,17 @@ class mcp_queue $post_info = get_post_data($post_id_list, 'm_approve'); + $is_disapproving = false; + foreach ($post_info as $post_id => $post_data) + { + if ($post_data['post_visibility'] == ITEM_DELETED) + { + continue; + } + + $is_disapproving = true; + } + if (confirm_box(true)) { $disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array(); @@ -996,6 +1007,7 @@ class mcp_queue 'post_subject' => $post_info[$post_id]['topic_title'], 'forum_id' => $post_info[$post_id]['forum_id'], 'topic_id' => 0, // useless to log a topic id, as it will be deleted + 'post_username' => ($post_info[$post_id]['poster_id'] == ANONYMOUS && !empty($post_info[$post_id]['post_username'])) ? $post_info[$post_id]['post_username'] : $post_info[$post_id]['username'], ); } } @@ -1007,6 +1019,7 @@ class mcp_queue 'post_subject' => $post_info[$post_id]['post_subject'], 'forum_id' => $post_info[$post_id]['forum_id'], 'topic_id' => $post_info[$post_id]['topic_id'], + 'post_username' => ($post_info[$post_id]['poster_id'] == ANONYMOUS && !empty($post_info[$post_id]['post_username'])) ? $post_info[$post_id]['post_username'] : $post_info[$post_id]['username'], ); } @@ -1037,7 +1050,16 @@ class mcp_queue foreach ($disapprove_log as $log_data) { - add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED', $log_data['post_subject'], $disapprove_reason); + if ($is_disapproving) + { + $l_log_message = ($log_data['type'] == 'topic') ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED'; + add_log('mod', $log_data['forum_id'], $log_data['topic_id'], $l_log_message, $log_data['post_subject'], $disapprove_reason); + } + else + { + $l_log_message = ($log_data['type'] == 'topic') ? 'LOG_DELETE_TOPIC' : 'LOG_DELETE_POST'; + add_log('mod', $log_data['forum_id'], $log_data['topic_id'], $l_log_message, $log_data['post_subject'], $log_data['post_username']); + } } } @@ -1115,21 +1137,29 @@ class mcp_queue unset($lang_reasons, $post_info, $disapprove_reason, $disapprove_reason_lang); + if ($num_disapproved_topics) { - $success_msg = ($num_disapproved_topics == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS'; + $success_msg = ($num_disapproved_topics == 1) ? 'TOPIC' : 'TOPICS'; } else { - $success_msg = ($num_disapproved_posts == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS'; + $success_msg = ($num_disapproved_posts == 1) ? 'POST' : 'POSTS'; + } + + if ($is_disapproving) + { + $success_msg .= '_DISAPPROVED_SUCCESS'; + } + else + { + $success_msg .= '_DELETED_SUCCESS'; } } else { include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); - display_reasons($reason_id); - $show_notify = false; foreach ($post_info as $post_data) @@ -1145,14 +1175,29 @@ class mcp_queue } } + $l_confirm_msg = 'DISAPPROVE_POST'; + $confirm_template = 'mcp_approve.html'; + if ($is_disapproving) + { + display_reasons($reason_id); + } + else + { + $user->add_lang('posting'); + + $l_confirm_msg = 'DELETE_POST_PERMANENTLY'; + $confirm_template = 'confirm_delete_body.html'; + } + $l_confirm_msg .= ((sizeof($post_id_list) == 1) ? '' : 'S'); + $template->assign_vars(array( 'S_NOTIFY_POSTER' => $show_notify, 'S_APPROVE' => false, - 'REASON' => $reason, - 'ADDITIONAL_MSG' => $additional_msg) - ); + 'REASON' => ($is_disapproving) ? $reason : '', + 'ADDITIONAL_MSG' => $additional_msg, + )); - confirm_box(false, 'DISAPPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); + confirm_box(false, $l_confirm_msg, $s_hidden_fields, $confirm_template); } $redirect = $request->variable('redirect', "index.$phpEx"); -- cgit v1.2.1 From 5b47d731470ddc1b5723ed13b63cc3f90f3e6671 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 12:08:09 +0200 Subject: [ticket/9657] DO not use \" inside of double quotes PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 29c0375e6c..a253a43136 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -305,7 +305,7 @@ class mcp_queue 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), - 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '", ''), + 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '', ''), 'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '', ''), 'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '', ''), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), @@ -730,7 +730,7 @@ class mcp_queue $add_message = '

' . sprintf($user->lang['RETURN_POST'], '', ''); } - $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; + $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '') . $add_message; if ($request->is_ajax()) { @@ -877,7 +877,7 @@ class mcp_queue $add_message = '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); } - $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; + $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '') . $add_message; if ($request->is_ajax()) { @@ -1209,7 +1209,7 @@ class mcp_queue } else { - $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", ''); + $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], '', ''); if ($request->is_ajax()) { -- cgit v1.2.1 From ed151cd6aaa5ec875d56d33e8908771a1244f98a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 12:12:18 +0200 Subject: [ticket/9657] Add , to last element of an array PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index a253a43136..a42ae6c48c 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -182,8 +182,8 @@ class mcp_queue $template->assign_vars(array( 'S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], - 'TOPIC_TITLE' => $post_info['topic_title']) - ); + 'TOPIC_TITLE' => $post_info['topic_title'], + )); } $extensions = $attachments = $topic_tracking_info = array(); @@ -246,8 +246,8 @@ class mcp_queue foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); + 'DISPLAY_ATTACHMENT' => $attachment, + )); } } } @@ -922,8 +922,8 @@ class mcp_queue 'mode' => $mode, 'post_id_list' => $post_id_list, 'action' => 'disapprove', - 'redirect' => $redirect) - ); + 'redirect' => $redirect, + )); $notify_poster = $request->is_set('notify_poster'); $disapprove_reason = ''; -- cgit v1.2.1 From 9aed758c1397c31b979f4aca51249c73d21bd6f5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 14:24:07 +0200 Subject: [ticket/9657] Use the service instead of the static class PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index a42ae6c48c..514d7bc4ee 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -634,9 +634,10 @@ class mcp_queue ); } + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); 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'])); + $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'])); } if (sizeof($post_info) >= 1) @@ -759,7 +760,7 @@ class mcp_queue static public function approve_topics($action, $topic_id_list, $id, $mode) { global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path, $request; + global $phpEx, $phpbb_root_path, $request, $phpbb_container; if (!check_ids($topic_id_list, TOPICS_TABLE, 'topic_id', array('m_approve'))) { @@ -784,9 +785,10 @@ class mcp_queue { $notify_poster = ($action == 'approve' && isset($_REQUEST['notify_poster'])) ? true : false; + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); foreach ($topic_info as $topic_id => $topic_data) { - phpbb_content_visibility::set_topic_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); + $phpbb_content_visibility->set_topic_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_data['forum_id']}&t={$topic_id}"); -- cgit v1.2.1 From 53c0647aed4a4995d3ae00ed775ff563eaa61b9a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 22:16:45 -0400 Subject: [ticket/9657] Use include instead of include_once PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 514d7bc4ee..ac3391c294 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -108,7 +108,10 @@ class mcp_queue return; } - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); + if (!class_exists('messenger')) + { + include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); + } if (!empty($topic_id_list)) { @@ -1042,7 +1045,7 @@ class mcp_queue { if (!function_exists('delete_posts')) { - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); } // We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts @@ -1160,7 +1163,10 @@ class mcp_queue } else { - include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); + if (!function_exists('display_reasons')) + { + include($phpbb_root_path . 'includes/functions_display.' . $phpEx); + } $show_notify = false; -- cgit v1.2.1 From 1911285b77fa791ca202f810e4ba40c822aa5ae9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 22:44:06 -0400 Subject: [ticket/9657] Notifications do not require emails or jabber anymore PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/mcp/mcp_queue.php') diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index ac3391c294..8a9390212f 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -692,7 +692,7 @@ class mcp_queue { $show_notify = false; - if ($action == 'approve' && ($config['email_enable'] || $config['jab_enable'])) + if ($action == 'approve') { foreach ($post_info as $post_data) { @@ -840,7 +840,7 @@ class mcp_queue { $show_notify = false; - if ($action == 'approve' && ($config['email_enable'] || $config['jab_enable'])) + if ($action == 'approve') { foreach ($topic_info as $topic_data) { -- cgit v1.2.1