|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @package mcp
|
|
|
ef5584 |
* @version $Id: mcp_queue.php 9133 2008-11-30 12:03:43Z acydburn $
|
|
|
ef5584 |
* @copyright (c) 2005 phpBB Group
|
|
|
ef5584 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
ef5584 |
*
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @ignore
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
if (!defined('IN_PHPBB'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* mcp_queue
|
|
|
ef5584 |
* Handling the moderation queue
|
|
|
ef5584 |
* @package mcp
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
class mcp_queue
|
|
|
ef5584 |
{
|
|
|
ef5584 |
var $p_master;
|
|
|
ef5584 |
var $u_action;
|
|
|
ef5584 |
|
|
|
ef5584 |
function mcp_queue(&$p_master)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->p_master = &$p_master;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
function main($id, $mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $auth, $db, $user, $template, $cache;
|
|
|
ef5584 |
global $config, $phpbb_root_path, $phpEx, $action;
|
|
|
ef5584 |
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_id = request_var('f', 0);
|
|
|
ef5584 |
$start = request_var('start', 0);
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->page_title = 'MCP_QUEUE';
|
|
|
ef5584 |
|
|
|
ef5584 |
switch ($action)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'approve':
|
|
|
ef5584 |
case 'disapprove':
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
$post_id_list = request_var('post_id_list', array(0));
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!sizeof($post_id_list))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('NO_POST_SELECTED');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($action == 'approve')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
approve_post($post_id_list, 'queue', $mode);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
disapprove_post($post_id_list, 'queue', $mode);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
switch ($mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'approve_details':
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->tpl_name = 'mcp_post';
|
|
|
ef5584 |
|
|
|
ef5584 |
$user->add_lang(array('posting', 'viewtopic'));
|
|
|
ef5584 |
|
|
|
ef5584 |
$post_id = request_var('p', 0);
|
|
|
ef5584 |
$topic_id = request_var('t', 0);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($topic_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_info = get_topic_data(array($topic_id), 'm_approve');
|
|
|
ef5584 |
if (isset($topic_info[$topic_id]['topic_first_post_id']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$post_id = (int) $topic_info[$topic_id]['topic_first_post_id'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_id = 0;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$post_info = get_post_data(array($post_id), 'm_approve', true);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!sizeof($post_info))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('NO_POST_SELECTED');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$post_info = $post_info[$post_id];
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($post_info['topic_first_post_id'] != $post_id && topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_TOPIC_REVIEW' => true,
|
|
|
ef5584 |
'TOPIC_TITLE' => $post_info['topic_title'])
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$extensions = $attachments = $topic_tracking_info = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Get topic tracking info
|
|
|
ef5584 |
if ($config['load_db_lastread'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$tmp_topic_data = array($post_info['topic_id'] => $post_info);
|
|
|
ef5584 |
$topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time']));
|
|
|
ef5584 |
unset($tmp_topic_data);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false;
|
|
|
ef5584 |
|
|
|
ef5584 |
// Process message, leave it uncensored
|
|
|
ef5584 |
$message = $post_info['post_text'];
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($post_info['bbcode_bitfield'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
|
|
ef5584 |
$bbcode = new bbcode($post_info['bbcode_bitfield']);
|
|
|
ef5584 |
$bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$message = bbcode_nl2br($message);
|
|
|
ef5584 |
$message = smiley_text($message);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$extensions = $cache->obtain_attach_extensions($post_info['forum_id']);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT *
|
|
|
ef5584 |
FROM ' . ATTACHMENTS_TABLE . '
|
|
|
ef5584 |
WHERE post_msg_id = ' . $post_id . '
|
|
|
ef5584 |
AND in_message = 0
|
|
|
ef5584 |
ORDER BY filetime DESC, post_msg_id ASC';
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$attachments[] = $row;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($attachments))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$update_count = array();
|
|
|
ef5584 |
parse_attachments($post_info['forum_id'], $message, $attachments, $update_count);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Display not already displayed Attachments for this post, we already parsed them. ;)
|
|
|
ef5584 |
if (!empty($attachments))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_var('S_HAS_ATTACHMENTS', true);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($attachments as $attachment)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_block_vars('attachment', array(
|
|
|
ef5584 |
'DISPLAY_ATTACHMENT' => $attachment)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']);
|
|
|
ef5584 |
$topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']);
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_MCP_QUEUE' => true,
|
|
|
ef5584 |
'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p=$post_id&f=$forum_id"),
|
|
|
ef5584 |
'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']),
|
|
|
ef5584 |
'S_POST_REPORTED' => $post_info['post_reported'],
|
|
|
ef5584 |
'S_POST_UNAPPROVED' => !$post_info['post_approved'],
|
|
|
ef5584 |
'S_POST_LOCKED' => $post_info['post_edit_locked'],
|
|
|
ef5584 |
'S_USER_NOTES' => true,
|
|
|
ef5584 |
|
|
|
ef5584 |
'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '',
|
|
|
ef5584 |
'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
|
|
|
ef5584 |
'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
|
|
|
ef5584 |
'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $post_info['user_id']),
|
|
|
ef5584 |
'U_MCP_WARN_USER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '',
|
|
|
ef5584 |
'U_VIEW_POST' => $post_url,
|
|
|
ef5584 |
'U_VIEW_TOPIC' => $topic_url,
|
|
|
ef5584 |
|
|
|
ef5584 |
'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
|
|
|
ef5584 |
|
|
|
ef5584 |
'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '", ''),
|
|
|
ef5584 |
'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '', ''),
|
|
|
ef5584 |
'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '', ''),
|
|
|
ef5584 |
'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']),
|
|
|
ef5584 |
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']),
|
|
|
ef5584 |
'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
|
|
ef5584 |
'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
|
|
ef5584 |
'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
|
|
ef5584 |
'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'POST_PREVIEW' => $message,
|
|
|
ef5584 |
'POST_SUBJECT' => $post_info['post_subject'],
|
|
|
ef5584 |
'POST_DATE' => $user->format_date($post_info['post_time']),
|
|
|
ef5584 |
'POST_IP' => $post_info['poster_ip'],
|
|
|
ef5584 |
'POST_IPADDR' => ($auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '',
|
|
|
ef5584 |
'POST_ID' => $post_info['post_id'],
|
|
|
ef5584 |
|
|
|
ef5584 |
'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id . '&lookup=' . $post_info['poster_ip']) . '#ip' : '',
|
|
|
ef5584 |
));
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'unapproved_topics':
|
|
|
ef5584 |
case 'unapproved_posts':
|
|
|
ef5584 |
$user->add_lang(array('viewtopic', 'viewforum'));
|
|
|
ef5584 |
|
|
|
ef5584 |
$topic_id = request_var('t', 0);
|
|
|
ef5584 |
$forum_info = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($topic_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_info = get_topic_data(array($topic_id));
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!sizeof($topic_info))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('TOPIC_NOT_EXIST');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$topic_info = $topic_info[$topic_id];
|
|
|
ef5584 |
$forum_id = $topic_info['forum_id'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_list_approve = get_forum_list('m_approve', false, true);
|
|
|
ef5584 |
$forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs
|
|
|
ef5584 |
|
|
|
ef5584 |
// Remove forums we cannot read
|
|
|
ef5584 |
foreach ($forum_list_approve as $k => $forum_data)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!isset($forum_list_read[$forum_data['forum_id']]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
unset($forum_list_approve[$k]);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
unset($forum_list_read);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$forum_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_list = array();
|
|
|
ef5584 |
foreach ($forum_list_approve as $row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_list[] = $row['forum_id'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!sizeof($forum_list))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('NOT_MODERATOR');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$global_id = $forum_list[0];
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_list = implode(', ', $forum_list);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT SUM(forum_topics) as sum_forum_topics
|
|
|
ef5584 |
FROM ' . FORUMS_TABLE . "
|
|
|
ef5584 |
WHERE forum_id IN (0, $forum_list)";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics');
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_info = get_forum_data(array($forum_id), 'm_approve');
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!sizeof($forum_info))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('NOT_MODERATOR');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_info = $forum_info[$forum_id];
|
|
|
ef5584 |
$forum_list = $forum_id;
|
|
|
ef5584 |
$global_id = $forum_id;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>';
|
|
|
ef5584 |
foreach ($forum_list_approve as $row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_options .= '<option value="' . $row['forum_id'] . '"' . (($forum_id == $row['forum_id']) ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . $row['forum_name'] . '</option>';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$sort_days = $total = 0;
|
|
|
ef5584 |
$sort_key = $sort_dir = '';
|
|
|
ef5584 |
$sort_by_sql = $sort_order_sql = array();
|
|
|
ef5584 |
mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id);
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total;
|
|
|
ef5584 |
$limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_names = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($mode == 'unapproved_posts')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'SELECT p.post_id
|
|
|
ef5584 |
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . "
|
|
|
ef5584 |
WHERE p.forum_id IN (0, $forum_list)
|
|
|
ef5584 |
AND p.post_approved = 0
|
|
|
ef5584 |
" . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . '
|
|
|
ef5584 |
' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . "
|
|
|
ef5584 |
AND t.topic_id = p.topic_id
|
|
|
ef5584 |
AND t.topic_first_post_id <> p.post_id
|
|
|
ef5584 |
$limit_time_sql
|
|
|
ef5584 |
ORDER BY $sort_order_sql";
|
|
|
ef5584 |
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
|
|
ef5584 |
|
|
|
ef5584 |
$i = 0;
|
|
|
ef5584 |
$post_ids = array();
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$post_ids[] = $row['post_id'];
|
|
|
ef5584 |
$row_num[$row['post_id']] = $i++;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($post_ids))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'SELECT t.topic_id, t.topic_title, t.forum_id, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username, u.username_clean, u.user_colour
|
|
|
ef5584 |
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
|
|
|
ef5584 |
WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . '
|
|
|
ef5584 |
AND t.topic_id = p.topic_id
|
|
|
ef5584 |
AND u.user_id = p.poster_id
|
|
|
ef5584 |
ORDER BY ' . $sort_order_sql;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$post_data = $rowset = array();
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($row['forum_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_names[] = $row['forum_id'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$post_data[$row['post_id']] = $row;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($post_ids as $post_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$rowset[] = $post_data[$post_id];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
unset($post_data, $post_ids);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$rowset = array();
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$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_first_poster_name AS username, t.topic_first_poster_colour AS user_colour
|
|
|
ef5584 |
FROM ' . TOPICS_TABLE . " t
|
|
|
ef5584 |
WHERE forum_id IN (0, $forum_list)
|
|
|
ef5584 |
AND topic_approved = 0
|
|
|
ef5584 |
$limit_time_sql
|
|
|
ef5584 |
ORDER BY $sort_order_sql";
|
|
|
ef5584 |
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
|
|
ef5584 |
|
|
|
ef5584 |
$rowset = array();
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($row['forum_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_names[] = $row['forum_id'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$rowset[] = $row;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($forum_names))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Select the names for the forum_ids
|
|
|
ef5584 |
$sql = 'SELECT forum_id, forum_name
|
|
|
ef5584 |
FROM ' . FORUMS_TABLE . '
|
|
|
ef5584 |
WHERE ' . $db->sql_in_set('forum_id', $forum_names);
|
|
|
ef5584 |
$result = $db->sql_query($sql, 3600);
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_names = array();
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_names[$row['forum_id']] = $row['forum_name'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($rowset as $row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$global_topic = ($row['forum_id']) ? false : true;
|
|
|
ef5584 |
if ($global_topic)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$row['forum_id'] = $global_id;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (empty($row['post_username']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$row['post_username'] = $user->lang['GUEST'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_block_vars('postrow', array(
|
|
|
ef5584 |
'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
|
|
|
ef5584 |
'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
|
|
|
ef5584 |
'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . (($mode == 'unapproved_posts') ? '#p' . $row['post_id'] : ''),
|
|
|
ef5584 |
'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&start=$start&mode=approve_details&f={$row['forum_id']}&p={$row['post_id']}" . (($mode == 'unapproved_topics') ? "&t={$row['topic_id']}" : '')),
|
|
|
ef5584 |
|
|
|
ef5584 |
'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
|
|
ef5584 |
'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
|
|
ef5584 |
'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
|
|
ef5584 |
'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'POST_ID' => $row['post_id'],
|
|
|
ef5584 |
'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'],
|
|
|
ef5584 |
'POST_SUBJECT' => $row['post_subject'],
|
|
|
ef5584 |
'TOPIC_TITLE' => $row['topic_title'],
|
|
|
ef5584 |
'POST_TIME' => $user->format_date($row['post_time']))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
unset($rowset, $forum_names);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Now display the page
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'L_DISPLAY_ITEMS' => ($mode == 'unapproved_posts') ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'],
|
|
|
ef5584 |
'L_EXPLAIN' => ($mode == 'unapproved_posts') ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS_EXPLAIN'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS_EXPLAIN'],
|
|
|
ef5584 |
'L_TITLE' => ($mode == 'unapproved_posts') ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS'],
|
|
|
ef5584 |
'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '',
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_FORUM_OPTIONS' => $forum_options,
|
|
|
ef5584 |
'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')),
|
|
|
ef5584 |
'S_TOPICS' => ($mode == 'unapproved_posts') ? false : true,
|
|
|
ef5584 |
|
|
|
ef5584 |
'PAGINATION' => generate_pagination($this->u_action . "&f=$forum_id&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $config['topics_per_page'], $start),
|
|
|
ef5584 |
'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start),
|
|
|
ef5584 |
'TOPIC_ID' => $topic_id,
|
|
|
ef5584 |
'TOTAL' => ($total == 1) ? (($mode == 'unapproved_posts') ? $user->lang['VIEW_TOPIC_POST'] : $user->lang['VIEW_FORUM_TOPIC']) : sprintf((($mode == 'unapproved_posts') ? $user->lang['VIEW_TOPIC_POSTS'] : $user->lang['VIEW_FORUM_TOPICS']), $total),
|
|
|
ef5584 |
));
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->tpl_name = 'mcp_queue';
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Approve Post/Topic
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function approve_post($post_id_list, $id, $mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $db, $template, $user, $config;
|
|
|
ef5584 |
global $phpEx, $phpbb_root_path;
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve')))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('NOT_AUTHORISED');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$redirect = request_var('redirect', build_url(array('quickmod')));
|
|
|
ef5584 |
$success_msg = '';
|
|
|
ef5584 |
|
|
|
ef5584 |
$s_hidden_fields = build_hidden_fields(array(
|
|
|
ef5584 |
'i' => $id,
|
|
|
ef5584 |
'mode' => $mode,
|
|
|
ef5584 |
'post_id_list' => $post_id_list,
|
|
|
ef5584 |
'action' => 'approve',
|
|
|
ef5584 |
'redirect' => $redirect)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$post_info = get_post_data($post_id_list, 'm_approve');
|
|
|
ef5584 |
|
|
|
ef5584 |
if (confirm_box(true))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false;
|
|
|
ef5584 |
|
|
|
ef5584 |
// If Topic -> total_topics = total_topics+1, total_posts = total_posts+1, forum_topics = forum_topics+1, forum_posts = forum_posts+1
|
|
|
ef5584 |
// If Post -> total_posts = total_posts+1, forum_posts = forum_posts+1, topic_replies = topic_replies+1
|
|
|
ef5584 |
|
|
|
ef5584 |
$total_topics = $total_posts = 0;
|
|
|
ef5584 |
$forum_topics_posts = $topic_approve_sql = $topic_replies_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array();
|
|
|
ef5584 |
$user_posts_sql = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
$update_forum_information = false;
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($post_info as $post_id => $post_data)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_id_list[$post_data['topic_id']] = 1;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($post_data['forum_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_id_list[$post_data['forum_id']] = 1;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// User post update (we do not care about topic or post, since user posts are strictly connected to posts)
|
|
|
ef5584 |
// But we care about forums where post counts get not increased. ;)
|
|
|
ef5584 |
if ($post_data['post_postcount'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$user_posts_sql[$post_data['poster_id']] = (empty($user_posts_sql[$post_data['poster_id']])) ? 1 : $user_posts_sql[$post_data['poster_id']] + 1;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Topic or Post. ;)
|
|
|
ef5584 |
if ($post_data['topic_first_post_id'] == $post_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($post_data['forum_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!isset($forum_topics_posts[$post_data['forum_id']]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_topics_posts[$post_data['forum_id']] = array(
|
|
|
ef5584 |
'forum_posts' => 0,
|
|
|
ef5584 |
'forum_topics' => 0
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$total_topics++;
|
|
|
ef5584 |
$forum_topics_posts[$post_data['forum_id']]['forum_topics']++;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$topic_approve_sql[] = $post_data['topic_id'];
|
|
|
ef5584 |
|
|
|
ef5584 |
$approve_log[] = array(
|
|
|
ef5584 |
'type' => 'topic',
|
|
|
ef5584 |
'post_subject' => $post_data['post_subject'],
|
|
|
ef5584 |
'forum_id' => $post_data['forum_id'],
|
|
|
ef5584 |
'topic_id' => $post_data['topic_id'],
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!isset($topic_replies_sql[$post_data['topic_id']]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_replies_sql[$post_data['topic_id']] = 0;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$topic_replies_sql[$post_data['topic_id']]++;
|
|
|
ef5584 |
|
|
|
ef5584 |
$approve_log[] = array(
|
|
|
ef5584 |
'type' => 'post',
|
|
|
ef5584 |
'post_subject' => $post_data['post_subject'],
|
|
|
ef5584 |
'forum_id' => $post_data['forum_id'],
|
|
|
ef5584 |
'topic_id' => $post_data['topic_id'],
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($post_data['forum_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!isset($forum_topics_posts[$post_data['forum_id']]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_topics_posts[$post_data['forum_id']] = array(
|
|
|
ef5584 |
'forum_posts' => 0,
|
|
|
ef5584 |
'forum_topics' => 0
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$total_posts++;
|
|
|
ef5584 |
$forum_topics_posts[$post_data['forum_id']]['forum_posts']++;
|
|
|
ef5584 |
|
|
|
ef5584 |
// Increment by topic_replies if we approve a topic...
|
|
|
ef5584 |
// This works because we do not adjust the topic_replies when re-approving a topic after an edit.
|
|
|
ef5584 |
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$total_posts += $post_data['topic_replies'];
|
|
|
ef5584 |
$forum_topics_posts[$post_data['forum_id']]['forum_posts'] += $post_data['topic_replies'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$post_approve_sql[] = $post_id;
|
|
|
ef5584 |
|
|
|
ef5584 |
// If the post is newer than the last post information stored we need to update the forum information
|
|
|
ef5584 |
if ($post_data['post_time'] >= $post_data['forum_last_post_time'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$update_forum_information = true;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($topic_approve_sql))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
|
ef5584 |
SET topic_approved = 1
|
|
|
ef5584 |
WHERE ' . $db->sql_in_set('topic_id', $topic_approve_sql);
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($post_approve_sql))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'UPDATE ' . POSTS_TABLE . '
|
|
|
ef5584 |
SET post_approved = 1
|
|
|
ef5584 |
WHERE ' . $db->sql_in_set('post_id', $post_approve_sql);
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($approve_log as $log_data)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_APPROVED' : 'LOG_POST_APPROVED', $log_data['post_subject']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($topic_replies_sql))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
foreach ($topic_replies_sql as $topic_id => $num_replies)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
|
|
ef5584 |
SET topic_replies = topic_replies + $num_replies
|
|
|
ef5584 |
WHERE topic_id = $topic_id";
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($forum_topics_posts))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
foreach ($forum_topics_posts as $forum_id => $row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
|
|
ef5584 |
SET ';
|
|
|
ef5584 |
$sql .= ($row['forum_topics']) ? "forum_topics = forum_topics + {$row['forum_topics']}" : '';
|
|
|
ef5584 |
$sql .= ($row['forum_topics'] && $row['forum_posts']) ? ', ' : '';
|
|
|
ef5584 |
$sql .= ($row['forum_posts']) ? "forum_posts = forum_posts + {$row['forum_posts']}" : '';
|
|
|
ef5584 |
$sql .= " WHERE forum_id = $forum_id";
|
|
|
ef5584 |
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($user_posts_sql))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Try to minimize the query count by merging users with the same post count additions
|
|
|
ef5584 |
$user_posts_update = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($user_posts_sql as $user_id => $user_posts)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$user_posts_update[$user_posts][] = $user_id;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($user_posts_update as $user_posts => $user_id_ary)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'UPDATE ' . USERS_TABLE . '
|
|
|
ef5584 |
SET user_posts = user_posts + ' . $user_posts . '
|
|
|
ef5584 |
WHERE ' . $db->sql_in_set('user_id', $user_id_ary);
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($total_topics)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
set_config('num_topics', $config['num_topics'] + $total_topics, true);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($total_posts)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
set_config('num_posts', $config['num_posts'] + $total_posts, true);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
unset($topic_approve_sql, $topic_replies_sql, $post_approve_sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
update_post_information('topic', array_keys($topic_id_list));
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($update_forum_information)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
update_post_information('forum', array_keys($forum_id_list));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
unset($topic_id_list, $forum_id_list);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger = new messenger();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Notify Poster?
|
|
|
ef5584 |
if ($notify_poster)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
foreach ($post_info as $post_id => $post_data)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($post_data['poster_id'] == ANONYMOUS)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
continue;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$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';
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->template($email_template, $post_data['user_lang']);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->to($post_data['user_email'], $post_data['username']);
|
|
|
ef5584 |
$messenger->im($post_data['user_jabber'], $post_data['username']);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->assign_vars(array(
|
|
|
ef5584 |
'USERNAME' => htmlspecialchars_decode($post_data['username']),
|
|
|
ef5584 |
'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])),
|
|
|
ef5584 |
'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])),
|
|
|
ef5584 |
|
|
|
ef5584 |
'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&e=0",
|
|
|
ef5584 |
'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&p=$post_id&e=$post_id")
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->send($post_data['user_notify_type']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->save_queue();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Send out normal user notifications
|
|
|
ef5584 |
$email_sig = str_replace(' ', "\n", "-- \n" . $config['board_email_sig']);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($post_info as $post_id => $post_data)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Forum Notifications
|
|
|
ef5584 |
user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Topic Notifications
|
|
|
ef5584 |
user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($post_id_list) == 1)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$post_data = $post_info[$post_id_list[0]];
|
|
|
ef5584 |
$post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$post_data['forum_id']}&t={$post_data['topic_id']}&p={$post_data['post_id']}") . '#p' . $post_data['post_id'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
unset($post_info);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($total_topics)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$success_msg = ($total_topics == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$success_msg = (sizeof($post_id_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$show_notify = false;
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($post_info as $post_data)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($post_data['poster_id'] == ANONYMOUS)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
continue;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$show_notify = true;
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_NOTIFY_POSTER' => $show_notify,
|
|
|
ef5584 |
'S_APPROVE' => true)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
confirm_box(false, 'APPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$redirect = request_var('redirect', "index.$phpEx");
|
|
|
ef5584 |
$redirect = reapply_sid($redirect);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$success_msg)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
redirect($redirect);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
meta_refresh(3, $redirect);
|
|
|
ef5584 |
|
|
|
ef5584 |
// If approving one post, also give links back to post...
|
|
|
ef5584 |
$add_message = '';
|
|
|
ef5584 |
if (sizeof($post_id_list) == 1 && !empty($post_url))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$add_message = '
' . sprintf($user->lang['RETURN_POST'], '', '');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
trigger_error($user->lang[$success_msg] . '
' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Disapprove Post/Topic
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function disapprove_post($post_id_list, $id, $mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $db, $template, $user, $config;
|
|
|
ef5584 |
global $phpEx, $phpbb_root_path;
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve')))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('NOT_AUTHORISED');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$redirect = request_var('redirect', build_url(array('t', 'mode', 'quickmod')) . "&mode=$mode");
|
|
|
ef5584 |
$reason = utf8_normalize_nfc(request_var('reason', '', true));
|
|
|
ef5584 |
$reason_id = request_var('reason_id', 0);
|
|
|
ef5584 |
$success_msg = $additional_msg = '';
|
|
|
ef5584 |
|
|
|
ef5584 |
$s_hidden_fields = build_hidden_fields(array(
|
|
|
ef5584 |
'i' => $id,
|
|
|
ef5584 |
'mode' => $mode,
|
|
|
ef5584 |
'post_id_list' => $post_id_list,
|
|
|
ef5584 |
'action' => 'disapprove',
|
|
|
ef5584 |
'redirect' => $redirect)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false;
|
|
|
ef5584 |
$disapprove_reason = '';
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($reason_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'SELECT reason_title, reason_description
|
|
|
ef5584 |
FROM ' . REPORTS_REASONS_TABLE . "
|
|
|
ef5584 |
WHERE reason_id = $reason_id";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$row || (!$reason && strtolower($row['reason_title']) == 'other'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$additional_msg = $user->lang['NO_REASON_DISAPPROVAL'];
|
|
|
ef5584 |
unset($_POST['confirm']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// If the reason is defined within the language file, we will use the localized version, else just use the database entry...
|
|
|
ef5584 |
$disapprove_reason = (strtolower($row['reason_title']) != 'other') ? ((isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description']) : '';
|
|
|
ef5584 |
$disapprove_reason .= ($reason) ? "\n\n" . $reason : '';
|
|
|
ef5584 |
|
|
|
ef5584 |
if (isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$disapprove_reason_lang = strtoupper($row['reason_title']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$email_disapprove_reason = $disapprove_reason;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$post_info = get_post_data($post_id_list, 'm_approve');
|
|
|
ef5584 |
|
|
|
ef5584 |
if (confirm_box(true))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
|
|
|
ef5584 |
// If Topic -> forum_topics_real -= 1
|
|
|
ef5584 |
// If Post -> topic_replies_real -= 1
|
|
|
ef5584 |
|
|
|
ef5584 |
$num_disapproved = 0;
|
|
|
ef5584 |
$forum_topics_real = $topic_id_list = $forum_id_list = $topic_replies_real_sql = $post_disapprove_sql = $disapprove_log = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($post_info as $post_id => $post_data)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_id_list[$post_data['topic_id']] = 1;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($post_data['forum_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_id_list[$post_data['forum_id']] = 1;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Topic or Post. ;)
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @todo this probably is a different method than the one used by delete_posts, does this cause counter inconsistency?
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($post_data['forum_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!isset($forum_topics_real[$post_data['forum_id']]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_topics_real[$post_data['forum_id']] = 0;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$forum_topics_real[$post_data['forum_id']]++;
|
|
|
ef5584 |
$num_disapproved++;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$disapprove_log[] = array(
|
|
|
ef5584 |
'type' => 'topic',
|
|
|
ef5584 |
'post_subject' => $post_data['post_subject'],
|
|
|
ef5584 |
'forum_id' => $post_data['forum_id'],
|
|
|
ef5584 |
'topic_id' => 0, // useless to log a topic id, as it will be deleted
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!isset($topic_replies_real_sql[$post_data['topic_id']]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_replies_real_sql[$post_data['topic_id']] = 0;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$topic_replies_real_sql[$post_data['topic_id']]++;
|
|
|
ef5584 |
|
|
|
ef5584 |
$disapprove_log[] = array(
|
|
|
ef5584 |
'type' => 'post',
|
|
|
ef5584 |
'post_subject' => $post_data['post_subject'],
|
|
|
ef5584 |
'forum_id' => $post_data['forum_id'],
|
|
|
ef5584 |
'topic_id' => $post_data['topic_id'],
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$post_disapprove_sql[] = $post_id;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
unset($post_data);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($forum_topics_real))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
foreach ($forum_topics_real as $forum_id => $topics_real)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
|
ef5584 |
SET forum_topics_real = forum_topics_real - $topics_real
|
|
|
ef5584 |
WHERE forum_id = $forum_id";
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($topic_replies_real_sql))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
foreach ($topic_replies_real_sql as $topic_id => $num_replies)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
|
|
ef5584 |
SET topic_replies_real = topic_replies_real - $num_replies
|
|
|
ef5584 |
WHERE topic_id = $topic_id";
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($post_disapprove_sql))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!function_exists('delete_posts'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
|
|
|
ef5584 |
delete_posts('post_id', $post_disapprove_sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($disapprove_log as $log_data)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED', $log_data['post_subject'], $disapprove_reason);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
unset($post_disapprove_sql, $topic_replies_real_sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
update_post_information('topic', array_keys($topic_id_list));
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($forum_id_list))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
update_post_information('forum', array_keys($forum_id_list));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
unset($topic_id_list, $forum_id_list);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger = new messenger();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Notify Poster?
|
|
|
ef5584 |
if ($notify_poster)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$lang_reasons = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($post_info as $post_id => $post_data)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($post_data['poster_id'] == ANONYMOUS)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
continue;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (isset($disapprove_reason_lang))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Okay we need to get the reason from the posters language
|
|
|
ef5584 |
if (!isset($lang_reasons[$post_data['user_lang']]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Assign the current users translation as the default, this is not ideal but getting the board default adds another layer of complexity.
|
|
|
ef5584 |
$lang_reasons[$post_data['user_lang']] = $user->lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang];
|
|
|
ef5584 |
|
|
|
ef5584 |
// Only load up the language pack if the language is different to the current one
|
|
|
ef5584 |
if ($post_data['user_lang'] != $user->lang_name && file_exists($phpbb_root_path . '/language/' . $post_data['user_lang'] . '/mcp.' . $phpEx))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Load up the language pack
|
|
|
ef5584 |
$lang = array();
|
|
|
ef5584 |
@include($phpbb_root_path . '/language/' . $post_data['user_lang'] . '/mcp.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
// If we find the reason in this language pack use it
|
|
|
ef5584 |
if (isset($lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$lang_reasons[$post_data['user_lang']] = $lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
unset($lang); // Free memory
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$email_disapprove_reason = $lang_reasons[$post_data['user_lang']];
|
|
|
ef5584 |
$email_disapprove_reason .= ($reason) ? "\n\n" . $reason : '';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$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';
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->template($email_template, $post_data['user_lang']);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->to($post_data['user_email'], $post_data['username']);
|
|
|
ef5584 |
$messenger->im($post_data['user_jabber'], $post_data['username']);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->assign_vars(array(
|
|
|
ef5584 |
'USERNAME' => htmlspecialchars_decode($post_data['username']),
|
|
|
ef5584 |
'REASON' => htmlspecialchars_decode($email_disapprove_reason),
|
|
|
ef5584 |
'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])),
|
|
|
ef5584 |
'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->send($post_data['user_notify_type']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
unset($lang_reasons);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
unset($post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->save_queue();
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($forum_topics_real))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$success_msg = ($num_disapproved == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$success_msg = (sizeof($post_id_list) == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
display_reasons($reason_id);
|
|
|
ef5584 |
|
|
|
ef5584 |
$show_notify = false;
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($post_info as $post_data)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($post_data['poster_id'] == ANONYMOUS)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
continue;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$show_notify = true;
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_NOTIFY_POSTER' => $show_notify,
|
|
|
ef5584 |
'S_APPROVE' => false,
|
|
|
ef5584 |
'REASON' => $reason,
|
|
|
ef5584 |
'ADDITIONAL_MSG' => $additional_msg)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
confirm_box(false, 'DISAPPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$redirect = request_var('redirect', "index.$phpEx");
|
|
|
ef5584 |
$redirect = reapply_sid($redirect);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$success_msg)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
redirect($redirect);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
meta_refresh(3, $redirect);
|
|
|
ef5584 |
trigger_error($user->lang[$success_msg] . '
' . sprintf($user->lang['RETURN_PAGE'], "", ''));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
?>
|