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/viewtopic.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 3fde5b5e03..282c23cd70 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -83,7 +83,7 @@ if ($view && !$post_id) $sql = 'SELECT post_id, topic_id, forum_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id - " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . " + AND " . topic_visibility::get_visibility_sql('post', $forum_id) . " AND post_time > $topic_last_read AND forum_id = $forum_id ORDER BY post_time ASC"; @@ -137,7 +137,7 @@ if ($view && !$post_id) WHERE forum_id = ' . $row['forum_id'] . " AND topic_moved_id = 0 AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} - " . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . " + AND" . topic_visibility::get_visibility_sql('topic', $row['forum_id']) . " ORDER BY topic_last_post_time $sql_ordering"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); @@ -174,7 +174,7 @@ $sql_array = array( // The FROM-Order is quite important here, else t.* columns can not be correctly bound. if ($post_id) { - $sql_array['SELECT'] .= ', p.post_approved, p.post_time, p.post_id'; + $sql_array['SELECT'] .= ', p.post_visibility, p.post_time, p.post_id'; $sql_array['FROM'][POSTS_TABLE] = 'p'; } @@ -249,7 +249,7 @@ $forum_id = (int) $topic_data['forum_id']; if ($post_id) { // are we where we are supposed to be? - if (!$topic_data['post_approved'] && !$auth->acl_get('m_approve', $topic_data['forum_id'])) + if ($topic_data['post_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $topic_data['forum_id'])) { // If post_id was submitted, we try at least to display the topic as a last resort... if ($topic_id) @@ -277,7 +277,7 @@ if ($post_id) $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p WHERE p.topic_id = {$topic_data['topic_id']} - " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : ''); + " . topic_visibility::get_visibility_sql('post', $forum_id, 'p'); if ($sort_dir == 'd') { @@ -315,7 +315,13 @@ if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == PO // Setup look and feel $user->setup('viewtopic', $topic_data['forum_style']); -if (!$topic_data['topic_approved'] && !$auth->acl_get('m_approve', $forum_id)) +/* the topic "does not exist": +* if the topic is unapproved and the user cannot approve it +* if the topic is deleted and the user cannot restore it +* NB: restoring a topic has two cases: moderator restore and poster restore. +*/ +if (($topic_data['topic_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $forum_id)) + || ($topic_data['topic_visibility'] == ITEM_DELETED && (!$auth->acl_get('m_restore', $forum_id) || ($user->data['user_id'] == $topic_data['topic_poster'] && $auth->acl_get('f_restore', $forum_id))))) { trigger_error('NO_TOPIC'); } @@ -402,7 +408,7 @@ if ($sort_days) FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id AND post_time >= $min_post_time - " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1'); + AND " . topic_visibility::get_visibility_sql('post', $forum_id); $result = $db->sql_query($sql); $total_posts = (int) $db->sql_fetchfield('num_posts'); $db->sql_freeresult($result); @@ -938,7 +944,7 @@ $i = $i_total = 0; $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . " WHERE p.topic_id = $topic_id - " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . " + AND " . topic_visibility::get_visibility_sql('post', $forum_id, 'p.') . " " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . " $limit_posts_time ORDER BY $sql_sort_order"; @@ -1020,7 +1026,7 @@ while ($row = $db->sql_fetchrow($result)) { $attach_list[] = (int) $row['post_id']; - if ($row['post_approved']) + if ($row['post_visibility'] == ITEM_UNAPPROVED) { $has_attachments = true; } @@ -1046,7 +1052,7 @@ while ($row = $db->sql_fetchrow($result)) // Make sure the icon actually exists 'icon_id' => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0, 'post_attachment' => $row['post_attachment'], - 'post_approved' => $row['post_approved'], + 'post_visibility' => $row['post_visibility'], 'post_reported' => $row['post_reported'], 'post_username' => $row['post_username'], 'post_text' => $row['post_text'], @@ -1313,8 +1319,8 @@ if (sizeof($attach_list)) $sql = 'SELECT a.post_msg_id as post_id FROM ' . ATTACHMENTS_TABLE . ' a, ' . POSTS_TABLE . " p WHERE p.topic_id = $topic_id - AND p.post_approved = 1 - AND p.topic_id = a.topic_id"; + AND p.post_visibility = " . ITEM_APPROVED . ' + AND p.topic_id = a.topic_id'; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -1605,7 +1611,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, 'S_MULTIPLE_ATTACHMENTS' => !empty($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]) > 1, - 'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true, + 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_APPROVED) ? false : true, 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false, 'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'], 'S_FRIEND' => ($row['friend']) ? true : false, -- cgit v1.2.1 From c32d76080605f843bb23e9a608c368d4b5dc55d8 Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Sun, 20 Jun 2010 15:01:26 -0500 Subject: [feature/soft-delete] I told you I was going to rename the class! Rename topic_visibility class to phpbb_visibility. Also a bit of work to the class itself, mostly cleanup and adding the comments that I'd previously written. PHPBB3-9657 --- phpBB/viewtopic.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 282c23cd70..b6c47211f7 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -83,7 +83,7 @@ if ($view && !$post_id) $sql = 'SELECT post_id, topic_id, forum_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id - AND " . topic_visibility::get_visibility_sql('post', $forum_id) . " + AND " . phpbb_visibility::get_visibility_sql('post', $forum_id) . " AND post_time > $topic_last_read AND forum_id = $forum_id ORDER BY post_time ASC"; @@ -137,7 +137,7 @@ if ($view && !$post_id) WHERE forum_id = ' . $row['forum_id'] . " AND topic_moved_id = 0 AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} - AND" . topic_visibility::get_visibility_sql('topic', $row['forum_id']) . " + AND" . phpbb_visibility::get_visibility_sql('topic', $row['forum_id']) . " ORDER BY topic_last_post_time $sql_ordering"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); @@ -277,7 +277,7 @@ if ($post_id) $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p WHERE p.topic_id = {$topic_data['topic_id']} - " . topic_visibility::get_visibility_sql('post', $forum_id, 'p'); + " . phpbb_visibility::get_visibility_sql('post', $forum_id, 'p'); if ($sort_dir == 'd') { @@ -408,7 +408,7 @@ if ($sort_days) FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id AND post_time >= $min_post_time - AND " . topic_visibility::get_visibility_sql('post', $forum_id); + AND " . phpbb_visibility::get_visibility_sql('post', $forum_id); $result = $db->sql_query($sql); $total_posts = (int) $db->sql_fetchfield('num_posts'); $db->sql_freeresult($result); @@ -944,7 +944,7 @@ $i = $i_total = 0; $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . " WHERE p.topic_id = $topic_id - AND " . topic_visibility::get_visibility_sql('post', $forum_id, 'p.') . " + AND " . phpbb_visibility::get_visibility_sql('post', $forum_id, 'p.') . " " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . " $limit_posts_time ORDER BY $sql_sort_order"; -- 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/viewtopic.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index b6c47211f7..e5a7f64cad 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -277,7 +277,7 @@ if ($post_id) $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p WHERE p.topic_id = {$topic_data['topic_id']} - " . phpbb_visibility::get_visibility_sql('post', $forum_id, 'p'); + " . phpbb_visibility::get_visibility_sql('post', $forum_id, 'p.'); if ($sort_dir == 'd') { @@ -615,6 +615,7 @@ $template->assign_vars(array( 'REPLY_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'), 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'), 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'), + 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'), @@ -1611,7 +1612,8 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, 'S_MULTIPLE_ATTACHMENTS' => !empty($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]) > 1, - 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_APPROVED) ? false : true, + 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED) ? true : false, + 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false, 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false, 'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'], 'S_FRIEND' => ($row['friend']) ? true : false, -- 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/viewtopic.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index e5a7f64cad..fde3631c56 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -83,7 +83,7 @@ if ($view && !$post_id) $sql = 'SELECT post_id, topic_id, forum_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id - AND " . phpbb_visibility::get_visibility_sql('post', $forum_id) . " + AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id) . " AND post_time > $topic_last_read AND forum_id = $forum_id ORDER BY post_time ASC"; @@ -137,7 +137,7 @@ if ($view && !$post_id) WHERE forum_id = ' . $row['forum_id'] . " AND topic_moved_id = 0 AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} - AND" . phpbb_visibility::get_visibility_sql('topic', $row['forum_id']) . " + AND" . phpbb_content_visibility::get_visibility_sql('topic', $row['forum_id']) . " ORDER BY topic_last_post_time $sql_ordering"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); @@ -277,7 +277,7 @@ if ($post_id) $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p WHERE p.topic_id = {$topic_data['topic_id']} - " . phpbb_visibility::get_visibility_sql('post', $forum_id, 'p.'); + " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); if ($sort_dir == 'd') { @@ -408,7 +408,7 @@ if ($sort_days) FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id AND post_time >= $min_post_time - AND " . phpbb_visibility::get_visibility_sql('post', $forum_id); + AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id); $result = $db->sql_query($sql); $total_posts = (int) $db->sql_fetchfield('num_posts'); $db->sql_freeresult($result); @@ -945,7 +945,7 @@ $i = $i_total = 0; $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . " WHERE p.topic_id = $topic_id - AND " . phpbb_visibility::get_visibility_sql('post', $forum_id, 'p.') . " + AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.') . " " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . " $limit_posts_time ORDER BY $sql_sort_order"; -- 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/viewtopic.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index fde3631c56..2b52e165c1 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1600,6 +1600,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', + 'U_MCP_RESTORE' => ($auth->acl_get('m_restore', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=deleted_posts&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '', 'U_PREV_POST_ID' => $prev_post_id, -- cgit v1.2.1 From d9a93a9cdc0e9607582c7a7293c99b1c469dc6c3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 28 Aug 2012 22:56:23 +0200 Subject: [feature/soft-delete] Fix missing AND in query PHPBB3-9657 --- phpBB/viewtopic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 2b52e165c1..4c598ab204 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -277,7 +277,7 @@ if ($post_id) $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p WHERE p.topic_id = {$topic_data['topic_id']} - " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); + AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); if ($sort_dir == 'd') { @@ -615,7 +615,7 @@ $template->assign_vars(array( 'REPLY_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'), 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'), 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'), - 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), + 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'), -- cgit v1.2.1 From a1e0690b6b25ffd64f6ae2fc2f7b17a04e931690 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 29 Aug 2012 22:12:33 +0200 Subject: [feature/soft-delete] Simplification part2: user can see all item visibilities If the user can see all visibilities, we can simply leave out the query part, instead of adding a bunch of ANDs. PHPBB3-9657 --- phpBB/viewtopic.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 4c598ab204..f05d94b8af 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -79,11 +79,12 @@ if ($view && !$post_id) $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0; + $sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id); $sql = 'SELECT post_id, topic_id, forum_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id - AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id) . " + " . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . " AND post_time > $topic_last_read AND forum_id = $forum_id ORDER BY post_time ASC"; @@ -132,12 +133,14 @@ if ($view && !$post_id) } else { + $sql_visibility = phpbb_content_visibility::get_visibility_sql('topic', $row['forum_id']); + $sql = 'SELECT topic_id, forum_id FROM ' . TOPICS_TABLE . ' WHERE forum_id = ' . $row['forum_id'] . " AND topic_moved_id = 0 AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} - AND" . phpbb_content_visibility::get_visibility_sql('topic', $row['forum_id']) . " + " . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . " ORDER BY topic_last_post_time $sql_ordering"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); @@ -274,10 +277,12 @@ if ($post_id) } else { + $sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); + $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p WHERE p.topic_id = {$topic_data['topic_id']} - AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); + " . (($sql_visibility) ? ' AND ' . $sql_visibility : ''); if ($sort_dir == 'd') { @@ -403,12 +408,13 @@ gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $ if ($sort_days) { $min_post_time = time() - ($sort_days * 86400); + $sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id); $sql = 'SELECT COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id AND post_time >= $min_post_time - AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id); + " . (($sql_visibility) ? ' AND ' . $sql_visibility : ''); $result = $db->sql_query($sql); $total_posts = (int) $db->sql_fetchfield('num_posts'); $db->sql_freeresult($result); @@ -942,10 +948,12 @@ $bbcode_bitfield = ''; $i = $i_total = 0; // Go ahead and pull all data for this topic +$sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); + $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . " WHERE p.topic_id = $topic_id - AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.') . " + " . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . " " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . " $limit_posts_time ORDER BY $sql_sort_order"; -- cgit v1.2.1 From a58a76ef5f496ea57f655e34c6d973b2639619c0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 15 Oct 2012 13:17:05 +0200 Subject: [feature/soft-delete] Fix permission check in viewtopic.php PHPBB3-9567 --- phpBB/viewtopic.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index f05d94b8af..59081163dd 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -248,6 +248,13 @@ if (!$topic_data) } $forum_id = (int) $topic_data['forum_id']; + +// Now we know the forum_id and can check the permissions +if ($topic_data['topic_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_approve', $forum_id)) +{ + trigger_error('NO_TOPIC'); +} + // This is for determining where we are (page) if ($post_id) { @@ -320,17 +327,6 @@ if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == PO // Setup look and feel $user->setup('viewtopic', $topic_data['forum_style']); -/* the topic "does not exist": -* if the topic is unapproved and the user cannot approve it -* if the topic is deleted and the user cannot restore it -* NB: restoring a topic has two cases: moderator restore and poster restore. -*/ -if (($topic_data['topic_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $forum_id)) - || ($topic_data['topic_visibility'] == ITEM_DELETED && (!$auth->acl_get('m_restore', $forum_id) || ($user->data['user_id'] == $topic_data['topic_poster'] && $auth->acl_get('f_restore', $forum_id))))) -{ - trigger_error('NO_TOPIC'); -} - // Start auth check if (!$auth->acl_get('f_read', $forum_id)) { -- cgit v1.2.1 From 9945561b4b58e4825fd2290ae1fbbb3d49fd3e7c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 22 Oct 2012 11:14:00 +0200 Subject: [feature/soft-delete] Correctly calculate the number of replies everywhere PHPBB3-9567 --- phpBB/viewtopic.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 59081163dd..ea250f046a 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -275,7 +275,7 @@ if ($post_id) if ($sort_dir == $check_sort) { - $topic_data['prev_posts'] = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies']; + $topic_data['prev_posts'] = phpbb_content_visibility::get_count('topic_posts', $topic_data, $forum_id) - 1; } else { @@ -309,8 +309,7 @@ if ($post_id) } $topic_id = (int) $topic_data['topic_id']; -// -$topic_replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies']; +$topic_replies = phpbb_content_visibility::get_count('topic_posts', $topic_data, $forum_id) - 1; // Check sticky/announcement time limit if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == POST_ANNOUNCE) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time()) -- cgit v1.2.1 From 7b3d794cad4c06b1bbb769439a2d051b7ca0a0d4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 24 Oct 2012 19:58:28 +0200 Subject: [feature/soft-delete] Display post delete reason if one is given PHPBB3-9567 --- phpBB/viewtopic.php | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index ea250f046a..a53931cc31 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -937,7 +937,7 @@ else } // Container for user details, only process once -$post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = array(); +$post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = $post_delete_list = array(); $has_attachments = $display_notice = false; $bbcode_bitfield = ''; $i = $i_total = 0; @@ -1052,6 +1052,9 @@ while ($row = $db->sql_fetchrow($result)) 'post_edit_reason' => $row['post_edit_reason'], 'post_edit_user' => $row['post_edit_user'], 'post_edit_locked' => $row['post_edit_locked'], + 'post_delete_time' => $row['post_delete_time'], + 'post_delete_reason'=> $row['post_delete_reason'], + 'post_delete_user' => $row['post_delete_user'], // Make sure the icon actually exists 'icon_id' => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0, @@ -1505,6 +1508,52 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) $l_edited_by = ''; } + // Deleting information + if ($row['post_visibility'] == ITEM_DELETED && $row['post_delete_user']) + { + // Get usernames for all following posts if not already stored + if (!sizeof($post_delete_list) && ($row['post_delete_reason'] || ($row['post_delete_user'] && !isset($user_cache[$row['post_delete_user']])))) + { + // Remove all post_ids already parsed (we do not have to check them) + $post_storage_list = (!$store_reverse) ? array_slice($post_list, $i) : array_slice(array_reverse($post_list), $i); + + $sql = 'SELECT DISTINCT u.user_id, u.username, u.user_colour + FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u + WHERE ' . $db->sql_in_set('p.post_id', $post_storage_list) . ' + AND p.post_delete_user <> 0 + AND p.post_delete_user = u.user_id'; + $result2 = $db->sql_query($sql); + while ($user_delete_row = $db->sql_fetchrow($result2)) + { + $post_delete_list[$user_delete_row['user_id']] = $user_delete_row; + } + $db->sql_freeresult($result2); + + unset($post_storage_list); + } + + if ($row['post_delete_user'] && !isset($user_cache[$row['post_delete_user']])) + { + $user_cache[$row['post_delete_user']] = $post_delete_list[$row['post_delete_user']]; + } + + // User having deleted the post also being the post author? + if (!$row['post_delete_user'] || $row['post_delete_user'] == $poster_id) + { + $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); + } + else + { + $display_username = get_username_string('full', $row['post_delete_user'], $user_cache[$row['post_delete_user']]['username'], $user_cache[$row['post_delete_user']]['user_colour']); + } + + $l_deleted_by = $user->lang('DELETED_INFORMATION', $display_username, $user->format_date($row['post_delete_time'], false, true)); + } + else + { + $l_deleted_by = ''; + } + // Bump information if ($topic_data['topic_bumped'] && $row['post_id'] == $topic_data['topic_last_post_id'] && isset($user_cache[$topic_data['topic_bumper']]) ) { @@ -1573,6 +1622,8 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'SIGNATURE' => ($row['enable_sig']) ? $user_cache[$poster_id]['sig'] : '', 'EDITED_MESSAGE' => $l_edited_by, 'EDIT_REASON' => $row['post_edit_reason'], + 'DELETED_MESSAGE' => $l_deleted_by, + 'DELETE_REASON' => $row['post_delete_reason'], 'BUMPED_MESSAGE' => $l_bumped_by, 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), -- cgit v1.2.1 From 4a8d38aab13099fdb4fb7e2a7b72cff1c05fda9c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 27 Oct 2012 17:12:34 +0200 Subject: [feature/soft-delete] Allow soft deleting/restoring topics via quickmoderation PHPBB3-9567 --- phpBB/viewtopic.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index a53931cc31..04e1697aac 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -532,6 +532,7 @@ $quickmod_array = array( 'lock' => array('LOCK_TOPIC', ($topic_data['topic_status'] == ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))), 'unlock' => array('UNLOCK_TOPIC', ($topic_data['topic_status'] != ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))), 'delete_topic' => array('DELETE_TOPIC', $auth->acl_get('m_delete', $forum_id)), + 'restore_topic' => array('RESTORE_TOPIC', (($topic_data['topic_visibility'] == ITEM_DELETED) && $auth->acl_get('m_approve', $forum_id))), 'move' => array('MOVE_TOPIC', $auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED), 'split' => array('SPLIT_TOPIC', $auth->acl_get('m_split', $forum_id)), 'merge' => array('MERGE_POSTS', $auth->acl_get('m_merge', $forum_id)), -- cgit v1.2.1 From 334265fc839f95d24cce44ec675ae8cef7b4bfaa Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 Nov 2012 22:57:49 +0100 Subject: [feature/soft-delete] Fix displaying the button/permission When the post is already softdeleted the options should only be available if *_delete is granted. PHPBB3-9567 --- phpBB/viewtopic.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 04e1697aac..2e04b660b2 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -531,7 +531,7 @@ $quickmod_array = array( 'lock' => array('LOCK_TOPIC', ($topic_data['topic_status'] == ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))), 'unlock' => array('UNLOCK_TOPIC', ($topic_data['topic_status'] != ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))), - 'delete_topic' => array('DELETE_TOPIC', $auth->acl_get('m_delete', $forum_id)), + 'delete_topic' => array('DELETE_TOPIC', ($auth->acl_get('m_delete', $forum_id) || (($topic_data['topic_visibility'] != ITEM_DELETED) && $auth->acl_get('m_softdelete', $forum_id)))), 'restore_topic' => array('RESTORE_TOPIC', (($topic_data['topic_visibility'] == ITEM_DELETED) && $auth->acl_get('m_approve', $forum_id))), 'move' => array('MOVE_TOPIC', $auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED), 'split' => array('SPLIT_TOPIC', $auth->acl_get('m_split', $forum_id)), @@ -1591,9 +1591,9 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) ($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']) ))); - $delete_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_delete', $forum_id) || ( + $delete_allowed = ($user->data['is_registered'] && (($auth->acl_get('m_delete', $forum_id) || ($auth->acl_get('m_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) || ( $user->data['user_id'] == $poster_id && - $auth->acl_get('f_delete', $forum_id) && + ($auth->acl_get('f_delete', $forum_id) || ($auth->acl_get('f_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) && $topic_data['topic_last_post_id'] == $row['post_id'] && ($row['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']) && // we do not want to allow removal of the last post if a moderator locked it! -- cgit v1.2.1 From 1c584ef8ba861ce361135dc44aeabd76423c0c94 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 9 Nov 2012 11:46:17 +0100 Subject: [feature/soft-delete] Use JS to display softdeleted/ignored posts PHPBB3-9567 --- phpBB/viewtopic.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 2e04b660b2..9dfef607b7 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1038,7 +1038,7 @@ while ($row = $db->sql_fetchrow($result)) } $rowset[$row['post_id']] = array( - 'hide_post' => ($row['foe'] && ($view != 'show' || $post_id != $row['post_id'])) ? true : false, + 'hide_post' => (($row['foe'] || $row['post_visibility'] == ITEM_DELETED) && ($view != 'show' || $post_id != $row['post_id'])) ? true : false, 'post_id' => $row['post_id'], 'post_time' => $row['post_time'], @@ -1548,11 +1548,19 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) $display_username = get_username_string('full', $row['post_delete_user'], $user_cache[$row['post_delete_user']]['username'], $user_cache[$row['post_delete_user']]['user_colour']); } + if ($row['post_delete_reason']) + { + $l_deleted_message = $user->lang('POST_DELETED_BY_REASON', $display_username, $user->format_date($row['post_delete_time'], false, true), $row['post_delete_reason']); + } + else + { + $l_deleted_message = $user->lang('POST_DELETED_BY', $display_username, $user->format_date($row['post_delete_time'], false, true)); + } $l_deleted_by = $user->lang('DELETED_INFORMATION', $display_username, $user->format_date($row['post_delete_time'], false, true)); } else { - $l_deleted_by = ''; + $l_deleted_by = $l_deleted_message = ''; } // Bump information @@ -1670,6 +1678,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'S_MULTIPLE_ATTACHMENTS' => !empty($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]) > 1, 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED) ? true : false, 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false, + 'L_POST_DELETED_MESSAGE' => $l_deleted_message, 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false, 'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'], 'S_FRIEND' => ($row['friend']) ? true : false, @@ -1678,8 +1687,10 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'S_CUSTOM_FIELDS' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false, 'S_TOPIC_POSTER' => ($topic_data['topic_poster'] == $poster_id) ? true : false, - 'S_IGNORE_POST' => ($row['hide_post']) ? true : false, - 'L_IGNORE_POST' => ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '', '') : '', + 'S_IGNORE_POST' => ($row['foe']) ? true : false, + 'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '', '') : '', + 'S_POST_HIDDEN' => $row['hide_post'], + 'L_POST_DISPLAY' => ($row['hide_post']) ? $user->lang('POST_DISPLAY', '', '') : '', ); $user_poster_data = $user_cache[$poster_id]; -- cgit v1.2.1 From 164a06c0665e0f5cbbfb3314b323ffe9a05648d7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 6 Mar 2013 12:43:03 +0100 Subject: [ticket/9657] Fix "Display this post" link if javascript is disabled PHPBB3-9657 --- phpBB/viewtopic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 49967d4c25..6cfbef6dc7 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1688,9 +1688,9 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'S_TOPIC_POSTER' => ($topic_data['topic_poster'] == $poster_id) ? true : false, 'S_IGNORE_POST' => ($row['foe']) ? true : false, - 'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '', '') : '', + 'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '', 'S_POST_HIDDEN' => $row['hide_post'], - 'L_POST_DISPLAY' => ($row['hide_post']) ? $user->lang('POST_DISPLAY', '', '') : '', + 'L_POST_DISPLAY' => ($row['hide_post']) ? $user->lang('POST_DISPLAY', '', '') : '', ); $user_poster_data = $user_cache[$poster_id]; -- cgit v1.2.1 From f5482e73fddc1a00f2c9df5f6428da70e2777547 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 6 Mar 2013 12:52:15 +0100 Subject: [ticket/9657] Correctly return to viewtopic page when handling posts While managing posts from viewtopic.php we should return to that page, rather then the MCP PHPBB3-9657 --- phpBB/viewtopic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 6cfbef6dc7..c192bb28d9 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1659,7 +1659,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_YIM' => $user_cache[$poster_id]['yim'], 'U_JABBER' => $user_cache[$poster_id]['jabber'], - 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p={$row['post_id']}&f=$forum_id"), + 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p={$row['post_id']}&f=$forum_id&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url . '&p=' . $row['post_id'] . '#p' . $row['post_id']))), 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', -- cgit v1.2.1 From cd95d3abf73d954618b370d6b20f9de86e267ba7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 11 Mar 2013 12:22:47 +0100 Subject: [ticket/9657] Include poster name in "deleted post" message Also switched from passive to active form PHPBB3-9657 --- phpBB/viewtopic.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index c192bb28d9..69da62cecd 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1538,10 +1538,12 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) $user_cache[$row['post_delete_user']] = $post_delete_list[$row['post_delete_user']]; } + $display_postername = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); + // User having deleted the post also being the post author? if (!$row['post_delete_user'] || $row['post_delete_user'] == $poster_id) { - $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); + $display_username = $display_postername; } else { @@ -1550,11 +1552,11 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) if ($row['post_delete_reason']) { - $l_deleted_message = $user->lang('POST_DELETED_BY_REASON', $display_username, $user->format_date($row['post_delete_time'], false, true), $row['post_delete_reason']); + $l_deleted_message = $user->lang('POST_DELETED_BY_REASON', $display_postername, $display_username, $user->format_date($row['post_delete_time'], false, true), $row['post_delete_reason']); } else { - $l_deleted_message = $user->lang('POST_DELETED_BY', $display_username, $user->format_date($row['post_delete_time'], false, true)); + $l_deleted_message = $user->lang('POST_DELETED_BY', $display_postername, $display_username, $user->format_date($row['post_delete_time'], false, true)); } $l_deleted_by = $user->lang('DELETED_INFORMATION', $display_username, $user->format_date($row['post_delete_time'], false, true)); } -- cgit v1.2.1 From 5da250148bc3a1a3a5be2c9fd9f6eb239d4410c1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 12 Mar 2013 09:14:39 +0100 Subject: [ticket/9657] Finish subsilver2 viewforum and viewtopic PHPBB3-9657 --- phpBB/viewtopic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 69da62cecd..a73db3938d 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1665,7 +1665,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - 'U_MCP_RESTORE' => ($auth->acl_get('m_restore', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=deleted_posts&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', + 'U_MCP_RESTORE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_data['topic_visibility'] != ITEM_DELETED) ? 'deleted_posts' : 'deleted_topics') . '&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '', 'U_PREV_POST_ID' => $prev_post_id, -- 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/viewtopic.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index a73db3938d..db8a192180 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -55,6 +55,8 @@ if (!$topic_id && !$post_id) trigger_error('NO_TOPIC'); } +$phpbb_content_visibility = $phpbb_container->get('content.visibility'); + // Find topic id if user requested a newer or older topic if ($view && !$post_id) { @@ -79,7 +81,7 @@ if ($view && !$post_id) $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0; - $sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id); + $sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id); $sql = 'SELECT post_id, topic_id, forum_id FROM ' . POSTS_TABLE . " @@ -133,7 +135,7 @@ if ($view && !$post_id) } else { - $sql_visibility = phpbb_content_visibility::get_visibility_sql('topic', $row['forum_id']); + $sql_visibility = $phpbb_content_visibility->get_visibility_sql('topic', $row['forum_id']); $sql = 'SELECT topic_id, forum_id FROM ' . TOPICS_TABLE . ' @@ -275,7 +277,7 @@ if ($post_id) if ($sort_dir == $check_sort) { - $topic_data['prev_posts'] = phpbb_content_visibility::get_count('topic_posts', $topic_data, $forum_id) - 1; + $topic_data['prev_posts'] = $phpbb_content_visibility->get_count('topic_posts', $topic_data, $forum_id) - 1; } else { @@ -284,7 +286,7 @@ if ($post_id) } else { - $sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); + $sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p @@ -309,7 +311,7 @@ if ($post_id) } $topic_id = (int) $topic_data['topic_id']; -$topic_replies = phpbb_content_visibility::get_count('topic_posts', $topic_data, $forum_id) - 1; +$topic_replies = $phpbb_content_visibility->get_count('topic_posts', $topic_data, $forum_id) - 1; // Check sticky/announcement time limit if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == POST_ANNOUNCE) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time()) @@ -403,7 +405,7 @@ gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $ if ($sort_days) { $min_post_time = time() - ($sort_days * 86400); - $sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id); + $sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id); $sql = 'SELECT COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . " @@ -944,7 +946,7 @@ $bbcode_bitfield = ''; $i = $i_total = 0; // Go ahead and pull all data for this topic -$sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); +$sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . " -- cgit v1.2.1 From 5ab0090e6c9fa1b497938a932cdf28ba55a17e7c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 22:35:55 -0400 Subject: [ticket/9657] Remove sql_visibility as it is always non-empty PHPBB3-9657 --- phpBB/viewtopic.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index db8a192180..55c8d8e5b3 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -79,14 +79,12 @@ if ($view && !$post_id) { // Get topic tracking info $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); - $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0; - $sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id); $sql = 'SELECT post_id, topic_id, forum_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id - " . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . " + AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id) . " AND post_time > $topic_last_read AND forum_id = $forum_id ORDER BY post_time ASC"; @@ -135,14 +133,12 @@ if ($view && !$post_id) } else { - $sql_visibility = $phpbb_content_visibility->get_visibility_sql('topic', $row['forum_id']); - $sql = 'SELECT topic_id, forum_id FROM ' . TOPICS_TABLE . ' WHERE forum_id = ' . $row['forum_id'] . " AND topic_moved_id = 0 AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} - " . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . " + AND " . $phpbb_content_visibility->get_visibility_sql('topic', $row['forum_id']) . " ORDER BY topic_last_post_time $sql_ordering"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); @@ -286,12 +282,10 @@ if ($post_id) } else { - $sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); - $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p WHERE p.topic_id = {$topic_data['topic_id']} - " . (($sql_visibility) ? ' AND ' . $sql_visibility : ''); + AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); if ($sort_dir == 'd') { @@ -405,13 +399,12 @@ gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $ if ($sort_days) { $min_post_time = time() - ($sort_days * 86400); - $sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id); $sql = 'SELECT COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id AND post_time >= $min_post_time - " . (($sql_visibility) ? ' AND ' . $sql_visibility : ''); + AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id); $result = $db->sql_query($sql); $total_posts = (int) $db->sql_fetchfield('num_posts'); $db->sql_freeresult($result); @@ -946,12 +939,10 @@ $bbcode_bitfield = ''; $i = $i_total = 0; // Go ahead and pull all data for this topic -$sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); - $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . " WHERE p.topic_id = $topic_id - " . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . " + AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.') . " " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . " $limit_posts_time ORDER BY $sql_sort_order"; -- cgit v1.2.1