mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 00:37:42 +02:00
- approve/disapprove posts/topics
- changed mcp_front to be more moderator friendly - able to change the forum in mcp_queue (for moderators moderating more than one forum) git-svn-id: file:///svn/phpbb/trunk@4937 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -26,6 +26,24 @@ class mcp_queue extends module
|
||||
{
|
||||
case 'approve':
|
||||
case 'disapprove':
|
||||
include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
|
||||
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
||||
|
||||
$post_id_list = get_array('post_id_list', 0);
|
||||
|
||||
if (!$post_id_list)
|
||||
{
|
||||
trigger_error('NO_POST_SELECTED');
|
||||
}
|
||||
|
||||
if ($mode == 'approve')
|
||||
{
|
||||
approve_post($post_id_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
disapprove_post($post_id_list);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -35,6 +53,14 @@ class mcp_queue extends module
|
||||
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
||||
|
||||
$post_id = request_var('p', 0);
|
||||
$topic_id = request_var('t', 0);
|
||||
|
||||
if ($topic_id)
|
||||
{
|
||||
$topic_info = get_topic_data(array($topic_id), 'm_approve');
|
||||
$post_id = (int) $topic_info[$topic_id]['topic_first_post_id'];
|
||||
}
|
||||
|
||||
$post_info = get_post_data(array($post_id), 'm_approve');
|
||||
|
||||
if (!sizeof($post_info))
|
||||
@@ -66,6 +92,7 @@ class mcp_queue extends module
|
||||
$message = smilie_text($message);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_MCP_QUEUE' => true,
|
||||
'S_APPROVE_ACTION' => "mcp.$phpEx$SID&i=queue&p=$post_id&f=$forum_id",
|
||||
|
||||
'S_CAN_VIEWIP' => $auth->acl_get('m_ip', $post_info['forum_id']),
|
||||
@@ -78,19 +105,22 @@ class mcp_queue extends module
|
||||
'U_VIEW_PROFILE' => "memberlist.$phpEx$SID&mode=viewprofile&u=" . $post_info['user_id'],
|
||||
'U_MCP_USERNOTES' => "mcp.$phpEx$SID&i=notes&mode=user_notes&u=" . $post_info['user_id'],
|
||||
'U_MCP_WARNINGS' => "mcp.$phpEx$SID&i=warnings&mode=view_user&u=" . $post_info['user_id'],
|
||||
'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? "{$phpbb_root_path}posting.$phpEx$SID&mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}" : '',
|
||||
|
||||
'REPORTED_IMG' => $user->img('icon_reported', $user->lang['POST_REPORTED']),
|
||||
'UNAPPROVED_IMG' => $user->img('icon_unapproved', $user->lang['POST_UNAPPROVED']),
|
||||
'EDIT_IMG' => $user->img('btn_edit', $user->lang['EDIT_POST']),
|
||||
|
||||
'POSTER_NAME' => $poster,
|
||||
'POST_PREVIEW' => $message,
|
||||
'POST_SUBJECT' => $post_info['post_subject'],
|
||||
'POST_DATE' => $user->format_date($post_info['post_time']),
|
||||
'POST_IP' => $post_info['poster_ip'],
|
||||
'POST_IPADDR' => @gethostbyaddr($post_info['poster_ip']))
|
||||
'POST_IPADDR' => @gethostbyaddr($post_info['poster_ip']),
|
||||
'POST_ID' => $post_info['post_id'])
|
||||
);
|
||||
|
||||
$this->display($user->lang['MCP_QUEUE'], 'mcp_approve.html');
|
||||
$this->display($user->lang['MCP_QUEUE'], 'mcp_post.html');
|
||||
|
||||
break;
|
||||
|
||||
@@ -221,7 +251,7 @@ class mcp_queue extends module
|
||||
$poster = $row['username'];
|
||||
}
|
||||
|
||||
$s_checkbox = ($mode == 'unapproved_posts') ? '<input type="checkbox" name="post_id_list[]" value="' . $row['post_id'] . '" />' : '<input type="checkbox" name="topic_id_list[]" value="' . $row['topic_id'] . '" />';
|
||||
$s_checkbox = '<input type="checkbox" name="post_id_list[]" value="' . $row['post_id'] . '" />';
|
||||
|
||||
$template->assign_block_vars('postrow', array(
|
||||
'U_VIEWFORUM' => "viewforum.$phpEx$SID&f=" . $row['forum_id'],
|
||||
@@ -272,4 +302,441 @@ class mcp_queue extends module
|
||||
}
|
||||
}
|
||||
|
||||
// Approve Post/Topic
|
||||
function approve_post($post_id_list)
|
||||
{
|
||||
global $db, $template, $user, $config;
|
||||
global $_REQUEST, $phpEx, $phpbb_root_path, $SID;
|
||||
|
||||
if (!($forum_id = check_ids($post_id_list, POSTS_TABLE, 'post_id', 'm_approve')))
|
||||
{
|
||||
trigger_error('NOT_AUTHORIZED');
|
||||
}
|
||||
|
||||
$redirect = request_var('redirect', $user->data['session_page']);
|
||||
$success_msg = '';
|
||||
|
||||
$s_hidden_fields = build_hidden_fields(array(
|
||||
'post_id_list' => $post_id_list,
|
||||
'f' => $forum_id,
|
||||
'mode' => 'approve',
|
||||
'redirect' => $redirect)
|
||||
);
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
$notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false;
|
||||
|
||||
$post_info = get_post_data($post_id_list, 'm_approve');
|
||||
|
||||
// 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 = $forum_topics = $forum_posts = 0;
|
||||
$topic_approve_sql = $topic_replies_sql = $post_approve_sql = $topic_id_list = array();
|
||||
|
||||
foreach ($post_info as $post_id => $post_data)
|
||||
{
|
||||
$topic_id_list[$post_data['topic_id']] = 1;
|
||||
|
||||
// Topic or Post. ;)
|
||||
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id)
|
||||
{
|
||||
if ($post_data['forum_id'])
|
||||
{
|
||||
$total_topics++;
|
||||
$forum_topics++;
|
||||
}
|
||||
|
||||
$topic_approve_sql[] = $post_data['topic_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($topic_replies_sql[$post_data['topic_id']]))
|
||||
{
|
||||
$topic_replies_sql[$post_data['topic_id']] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_replies_sql[$post_data['topic_id']]++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($post_data['forum_id'])
|
||||
{
|
||||
$total_posts++;
|
||||
$forum_posts++;
|
||||
}
|
||||
|
||||
$post_approve_sql[] = $post_id;
|
||||
}
|
||||
|
||||
if (sizeof($topic_approve_sql))
|
||||
{
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
||||
SET topic_approved = 1
|
||||
WHERE topic_id IN (' . implode(', ', $topic_approve_sql) . ')';
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
if (sizeof($post_approve_sql))
|
||||
{
|
||||
$sql = 'UPDATE ' . POSTS_TABLE . '
|
||||
SET post_approved = 1
|
||||
WHERE post_id IN (' . implode(', ', $post_approve_sql) . ')';
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
if (sizeof($topic_replies_sql))
|
||||
{
|
||||
foreach ($topic_replies_sql as $topic_id => $num_replies)
|
||||
{
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
||||
SET topic_replies = topic_replies + $num_replies
|
||||
WHERE topic_id = $topic_id";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
if ($forum_topics || $forum_posts)
|
||||
{
|
||||
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
||||
SET ';
|
||||
$sql .= ($forum_topics) ? "forum_topics = forum_topics + $forum_topics" : '';
|
||||
$sql .= ($forum_topics && $forum_posts) ? ', ' : '';
|
||||
$sql .= ($forum_posts) ? "forum_posts = forum_posts + $forum_posts" : '';
|
||||
$sql .= " WHERE forum_id = $forum_id";
|
||||
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
if ($total_topics)
|
||||
{
|
||||
set_config('num_topics', $config['num_topics'] + $total_topics, true);
|
||||
}
|
||||
|
||||
if ($total_posts)
|
||||
{
|
||||
set_config('num_posts', $config['num_posts'] + $total_posts, true);
|
||||
}
|
||||
unset($topic_approve_sql, $topic_replies_sql, $post_approve_sql);
|
||||
|
||||
update_post_information('topic', array_keys($topic_id_list));
|
||||
update_post_information('forum', $forum_id);
|
||||
unset($topic_id_list);
|
||||
|
||||
$messenger = new messenger();
|
||||
|
||||
// Notify Poster?
|
||||
if ($notify_poster)
|
||||
{
|
||||
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
|
||||
|
||||
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->replyto($config['board_email']);
|
||||
$messenger->to($post_data['user_email'], $post_data['username']);
|
||||
$messenger->im($post_data['user_jabber'], $post_data['username']);
|
||||
|
||||
$messenger->assign_vars(array(
|
||||
'EMAIL_SIG' => $email_sig,
|
||||
'SITENAME' => $config['sitename'],
|
||||
'USERNAME' => $post_data['username'],
|
||||
'POST_SUBJECT' => censor_text($post_data['post_subject']),
|
||||
'TOPIC_TITLE' => censor_text($post_data['topic_title']),
|
||||
|
||||
'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t={$post_data['topic_id']}&e=0",
|
||||
'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t={$post_data['topic_id']}&p=$post_id&e=$post_id")
|
||||
);
|
||||
|
||||
$messenger->send($post_data['user_notify_type']);
|
||||
$messenger->reset();
|
||||
|
||||
if ($messenger->queue)
|
||||
{
|
||||
$messenger->queue->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send out normal user notifications
|
||||
$email_sig = str_replace('<br />', "\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'])
|
||||
{
|
||||
// Forum Notifications
|
||||
user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $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'], $forum_id, $post_data['topic_id'], $post_id);
|
||||
}
|
||||
}
|
||||
unset($post_info);
|
||||
|
||||
if ($forum_topics)
|
||||
{
|
||||
$success_msg = ($forum_topics == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS';
|
||||
}
|
||||
else
|
||||
{
|
||||
$success_msg = (sizeof($post_id_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_NOTIFY_POSTER' => true,
|
||||
'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$SID");
|
||||
|
||||
if (strpos($redirect, '?') === false)
|
||||
{
|
||||
$redirect = substr_replace($redirect, ".$phpEx$SID&", strpos($redirect, '&'), 1);
|
||||
}
|
||||
|
||||
if (!$success_msg)
|
||||
{
|
||||
redirect($redirect);
|
||||
}
|
||||
else
|
||||
{
|
||||
meta_refresh(3, $redirect);
|
||||
trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '">', '</a>'));
|
||||
}
|
||||
}
|
||||
|
||||
// Disapprove Post/Topic
|
||||
function disapprove_post($post_id_list)
|
||||
{
|
||||
global $db, $template, $user, $config;
|
||||
global $_REQUEST, $_POST, $phpEx, $phpbb_root_path, $SID;
|
||||
|
||||
if (!($forum_id = check_ids($post_id_list, POSTS_TABLE, 'post_id', 'm_approve')))
|
||||
{
|
||||
trigger_error('NOT_AUTHORIZED');
|
||||
}
|
||||
|
||||
$redirect = request_var('redirect', $user->data['session_page']);
|
||||
$reason = request_var('reason', '');
|
||||
$reason_id = request_var('reason_id', 0);
|
||||
$success_msg = $additional_msg = '';
|
||||
|
||||
$s_hidden_fields = build_hidden_fields(array(
|
||||
'post_id_list' => $post_id_list,
|
||||
'f' => $forum_id,
|
||||
'mode' => 'disapprove',
|
||||
'redirect' => $redirect)
|
||||
);
|
||||
|
||||
$notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false;
|
||||
|
||||
if ($reason_id)
|
||||
{
|
||||
$sql = 'SELECT reason_name
|
||||
FROM ' . REASONS_TABLE . "
|
||||
WHERE reason_id = $reason_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if (!($row = $db->sql_fetchrow($result)) || (!$reason && $row['reason_name'] == 'other'))
|
||||
{
|
||||
$additional_msg = 'Please give an appropiate reason for disapproval';
|
||||
unset($_POST['confirm']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$disapprove_reason = ($row['reason_name'] != 'other') ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_name'])] : '';
|
||||
$disapprove_reason .= ($reason) ? "\n\n" . $_REQUEST['reason'] : '';
|
||||
unset($reason);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
$post_info = get_post_data($post_id_list, 'm_approve');
|
||||
|
||||
// If Topic -> forum_topics_real -= 1
|
||||
// If Post -> topic_replies_real -= 1
|
||||
|
||||
$forum_topics_real = 0;
|
||||
$topic_replies_real_sql = $post_disapprove_sql = $topic_id_list = array();
|
||||
|
||||
foreach ($post_info as $post_id => $post_data)
|
||||
{
|
||||
$topic_id_list[$post_data['topic_id']] = 1;
|
||||
|
||||
// Topic or Post. ;)
|
||||
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id)
|
||||
{
|
||||
if ($post_data['forum_id'])
|
||||
{
|
||||
$forum_topics_real++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($topic_replies_real_sql[$post_data['topic_id']]))
|
||||
{
|
||||
$topic_replies_real_sql[$post_data['topic_id']] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_replies_real_sql[$post_data['topic_id']]++;
|
||||
}
|
||||
}
|
||||
|
||||
$post_disapprove_sql[] = $post_id;
|
||||
}
|
||||
|
||||
if ($forum_topics_real)
|
||||
{
|
||||
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
||||
SET forum_topics_real = forum_topics_real - $forum_topics_real
|
||||
WHERE forum_id = $forum_id";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
if (sizeof($topic_replies_real_sql))
|
||||
{
|
||||
foreach ($topic_replies_real_sql as $topic_id => $num_replies)
|
||||
{
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
||||
SET topic_replies_real = topic_replies_real - $num_replies
|
||||
WHERE topic_id = $topic_id";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof($post_disapprove_sql))
|
||||
{
|
||||
// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
|
||||
delete_posts('post_id', $post_disapprove_sql);
|
||||
}
|
||||
unset($post_disapprove_sql, $topic_replies_real_sql);
|
||||
|
||||
update_post_information('topic', array_keys($topic_id_list));
|
||||
update_post_information('forum', $forum_id);
|
||||
unset($topic_id_list);
|
||||
|
||||
$messenger = new messenger();
|
||||
|
||||
// Notify Poster?
|
||||
if ($notify_poster)
|
||||
{
|
||||
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
|
||||
|
||||
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_disapproved' : 'post_disapproved';
|
||||
|
||||
$messenger->template($email_template, $post_data['user_lang']);
|
||||
|
||||
$messenger->replyto($config['board_email']);
|
||||
$messenger->to($post_data['user_email'], $post_data['username']);
|
||||
$messenger->im($post_data['user_jabber'], $post_data['username']);
|
||||
|
||||
$messenger->assign_vars(array(
|
||||
'EMAIL_SIG' => $email_sig,
|
||||
'SITENAME' => $config['sitename'],
|
||||
'USERNAME' => $post_data['username'],
|
||||
'REASON' => stripslashes($disapprove_reason),
|
||||
'POST_SUBJECT' => censor_text($post_data['post_subject']),
|
||||
'TOPIC_TITLE' => censor_text($post_data['topic_title']))
|
||||
);
|
||||
|
||||
$messenger->send($post_data['user_notify_type']);
|
||||
$messenger->reset();
|
||||
|
||||
if ($messenger->queue)
|
||||
{
|
||||
$messenger->queue->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($post_info, $disapprove_reason);
|
||||
|
||||
if ($forum_topics_real)
|
||||
{
|
||||
$success_msg = ($forum_topics_real == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
|
||||
}
|
||||
else
|
||||
{
|
||||
$success_msg = (sizeof($post_id_list) == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . REASONS_TABLE . '
|
||||
ORDER BY reason_priority ASC';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$row['reason_name'] = strtoupper($row['reason_name']);
|
||||
|
||||
$reason_title = (!empty($user->lang['report_reasons']['TITLE'][$row['reason_name']])) ? $user->lang['report_reasons']['TITLE'][$row['reason_name']] : ucwords(str_replace('_', ' ', $row['reason_name']));
|
||||
|
||||
$reason_desc = (!empty($user->lang['report_reasons']['DESCRIPTION'][$row['reason_name']])) ? $user->lang['report_reasons']['DESCRIPTION'][$row['reason_name']] : $row['reason_desc'];
|
||||
|
||||
$template->assign_block_vars('reason', array(
|
||||
'ID' => $row['reason_id'],
|
||||
'NAME' => htmlspecialchars($reason_title),
|
||||
'DESCRIPTION' => htmlspecialchars($reason_desc),
|
||||
'S_SELECTED' => ($row['reason_id'] == $reason_id) ? true : false)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_NOTIFY_POSTER' => true,
|
||||
'S_APPROVE' => false,
|
||||
'REASON' => $reason,
|
||||
'ADDITIONAL_MSG' => $additional_msg)
|
||||
);
|
||||
|
||||
confirm_box(false, 'APPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html');
|
||||
}
|
||||
|
||||
$redirect = request_var('redirect', "index.$phpEx$SID");
|
||||
|
||||
if (strpos($redirect, '?') === false)
|
||||
{
|
||||
$redirect = substr_replace($redirect, ".$phpEx$SID&", strpos($redirect, '&'), 1);
|
||||
}
|
||||
|
||||
if (!$success_msg)
|
||||
{
|
||||
redirect($redirect);
|
||||
}
|
||||
else
|
||||
{
|
||||
meta_refresh(3, "viewforum.$phpEx$SID&f=$forum_id");
|
||||
trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '">', '</a>'));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user