aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2012-10-15 15:53:32 +0200
committerJoas Schilling <nickvergessen@gmx.de>2012-10-15 15:53:32 +0200
commit33073fafbe53cb103e9e00bceb249a0879a2eb9c (patch)
tree3bced7cf702eec4ddfcc7c26a05936c756447c71 /phpBB
parentb1ce8a8c13eca920abf3659fcbfec267684071bb (diff)
downloadforums-33073fafbe53cb103e9e00bceb249a0879a2eb9c.tar
forums-33073fafbe53cb103e9e00bceb249a0879a2eb9c.tar.gz
forums-33073fafbe53cb103e9e00bceb249a0879a2eb9c.tar.bz2
forums-33073fafbe53cb103e9e00bceb249a0879a2eb9c.tar.xz
forums-33073fafbe53cb103e9e00bceb249a0879a2eb9c.zip
[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
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/mcp/info/mcp_queue.php1
-rw-r--r--phpBB/includes/mcp/mcp_queue.php120
-rw-r--r--phpBB/language/en/mcp.php4
-rw-r--r--phpBB/mcp.php8
-rw-r--r--phpBB/styles/prosilver/template/mcp_queue.html8
5 files changed, 121 insertions, 20 deletions
diff --git a/phpBB/includes/mcp/info/mcp_queue.php b/phpBB/includes/mcp/info/mcp_queue.php
index 43f6c81694..68cac5abd2 100644
--- a/phpBB/includes/mcp/info/mcp_queue.php
+++ b/phpBB/includes/mcp/info/mcp_queue.php
@@ -21,6 +21,7 @@ class mcp_queue_info
'modes' => array(
'unapproved_topics' => array('title' => 'MCP_QUEUE_UNAPPROVED_TOPICS', 'auth' => 'aclf_m_approve', 'cat' => array('MCP_QUEUE')),
'unapproved_posts' => array('title' => 'MCP_QUEUE_UNAPPROVED_POSTS', 'auth' => 'aclf_m_approve', 'cat' => array('MCP_QUEUE')),
+ 'deleted_topics' => array('title' => 'MCP_QUEUE_DELETED_TOPICS', 'auth' => 'aclf_m_approve', 'cat' => array('MCP_QUEUE')),
'deleted_posts' => array('title' => 'MCP_QUEUE_DELETED_POSTS', 'auth' => 'aclf_m_approve', 'cat' => array('MCP_QUEUE')),
'approve_details' => array('title' => 'MCP_QUEUE_APPROVE_DETAILS', 'auth' => 'acl_m_approve,$id || (!$id && aclf_m_approve)', 'cat' => array('MCP_QUEUE')),
),
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 . "&amp;f=$forum_id&amp;st=$sort_days&amp;sk=$sort_key&amp;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');
@@ -569,6 +570,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']}&amp;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 = '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $topic_url . '">', '</a>');
+ }
+
+ $message = $user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>') . $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
*/
function approve_posts($post_id_list, $id, $mode)
diff --git a/phpBB/language/en/mcp.php b/phpBB/language/en/mcp.php
index 327c0fba69..a19fa36295 100644
--- a/phpBB/language/en/mcp.php
+++ b/phpBB/language/en/mcp.php
@@ -203,6 +203,8 @@ $lang = array_merge($lang, array(
'MCP_QUEUE_UNAPPROVED_TOPICS_EXPLAIN' => 'This is a list of all topics which require approving before they will be visible to users.',
'MCP_QUEUE_DELETED_POSTS' => 'Deleted posts',
'MCP_QUEUE_DELETED_POSTS_EXPLAIN' => 'This is a list of all posts which have been soft deleted. You can restore or permanently delete the posts from this screen.',
+ 'MCP_QUEUE_DELETED_TOPICS' => 'Deleted topics',
+ 'MCP_QUEUE_DELETED_TOPICS_EXPLAIN' => 'This is a list of all topics which have been soft deleted. You can restore or permanently delete the topics from this screen.',
'MCP_VIEW_USER' => 'View warnings for a specific user',
@@ -240,6 +242,7 @@ $lang = array_merge($lang, array(
'NO_POST' => 'You have to select a post in order to warn the user for a post.',
'NO_POST_REPORT' => 'This post was not reported.',
'NO_POST_SELECTED' => 'You must select at least one post to perform this action.',
+ 'NO_POSTS_DELETED' => 'There are no soft deleted posts.',
'NO_POSTS_QUEUE' => 'There are no posts waiting for approval.',
'NO_REASON_DISAPPROVAL' => 'Please give an appropriate reason for disapproval.',
'NO_REPORT' => 'No report found',
@@ -247,6 +250,7 @@ $lang = array_merge($lang, array(
'NO_REPORT_SELECTED' => 'You must select at least one report to perform this action.',
'NO_TOPIC_ICON' => 'None',
'NO_TOPIC_SELECTED' => 'You must select at least one topic to perform this action.',
+ 'NO_TOPICS_DELETED' => 'There are no soft deleted topics.',
'NO_TOPICS_QUEUE' => 'There are no topics waiting for approval.',
'ONLY_TOPIC' => 'Only topic ā€œ%sā€',
diff --git a/phpBB/mcp.php b/phpBB/mcp.php
index a4801940a6..09fe70cde1 100644
--- a/phpBB/mcp.php
+++ b/phpBB/mcp.php
@@ -652,7 +652,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
$where_sql " . $db->sql_in_set('p.forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
AND p.post_visibility = ' . $visibility_const . '
AND t.topic_id = p.topic_id
- AND t.topic_first_post_id <> p.post_id';
+ AND t.topic_visibility <> p.post_visibility';
if ($min_time)
{
@@ -661,6 +661,8 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
break;
case 'unapproved_topics':
+ case 'deleted_topics':
+ $visibility_const = ($mode == 'unapproved_topics') ? ITEM_UNAPPROVED : ITEM_DELETED;
$type = 'topics';
$default_key = 't';
$default_dir = 'd';
@@ -668,7 +670,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
$sql = 'SELECT COUNT(topic_id) AS total
FROM ' . TOPICS_TABLE . "
$where_sql " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
- AND topic_visibility = ' . ITEM_UNAPPROVED;
+ AND topic_visibility = ' . $visibility_const;
if ($min_time)
{
@@ -798,7 +800,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
'S_SELECT_SORT_DAYS' => $s_limit_days)
);
- if (($sort_days && $mode != 'viewlogs') || in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts', 'deleted_posts')) || $where_sql != 'WHERE')
+ if (($sort_days && $mode != 'viewlogs') || in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts', 'deleted_topics', 'deleted_posts')) || $where_sql != 'WHERE')
{
$result = $db->sql_query($sql);
$total = (int) $db->sql_fetchfield('total');
diff --git a/phpBB/styles/prosilver/template/mcp_queue.html b/phpBB/styles/prosilver/template/mcp_queue.html
index 4b48674673..f4c393e980 100644
--- a/phpBB/styles/prosilver/template/mcp_queue.html
+++ b/phpBB/styles/prosilver/template/mcp_queue.html
@@ -86,7 +86,13 @@
</li>
</ul>
<!-- ELSE -->
- <p class="notopics"><strong><!-- IF S_TOPICS -->{L_NO_TOPICS_QUEUE}<!-- ELSE -->{L_NO_POSTS_QUEUE}<!-- ENDIF --></strong></p>
+ <p class="notopics"><strong>
+ <!-- IF S_RESTORE -->
+ <!-- IF S_TOPICS -->{L_NO_TOPICS_DELETED}<!-- ELSE -->{L_NO_POSTS_DELETED}<!-- ENDIF -->
+ <!-- ELSE -->
+ <!-- IF S_TOPICS -->{L_NO_TOPICS_QUEUE}<!-- ELSE -->{L_NO_POSTS_QUEUE}<!-- ENDIF -->
+ <!-- ENDIF -->
+ </strong></p>
<!-- ENDIF -->
</div>