mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 12:28:52 +00:00
[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
This commit is contained in:
parent
b1ce8a8c13
commit
33073fafbe
5 changed files with 121 additions and 20 deletions
|
@ -21,6 +21,7 @@ class mcp_queue_info
|
||||||
'modes' => array(
|
'modes' => array(
|
||||||
'unapproved_topics' => array('title' => 'MCP_QUEUE_UNAPPROVED_TOPICS', 'auth' => 'aclf_m_approve', 'cat' => array('MCP_QUEUE')),
|
'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')),
|
'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')),
|
'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')),
|
'approve_details' => array('title' => 'MCP_QUEUE_APPROVE_DETAILS', 'auth' => 'acl_m_approve,$id || (!$id && aclf_m_approve)', 'cat' => array('MCP_QUEUE')),
|
||||||
),
|
),
|
||||||
|
|
|
@ -229,8 +229,12 @@ class mcp_queue
|
||||||
|
|
||||||
case 'unapproved_topics':
|
case 'unapproved_topics':
|
||||||
case 'unapproved_posts':
|
case 'unapproved_posts':
|
||||||
|
case 'deleted_topics':
|
||||||
case 'deleted_posts':
|
case 'deleted_posts':
|
||||||
$m_perm = 'm_approve';
|
$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'));
|
$user->add_lang(array('viewtopic', 'viewforum'));
|
||||||
|
|
||||||
|
@ -312,11 +316,8 @@ class mcp_queue
|
||||||
|
|
||||||
$forum_names = array();
|
$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
|
$sql = 'SELECT p.post_id
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . '
|
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) . '
|
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' : '') . '
|
' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . '
|
||||||
' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . "
|
' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . "
|
||||||
AND t.topic_id = p.topic_id
|
AND t.topic_id = p.topic_id
|
||||||
$starter_sql
|
AND t.topic_visibility <> p.post_visibility
|
||||||
$limit_time_sql
|
$limit_time_sql
|
||||||
ORDER BY $sort_order_sql";
|
ORDER BY $sort_order_sql";
|
||||||
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
||||||
|
@ -370,9 +371,9 @@ class mcp_queue
|
||||||
else
|
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
|
$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
|
FROM ' . TOPICS_TABLE . ' t
|
||||||
WHERE " . $db->sql_in_set('forum_id', $forum_list) . "
|
WHERE ' . $db->sql_in_set('forum_id', $forum_list) . '
|
||||||
AND topic_visibility = " . ITEM_UNAPPROVED . "
|
AND topic_visibility = ' . $visibility_const . "
|
||||||
$limit_time_sql
|
$limit_time_sql
|
||||||
ORDER BY $sort_order_sql";
|
ORDER BY $sort_order_sql";
|
||||||
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
||||||
|
@ -435,19 +436,19 @@ class mcp_queue
|
||||||
|
|
||||||
// Now display the page
|
// Now display the page
|
||||||
$template->assign_vars(array(
|
$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_EXPLAIN' => $user->lang['MCP_QUEUE_' . strtoupper($mode) . '_EXPLAIN'],
|
||||||
'L_TITLE' => $user->lang['MCP_QUEUE_' . strtoupper($mode)],
|
'L_TITLE' => $user->lang['MCP_QUEUE_' . strtoupper($mode)],
|
||||||
'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '',
|
'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '',
|
||||||
|
|
||||||
'S_FORUM_OPTIONS' => $forum_options,
|
'S_FORUM_OPTIONS' => $forum_options,
|
||||||
'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')),
|
'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')),
|
||||||
'S_TOPICS' => ($mode == 'unapproved_topics') ? true : false,
|
'S_TOPICS' => $is_topics,
|
||||||
'S_RESTORE' => ($mode == 'deleted_posts') ? true : false,
|
'S_RESTORE' => $is_restore,
|
||||||
|
|
||||||
'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start),
|
'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start),
|
||||||
'TOPIC_ID' => $topic_id,
|
'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';
|
$this->tpl_name = 'mcp_queue';
|
||||||
|
@ -480,9 +481,9 @@ class mcp_queue
|
||||||
'i' => $id,
|
'i' => $id,
|
||||||
'mode' => $mode,
|
'mode' => $mode,
|
||||||
'post_id_list' => $post_id_list,
|
'post_id_list' => $post_id_list,
|
||||||
'action' => 'approve',
|
'action' => 'restore',
|
||||||
'redirect' => $redirect)
|
'redirect' => $redirect,
|
||||||
);
|
));
|
||||||
|
|
||||||
$post_info = get_post_data($post_id_list, 'm_approve');
|
$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 = '<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
|
* Approve Post/Topic
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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_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' => '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_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',
|
'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' => '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_REPORT' => 'This post was not reported.',
|
||||||
'NO_POST_SELECTED' => 'You must select at least one post to perform this action.',
|
'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_POSTS_QUEUE' => 'There are no posts waiting for approval.',
|
||||||
'NO_REASON_DISAPPROVAL' => 'Please give an appropriate reason for disapproval.',
|
'NO_REASON_DISAPPROVAL' => 'Please give an appropriate reason for disapproval.',
|
||||||
'NO_REPORT' => 'No report found',
|
'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_REPORT_SELECTED' => 'You must select at least one report to perform this action.',
|
||||||
'NO_TOPIC_ICON' => 'None',
|
'NO_TOPIC_ICON' => 'None',
|
||||||
'NO_TOPIC_SELECTED' => 'You must select at least one topic to perform this action.',
|
'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.',
|
'NO_TOPICS_QUEUE' => 'There are no topics waiting for approval.',
|
||||||
|
|
||||||
'ONLY_TOPIC' => 'Only topic “%s”',
|
'ONLY_TOPIC' => 'Only topic “%s”',
|
||||||
|
|
|
@ -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'))) . '
|
$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 p.post_visibility = ' . $visibility_const . '
|
||||||
AND t.topic_id = p.topic_id
|
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)
|
if ($min_time)
|
||||||
{
|
{
|
||||||
|
@ -661,6 +661,8 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'unapproved_topics':
|
case 'unapproved_topics':
|
||||||
|
case 'deleted_topics':
|
||||||
|
$visibility_const = ($mode == 'unapproved_topics') ? ITEM_UNAPPROVED : ITEM_DELETED;
|
||||||
$type = 'topics';
|
$type = 'topics';
|
||||||
$default_key = 't';
|
$default_key = 't';
|
||||||
$default_dir = 'd';
|
$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
|
$sql = 'SELECT COUNT(topic_id) AS total
|
||||||
FROM ' . TOPICS_TABLE . "
|
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'))) . '
|
$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)
|
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)
|
'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);
|
$result = $db->sql_query($sql);
|
||||||
$total = (int) $db->sql_fetchfield('total');
|
$total = (int) $db->sql_fetchfield('total');
|
||||||
|
|
|
@ -86,7 +86,13 @@
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- ELSE -->
|
<!-- 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 -->
|
<!-- ENDIF -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue