PDF rausgenommen
This commit is contained in:
36
msd2/phpBB3/includes/mcp/info/mcp_ban.php
Normal file
36
msd2/phpBB3/includes/mcp/info/mcp_ban.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
class mcp_ban_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'mcp_ban',
|
||||
'title' => 'MCP_BAN',
|
||||
'modes' => array(
|
||||
'user' => array('title' => 'MCP_BAN_USERNAMES', 'auth' => 'acl_m_ban', 'cat' => array('MCP_BAN')),
|
||||
'ip' => array('title' => 'MCP_BAN_IPS', 'auth' => 'acl_m_ban', 'cat' => array('MCP_BAN')),
|
||||
'email' => array('title' => 'MCP_BAN_EMAILS', 'auth' => 'acl_m_ban', 'cat' => array('MCP_BAN')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
36
msd2/phpBB3/includes/mcp/info/mcp_logs.php
Normal file
36
msd2/phpBB3/includes/mcp/info/mcp_logs.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
class mcp_logs_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'mcp_logs',
|
||||
'title' => 'MCP_LOGS',
|
||||
'modes' => array(
|
||||
'front' => array('title' => 'MCP_LOGS_FRONT', 'auth' => 'acl_m_ || aclf_m_', 'cat' => array('MCP_LOGS')),
|
||||
'forum_logs' => array('title' => 'MCP_LOGS_FORUM_VIEW', 'auth' => 'acl_m_,$id', 'cat' => array('MCP_LOGS')),
|
||||
'topic_logs' => array('title' => 'MCP_LOGS_TOPIC_VIEW', 'auth' => 'acl_m_,$id', 'cat' => array('MCP_LOGS')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
37
msd2/phpBB3/includes/mcp/info/mcp_main.php
Normal file
37
msd2/phpBB3/includes/mcp/info/mcp_main.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
class mcp_main_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'mcp_main',
|
||||
'title' => 'MCP_MAIN',
|
||||
'modes' => array(
|
||||
'front' => array('title' => 'MCP_MAIN_FRONT', 'auth' => '', 'cat' => array('MCP_MAIN')),
|
||||
'forum_view' => array('title' => 'MCP_MAIN_FORUM_VIEW', 'auth' => 'acl_m_,$id', 'cat' => array('MCP_MAIN')),
|
||||
'topic_view' => array('title' => 'MCP_MAIN_TOPIC_VIEW', 'auth' => 'acl_m_,$id', 'cat' => array('MCP_MAIN')),
|
||||
'post_details' => array('title' => 'MCP_MAIN_POST_DETAILS', 'auth' => 'acl_m_,$id || (!$id && aclf_m_)', 'cat' => array('MCP_MAIN')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
35
msd2/phpBB3/includes/mcp/info/mcp_notes.php
Normal file
35
msd2/phpBB3/includes/mcp/info/mcp_notes.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
class mcp_notes_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'mcp_notes',
|
||||
'title' => 'MCP_NOTES',
|
||||
'modes' => array(
|
||||
'front' => array('title' => 'MCP_NOTES_FRONT', 'auth' => '', 'cat' => array('MCP_NOTES')),
|
||||
'user_notes' => array('title' => 'MCP_NOTES_USER', 'auth' => '', 'cat' => array('MCP_NOTES')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
36
msd2/phpBB3/includes/mcp/info/mcp_pm_reports.php
Normal file
36
msd2/phpBB3/includes/mcp/info/mcp_pm_reports.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
class mcp_pm_reports_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'mcp_pm_reports',
|
||||
'title' => 'MCP_PM_REPORTS',
|
||||
'modes' => array(
|
||||
'pm_reports' => array('title' => 'MCP_PM_REPORTS_OPEN', 'auth' => 'acl_m_pm_report', 'cat' => array('MCP_REPORTS')),
|
||||
'pm_reports_closed' => array('title' => 'MCP_PM_REPORTS_CLOSED', 'auth' => 'acl_m_pm_report', 'cat' => array('MCP_REPORTS')),
|
||||
'pm_report_details' => array('title' => 'MCP_PM_REPORT_DETAILS', 'auth' => 'acl_m_pm_report', 'cat' => array('MCP_REPORTS')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
38
msd2/phpBB3/includes/mcp/info/mcp_queue.php
Normal file
38
msd2/phpBB3/includes/mcp/info/mcp_queue.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
class mcp_queue_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'mcp_queue',
|
||||
'title' => 'MCP_QUEUE',
|
||||
'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')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
36
msd2/phpBB3/includes/mcp/info/mcp_reports.php
Normal file
36
msd2/phpBB3/includes/mcp/info/mcp_reports.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
class mcp_reports_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'mcp_reports',
|
||||
'title' => 'MCP_REPORTS',
|
||||
'modes' => array(
|
||||
'reports' => array('title' => 'MCP_REPORTS_OPEN', 'auth' => 'aclf_m_report', 'cat' => array('MCP_REPORTS')),
|
||||
'reports_closed' => array('title' => 'MCP_REPORTS_CLOSED', 'auth' => 'aclf_m_report', 'cat' => array('MCP_REPORTS')),
|
||||
'report_details' => array('title' => 'MCP_REPORT_DETAILS', 'auth' => 'acl_m_report,$id || (!$id && aclf_m_report)', 'cat' => array('MCP_REPORTS')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
37
msd2/phpBB3/includes/mcp/info/mcp_warn.php
Normal file
37
msd2/phpBB3/includes/mcp/info/mcp_warn.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
class mcp_warn_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'mcp_warn',
|
||||
'title' => 'MCP_WARN',
|
||||
'modes' => array(
|
||||
'front' => array('title' => 'MCP_WARN_FRONT', 'auth' => 'aclf_m_warn', 'cat' => array('MCP_WARN')),
|
||||
'list' => array('title' => 'MCP_WARN_LIST', 'auth' => 'aclf_m_warn', 'cat' => array('MCP_WARN')),
|
||||
'warn_user' => array('title' => 'MCP_WARN_USER', 'auth' => 'aclf_m_warn', 'cat' => array('MCP_WARN')),
|
||||
'warn_post' => array('title' => 'MCP_WARN_POST', 'auth' => 'acl_m_warn && acl_f_read,$id', 'cat' => array('MCP_WARN')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
298
msd2/phpBB3/includes/mcp/mcp_ban.php
Normal file
298
msd2/phpBB3/includes/mcp/mcp_ban.php
Normal file
@ -0,0 +1,298 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class mcp_ban
|
||||
{
|
||||
var $u_action;
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $db, $user, $auth, $template, $request, $phpbb_dispatcher;
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
if (!function_exists('user_ban'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||
}
|
||||
|
||||
// Include the admin banning interface...
|
||||
include($phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx);
|
||||
|
||||
$bansubmit = $request->is_set_post('bansubmit');
|
||||
$unbansubmit = $request->is_set_post('unbansubmit');
|
||||
|
||||
$user->add_lang(array('acp/ban', 'acp/users'));
|
||||
$this->tpl_name = 'mcp_ban';
|
||||
|
||||
/**
|
||||
* Use this event to pass perform actions when a ban is issued or revoked
|
||||
*
|
||||
* @event core.mcp_ban_main
|
||||
* @var bool bansubmit True if a ban is issued
|
||||
* @var bool unbansubmit True if a ban is removed
|
||||
* @var string mode Mode of the ban that is being worked on
|
||||
* @since 3.1.0-RC5
|
||||
*/
|
||||
$vars = array(
|
||||
'bansubmit',
|
||||
'unbansubmit',
|
||||
'mode',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_ban_main', compact($vars)));
|
||||
|
||||
// Ban submitted?
|
||||
if ($bansubmit)
|
||||
{
|
||||
// Grab the list of entries
|
||||
$ban = $request->variable('ban', '', $mode === 'user');
|
||||
$ban_length = $request->variable('banlength', 0);
|
||||
$ban_length_other = $request->variable('banlengthother', '');
|
||||
$ban_exclude = $request->variable('banexclude', 0);
|
||||
$ban_reason = $request->variable('banreason', '', true);
|
||||
$ban_give_reason = $request->variable('bangivereason', '', true);
|
||||
|
||||
if ($ban)
|
||||
{
|
||||
if (confirm_box(true))
|
||||
{
|
||||
$abort_ban = false;
|
||||
/**
|
||||
* Use this event to modify the ban details before the ban is performed
|
||||
*
|
||||
* @event core.mcp_ban_before
|
||||
* @var string mode One of the following: user, ip, email
|
||||
* @var string ban Either string or array with usernames, ips or email addresses
|
||||
* @var int ban_length Ban length in minutes
|
||||
* @var string ban_length_other Ban length as a date (YYYY-MM-DD)
|
||||
* @var bool ban_exclude Are we banning or excluding from another ban
|
||||
* @var string ban_reason Ban reason displayed to moderators
|
||||
* @var string ban_give_reason Ban reason displayed to the banned user
|
||||
* @var mixed abort_ban Either false, or an error message that is displayed to the user.
|
||||
* If a string is given the bans are not issued.
|
||||
* @since 3.1.0-RC5
|
||||
*/
|
||||
$vars = array(
|
||||
'mode',
|
||||
'ban',
|
||||
'ban_length',
|
||||
'ban_length_other',
|
||||
'ban_exclude',
|
||||
'ban_reason',
|
||||
'ban_give_reason',
|
||||
'abort_ban',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_ban_before', compact($vars)));
|
||||
|
||||
if ($abort_ban)
|
||||
{
|
||||
trigger_error($abort_ban);
|
||||
}
|
||||
user_ban($mode, $ban, $ban_length, $ban_length_other, $ban_exclude, $ban_reason, $ban_give_reason);
|
||||
|
||||
/**
|
||||
* Use this event to perform actions after the ban has been performed
|
||||
*
|
||||
* @event core.mcp_ban_after
|
||||
* @var string mode One of the following: user, ip, email
|
||||
* @var string ban Either string or array with usernames, ips or email addresses
|
||||
* @var int ban_length Ban length in minutes
|
||||
* @var string ban_length_other Ban length as a date (YYYY-MM-DD)
|
||||
* @var bool ban_exclude Are we banning or excluding from another ban
|
||||
* @var string ban_reason Ban reason displayed to moderators
|
||||
* @var string ban_give_reason Ban reason displayed to the banned user
|
||||
* @since 3.1.0-RC5
|
||||
*/
|
||||
$vars = array(
|
||||
'mode',
|
||||
'ban',
|
||||
'ban_length',
|
||||
'ban_length_other',
|
||||
'ban_exclude',
|
||||
'ban_reason',
|
||||
'ban_give_reason',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_ban_after', compact($vars)));
|
||||
|
||||
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$hidden_fields = array(
|
||||
'mode' => $mode,
|
||||
'ban' => $ban,
|
||||
'bansubmit' => true,
|
||||
'banlength' => $ban_length,
|
||||
'banlengthother' => $ban_length_other,
|
||||
'banexclude' => $ban_exclude,
|
||||
'banreason' => $ban_reason,
|
||||
'bangivereason' => $ban_give_reason,
|
||||
);
|
||||
|
||||
/**
|
||||
* Use this event to pass data from the ban form to the confirmation screen
|
||||
*
|
||||
* @event core.mcp_ban_confirm
|
||||
* @var array hidden_fields Hidden fields that are passed through the confirm screen
|
||||
* @since 3.1.0-RC5
|
||||
*/
|
||||
$vars = array('hidden_fields');
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_ban_confirm', compact($vars)));
|
||||
|
||||
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($hidden_fields));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($unbansubmit)
|
||||
{
|
||||
$ban = $request->variable('unban', array(''));
|
||||
|
||||
if ($ban)
|
||||
{
|
||||
if (confirm_box(true))
|
||||
{
|
||||
user_unban($mode, $ban);
|
||||
|
||||
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
|
||||
'mode' => $mode,
|
||||
'unbansubmit' => true,
|
||||
'unban' => $ban)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ban length options
|
||||
$ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['UNTIL'] . ' -> ');
|
||||
|
||||
$ban_end_options = '';
|
||||
foreach ($ban_end_text as $length => $text)
|
||||
{
|
||||
$ban_end_options .= '<option value="' . $length . '">' . $text . '</option>';
|
||||
}
|
||||
|
||||
// Define language vars
|
||||
$this->page_title = $user->lang[strtoupper($mode) . '_BAN'];
|
||||
|
||||
$l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN'];
|
||||
$l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN'];
|
||||
$l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN'];
|
||||
$l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN'];
|
||||
$l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED'];
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case 'user':
|
||||
$l_ban_cell = $user->lang['USERNAME'];
|
||||
break;
|
||||
|
||||
case 'ip':
|
||||
$l_ban_cell = $user->lang['IP_HOSTNAME'];
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
$l_ban_cell = $user->lang['EMAIL_ADDRESS'];
|
||||
break;
|
||||
}
|
||||
|
||||
acp_ban::display_ban_options($mode);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'L_TITLE' => $this->page_title,
|
||||
'L_EXPLAIN' => $l_ban_explain,
|
||||
'L_UNBAN_TITLE' => $l_unban_title,
|
||||
'L_UNBAN_EXPLAIN' => $l_unban_explain,
|
||||
'L_BAN_CELL' => $l_ban_cell,
|
||||
'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain,
|
||||
'L_NO_BAN_CELL' => $l_no_ban_cell,
|
||||
|
||||
'S_USERNAME_BAN' => ($mode == 'user') ? true : false,
|
||||
|
||||
'U_ACTION' => $this->u_action,
|
||||
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp_ban&field=ban'),
|
||||
));
|
||||
|
||||
if ($mode === 'email' && !$auth->acl_get('a_user'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// As a "service" we will check if any post id is specified and populate the username of the poster id if given
|
||||
$post_id = $request->variable('p', 0);
|
||||
$user_id = $request->variable('u', 0);
|
||||
$pre_fill = false;
|
||||
|
||||
if ($user_id && $user_id <> ANONYMOUS)
|
||||
{
|
||||
$sql = 'SELECT username, user_email, user_ip
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE user_id = ' . $user_id;
|
||||
$result = $db->sql_query($sql);
|
||||
switch ($mode)
|
||||
{
|
||||
case 'user':
|
||||
$pre_fill = (string) $db->sql_fetchfield('username');
|
||||
break;
|
||||
|
||||
case 'ip':
|
||||
$pre_fill = (string) $db->sql_fetchfield('user_ip');
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
$pre_fill = (string) $db->sql_fetchfield('user_email');
|
||||
break;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
else if ($post_id)
|
||||
{
|
||||
$post_info = phpbb_get_post_data($post_id, 'm_ban');
|
||||
|
||||
if (count($post_info) && !empty($post_info[$post_id]))
|
||||
{
|
||||
switch ($mode)
|
||||
{
|
||||
case 'user':
|
||||
$pre_fill = $post_info[$post_id]['username'];
|
||||
break;
|
||||
|
||||
case 'ip':
|
||||
$pre_fill = $post_info[$post_id]['poster_ip'];
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
$pre_fill = $post_info[$post_id]['user_email'];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($pre_fill)
|
||||
{
|
||||
// left for legacy template compatibility
|
||||
$template->assign_var('USERNAMES', $pre_fill);
|
||||
$template->assign_var('BAN_QUANTIFIER', $pre_fill);
|
||||
}
|
||||
}
|
||||
}
|
548
msd2/phpBB3/includes/mcp/mcp_forum.php
Normal file
548
msd2/phpBB3/includes/mcp/mcp_forum.php
Normal file
@ -0,0 +1,548 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* MCP Forum View
|
||||
*/
|
||||
function mcp_forum_view($id, $mode, $action, $forum_info)
|
||||
{
|
||||
global $template, $db, $user, $auth, $cache, $module;
|
||||
global $phpEx, $phpbb_root_path, $config;
|
||||
global $request, $phpbb_dispatcher, $phpbb_container;
|
||||
|
||||
$user->add_lang(array('viewtopic', 'viewforum'));
|
||||
|
||||
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||
|
||||
// merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action
|
||||
$merge_select = ($action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics') ? true : false;
|
||||
|
||||
$forum_id = $forum_info['forum_id'];
|
||||
$start = $request->variable('start', 0);
|
||||
$topic_id_list = $request->variable('topic_id_list', array(0));
|
||||
$post_id_list = $request->variable('post_id_list', array(0));
|
||||
$source_topic_ids = array($request->variable('t', 0));
|
||||
$to_topic_id = $request->variable('to_topic_id', 0);
|
||||
|
||||
$url_extra = '';
|
||||
$url_extra .= ($forum_id) ? "&f=$forum_id" : '';
|
||||
$url_extra .= ($GLOBALS['topic_id']) ? '&t=' . $GLOBALS['topic_id'] : '';
|
||||
$url_extra .= ($GLOBALS['post_id']) ? '&p=' . $GLOBALS['post_id'] : '';
|
||||
$url_extra .= ($GLOBALS['user_id']) ? '&u=' . $GLOBALS['user_id'] : '';
|
||||
|
||||
$url = append_sid("{$phpbb_root_path}mcp.$phpEx?$url_extra");
|
||||
|
||||
// Resync Topics
|
||||
switch ($action)
|
||||
{
|
||||
case 'resync':
|
||||
$topic_ids = $request->variable('topic_id_list', array(0));
|
||||
mcp_resync_topics($topic_ids);
|
||||
break;
|
||||
|
||||
case 'merge_topics':
|
||||
$source_topic_ids = $topic_id_list;
|
||||
case 'merge_topic':
|
||||
if ($to_topic_id)
|
||||
{
|
||||
merge_topics($forum_id, $source_topic_ids, $to_topic_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get some data in order to execute other actions.
|
||||
*
|
||||
* @event core.mcp_forum_view_before
|
||||
* @var string action The action
|
||||
* @var array forum_info Array with forum infos
|
||||
* @var int start Start value
|
||||
* @var array topic_id_list Array of topics ids
|
||||
* @var array post_id_list Array of posts ids
|
||||
* @var array source_topic_ids Array of source topics ids
|
||||
* @var int to_topic_id Array of destination topics ids
|
||||
* @since 3.1.6-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'action',
|
||||
'forum_info',
|
||||
'start',
|
||||
'topic_id_list',
|
||||
'post_id_list',
|
||||
'source_topic_ids',
|
||||
'to_topic_id',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_forum_view_before', compact($vars)));
|
||||
|
||||
/* @var $pagination \phpbb\pagination */
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
|
||||
$selected_ids = '';
|
||||
if (count($post_id_list) && $action != 'merge_topics')
|
||||
{
|
||||
foreach ($post_id_list as $num => $post_id)
|
||||
{
|
||||
$selected_ids .= '&post_id_list[' . $num . ']=' . $post_id;
|
||||
}
|
||||
}
|
||||
else if (count($topic_id_list) && $action == 'merge_topics')
|
||||
{
|
||||
foreach ($topic_id_list as $num => $topic_id)
|
||||
{
|
||||
$selected_ids .= '&topic_id_list[' . $num . ']=' . $topic_id;
|
||||
}
|
||||
}
|
||||
|
||||
make_jumpbox($url . "&i=$id&action=$action&mode=$mode" . (($merge_select) ? $selected_ids : ''), $forum_id, false, 'm_', true);
|
||||
|
||||
$topics_per_page = ($forum_info['forum_topics_per_page']) ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
|
||||
|
||||
$sort_days = $total = 0;
|
||||
$sort_key = $sort_dir = '';
|
||||
$sort_by_sql = $sort_order_sql = array();
|
||||
phpbb_mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id);
|
||||
|
||||
$forum_topics = ($total == -1) ? $forum_info['forum_topics_approved'] : $total;
|
||||
$limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
|
||||
|
||||
$base_url = $url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : '');
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ACTION' => $action,
|
||||
'FORUM_NAME' => $forum_info['forum_name'],
|
||||
'FORUM_DESCRIPTION' => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield'], $forum_info['forum_desc_options']),
|
||||
|
||||
'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'),
|
||||
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'),
|
||||
'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
|
||||
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
|
||||
|
||||
'S_CAN_REPORT' => $auth->acl_get('m_report', $forum_id),
|
||||
'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id),
|
||||
'S_CAN_RESTORE' => $auth->acl_get('m_approve', $forum_id),
|
||||
'S_CAN_MERGE' => $auth->acl_get('m_merge', $forum_id),
|
||||
'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id),
|
||||
'S_CAN_FORK' => $auth->acl_get('m_', $forum_id),
|
||||
'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id),
|
||||
'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id),
|
||||
'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id),
|
||||
'S_MERGE_SELECT' => ($merge_select) ? true : false,
|
||||
'S_CAN_MAKE_NORMAL' => $auth->acl_gets('f_sticky', 'f_announce', 'f_announce_global', $forum_id),
|
||||
'S_CAN_MAKE_STICKY' => $auth->acl_get('f_sticky', $forum_id),
|
||||
'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id),
|
||||
'S_CAN_MAKE_ANNOUNCE_GLOBAL' => $auth->acl_get('f_announce_global', $forum_id),
|
||||
|
||||
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
|
||||
'U_VIEW_FORUM_LOGS' => ($auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&mode=forum_logs&f=' . $forum_id) : '',
|
||||
|
||||
'S_MCP_ACTION' => $url . "&i=$id&forum_action=$action&mode=$mode&start=$start" . (($merge_select) ? $selected_ids : ''),
|
||||
|
||||
'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics),
|
||||
));
|
||||
|
||||
// Grab icons
|
||||
$icons = $cache->obtain_icons();
|
||||
|
||||
$topic_rows = array();
|
||||
|
||||
if ($config['load_db_lastread'])
|
||||
{
|
||||
$read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')';
|
||||
$read_tracking_select = ', tt.mark_time';
|
||||
}
|
||||
else
|
||||
{
|
||||
$read_tracking_join = $read_tracking_select = '';
|
||||
}
|
||||
|
||||
/* @var $phpbb_content_visibility \phpbb\content_visibility */
|
||||
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
|
||||
|
||||
$sql = 'SELECT t.topic_id
|
||||
FROM ' . TOPICS_TABLE . ' t
|
||||
WHERE t.forum_id = ' . $forum_id . '
|
||||
AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . "
|
||||
$limit_time_sql
|
||||
ORDER BY t.topic_type DESC, $sort_order_sql";
|
||||
|
||||
/**
|
||||
* Modify SQL query before MCP forum view topic list is queried
|
||||
*
|
||||
* @event core.mcp_view_forum_modify_sql
|
||||
* @var string sql SQL query for forum view topic list
|
||||
* @var int forum_id ID of the forum
|
||||
* @var string limit_time_sql SQL query part for limit time
|
||||
* @var string sort_order_sql SQL query part for sort order
|
||||
* @var int topics_per_page Number of topics per page
|
||||
* @var int start Start value
|
||||
* @since 3.1.2-RC1
|
||||
*/
|
||||
$vars = array('sql', 'forum_id', 'limit_time_sql', 'sort_order_sql', 'topics_per_page', 'start');
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_sql', compact($vars)));
|
||||
|
||||
$result = $db->sql_query_limit($sql, $topics_per_page, $start);
|
||||
|
||||
$topic_list = $topic_tracking_info = array();
|
||||
|
||||
while ($row_ary = $db->sql_fetchrow($result))
|
||||
{
|
||||
$topic_list[] = $row_ary['topic_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT t.*$read_tracking_select
|
||||
FROM " . TOPICS_TABLE . " t $read_tracking_join
|
||||
WHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true);
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
while ($row_ary = $db->sql_fetchrow($result))
|
||||
{
|
||||
$topic_rows[$row_ary['topic_id']] = $row_ary;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync
|
||||
if (!count($topic_list) && $forum_topics && $start > 0)
|
||||
{
|
||||
redirect($url . "&i=$id&action=$action&mode=$mode");
|
||||
}
|
||||
|
||||
// Get topic tracking info
|
||||
if (count($topic_list))
|
||||
{
|
||||
if ($config['load_db_lastread'])
|
||||
{
|
||||
$topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($topic_list as $topic_id)
|
||||
{
|
||||
$row_ary = &$topic_rows[$topic_id];
|
||||
|
||||
$replies = $phpbb_content_visibility->get_count('topic_posts', $row_ary, $forum_id) - 1;
|
||||
|
||||
if ($row_ary['topic_status'] == ITEM_MOVED)
|
||||
{
|
||||
$unread_topic = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row_ary['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
||||
}
|
||||
|
||||
// Get folder img, topic status/type related information
|
||||
$folder_img = $folder_alt = $topic_type = '';
|
||||
topic_status($row_ary, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
|
||||
|
||||
$topic_title = censor_text($row_ary['topic_title']);
|
||||
|
||||
$topic_unapproved = (($row_ary['topic_visibility'] == ITEM_UNAPPROVED || $row_ary['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row_ary['forum_id'])) ? true : false;
|
||||
$posts_unapproved = ($row_ary['topic_visibility'] == ITEM_APPROVED && $row_ary['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row_ary['forum_id'])) ? true : false;
|
||||
$topic_deleted = $row_ary['topic_visibility'] == ITEM_DELETED;
|
||||
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&t=' . $row_ary['topic_id'] : '';
|
||||
$u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? $url . '&i=queue&mode=deleted_topics&t=' . $topic_id : $u_mcp_queue;
|
||||
|
||||
$topic_row = array(
|
||||
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row_ary['forum_id']) && $row_ary['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
'TOPIC_IMG_STYLE' => $folder_img,
|
||||
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
|
||||
'TOPIC_ICON_IMG' => (!empty($icons[$row_ary['icon_id']])) ? $icons[$row_ary['icon_id']]['img'] : '',
|
||||
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row_ary['icon_id']])) ? $icons[$row_ary['icon_id']]['width'] : '',
|
||||
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row_ary['icon_id']])) ? $icons[$row_ary['icon_id']]['height'] : '',
|
||||
'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
|
||||
'DELETED_IMG' => ($topic_deleted) ? $user->img('icon_topic_deleted', 'TOPIC_DELETED') : '',
|
||||
|
||||
'TOPIC_AUTHOR' => get_username_string('username', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']),
|
||||
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']),
|
||||
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']),
|
||||
'U_TOPIC_AUTHOR' => get_username_string('profile', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']),
|
||||
|
||||
'LAST_POST_AUTHOR' => get_username_string('username', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']),
|
||||
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']),
|
||||
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']),
|
||||
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']),
|
||||
|
||||
'TOPIC_TYPE' => $topic_type,
|
||||
'TOPIC_TITLE' => $topic_title,
|
||||
'REPLIES' => $phpbb_content_visibility->get_count('topic_posts', $row_ary, $row_ary['forum_id']) - 1,
|
||||
'LAST_POST_TIME' => $user->format_date($row_ary['topic_last_post_time']),
|
||||
'FIRST_POST_TIME' => $user->format_date($row_ary['topic_time']),
|
||||
'LAST_POST_SUBJECT' => $row_ary['topic_last_post_subject'],
|
||||
'LAST_VIEW_TIME' => $user->format_date($row_ary['topic_last_view_time']),
|
||||
|
||||
'S_TOPIC_REPORTED' => (!empty($row_ary['topic_reported']) && empty($row_ary['topic_moved_id']) && $auth->acl_get('m_report', $row_ary['forum_id'])) ? true : false,
|
||||
'S_TOPIC_UNAPPROVED' => $topic_unapproved,
|
||||
'S_POSTS_UNAPPROVED' => $posts_unapproved,
|
||||
'S_TOPIC_DELETED' => $topic_deleted,
|
||||
'S_UNREAD_TOPIC' => $unread_topic,
|
||||
);
|
||||
|
||||
if ($row_ary['topic_status'] == ITEM_MOVED)
|
||||
{
|
||||
$topic_row = array_merge($topic_row, array(
|
||||
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row_ary['topic_moved_id']}"),
|
||||
'U_DELETE_TOPIC' => ($auth->acl_get('m_delete', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&topic_id_list[]={$row_ary['topic_id']}&mode=forum_view&action=delete_topic") : '',
|
||||
'S_MOVED_TOPIC' => true,
|
||||
'TOPIC_ID' => $row_ary['topic_moved_id'],
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($action == 'merge_topic' || $action == 'merge_topics')
|
||||
{
|
||||
$u_select_topic = $url . "&i=$id&mode=forum_view&action=$action&to_topic_id=" . $row_ary['topic_id'] . $selected_ids;
|
||||
}
|
||||
else
|
||||
{
|
||||
$u_select_topic = $url . "&i=$id&mode=topic_view&action=merge&to_topic_id=" . $row_ary['topic_id'] . $selected_ids;
|
||||
}
|
||||
$topic_row = array_merge($topic_row, array(
|
||||
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&t={$row_ary['topic_id']}&mode=topic_view"),
|
||||
|
||||
'S_SELECT_TOPIC' => ($merge_select && !in_array($row_ary['topic_id'], $source_topic_ids)) ? true : false,
|
||||
'U_SELECT_TOPIC' => $u_select_topic,
|
||||
'U_MCP_QUEUE' => $u_mcp_queue,
|
||||
'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&t=' . $row_ary['topic_id'] . '&action=reports') : '',
|
||||
'TOPIC_ID' => $row_ary['topic_id'],
|
||||
'S_TOPIC_CHECKED' => ($topic_id_list && in_array($row_ary['topic_id'], $topic_id_list)) ? true : false,
|
||||
));
|
||||
}
|
||||
|
||||
$row = $row_ary;
|
||||
/**
|
||||
* Modify the topic data before it is assigned to the template in MCP
|
||||
*
|
||||
* @event core.mcp_view_forum_modify_topicrow
|
||||
* @var array row Array with topic data
|
||||
* @var array topic_row Template array with topic data
|
||||
* @since 3.1.0-a1
|
||||
*/
|
||||
$vars = array('row', 'topic_row');
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars)));
|
||||
$row_ary = $row;
|
||||
unset($row);
|
||||
|
||||
$template->assign_block_vars('topicrow', $topic_row);
|
||||
}
|
||||
unset($topic_rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resync topics
|
||||
*/
|
||||
function mcp_resync_topics($topic_ids)
|
||||
{
|
||||
global $db, $user, $phpbb_log, $request;
|
||||
|
||||
if (!count($topic_ids))
|
||||
{
|
||||
trigger_error('NO_TOPIC_SELECTED');
|
||||
}
|
||||
|
||||
if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Sync everything and perform extra checks separately
|
||||
sync('topic_reported', 'topic_id', $topic_ids, false, true);
|
||||
sync('topic_attachment', 'topic_id', $topic_ids, false, true);
|
||||
sync('topic', 'topic_id', $topic_ids, true, false);
|
||||
|
||||
$sql = 'SELECT topic_id, forum_id, topic_title
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
// Log this action
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_TOPIC_RESYNC', false, array(
|
||||
'forum_id' => $row['forum_id'],
|
||||
'topic_id' => $row['topic_id'],
|
||||
$row['topic_title']
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$msg = (count($topic_ids) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS'];
|
||||
|
||||
$redirect = $request->variable('redirect', $user->data['session_page']);
|
||||
|
||||
meta_refresh(3, $redirect);
|
||||
trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge selected topics into selected topic
|
||||
*/
|
||||
function merge_topics($forum_id, $topic_ids, $to_topic_id)
|
||||
{
|
||||
global $db, $template, $user, $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher;
|
||||
|
||||
if (!count($topic_ids))
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
|
||||
return;
|
||||
}
|
||||
if (!$to_topic_id)
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
|
||||
return;
|
||||
}
|
||||
|
||||
$sync_topics = array_merge($topic_ids, array($to_topic_id));
|
||||
|
||||
$all_topic_data = phpbb_get_topic_data($sync_topics, 'm_merge');
|
||||
|
||||
if (!count($all_topic_data) || empty($all_topic_data[$to_topic_id]))
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
|
||||
return;
|
||||
}
|
||||
|
||||
$sync_forums = array();
|
||||
$topic_views = 0;
|
||||
foreach ($all_topic_data as $data)
|
||||
{
|
||||
$sync_forums[$data['forum_id']] = $data['forum_id'];
|
||||
$topic_views = max($topic_views, $data['topic_views']);
|
||||
}
|
||||
|
||||
$to_topic_data = $all_topic_data[$to_topic_id];
|
||||
|
||||
$post_id_list = $request->variable('post_id_list', array(0));
|
||||
$start = $request->variable('start', 0);
|
||||
|
||||
if (!count($post_id_list) && count($topic_ids))
|
||||
{
|
||||
$sql = 'SELECT post_id
|
||||
FROM ' . POSTS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$post_id_list = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$post_id_list[] = $row['post_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
if (!count($post_id_list))
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge')))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$redirect = $request->variable('redirect', "{$phpbb_root_path}mcp.$phpEx?f=$forum_id&i=main&mode=forum_view");
|
||||
|
||||
$s_hidden_fields = build_hidden_fields(array(
|
||||
'i' => 'main',
|
||||
'f' => $forum_id,
|
||||
'post_id_list' => $post_id_list,
|
||||
'to_topic_id' => $to_topic_id,
|
||||
'mode' => 'forum_view',
|
||||
'action' => 'merge_topics',
|
||||
'start' => $start,
|
||||
'redirect' => $redirect,
|
||||
'topic_id_list' => $topic_ids)
|
||||
);
|
||||
$return_link = '';
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
$to_forum_id = $to_topic_data['forum_id'];
|
||||
|
||||
move_posts($post_id_list, $to_topic_id, false);
|
||||
|
||||
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MERGE', false, array(
|
||||
'forum_id' => $to_forum_id,
|
||||
'topic_id' => $to_topic_id,
|
||||
$to_topic_data['topic_title']
|
||||
));
|
||||
|
||||
// Update topic views count
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
||||
SET topic_views = ' . $topic_views . '
|
||||
WHERE topic_id = ' . $to_topic_id;
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Message and return links
|
||||
$success_msg = 'POSTS_MERGED_SUCCESS';
|
||||
|
||||
if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx);
|
||||
}
|
||||
|
||||
// Update the topic watch table.
|
||||
phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id);
|
||||
|
||||
// Update the bookmarks table.
|
||||
phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $topic_ids, $to_topic_id);
|
||||
|
||||
// Re-sync the topics and forums because the auto-sync was deactivated in the call of move_posts()
|
||||
sync('topic_reported', 'topic_id', $sync_topics);
|
||||
sync('topic_attachment', 'topic_id', $sync_topics);
|
||||
sync('topic', 'topic_id', $sync_topics, true);
|
||||
sync('forum', 'forum_id', $sync_forums, true, true);
|
||||
|
||||
// Link to the new topic
|
||||
$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>');
|
||||
$redirect = $request->variable('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id");
|
||||
$redirect = reapply_sid($redirect);
|
||||
|
||||
/**
|
||||
* Perform additional actions after merging topics.
|
||||
*
|
||||
* @event core.mcp_forum_merge_topics_after
|
||||
* @var array all_topic_data The data from all topics involved in the merge
|
||||
* @var int to_topic_id The ID of the topic into which the rest are merged
|
||||
* @since 3.1.11-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'all_topic_data',
|
||||
'to_topic_id',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_forum_merge_topics_after', compact($vars)));
|
||||
|
||||
meta_refresh(3, $redirect);
|
||||
trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields);
|
||||
}
|
||||
}
|
391
msd2/phpBB3/includes/mcp/mcp_front.php
Normal file
391
msd2/phpBB3/includes/mcp/mcp_front.php
Normal file
@ -0,0 +1,391 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* MCP Front Panel
|
||||
*/
|
||||
function mcp_front_view($id, $mode, $action)
|
||||
{
|
||||
global $phpEx, $phpbb_root_path;
|
||||
global $template, $db, $user, $auth, $module;
|
||||
global $phpbb_dispatcher, $request;
|
||||
|
||||
// Latest 5 unapproved
|
||||
if ($module->loaded('queue'))
|
||||
{
|
||||
$forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_approve')));
|
||||
$post_list = array();
|
||||
$forum_names = array();
|
||||
|
||||
$forum_id = $request->variable('f', 0);
|
||||
|
||||
$template->assign_var('S_SHOW_UNAPPROVED', (!empty($forum_list)) ? true : false);
|
||||
|
||||
if (!empty($forum_list))
|
||||
{
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'COUNT(post_id) AS total',
|
||||
'FROM' => array(
|
||||
POSTS_TABLE => 'p',
|
||||
),
|
||||
'WHERE' => $db->sql_in_set('p.forum_id', $forum_list) . '
|
||||
AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE))
|
||||
);
|
||||
|
||||
/**
|
||||
* Allow altering the query to get the number of unapproved posts
|
||||
*
|
||||
* @event core.mcp_front_queue_unapproved_total_before
|
||||
* @var array sql_ary Query array to get the total number of unapproved posts
|
||||
* @var array forum_list List of forums to look for unapproved posts
|
||||
* @since 3.1.5-RC1
|
||||
*/
|
||||
$vars = array('sql_ary', 'forum_list');
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_front_queue_unapproved_total_before', compact($vars)));
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query($sql);
|
||||
$total = (int) $db->sql_fetchfield('total');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($total)
|
||||
{
|
||||
$sql = 'SELECT forum_id, forum_name
|
||||
FROM ' . FORUMS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('forum_id', $forum_list);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forum_names[$row['forum_id']] = $row['forum_name'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = 'SELECT post_id
|
||||
FROM ' . POSTS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('forum_id', $forum_list) . '
|
||||
AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . '
|
||||
ORDER BY post_time DESC, post_id DESC';
|
||||
$result = $db->sql_query_limit($sql, 5);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$post_list[] = $row['post_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (empty($post_list))
|
||||
{
|
||||
$total = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter list of posts and total as required
|
||||
*
|
||||
* @event core.mcp_front_view_queue_postid_list_after
|
||||
* @var int total Number of unapproved posts
|
||||
* @var array post_list List of unapproved posts
|
||||
* @var array forum_list List of forums that contain the posts
|
||||
* @var array forum_names Associative array with forum_id as key and it's corresponding forum_name as value
|
||||
* @since 3.1.0-RC3
|
||||
*/
|
||||
$vars = array('total', 'post_list', 'forum_list', 'forum_names');
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_front_view_queue_postid_list_after', compact($vars)));
|
||||
|
||||
if ($total)
|
||||
{
|
||||
$sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.post_attachment, p.poster_id, p.post_username, u.username, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id
|
||||
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
|
||||
WHERE ' . $db->sql_in_set('p.post_id', $post_list) . '
|
||||
AND t.topic_id = p.topic_id
|
||||
AND p.poster_id = u.user_id
|
||||
ORDER BY p.post_time DESC, p.post_id DESC';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_block_vars('unapproved', array(
|
||||
'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $row['forum_id'] . '&p=' . $row['post_id']),
|
||||
'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view&f=' . $row['forum_id']),
|
||||
'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
|
||||
'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
|
||||
'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
|
||||
|
||||
'AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']),
|
||||
'AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour']),
|
||||
'AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour']),
|
||||
'U_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour']),
|
||||
|
||||
'FORUM_NAME' => $forum_names[$row['forum_id']],
|
||||
'POST_ID' => $row['post_id'],
|
||||
'TOPIC_TITLE' => $row['topic_title'],
|
||||
'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
|
||||
'POST_TIME' => $user->format_date($row['post_time']),
|
||||
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$s_hidden_fields = build_hidden_fields(array(
|
||||
'redirect' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main' . (($forum_id) ? '&f=' . $forum_id : ''))
|
||||
));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_HIDDEN_FIELDS' => $s_hidden_fields,
|
||||
'S_MCP_QUEUE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue"),
|
||||
'L_UNAPPROVED_TOTAL' => $user->lang('UNAPPROVED_POSTS_TOTAL', (int) $total),
|
||||
'S_HAS_UNAPPROVED_POSTS'=> ($total != 0),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// Latest 5 reported
|
||||
if ($module->loaded('reports'))
|
||||
{
|
||||
$forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_report')));
|
||||
|
||||
$template->assign_var('S_SHOW_REPORTS', (!empty($forum_list)) ? true : false);
|
||||
|
||||
if (!empty($forum_list))
|
||||
{
|
||||
$sql = 'SELECT COUNT(r.report_id) AS total
|
||||
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
|
||||
WHERE r.post_id = p.post_id
|
||||
AND r.pm_id = 0
|
||||
AND r.report_closed = 0
|
||||
AND ' . $db->sql_in_set('p.forum_id', $forum_list);
|
||||
|
||||
/**
|
||||
* Alter sql query to count the number of reported posts
|
||||
*
|
||||
* @event core.mcp_front_reports_count_query_before
|
||||
* @var string sql The query string used to get the number of reports that exist
|
||||
* @var array forum_list List of forums that contain the posts
|
||||
* @since 3.1.5-RC1
|
||||
*/
|
||||
$vars = array('sql', 'forum_list');
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_count_query_before', compact($vars)));
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
$total = (int) $db->sql_fetchfield('total');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($total)
|
||||
{
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name',
|
||||
|
||||
'FROM' => array(
|
||||
REPORTS_TABLE => 'r',
|
||||
REPORTS_REASONS_TABLE => 'rr',
|
||||
TOPICS_TABLE => 't',
|
||||
USERS_TABLE => array('u', 'u2'),
|
||||
POSTS_TABLE => 'p',
|
||||
),
|
||||
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(FORUMS_TABLE => 'f'),
|
||||
'ON' => 'f.forum_id = p.forum_id',
|
||||
),
|
||||
),
|
||||
|
||||
'WHERE' => 'r.post_id = p.post_id
|
||||
AND r.pm_id = 0
|
||||
AND r.report_closed = 0
|
||||
AND r.reason_id = rr.reason_id
|
||||
AND p.topic_id = t.topic_id
|
||||
AND r.user_id = u.user_id
|
||||
AND p.poster_id = u2.user_id
|
||||
AND ' . $db->sql_in_set('p.forum_id', $forum_list),
|
||||
|
||||
'ORDER_BY' => 'p.post_time DESC, p.post_id DESC',
|
||||
);
|
||||
|
||||
/**
|
||||
* Alter sql query to get latest reported posts
|
||||
*
|
||||
* @event core.mcp_front_reports_listing_query_before
|
||||
* @var array sql_ary Associative array with the query to be executed
|
||||
* @var array forum_list List of forums that contain the posts
|
||||
* @since 3.1.0-RC3
|
||||
*/
|
||||
$vars = array('sql_ary', 'forum_list');
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_listing_query_before', compact($vars)));
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query_limit($sql, 5);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_block_vars('report', array(
|
||||
'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id'] . "&i=reports&mode=report_details"),
|
||||
'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&i=$id&mode=forum_view"),
|
||||
'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . "&i=$id&mode=topic_view"),
|
||||
'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
|
||||
'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
|
||||
|
||||
'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
|
||||
'AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']),
|
||||
'AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']),
|
||||
'AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']),
|
||||
'U_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']),
|
||||
|
||||
'FORUM_NAME' => $row['forum_name'],
|
||||
'TOPIC_TITLE' => $row['topic_title'],
|
||||
'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
|
||||
'REPORT_TIME' => $user->format_date($row['report_time']),
|
||||
'POST_TIME' => $user->format_date($row['post_time']),
|
||||
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'L_REPORTS_TOTAL' => $user->lang('REPORTS_TOTAL', (int) $total),
|
||||
'S_HAS_REPORTS' => ($total != 0),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// Latest 5 reported PMs
|
||||
if ($module->loaded('pm_reports') && $auth->acl_get('m_pm_report'))
|
||||
{
|
||||
$template->assign_var('S_SHOW_PM_REPORTS', true);
|
||||
$user->add_lang(array('ucp'));
|
||||
|
||||
$sql = 'SELECT COUNT(r.report_id) AS total
|
||||
FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p
|
||||
WHERE r.post_id = 0
|
||||
AND r.pm_id = p.msg_id
|
||||
AND r.report_closed = 0';
|
||||
$result = $db->sql_query($sql);
|
||||
$total = (int) $db->sql_fetchfield('total');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($total)
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
|
||||
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'r.report_id, r.report_time, p.msg_id, p.message_subject, p.message_time, p.to_address, p.bcc_address, p.message_attachment, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id',
|
||||
|
||||
'FROM' => array(
|
||||
REPORTS_TABLE => 'r',
|
||||
REPORTS_REASONS_TABLE => 'rr',
|
||||
USERS_TABLE => array('u', 'u2'),
|
||||
PRIVMSGS_TABLE => 'p',
|
||||
),
|
||||
|
||||
'WHERE' => 'r.pm_id = p.msg_id
|
||||
AND r.post_id = 0
|
||||
AND r.report_closed = 0
|
||||
AND r.reason_id = rr.reason_id
|
||||
AND r.user_id = u.user_id
|
||||
AND p.author_id = u2.user_id',
|
||||
|
||||
'ORDER_BY' => 'p.message_time DESC',
|
||||
);
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query_limit($sql, 5);
|
||||
|
||||
$pm_by_id = $pm_list = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$pm_by_id[(int) $row['msg_id']] = $row;
|
||||
$pm_list[] = (int) $row['msg_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$address_list = get_recipient_strings($pm_by_id);
|
||||
|
||||
foreach ($pm_list as $message_id)
|
||||
{
|
||||
$row = $pm_by_id[$message_id];
|
||||
|
||||
$template->assign_block_vars('pm_report', array(
|
||||
'U_PM_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'r=' . $row['report_id'] . "&i=pm_reports&mode=pm_report_details"),
|
||||
|
||||
'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
|
||||
'PM_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']),
|
||||
'PM_AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']),
|
||||
'PM_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']),
|
||||
'U_PM_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']),
|
||||
|
||||
'PM_SUBJECT' => $row['message_subject'],
|
||||
'REPORT_TIME' => $user->format_date($row['report_time']),
|
||||
'PM_TIME' => $user->format_date($row['message_time']),
|
||||
'RECIPIENTS' => implode(', ', $address_list[$row['msg_id']]),
|
||||
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $row['message_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'L_PM_REPORTS_TOTAL' => $user->lang('PM_REPORTS_TOTAL', (int) $total),
|
||||
'S_HAS_PM_REPORTS' => ($total != 0),
|
||||
));
|
||||
}
|
||||
|
||||
// Latest 5 logs
|
||||
if ($module->loaded('logs'))
|
||||
{
|
||||
$forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
|
||||
|
||||
if (!empty($forum_list))
|
||||
{
|
||||
$log_count = false;
|
||||
$log = array();
|
||||
view_log('mod', $log, $log_count, 5, 0, $forum_list);
|
||||
|
||||
foreach ($log as $row)
|
||||
{
|
||||
$template->assign_block_vars('log', array(
|
||||
'USERNAME' => $row['username_full'],
|
||||
'IP' => $row['ip'],
|
||||
'TIME' => $user->format_date($row['time']),
|
||||
'ACTION' => $row['action'],
|
||||
'U_VIEW_TOPIC' => (!empty($row['viewtopic'])) ? $row['viewtopic'] : '',
|
||||
'U_VIEWLOGS' => (!empty($row['viewlogs'])) ? $row['viewlogs'] : '')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_SHOW_LOGS' => (!empty($forum_list)) ? true : false,
|
||||
'S_HAS_LOGS' => (!empty($log)) ? true : false)
|
||||
);
|
||||
}
|
||||
|
||||
$template->assign_var('S_MCP_ACTION', append_sid("{$phpbb_root_path}mcp.$phpEx"));
|
||||
make_jumpbox(append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view'), 0, false, 'm_', true);
|
||||
}
|
230
msd2/phpBB3/includes/mcp/mcp_logs.php
Normal file
230
msd2/phpBB3/includes/mcp/mcp_logs.php
Normal file
@ -0,0 +1,230 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* mcp_logs
|
||||
* Handling warning the users
|
||||
*/
|
||||
class mcp_logs
|
||||
{
|
||||
var $u_action;
|
||||
var $p_master;
|
||||
|
||||
function __construct(&$p_master)
|
||||
{
|
||||
$this->p_master = &$p_master;
|
||||
}
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $auth, $db, $user, $template, $request;
|
||||
global $config, $phpbb_container, $phpbb_log;
|
||||
|
||||
$user->add_lang('acp/common');
|
||||
|
||||
$action = $request->variable('action', array('' => ''));
|
||||
|
||||
if (is_array($action))
|
||||
{
|
||||
list($action, ) = each($action);
|
||||
}
|
||||
else
|
||||
{
|
||||
$action = $request->variable('action', '');
|
||||
}
|
||||
|
||||
// Set up general vars
|
||||
$start = $request->variable('start', 0);
|
||||
$deletemark = ($action == 'del_marked') ? true : false;
|
||||
$deleteall = ($action == 'del_all') ? true : false;
|
||||
$marked = $request->variable('mark', array(0));
|
||||
|
||||
// Sort keys
|
||||
$sort_days = $request->variable('st', 0);
|
||||
$sort_key = $request->variable('sk', 't');
|
||||
$sort_dir = $request->variable('sd', 'd');
|
||||
|
||||
$this->tpl_name = 'mcp_logs';
|
||||
$this->page_title = 'MCP_LOGS';
|
||||
|
||||
/* @var $pagination \phpbb\pagination */
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
|
||||
$forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
|
||||
$forum_list[] = 0;
|
||||
|
||||
$forum_id = $topic_id = 0;
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case 'front':
|
||||
break;
|
||||
|
||||
case 'forum_logs':
|
||||
$forum_id = $request->variable('f', 0);
|
||||
|
||||
if (!in_array($forum_id, $forum_list))
|
||||
{
|
||||
send_status_line(403, 'Forbidden');
|
||||
trigger_error('NOT_AUTHORISED');
|
||||
}
|
||||
|
||||
$forum_list = array($forum_id);
|
||||
break;
|
||||
|
||||
case 'topic_logs':
|
||||
$topic_id = $request->variable('t', 0);
|
||||
|
||||
$sql = 'SELECT forum_id
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE topic_id = ' . $topic_id;
|
||||
$result = $db->sql_query($sql);
|
||||
$forum_id = (int) $db->sql_fetchfield('forum_id');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!in_array($forum_id, $forum_list))
|
||||
{
|
||||
send_status_line(403, 'Forbidden');
|
||||
trigger_error('NOT_AUTHORISED');
|
||||
}
|
||||
|
||||
$forum_list = array($forum_id);
|
||||
break;
|
||||
}
|
||||
|
||||
// Delete entries if requested and able
|
||||
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
|
||||
{
|
||||
if (confirm_box(true))
|
||||
{
|
||||
if ($deletemark && count($marked))
|
||||
{
|
||||
$conditions = array(
|
||||
'forum_id' => array('IN' => $forum_list),
|
||||
'log_id' => array('IN' => $marked),
|
||||
);
|
||||
|
||||
$phpbb_log->delete('mod', $conditions);
|
||||
}
|
||||
else if ($deleteall)
|
||||
{
|
||||
$keywords = $request->variable('keywords', '', true);
|
||||
|
||||
$conditions = array(
|
||||
'forum_id' => array('IN' => $forum_list),
|
||||
'keywords' => $keywords,
|
||||
);
|
||||
|
||||
if ($sort_days)
|
||||
{
|
||||
$conditions['log_time'] = array('>=', time() - ($sort_days * 86400));
|
||||
}
|
||||
|
||||
if ($mode == 'topic_logs')
|
||||
{
|
||||
$conditions['topic_id'] = $topic_id;
|
||||
}
|
||||
|
||||
$phpbb_log->delete('mod', $conditions);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
|
||||
'f' => $forum_id,
|
||||
't' => $topic_id,
|
||||
'start' => $start,
|
||||
'delmarked' => $deletemark,
|
||||
'delall' => $deleteall,
|
||||
'mark' => $marked,
|
||||
'st' => $sort_days,
|
||||
'sk' => $sort_key,
|
||||
'sd' => $sort_dir,
|
||||
'i' => $id,
|
||||
'mode' => $mode,
|
||||
'action' => $request->variable('action', array('' => ''))))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Sorting
|
||||
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
|
||||
$sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
|
||||
|
||||
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
|
||||
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
|
||||
|
||||
// Define where and sort sql for use in displaying logs
|
||||
$sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
|
||||
$sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
||||
|
||||
$keywords = $request->variable('keywords', '', true);
|
||||
$keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
|
||||
|
||||
// Grab log data
|
||||
$log_data = array();
|
||||
$log_count = 0;
|
||||
$start = view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $keywords);
|
||||
|
||||
$base_url = $this->u_action . "&$u_sort_param$keywords_param";
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'TOTAL' => $user->lang('TOTAL_LOGS', (int) $log_count),
|
||||
|
||||
'L_TITLE' => $user->lang['MCP_LOGS'],
|
||||
|
||||
'U_POST_ACTION' => $this->u_action . "&$u_sort_param$keywords_param&start=$start",
|
||||
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
|
||||
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
||||
'S_SELECT_SORT_KEY' => $s_sort_key,
|
||||
'S_SELECT_SORT_DAYS' => $s_limit_days,
|
||||
'S_LOGS' => ($log_count > 0),
|
||||
'S_KEYWORDS' => $keywords,
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($log_data as $row)
|
||||
{
|
||||
$data = array();
|
||||
|
||||
$checks = array('viewpost', 'viewtopic', 'viewforum');
|
||||
foreach ($checks as $check)
|
||||
{
|
||||
if (isset($row[$check]) && $row[$check])
|
||||
{
|
||||
$data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_block_vars('log', array(
|
||||
'USERNAME' => $row['username_full'],
|
||||
'IP' => $row['ip'],
|
||||
'DATE' => $user->format_date($row['time']),
|
||||
'ACTION' => $row['action'],
|
||||
'DATA' => (count($data)) ? implode(' | ', $data) : '',
|
||||
'ID' => $row['id'],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
1655
msd2/phpBB3/includes/mcp/mcp_main.php
Normal file
1655
msd2/phpBB3/includes/mcp/mcp_main.php
Normal file
File diff suppressed because it is too large
Load Diff
258
msd2/phpBB3/includes/mcp/mcp_notes.php
Normal file
258
msd2/phpBB3/includes/mcp/mcp_notes.php
Normal file
@ -0,0 +1,258 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* mcp_notes
|
||||
* Displays notes about a user
|
||||
*/
|
||||
class mcp_notes
|
||||
{
|
||||
var $p_master;
|
||||
var $u_action;
|
||||
|
||||
function __construct(&$p_master)
|
||||
{
|
||||
$this->p_master = &$p_master;
|
||||
}
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $user, $template, $request;
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$action = $request->variable('action', array('' => ''));
|
||||
|
||||
if (is_array($action))
|
||||
{
|
||||
list($action, ) = each($action);
|
||||
}
|
||||
|
||||
$this->page_title = 'MCP_NOTES';
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case 'front':
|
||||
$template->assign_vars(array(
|
||||
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp&field=username&select_single=true'),
|
||||
'U_POST_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes'),
|
||||
|
||||
'L_TITLE' => $user->lang['MCP_NOTES'],
|
||||
));
|
||||
|
||||
$this->tpl_name = 'mcp_notes_front';
|
||||
break;
|
||||
|
||||
case 'user_notes':
|
||||
$user->add_lang('acp/common');
|
||||
|
||||
$this->mcp_notes_user_view($action);
|
||||
$this->tpl_name = 'mcp_notes_user';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display user notes
|
||||
*/
|
||||
function mcp_notes_user_view($action)
|
||||
{
|
||||
global $config, $phpbb_log, $request;
|
||||
global $template, $db, $user, $auth, $phpbb_container;
|
||||
|
||||
$user_id = $request->variable('u', 0);
|
||||
$username = $request->variable('username', '', true);
|
||||
$start = $request->variable('start', 0);
|
||||
$st = $request->variable('st', 0);
|
||||
$sk = $request->variable('sk', 'b');
|
||||
$sd = $request->variable('sd', 'd');
|
||||
|
||||
/* @var $pagination \phpbb\pagination */
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
|
||||
add_form_key('mcp_notes');
|
||||
|
||||
$sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE $sql_where";
|
||||
$result = $db->sql_query($sql);
|
||||
$userrow = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$userrow)
|
||||
{
|
||||
trigger_error('NO_USER');
|
||||
}
|
||||
|
||||
$user_id = $userrow['user_id'];
|
||||
|
||||
// Populate user id to the currently active module (this module)
|
||||
// The following method is another way of adjusting module urls. It is the easy variant if we want
|
||||
// to directly adjust the current module url based on data retrieved within the same module.
|
||||
if (strpos($this->u_action, "&u=$user_id") === false)
|
||||
{
|
||||
$this->p_master->adjust_url('&u=' . $user_id);
|
||||
$this->u_action .= "&u=$user_id";
|
||||
}
|
||||
|
||||
$deletemark = ($action == 'del_marked') ? true : false;
|
||||
$deleteall = ($action == 'del_all') ? true : false;
|
||||
$marked = $request->variable('marknote', array(0));
|
||||
$usernote = $request->variable('usernote', '', true);
|
||||
|
||||
// Handle any actions
|
||||
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
|
||||
{
|
||||
$where_sql = '';
|
||||
if ($deletemark && $marked)
|
||||
{
|
||||
$sql_in = array();
|
||||
foreach ($marked as $mark)
|
||||
{
|
||||
$sql_in[] = $mark;
|
||||
}
|
||||
$where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in);
|
||||
unset($sql_in);
|
||||
}
|
||||
|
||||
if ($where_sql || $deleteall)
|
||||
{
|
||||
if (check_form_key('mcp_notes'))
|
||||
{
|
||||
$sql = 'DELETE FROM ' . LOG_TABLE . '
|
||||
WHERE log_type = ' . LOG_USERS . "
|
||||
AND reportee_id = $user_id
|
||||
$where_sql";
|
||||
$db->sql_query($sql);
|
||||
|
||||
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CLEAR_USER', false, array($userrow['username']));
|
||||
|
||||
$msg = ($deletemark) ? 'MARKED_NOTES_DELETED' : 'ALL_NOTES_DELETED';
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = 'FORM_INVALID';
|
||||
}
|
||||
$redirect = $this->u_action . '&u=' . $user_id;
|
||||
meta_refresh(3, $redirect);
|
||||
trigger_error($user->lang[$msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($usernote && $action == 'add_feedback')
|
||||
{
|
||||
if (check_form_key('mcp_notes'))
|
||||
{
|
||||
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array($userrow['username']));
|
||||
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array(
|
||||
'forum_id' => 0,
|
||||
'topic_id' => 0,
|
||||
$userrow['username']
|
||||
));
|
||||
$phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GENERAL', false, array(
|
||||
'reportee_id' => $user_id,
|
||||
$usernote
|
||||
));
|
||||
|
||||
$msg = $user->lang['USER_FEEDBACK_ADDED'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = $user->lang['FORM_INVALID'];
|
||||
}
|
||||
$redirect = $this->u_action;
|
||||
meta_refresh(3, $redirect);
|
||||
|
||||
trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
|
||||
}
|
||||
|
||||
// Generate the appropriate user information for the user we are looking at
|
||||
|
||||
$rank_title = $rank_img = '';
|
||||
$avatar_img = phpbb_get_user_avatar($userrow);
|
||||
|
||||
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']);
|
||||
$sort_by_sql = array('a' => 'u.username_clean', 'b' => 'l.log_time', 'c' => 'l.log_ip', 'd' => 'l.log_operation');
|
||||
|
||||
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
|
||||
gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
|
||||
|
||||
// Define where and sort sql for use in displaying logs
|
||||
$sql_where = ($st) ? (time() - ($st * 86400)) : 0;
|
||||
$sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC');
|
||||
|
||||
$keywords = $request->variable('keywords', '', true);
|
||||
$keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
|
||||
|
||||
$log_data = array();
|
||||
$log_count = 0;
|
||||
$start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort, $keywords);
|
||||
|
||||
if ($log_count)
|
||||
{
|
||||
$template->assign_var('S_USER_NOTES', true);
|
||||
|
||||
foreach ($log_data as $row)
|
||||
{
|
||||
$template->assign_block_vars('usernotes', array(
|
||||
'REPORT_BY' => $row['username_full'],
|
||||
'REPORT_AT' => $user->format_date($row['time']),
|
||||
'ACTION' => $row['action'],
|
||||
'IP' => $row['ip'],
|
||||
'ID' => $row['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$base_url = $this->u_action . "&$u_sort_param$keywords_param";
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'U_POST_ACTION' => $this->u_action,
|
||||
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
|
||||
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
||||
'S_SELECT_SORT_KEY' => $s_sort_key,
|
||||
'S_SELECT_SORT_DAYS' => $s_limit_days,
|
||||
'S_KEYWORDS' => $keywords,
|
||||
|
||||
'L_TITLE' => $user->lang['MCP_NOTES_USER'],
|
||||
|
||||
'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $log_count),
|
||||
|
||||
'RANK_TITLE' => $rank_title,
|
||||
'JOINED' => $user->format_date($userrow['user_regdate']),
|
||||
'POSTS' => ($userrow['user_posts']) ? $userrow['user_posts'] : 0,
|
||||
'WARNINGS' => ($userrow['user_warnings']) ? $userrow['user_warnings'] : 0,
|
||||
|
||||
'USERNAME_FULL' => get_username_string('full', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
|
||||
'USERNAME_COLOUR' => get_username_string('colour', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
|
||||
'USERNAME' => get_username_string('username', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
|
||||
'U_PROFILE' => get_username_string('profile', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
|
||||
|
||||
'AVATAR_IMG' => $avatar_img,
|
||||
'RANK_IMG' => $rank_img,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
326
msd2/phpBB3/includes/mcp/mcp_pm_reports.php
Normal file
326
msd2/phpBB3/includes/mcp/mcp_pm_reports.php
Normal file
@ -0,0 +1,326 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* mcp_reports
|
||||
* Handling the reports queue
|
||||
*/
|
||||
class mcp_pm_reports
|
||||
{
|
||||
var $p_master;
|
||||
var $u_action;
|
||||
|
||||
function __construct(&$p_master)
|
||||
{
|
||||
$this->p_master = &$p_master;
|
||||
}
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $auth, $db, $user, $template, $request;
|
||||
global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container;
|
||||
|
||||
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
||||
include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
|
||||
|
||||
/* @var $pagination \phpbb\pagination */
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
$start = $request->variable('start', 0);
|
||||
|
||||
$this->page_title = 'MCP_PM_REPORTS';
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
case 'close':
|
||||
case 'delete':
|
||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
||||
|
||||
$report_id_list = $request->variable('report_id_list', array(0));
|
||||
|
||||
if (!count($report_id_list))
|
||||
{
|
||||
trigger_error('NO_REPORT_SELECTED');
|
||||
}
|
||||
|
||||
if (!function_exists('close_report'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/mcp/mcp_reports.' . $phpEx);
|
||||
}
|
||||
|
||||
close_report($report_id_list, $mode, $action, true);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case 'pm_report_details':
|
||||
|
||||
$user->add_lang(array('posting', 'viewforum', 'viewtopic', 'ucp'));
|
||||
|
||||
$report_id = $request->variable('r', 0);
|
||||
|
||||
$sql = 'SELECT r.pm_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour
|
||||
FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u
|
||||
WHERE r.report_id = ' . $report_id . '
|
||||
AND rr.reason_id = r.reason_id
|
||||
AND r.user_id = u.user_id
|
||||
AND r.post_id = 0
|
||||
ORDER BY report_closed ASC';
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$report = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$report_id || !$report)
|
||||
{
|
||||
trigger_error('NO_REPORT');
|
||||
}
|
||||
|
||||
/* @var $phpbb_notifications \phpbb\notification\manager */
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
$phpbb_notifications->mark_notifications_by_parent('report_pm', $report_id, $user->data['user_id']);
|
||||
|
||||
$pm_id = $report['pm_id'];
|
||||
$report_id = $report['report_id'];
|
||||
|
||||
$pm_info = phpbb_get_pm_data(array($pm_id));
|
||||
|
||||
if (!count($pm_info))
|
||||
{
|
||||
trigger_error('NO_REPORT_SELECTED');
|
||||
}
|
||||
|
||||
$pm_info = $pm_info[$pm_id];
|
||||
|
||||
write_pm_addresses(array('to' => $pm_info['to_address'], 'bcc' => $pm_info['bcc_address']), (int) $pm_info['author_id']);
|
||||
|
||||
$reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']);
|
||||
if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]))
|
||||
{
|
||||
$reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])];
|
||||
$reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])];
|
||||
}
|
||||
|
||||
// Process message, leave it uncensored
|
||||
$parse_flags = ($pm_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
|
||||
$message = generate_text_for_display($pm_info['message_text'], $pm_info['bbcode_uid'], $pm_info['bbcode_bitfield'], $parse_flags, false);
|
||||
|
||||
$report['report_text'] = make_clickable(bbcode_nl2br($report['report_text']));
|
||||
|
||||
if ($pm_info['message_attachment'] && $auth->acl_get('u_pm_download'))
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
WHERE post_msg_id = ' . $pm_id . '
|
||||
AND in_message = 1
|
||||
ORDER BY filetime DESC';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$attachments[] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (count($attachments))
|
||||
{
|
||||
$update_count = array();
|
||||
parse_attachments(0, $message, $attachments, $update_count);
|
||||
}
|
||||
|
||||
// Display not already displayed Attachments for this post, we already parsed them. ;)
|
||||
if (!empty($attachments))
|
||||
{
|
||||
$template->assign_var('S_HAS_ATTACHMENTS', true);
|
||||
|
||||
foreach ($attachments as $attachment)
|
||||
{
|
||||
$template->assign_block_vars('attachment', array(
|
||||
'DISPLAY_ATTACHMENT' => $attachment)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_MCP_REPORT' => true,
|
||||
'S_PM' => true,
|
||||
'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $report_id),
|
||||
'S_CAN_VIEWIP' => $auth->acl_getf_global('m_info'),
|
||||
'S_POST_REPORTED' => $pm_info['message_reported'],
|
||||
'S_REPORT_CLOSED' => $report['report_closed'],
|
||||
'S_USER_NOTES' => true,
|
||||
|
||||
'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $report_id),
|
||||
'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $report['user_id']),
|
||||
'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $pm_info['author_id']),
|
||||
'U_MCP_WARN_REPORTER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '',
|
||||
'U_MCP_WARN_USER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $pm_info['author_id']) : '',
|
||||
|
||||
'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']),
|
||||
'MINI_POST_IMG' => $user->img('icon_post_target', 'POST'),
|
||||
|
||||
'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports' . (($pm_info['message_reported']) ? '&mode=pm_reports' : '&mode=pm_reports_closed') . '&start=' . $start) . '">', '</a>'),
|
||||
'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']),
|
||||
'REPORT_DATE' => $user->format_date($report['report_time']),
|
||||
'REPORT_ID' => $report_id,
|
||||
'REPORT_REASON_TITLE' => $reason['title'],
|
||||
'REPORT_REASON_DESCRIPTION' => $reason['description'],
|
||||
'REPORT_TEXT' => $report['report_text'],
|
||||
|
||||
'POST_AUTHOR_FULL' => get_username_string('full', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']),
|
||||
'POST_AUTHOR_COLOUR' => get_username_string('colour', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']),
|
||||
'POST_AUTHOR' => get_username_string('username', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']),
|
||||
'U_POST_AUTHOR' => get_username_string('profile', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']),
|
||||
|
||||
'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']),
|
||||
'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']),
|
||||
'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']),
|
||||
'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']),
|
||||
|
||||
'POST_PREVIEW' => $message,
|
||||
'POST_SUBJECT' => ($pm_info['message_subject']) ? $pm_info['message_subject'] : $user->lang['NO_SUBJECT'],
|
||||
'POST_DATE' => $user->format_date($pm_info['message_time']),
|
||||
'POST_IP' => $pm_info['author_ip'],
|
||||
'POST_IPADDR' => ($auth->acl_getf_global('m_info') && $request->variable('lookup', '')) ? @gethostbyaddr($pm_info['author_ip']) : '',
|
||||
'POST_ID' => $pm_info['msg_id'],
|
||||
|
||||
'U_LOOKUP_IP' => ($auth->acl_getf_global('m_info')) ? $this->u_action . '&r=' . $report_id . '&pm=' . $pm_id . '&lookup=' . $pm_info['author_ip'] . '#ip' : '',
|
||||
));
|
||||
|
||||
$this->tpl_name = 'mcp_post';
|
||||
|
||||
break;
|
||||
|
||||
case 'pm_reports':
|
||||
case 'pm_reports_closed':
|
||||
$user->add_lang(array('ucp'));
|
||||
|
||||
$sort_days = $total = 0;
|
||||
$sort_key = $sort_dir = '';
|
||||
$sort_by_sql = $sort_order_sql = array();
|
||||
phpbb_mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total);
|
||||
|
||||
$limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : '';
|
||||
|
||||
if ($mode == 'pm_reports')
|
||||
{
|
||||
$report_state = 'p.message_reported = 1 AND r.report_closed = 0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$report_state = 'r.report_closed = 1';
|
||||
}
|
||||
|
||||
$sql = 'SELECT r.report_id
|
||||
FROM ' . PRIVMSGS_TABLE . ' p, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . "
|
||||
WHERE $report_state
|
||||
AND r.pm_id = p.msg_id
|
||||
" . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.author_id' : '') . '
|
||||
' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = r.user_id' : '') . "
|
||||
AND r.post_id = 0
|
||||
$limit_time_sql
|
||||
ORDER BY $sort_order_sql";
|
||||
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
||||
|
||||
$i = 0;
|
||||
$report_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$report_ids[] = $row['report_id'];
|
||||
$row_num[$row['report_id']] = $i++;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (count($report_ids))
|
||||
{
|
||||
$sql = 'SELECT p.*, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id
|
||||
FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru
|
||||
WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . "
|
||||
AND r.pm_id = p.msg_id
|
||||
AND p.author_id = u.user_id
|
||||
AND ru.user_id = r.user_id
|
||||
ORDER BY $sort_order_sql";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$pm_list = $pm_by_id = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$pm_by_id[(int) $row['msg_id']] = $row;
|
||||
$pm_list[] = (int) $row['msg_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (count($pm_list))
|
||||
{
|
||||
$address_list = get_recipient_strings($pm_by_id);
|
||||
|
||||
foreach ($pm_list as $message_id)
|
||||
{
|
||||
$row = $pm_by_id[$message_id];
|
||||
$template->assign_block_vars('postrow', array(
|
||||
'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=pm_reports&mode=pm_report_details&r={$row['report_id']}"),
|
||||
|
||||
'PM_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['username'], $row['user_colour']),
|
||||
'PM_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['username'], $row['user_colour']),
|
||||
'PM_AUTHOR' => get_username_string('username', $row['author_id'], $row['username'], $row['user_colour']),
|
||||
'U_PM_AUTHOR' => get_username_string('profile', $row['author_id'], $row['username'], $row['user_colour']),
|
||||
|
||||
'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
|
||||
'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
|
||||
'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
|
||||
'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
|
||||
|
||||
'PM_SUBJECT' => ($row['message_subject']) ? $row['message_subject'] : $user->lang['NO_SUBJECT'],
|
||||
'PM_TIME' => $user->format_date($row['message_time']),
|
||||
'REPORT_ID' => $row['report_id'],
|
||||
'REPORT_TIME' => $user->format_date($row['report_time']),
|
||||
|
||||
'RECIPIENTS' => implode($user->lang['COMMA_SEPARATOR'], $address_list[$row['msg_id']]),
|
||||
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $row['message_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$base_url = $this->u_action . "&st=$sort_days&sk=$sort_key&sd=$sort_dir";
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start);
|
||||
|
||||
// Now display the page
|
||||
$template->assign_vars(array(
|
||||
'L_EXPLAIN' => ($mode == 'pm_reports') ? $user->lang['MCP_PM_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_PM_REPORTS_CLOSED_EXPLAIN'],
|
||||
'L_TITLE' => ($mode == 'pm_reports') ? $user->lang['MCP_PM_REPORTS_OPEN'] : $user->lang['MCP_PM_REPORTS_CLOSED'],
|
||||
|
||||
'S_PM' => true,
|
||||
'S_MCP_ACTION' => $this->u_action,
|
||||
'S_CLOSED' => ($mode == 'pm_reports_closed') ? true : false,
|
||||
|
||||
'TOTAL' => $total,
|
||||
'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total),
|
||||
)
|
||||
);
|
||||
|
||||
$this->tpl_name = 'mcp_reports';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
680
msd2/phpBB3/includes/mcp/mcp_post.php
Normal file
680
msd2/phpBB3/includes/mcp/mcp_post.php
Normal file
@ -0,0 +1,680 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handling actions in post details screen
|
||||
*/
|
||||
function mcp_post_details($id, $mode, $action)
|
||||
{
|
||||
global $phpEx, $phpbb_root_path, $config, $request;
|
||||
global $template, $db, $user, $auth;
|
||||
global $phpbb_container, $phpbb_dispatcher;
|
||||
|
||||
$user->add_lang('posting');
|
||||
|
||||
$post_id = $request->variable('p', 0);
|
||||
$start = $request->variable('start', 0);
|
||||
|
||||
// Get post data
|
||||
$post_info = phpbb_get_post_data(array($post_id), false, true);
|
||||
|
||||
add_form_key('mcp_post_details');
|
||||
|
||||
if (!count($post_info))
|
||||
{
|
||||
trigger_error('POST_NOT_EXIST');
|
||||
}
|
||||
|
||||
$post_info = $post_info[$post_id];
|
||||
$url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . phpbb_extra_url());
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
case 'whois':
|
||||
|
||||
if ($auth->acl_get('m_info', $post_info['forum_id']))
|
||||
{
|
||||
$ip = $request->variable('ip', '');
|
||||
if (!function_exists('user_ipwhois'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&mode=$mode&p=$post_id") . '">', '</a>'),
|
||||
'U_RETURN_POST' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&mode=$mode&p=$post_id"),
|
||||
'L_RETURN_POST' => sprintf($user->lang['RETURN_POST'], '', ''),
|
||||
'WHOIS' => user_ipwhois($ip),
|
||||
));
|
||||
}
|
||||
|
||||
// We're done with the whois page so return
|
||||
return;
|
||||
|
||||
break;
|
||||
|
||||
case 'chgposter':
|
||||
case 'chgposter_ip':
|
||||
|
||||
if ($action == 'chgposter')
|
||||
{
|
||||
$username = $request->variable('username', '', true);
|
||||
$sql_where = "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_user_id = $request->variable('u', 0);
|
||||
$sql_where = 'user_id = ' . $new_user_id;
|
||||
}
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE ' . $sql_where;
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$row)
|
||||
{
|
||||
trigger_error('NO_USER');
|
||||
}
|
||||
|
||||
if ($auth->acl_get('m_chgposter', $post_info['forum_id']))
|
||||
{
|
||||
if (check_form_key('mcp_post_details'))
|
||||
{
|
||||
change_poster($post_info, $row);
|
||||
}
|
||||
else
|
||||
{
|
||||
trigger_error('FORM_INVALID');
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
/**
|
||||
* This event allows you to handle custom post moderation options
|
||||
*
|
||||
* @event core.mcp_post_additional_options
|
||||
* @var string action Post moderation action name
|
||||
* @var array post_info Information on the affected post
|
||||
* @since 3.1.5-RC1
|
||||
*/
|
||||
$vars = array('action', 'post_info');
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_post_additional_options', compact($vars)));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Set some vars
|
||||
$users_ary = $usernames_ary = array();
|
||||
$attachments = $extensions = array();
|
||||
$post_id = $post_info['post_id'];
|
||||
|
||||
// Get topic tracking info
|
||||
if ($config['load_db_lastread'])
|
||||
{
|
||||
$tmp_topic_data = array($post_info['topic_id'] => $post_info);
|
||||
$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']));
|
||||
unset($tmp_topic_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']);
|
||||
}
|
||||
|
||||
$post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false;
|
||||
|
||||
// Process message, leave it uncensored
|
||||
$parse_flags = ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
|
||||
$message = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], $parse_flags, false);
|
||||
|
||||
if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id']))
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
WHERE post_msg_id = ' . $post_id . '
|
||||
AND in_message = 0
|
||||
ORDER BY filetime DESC, post_msg_id ASC';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$attachments[] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (count($attachments))
|
||||
{
|
||||
$user->add_lang('viewtopic');
|
||||
$update_count = array();
|
||||
parse_attachments($post_info['forum_id'], $message, $attachments, $update_count);
|
||||
}
|
||||
|
||||
// Display not already displayed Attachments for this post, we already parsed them. ;)
|
||||
if (!empty($attachments))
|
||||
{
|
||||
$template->assign_var('S_HAS_ATTACHMENTS', true);
|
||||
|
||||
foreach ($attachments as $attachment)
|
||||
{
|
||||
$template->assign_block_vars('attachment', array(
|
||||
'DISPLAY_ATTACHMENT' => $attachment)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Deleting information
|
||||
if ($post_info['post_visibility'] == ITEM_DELETED && $post_info['post_delete_user'])
|
||||
{
|
||||
// User having deleted the post also being the post author?
|
||||
if (!$post_info['post_delete_user'] || $post_info['post_delete_user'] == $post_info['poster_id'])
|
||||
{
|
||||
$display_username = get_username_string('full', $post_info['poster_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT user_id, username, user_colour
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE user_id = ' . (int) $post_info['post_delete_user'];
|
||||
$result = $db->sql_query($sql);
|
||||
$user_delete_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
$display_username = get_username_string('full', $post_info['post_delete_user'], $user_delete_row['username'], $user_delete_row['user_colour']);
|
||||
}
|
||||
|
||||
$user->add_lang('viewtopic');
|
||||
$l_deleted_by = $user->lang('DELETED_INFORMATION', $display_username, $user->format_date($post_info['post_delete_time'], false, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
$l_deleted_by = '';
|
||||
}
|
||||
|
||||
// parse signature
|
||||
$parse_flags = ($post_info['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
|
||||
$post_info['user_sig'] = generate_text_for_display($post_info['user_sig'], $post_info['user_sig_bbcode_uid'], $post_info['user_sig_bbcode_bitfield'], $parse_flags, true);
|
||||
|
||||
$mcp_post_template_data = array(
|
||||
'U_MCP_ACTION' => "$url&i=main&quickmod=1&mode=post_details", // Use this for mode paramaters
|
||||
'U_POST_ACTION' => "$url&i=$id&mode=post_details", // Use this for action parameters
|
||||
'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p=$post_id&f={$post_info['forum_id']}"),
|
||||
|
||||
'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']),
|
||||
'S_CAN_CHGPOSTER' => $auth->acl_get('m_chgposter', $post_info['forum_id']),
|
||||
'S_CAN_LOCK_POST' => $auth->acl_get('m_lock', $post_info['forum_id']),
|
||||
'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']),
|
||||
|
||||
'S_POST_REPORTED' => ($post_info['post_reported']) ? true : false,
|
||||
'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE) ? true : false,
|
||||
'S_POST_DELETED' => ($post_info['post_visibility'] == ITEM_DELETED) ? true : false,
|
||||
'S_POST_LOCKED' => ($post_info['post_edit_locked']) ? true : false,
|
||||
'S_USER_NOTES' => true,
|
||||
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
|
||||
'DELETED_MESSAGE' => $l_deleted_by,
|
||||
'DELETE_REASON' => $post_info['post_delete_reason'],
|
||||
|
||||
'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']}") : '',
|
||||
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp_chgposter&field=username&select_single=true'),
|
||||
'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
|
||||
'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
|
||||
'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $post_info['user_id']),
|
||||
'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']) : '',
|
||||
'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']),
|
||||
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']),
|
||||
|
||||
'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'),
|
||||
|
||||
'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$post_info['forum_id']}&p=$post_id") . "#p$post_id\">", '</a>'),
|
||||
'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$post_info['forum_id']}&start={$start}") . '">', '</a>'),
|
||||
'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']),
|
||||
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']),
|
||||
'DELETED_IMG' => $user->img('icon_topic_deleted', $user->lang['POST_DELETED']),
|
||||
'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']),
|
||||
'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']),
|
||||
|
||||
'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
||||
'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
||||
'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
||||
'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
||||
|
||||
'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' => ($auth->acl_get('m_info', $post_info['forum_id']) && $request->variable('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '',
|
||||
'POST_ID' => $post_info['post_id'],
|
||||
'SIGNATURE' => $post_info['user_sig'],
|
||||
|
||||
'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? "$url&i=$id&mode=$mode&lookup={$post_info['poster_ip']}#ip" : '',
|
||||
'U_WHOIS' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&mode=$mode&action=whois&p=$post_id&ip={$post_info['poster_ip']}") : '',
|
||||
);
|
||||
|
||||
$s_additional_opts = false;
|
||||
|
||||
/**
|
||||
* Event to add/modify MCP post template data
|
||||
*
|
||||
* @event core.mcp_post_template_data
|
||||
* @var array post_info Array with the post information
|
||||
* @var array mcp_post_template_data Array with the MCP post template data
|
||||
* @var array attachments Array with the post attachments, if any
|
||||
* @var bool s_additional_opts Must be set to true in extension if additional options are presented in MCP post panel
|
||||
* @since 3.1.5-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'post_info',
|
||||
'mcp_post_template_data',
|
||||
'attachments',
|
||||
's_additional_opts',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_post_template_data', compact($vars)));
|
||||
|
||||
$template->assign_vars($mcp_post_template_data);
|
||||
$template->assign_var('S_MCP_POST_ADDITIONAL_OPTS', $s_additional_opts);
|
||||
|
||||
unset($mcp_post_template_data);
|
||||
|
||||
// Get User Notes
|
||||
$log_data = array();
|
||||
$log_count = false;
|
||||
view_log('user', $log_data, $log_count, $config['posts_per_page'], 0, 0, 0, $post_info['user_id']);
|
||||
|
||||
if (!empty($log_data))
|
||||
{
|
||||
$template->assign_var('S_USER_NOTES', true);
|
||||
|
||||
foreach ($log_data as $row)
|
||||
{
|
||||
$template->assign_block_vars('usernotes', array(
|
||||
'REPORT_BY' => $row['username_full'],
|
||||
'REPORT_AT' => $user->format_date($row['time']),
|
||||
'ACTION' => $row['action'],
|
||||
'ID' => $row['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Get Reports
|
||||
if ($auth->acl_get('m_report', $post_info['forum_id']))
|
||||
{
|
||||
$sql = 'SELECT r.*, re.*, u.user_id, u.username
|
||||
FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u, ' . REPORTS_REASONS_TABLE . " re
|
||||
WHERE r.post_id = $post_id
|
||||
AND r.reason_id = re.reason_id
|
||||
AND u.user_id = r.user_id
|
||||
ORDER BY r.report_time DESC";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_var('S_SHOW_REPORTS', true);
|
||||
|
||||
do
|
||||
{
|
||||
// If the reason is defined within the language file, we will use the localized version, else just use the database entry...
|
||||
if (isset($user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]))
|
||||
{
|
||||
$row['reson_description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])];
|
||||
$row['reason_title'] = $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])];
|
||||
}
|
||||
|
||||
$template->assign_block_vars('reports', array(
|
||||
'REPORT_ID' => $row['report_id'],
|
||||
'REASON_TITLE' => $row['reason_title'],
|
||||
'REASON_DESC' => $row['reason_description'],
|
||||
'REPORTER' => get_username_string('username', $row['user_id'], $row['username']),
|
||||
'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username']),
|
||||
'USER_NOTIFY' => ($row['user_notify']) ? true : false,
|
||||
'REPORT_TIME' => $user->format_date($row['report_time']),
|
||||
'REPORT_TEXT' => bbcode_nl2br(trim($row['report_text'])),
|
||||
));
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
// Get IP
|
||||
if ($auth->acl_get('m_info', $post_info['forum_id']))
|
||||
{
|
||||
/** @var \phpbb\pagination $pagination */
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
|
||||
$rdns_ip_num = $request->variable('rdns', '');
|
||||
$start_users = $request->variable('start_users', 0);
|
||||
|
||||
if ($rdns_ip_num != 'all')
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'U_LOOKUP_ALL' => "$url&i=main&mode=post_details&rdns=all")
|
||||
);
|
||||
}
|
||||
|
||||
$num_users = false;
|
||||
if ($start_users)
|
||||
{
|
||||
$num_users = phpbb_get_num_posters_for_ip($db, $post_info['poster_ip']);
|
||||
$start_users = $pagination->validate_start($start_users, $config['posts_per_page'], $num_users);
|
||||
}
|
||||
|
||||
// Get other users who've posted under this IP
|
||||
$sql = 'SELECT poster_id, COUNT(poster_id) as postings
|
||||
FROM ' . POSTS_TABLE . "
|
||||
WHERE poster_ip = '" . $db->sql_escape($post_info['poster_ip']) . "'
|
||||
AND poster_id <> " . (int) $post_info['poster_id'] . "
|
||||
GROUP BY poster_id
|
||||
ORDER BY postings DESC, poster_id ASC";
|
||||
$result = $db->sql_query_limit($sql, $config['posts_per_page'], $start_users);
|
||||
|
||||
$page_users = 0;
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$page_users++;
|
||||
$users_ary[$row['poster_id']] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($page_users == $config['posts_per_page'] || $start_users)
|
||||
{
|
||||
if ($num_users === false)
|
||||
{
|
||||
$num_users = phpbb_get_num_posters_for_ip($db, $post_info['poster_ip']);
|
||||
}
|
||||
|
||||
$pagination->generate_template_pagination(
|
||||
$url . '&i=main&mode=post_details',
|
||||
'pagination',
|
||||
'start_users',
|
||||
$num_users,
|
||||
$config['posts_per_page'],
|
||||
$start_users
|
||||
);
|
||||
}
|
||||
|
||||
if (count($users_ary))
|
||||
{
|
||||
// Get the usernames
|
||||
$sql = 'SELECT user_id, username
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('user_id', array_keys($users_ary));
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$users_ary[$row['user_id']]['username'] = $row['username'];
|
||||
$usernames_ary[utf8_clean_string($row['username'])] = $users_ary[$row['user_id']];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
foreach ($users_ary as $user_id => $user_row)
|
||||
{
|
||||
$template->assign_block_vars('userrow', array(
|
||||
'USERNAME' => get_username_string('username', $user_id, $user_row['username']),
|
||||
'NUM_POSTS' => $user_row['postings'],
|
||||
'L_POST_S' => ($user_row['postings'] == 1) ? $user->lang['POST'] : $user->lang['POSTS'],
|
||||
|
||||
'U_PROFILE' => get_username_string('profile', $user_id, $user_row['username']),
|
||||
'U_SEARCHPOSTS' => append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $user_id . '&sr=topics'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Get other IP's this user has posted under
|
||||
|
||||
// A compound index on poster_id, poster_ip (posts table) would help speed up this query a lot,
|
||||
// but the extra size is only valuable if there are persons having more than a thousands posts.
|
||||
// This is better left to the really really big forums.
|
||||
$start_ips = $request->variable('start_ips', 0);
|
||||
|
||||
$num_ips = false;
|
||||
if ($start_ips)
|
||||
{
|
||||
$num_ips = phpbb_get_num_ips_for_poster($db, $post_info['poster_id']);
|
||||
$start_ips = $pagination->validate_start($start_ips, $config['posts_per_page'], $num_ips);
|
||||
}
|
||||
|
||||
$sql = 'SELECT poster_ip, COUNT(poster_ip) AS postings
|
||||
FROM ' . POSTS_TABLE . '
|
||||
WHERE poster_id = ' . $post_info['poster_id'] . "
|
||||
GROUP BY poster_ip
|
||||
ORDER BY postings DESC, poster_ip ASC";
|
||||
$result = $db->sql_query_limit($sql, $config['posts_per_page'], $start_ips);
|
||||
|
||||
$page_ips = 0;
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$page_ips++;
|
||||
$hostname = (($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') && $row['poster_ip']) ? @gethostbyaddr($row['poster_ip']) : '';
|
||||
|
||||
$template->assign_block_vars('iprow', array(
|
||||
'IP' => $row['poster_ip'],
|
||||
'HOSTNAME' => $hostname,
|
||||
'NUM_POSTS' => $row['postings'],
|
||||
'L_POST_S' => ($row['postings'] == 1) ? $user->lang['POST'] : $user->lang['POSTS'],
|
||||
|
||||
'U_LOOKUP_IP' => ($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? '' : "$url&i=$id&mode=post_details&rdns={$row['poster_ip']}#ip",
|
||||
'U_WHOIS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&mode=$mode&action=whois&p=$post_id&ip={$row['poster_ip']}"))
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($page_ips == $config['posts_per_page'] || $start_ips)
|
||||
{
|
||||
if ($num_ips === false)
|
||||
{
|
||||
$num_ips = phpbb_get_num_ips_for_poster($db, $post_info['poster_id']);
|
||||
}
|
||||
|
||||
$pagination->generate_template_pagination(
|
||||
$url . '&i=main&mode=post_details',
|
||||
'pagination_ips',
|
||||
'start_ips',
|
||||
$num_ips,
|
||||
$config['posts_per_page'],
|
||||
$start_ips
|
||||
);
|
||||
}
|
||||
|
||||
$user_select = '';
|
||||
|
||||
if (count($usernames_ary))
|
||||
{
|
||||
ksort($usernames_ary);
|
||||
|
||||
foreach ($usernames_ary as $row)
|
||||
{
|
||||
$user_select .= '<option value="' . $row['poster_id'] . '">' . $row['username'] . "</option>\n";
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_var('S_USER_SELECT', $user_select);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of posters for a given ip
|
||||
*
|
||||
* @param \phpbb\db\driver\driver_interface $db DBAL interface
|
||||
* @param string $poster_ip IP
|
||||
* @return int Number of posters
|
||||
*/
|
||||
function phpbb_get_num_posters_for_ip(\phpbb\db\driver\driver_interface $db, $poster_ip)
|
||||
{
|
||||
$sql = 'SELECT COUNT(DISTINCT poster_id) as num_users
|
||||
FROM ' . POSTS_TABLE . "
|
||||
WHERE poster_ip = '" . $db->sql_escape($poster_ip) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$num_users = (int) $db->sql_fetchfield('num_users');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return $num_users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of ips for a given poster
|
||||
*
|
||||
* @param \phpbb\db\driver\driver_interface $db
|
||||
* @param int $poster_id Poster user ID
|
||||
* @return int Number of IPs for given poster
|
||||
*/
|
||||
function phpbb_get_num_ips_for_poster(\phpbb\db\driver\driver_interface $db, $poster_id)
|
||||
{
|
||||
$sql = 'SELECT COUNT(DISTINCT poster_ip) as num_ips
|
||||
FROM ' . POSTS_TABLE . '
|
||||
WHERE poster_id = ' . (int) $poster_id;
|
||||
$result = $db->sql_query($sql);
|
||||
$num_ips = (int) $db->sql_fetchfield('num_ips');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return $num_ips;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a post's poster
|
||||
*/
|
||||
function change_poster(&$post_info, $userdata)
|
||||
{
|
||||
global $auth, $db, $config, $phpbb_root_path, $phpEx, $user, $phpbb_log, $phpbb_dispatcher;
|
||||
|
||||
if (empty($userdata) || $userdata['user_id'] == $post_info['user_id'])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$post_id = $post_info['post_id'];
|
||||
|
||||
$sql = 'UPDATE ' . POSTS_TABLE . "
|
||||
SET poster_id = {$userdata['user_id']}
|
||||
WHERE post_id = $post_id";
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Resync topic/forum if needed
|
||||
if ($post_info['topic_last_post_id'] == $post_id || $post_info['forum_last_post_id'] == $post_id || $post_info['topic_first_post_id'] == $post_id)
|
||||
{
|
||||
sync('topic', 'topic_id', $post_info['topic_id'], false, false);
|
||||
sync('forum', 'forum_id', $post_info['forum_id'], false, false);
|
||||
}
|
||||
|
||||
// Adjust post counts... only if the post is approved (else, it was not added the users post count anyway)
|
||||
if ($post_info['post_postcount'] && $post_info['post_visibility'] == ITEM_APPROVED)
|
||||
{
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_posts = user_posts - 1
|
||||
WHERE user_id = ' . $post_info['user_id'] .'
|
||||
AND user_posts > 0';
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_posts = user_posts + 1
|
||||
WHERE user_id = ' . $userdata['user_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
// Add posted to information for this topic for the new user
|
||||
markread('post', $post_info['forum_id'], $post_info['topic_id'], time(), $userdata['user_id']);
|
||||
|
||||
// Remove the dotted topic option if the old user has no more posts within this topic
|
||||
if ($config['load_db_track'] && $post_info['user_id'] != ANONYMOUS)
|
||||
{
|
||||
$sql = 'SELECT topic_id
|
||||
FROM ' . POSTS_TABLE . '
|
||||
WHERE topic_id = ' . $post_info['topic_id'] . '
|
||||
AND poster_id = ' . $post_info['user_id'];
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$topic_id = (int) $db->sql_fetchfield('topic_id');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$topic_id)
|
||||
{
|
||||
$sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . '
|
||||
WHERE user_id = ' . $post_info['user_id'] . '
|
||||
AND topic_id = ' . $post_info['topic_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
// change the poster_id within the attachments table, else the data becomes out of sync and errors displayed because of wrong ownership
|
||||
if ($post_info['post_attachment'])
|
||||
{
|
||||
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
|
||||
SET poster_id = ' . $userdata['user_id'] . '
|
||||
WHERE poster_id = ' . $post_info['user_id'] . '
|
||||
AND post_msg_id = ' . $post_info['post_id'] . '
|
||||
AND topic_id = ' . $post_info['topic_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
// refresh search cache of this post
|
||||
$search_type = $config['search_type'];
|
||||
|
||||
if (class_exists($search_type))
|
||||
{
|
||||
// We do some additional checks in the module to ensure it can actually be utilised
|
||||
$error = false;
|
||||
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
|
||||
|
||||
if (!$error && method_exists($search, 'destroy_cache'))
|
||||
{
|
||||
$search->destroy_cache(array(), array($post_info['user_id'], $userdata['user_id']));
|
||||
}
|
||||
}
|
||||
|
||||
$from_username = $post_info['username'];
|
||||
$to_username = $userdata['username'];
|
||||
|
||||
/**
|
||||
* This event allows you to perform additional tasks after changing a post's poster
|
||||
*
|
||||
* @event core.mcp_change_poster_after
|
||||
* @var array userdata Information on a post's new poster
|
||||
* @var array post_info Information on the affected post
|
||||
* @since 3.1.6-RC1
|
||||
* @changed 3.1.7-RC1 Change location to prevent post_info from being set to the new post information
|
||||
*/
|
||||
$vars = array('userdata', 'post_info');
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_change_poster_after', compact($vars)));
|
||||
|
||||
// Renew post info
|
||||
$post_info = phpbb_get_post_data(array($post_id), false, true);
|
||||
|
||||
if (!count($post_info))
|
||||
{
|
||||
trigger_error('POST_NOT_EXIST');
|
||||
}
|
||||
|
||||
$post_info = $post_info[$post_id];
|
||||
|
||||
// Now add log entry
|
||||
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MCP_CHANGE_POSTER', false, array(
|
||||
'forum_id' => $post_info['forum_id'],
|
||||
'topic_id' => $post_info['topic_id'],
|
||||
'post_id' => $post_info['post_id'],
|
||||
$post_info['topic_title'],
|
||||
$from_username,
|
||||
$to_username
|
||||
));
|
||||
}
|
1530
msd2/phpBB3/includes/mcp/mcp_queue.php
Normal file
1530
msd2/phpBB3/includes/mcp/mcp_queue.php
Normal file
File diff suppressed because it is too large
Load Diff
834
msd2/phpBB3/includes/mcp/mcp_reports.php
Normal file
834
msd2/phpBB3/includes/mcp/mcp_reports.php
Normal file
@ -0,0 +1,834 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* mcp_reports
|
||||
* Handling the reports queue
|
||||
*/
|
||||
class mcp_reports
|
||||
{
|
||||
var $p_master;
|
||||
var $u_action;
|
||||
|
||||
function __construct(&$p_master)
|
||||
{
|
||||
$this->p_master = &$p_master;
|
||||
}
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $auth, $db, $user, $template, $request;
|
||||
global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container, $phpbb_dispatcher;
|
||||
|
||||
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
||||
|
||||
$forum_id = $request->variable('f', 0);
|
||||
$start = $request->variable('start', 0);
|
||||
|
||||
$this->page_title = 'MCP_REPORTS';
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
case 'close':
|
||||
case 'delete':
|
||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
||||
|
||||
$report_id_list = $request->variable('report_id_list', array(0));
|
||||
|
||||
if (!count($report_id_list))
|
||||
{
|
||||
trigger_error('NO_REPORT_SELECTED');
|
||||
}
|
||||
|
||||
close_report($report_id_list, $mode, $action);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case 'report_details':
|
||||
|
||||
$user->add_lang(array('posting', 'viewforum', 'viewtopic'));
|
||||
|
||||
$post_id = $request->variable('p', 0);
|
||||
|
||||
// closed reports are accessed by report id
|
||||
$report_id = $request->variable('r', 0);
|
||||
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour',
|
||||
|
||||
'FROM' => array(
|
||||
REPORTS_TABLE => 'r',
|
||||
REPORTS_REASONS_TABLE => 'rr',
|
||||
USERS_TABLE => 'u',
|
||||
),
|
||||
|
||||
'WHERE' => (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . '
|
||||
AND rr.reason_id = r.reason_id
|
||||
AND r.user_id = u.user_id
|
||||
AND r.pm_id = 0',
|
||||
|
||||
'ORDER_BY' => 'report_closed ASC',
|
||||
);
|
||||
|
||||
/**
|
||||
* Allow changing the query to obtain the user-submitted report.
|
||||
*
|
||||
* @event core.mcp_reports_report_details_query_before
|
||||
* @var array sql_ary The array in the format of the query builder with the query
|
||||
* @var int forum_id The forum_id, the number in the f GET parameter
|
||||
* @var int post_id The post_id of the report being viewed (if 0, it is meaningless)
|
||||
* @var int report_id The report_id of the report being viewed
|
||||
* @since 3.1.5-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'sql_ary',
|
||||
'forum_id',
|
||||
'post_id',
|
||||
'report_id',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_reports_report_details_query_before', compact($vars)));
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$report = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
/**
|
||||
* Allow changing the data obtained from the user-submitted report.
|
||||
*
|
||||
* @event core.mcp_reports_report_details_query_after
|
||||
* @var array sql_ary The array in the format of the query builder with the query that had been executted
|
||||
* @var int forum_id The forum_id, the number in the f GET parameter
|
||||
* @var int post_id The post_id of the report being viewed (if 0, it is meaningless)
|
||||
* @var int report_id The report_id of the report being viewed
|
||||
* @var array report The query's resulting row.
|
||||
* @since 3.1.5-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'sql_ary',
|
||||
'forum_id',
|
||||
'post_id',
|
||||
'report_id',
|
||||
'report',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_reports_report_details_query_after', compact($vars)));
|
||||
|
||||
if (!$report)
|
||||
{
|
||||
trigger_error('NO_REPORT');
|
||||
}
|
||||
|
||||
/* @var $phpbb_notifications \phpbb\notification\manager */
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
$phpbb_notifications->mark_notifications('report_post', $post_id, $user->data['user_id']);
|
||||
|
||||
if (!$report_id && $report['report_closed'])
|
||||
{
|
||||
trigger_error('REPORT_CLOSED');
|
||||
}
|
||||
|
||||
$post_id = $report['post_id'];
|
||||
$report_id = $report['report_id'];
|
||||
|
||||
$parse_post_flags = $report['reported_post_enable_bbcode'] ? OPTION_FLAG_BBCODE : 0;
|
||||
$parse_post_flags += $report['reported_post_enable_smilies'] ? OPTION_FLAG_SMILIES : 0;
|
||||
$parse_post_flags += $report['reported_post_enable_magic_url'] ? OPTION_FLAG_LINKS : 0;
|
||||
|
||||
$post_info = phpbb_get_post_data(array($post_id), 'm_report', true);
|
||||
|
||||
if (!count($post_info))
|
||||
{
|
||||
trigger_error('NO_REPORT_SELECTED');
|
||||
}
|
||||
|
||||
$post_info = $post_info[$post_id];
|
||||
|
||||
$reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']);
|
||||
if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]))
|
||||
{
|
||||
$reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])];
|
||||
$reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])];
|
||||
}
|
||||
|
||||
if (topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false))
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_TOPIC_REVIEW' => true,
|
||||
'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'],
|
||||
'TOPIC_TITLE' => $post_info['topic_title'],
|
||||
'REPORTED_POST_ID' => $post_id,
|
||||
));
|
||||
}
|
||||
|
||||
$attachments = array();
|
||||
// Get topic tracking info
|
||||
if ($config['load_db_lastread'])
|
||||
{
|
||||
$tmp_topic_data = array($post_info['topic_id'] => $post_info);
|
||||
$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']));
|
||||
unset($tmp_topic_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']);
|
||||
}
|
||||
|
||||
$post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false;
|
||||
$message = generate_text_for_display(
|
||||
$report['reported_post_text'],
|
||||
$report['reported_post_uid'],
|
||||
$report['reported_post_bitfield'],
|
||||
$parse_post_flags,
|
||||
false
|
||||
);
|
||||
|
||||
$report['report_text'] = make_clickable(bbcode_nl2br($report['report_text']));
|
||||
|
||||
if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id']))
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
WHERE post_msg_id = ' . $post_id . '
|
||||
AND in_message = 0
|
||||
AND filetime <= ' . (int) $report['report_time'] . '
|
||||
ORDER BY filetime DESC';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$attachments[] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (count($attachments))
|
||||
{
|
||||
$update_count = array();
|
||||
parse_attachments($post_info['forum_id'], $message, $attachments, $update_count);
|
||||
}
|
||||
|
||||
// Display not already displayed Attachments for this post, we already parsed them. ;)
|
||||
if (!empty($attachments))
|
||||
{
|
||||
$template->assign_var('S_HAS_ATTACHMENTS', true);
|
||||
|
||||
foreach ($attachments as $attachment)
|
||||
{
|
||||
$template->assign_block_vars('attachment', array(
|
||||
'DISPLAY_ATTACHMENT' => $attachment)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// parse signature
|
||||
$parse_flags = ($post_info['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
|
||||
$post_info['user_sig'] = generate_text_for_display($post_info['user_sig'], $post_info['user_sig_bbcode_uid'], $post_info['user_sig_bbcode_bitfield'], $parse_flags, true);
|
||||
|
||||
$topic_id = (int) $post_info['topic_id'];
|
||||
|
||||
// So it can be sent through the event below.
|
||||
$report_template = array(
|
||||
'S_MCP_REPORT' => true,
|
||||
'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
|
||||
'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']),
|
||||
'S_POST_REPORTED' => $post_info['post_reported'],
|
||||
'S_POST_UNAPPROVED' => $post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE,
|
||||
'S_POST_LOCKED' => $post_info['post_edit_locked'],
|
||||
'S_REPORT_CLOSED' => $report['report_closed'],
|
||||
'S_USER_NOTES' => true,
|
||||
|
||||
'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']}") : '',
|
||||
'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
|
||||
'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
|
||||
'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $report['user_id']),
|
||||
'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $post_info['user_id']),
|
||||
'U_MCP_WARN_REPORTER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '',
|
||||
'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']) : '',
|
||||
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $post_info['forum_id']),
|
||||
'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']),
|
||||
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']),
|
||||
|
||||
'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']),
|
||||
'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'),
|
||||
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']),
|
||||
|
||||
'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports' . (($post_info['post_reported']) ? '&mode=reports' : '&mode=reports_closed') . '&start=' . $start . '&f=' . $post_info['forum_id']) . '">', '</a>'),
|
||||
'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']),
|
||||
'REPORT_DATE' => $user->format_date($report['report_time']),
|
||||
'REPORT_ID' => $report_id,
|
||||
'REPORT_REASON_TITLE' => $reason['title'],
|
||||
'REPORT_REASON_DESCRIPTION' => $reason['description'],
|
||||
'REPORT_TEXT' => $report['report_text'],
|
||||
|
||||
'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
||||
'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
||||
'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
||||
'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
||||
|
||||
'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']),
|
||||
'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']),
|
||||
'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']),
|
||||
'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']),
|
||||
|
||||
'POST_PREVIEW' => $message,
|
||||
'POST_SUBJECT' => ($post_info['post_subject']) ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'],
|
||||
'POST_DATE' => $user->format_date($post_info['post_time']),
|
||||
'POST_IP' => $post_info['poster_ip'],
|
||||
'POST_IPADDR' => ($auth->acl_get('m_info', $post_info['forum_id']) && $request->variable('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '',
|
||||
'POST_ID' => $post_info['post_id'],
|
||||
'SIGNATURE' => $post_info['user_sig'],
|
||||
|
||||
'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? $this->u_action . '&r=' . $report_id . '&p=' . $post_id . '&f=' . $forum_id . '&lookup=' . $post_info['poster_ip'] . '#ip' : '',
|
||||
);
|
||||
|
||||
/**
|
||||
* Event to add/modify MCP report details template data.
|
||||
*
|
||||
* @event core.mcp_report_template_data
|
||||
* @var int forum_id The forum_id, the number in the f GET parameter
|
||||
* @var int topic_id The topic_id of the report being viewed
|
||||
* @var int post_id The post_id of the report being viewed (if 0, it is meaningless)
|
||||
* @var int report_id The report_id of the report being viewed
|
||||
* @var array report Array with the report data
|
||||
* @var array report_template Array with the report template data
|
||||
* @var array post_info Array with the reported post data
|
||||
* @since 3.2.5-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'forum_id',
|
||||
'topic_id',
|
||||
'post_id',
|
||||
'report_id',
|
||||
'report',
|
||||
'report_template',
|
||||
'post_info',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_report_template_data', compact($vars)));
|
||||
|
||||
$template->assign_vars($report_template);
|
||||
|
||||
$this->tpl_name = 'mcp_post';
|
||||
|
||||
break;
|
||||
|
||||
case 'reports':
|
||||
case 'reports_closed':
|
||||
$topic_id = $request->variable('t', 0);
|
||||
|
||||
$forum_info = array();
|
||||
$forum_list_reports = get_forum_list('m_report', false, true);
|
||||
$forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs
|
||||
|
||||
// Remove forums we cannot read
|
||||
foreach ($forum_list_reports as $k => $forum_data)
|
||||
{
|
||||
if (!isset($forum_list_read[$forum_data['forum_id']]))
|
||||
{
|
||||
unset($forum_list_reports[$k]);
|
||||
}
|
||||
}
|
||||
unset($forum_list_read);
|
||||
|
||||
if ($topic_id)
|
||||
{
|
||||
$topic_info = phpbb_get_topic_data(array($topic_id));
|
||||
|
||||
if (!count($topic_info))
|
||||
{
|
||||
trigger_error('TOPIC_NOT_EXIST');
|
||||
}
|
||||
|
||||
if ($forum_id != $topic_info[$topic_id]['forum_id'])
|
||||
{
|
||||
$topic_id = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_info = $topic_info[$topic_id];
|
||||
$forum_id = (int) $topic_info['forum_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$forum_list = array();
|
||||
|
||||
if (!$forum_id)
|
||||
{
|
||||
foreach ($forum_list_reports as $row)
|
||||
{
|
||||
$forum_list[] = $row['forum_id'];
|
||||
}
|
||||
|
||||
if (!count($forum_list))
|
||||
{
|
||||
trigger_error('NOT_MODERATOR');
|
||||
}
|
||||
|
||||
$sql = 'SELECT SUM(forum_topics_approved) as sum_forum_topics
|
||||
FROM ' . FORUMS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('forum_id', $forum_list);
|
||||
$result = $db->sql_query($sql);
|
||||
$forum_info['forum_topics_approved'] = (int) $db->sql_fetchfield('sum_forum_topics');
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_info = phpbb_get_forum_data(array($forum_id), 'm_report');
|
||||
|
||||
if (!count($forum_info))
|
||||
{
|
||||
trigger_error('NOT_MODERATOR');
|
||||
}
|
||||
|
||||
$forum_list = array($forum_id);
|
||||
}
|
||||
|
||||
/* @var $pagination \phpbb\pagination */
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
$forum_list[] = 0;
|
||||
$forum_data = array();
|
||||
|
||||
$forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>';
|
||||
foreach ($forum_list_reports as $row)
|
||||
{
|
||||
$forum_options .= '<option value="' . $row['forum_id'] . '"' . (($forum_id == $row['forum_id']) ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . $row['forum_name'] . '</option>';
|
||||
$forum_data[$row['forum_id']] = $row;
|
||||
}
|
||||
unset($forum_list_reports);
|
||||
|
||||
$sort_days = $total = 0;
|
||||
$sort_key = $sort_dir = '';
|
||||
$sort_by_sql = $sort_order_sql = array();
|
||||
phpbb_mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id);
|
||||
|
||||
$limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : '';
|
||||
|
||||
if ($mode == 'reports')
|
||||
{
|
||||
$report_state = 'AND p.post_reported = 1 AND r.report_closed = 0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$report_state = 'AND r.report_closed = 1';
|
||||
}
|
||||
|
||||
$sql = 'SELECT r.report_id
|
||||
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . '
|
||||
WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . "
|
||||
$report_state
|
||||
AND r.post_id = p.post_id
|
||||
" . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . '
|
||||
' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = r.user_id' : '') . '
|
||||
' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . "
|
||||
AND t.topic_id = p.topic_id
|
||||
AND r.pm_id = 0
|
||||
$limit_time_sql
|
||||
ORDER BY $sort_order_sql";
|
||||
|
||||
/**
|
||||
* Alter sql query to get report id of all reports for requested forum and topic or just forum
|
||||
*
|
||||
* @event core.mcp_reports_get_reports_query_before
|
||||
* @var string sql String with the query to be executed
|
||||
* @var array forum_list List of forums that contain the posts
|
||||
* @var int topic_id topic_id in the page request
|
||||
* @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string)
|
||||
* @var string sort_order_sql String with the ORDER BY SQL code used in this query
|
||||
* @since 3.1.0-RC4
|
||||
*/
|
||||
$vars = array(
|
||||
'sql',
|
||||
'forum_list',
|
||||
'topic_id',
|
||||
'limit_time_sql',
|
||||
'sort_order_sql',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_reports_get_reports_query_before', compact($vars)));
|
||||
|
||||
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
||||
|
||||
$i = 0;
|
||||
$report_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$report_ids[] = $row['report_id'];
|
||||
$row_num[$row['report_id']] = $i++;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (count($report_ids))
|
||||
{
|
||||
$sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id
|
||||
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru
|
||||
WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . '
|
||||
AND t.topic_id = p.topic_id
|
||||
AND r.post_id = p.post_id
|
||||
AND u.user_id = p.poster_id
|
||||
AND ru.user_id = r.user_id
|
||||
AND r.pm_id = 0
|
||||
ORDER BY ' . $sort_order_sql;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_block_vars('postrow', array(
|
||||
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
|
||||
'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'],
|
||||
'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&start=$start&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"),
|
||||
|
||||
'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
||||
'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
||||
'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
||||
'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
||||
|
||||
'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
|
||||
'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
|
||||
'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
|
||||
'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
|
||||
|
||||
'FORUM_NAME' => $forum_data[$row['forum_id']]['forum_name'],
|
||||
'POST_ID' => $row['post_id'],
|
||||
'POST_SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
|
||||
'POST_TIME' => $user->format_date($row['post_time']),
|
||||
'REPORT_ID' => $row['report_id'],
|
||||
'REPORT_TIME' => $user->format_date($row['report_time']),
|
||||
'TOPIC_TITLE' => $row['topic_title'],
|
||||
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
unset($report_ids, $row);
|
||||
}
|
||||
|
||||
$base_url = $this->u_action . "&f=$forum_id&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir";
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start);
|
||||
|
||||
// Now display the page
|
||||
$template->assign_vars(array(
|
||||
'L_EXPLAIN' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'],
|
||||
'L_TITLE' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN'] : $user->lang['MCP_REPORTS_CLOSED'],
|
||||
'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '',
|
||||
|
||||
'S_MCP_ACTION' => $this->u_action,
|
||||
'S_FORUM_OPTIONS' => $forum_options,
|
||||
'S_CLOSED' => ($mode == 'reports_closed') ? true : false,
|
||||
|
||||
'TOPIC_ID' => $topic_id,
|
||||
'TOTAL' => $total,
|
||||
'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total),
|
||||
)
|
||||
);
|
||||
|
||||
$this->tpl_name = 'mcp_reports';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes a report
|
||||
*/
|
||||
function close_report($report_id_list, $mode, $action, $pm = false)
|
||||
{
|
||||
global $db, $user, $auth, $phpbb_log, $request;
|
||||
global $phpEx, $phpbb_root_path, $phpbb_container;
|
||||
|
||||
$pm_where = ($pm) ? ' AND r.post_id = 0 ' : ' AND r.pm_id = 0 ';
|
||||
$id_column = ($pm) ? 'pm_id' : 'post_id';
|
||||
$module = ($pm) ? 'pm_reports' : 'reports';
|
||||
$pm_prefix = ($pm) ? 'PM_' : '';
|
||||
|
||||
$sql = "SELECT r.$id_column
|
||||
FROM " . REPORTS_TABLE . ' r
|
||||
WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . $pm_where;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$post_id_list = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$post_id_list[] = $row[$id_column];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$post_id_list = array_unique($post_id_list);
|
||||
|
||||
if ($pm)
|
||||
{
|
||||
if (!$auth->acl_getf_global('m_report'))
|
||||
{
|
||||
send_status_line(403, 'Forbidden');
|
||||
trigger_error('NOT_AUTHORISED');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report')))
|
||||
{
|
||||
send_status_line(403, 'Forbidden');
|
||||
trigger_error('NOT_AUTHORISED');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'delete' && strpos($user->data['session_page'], 'mode=report_details') !== false)
|
||||
{
|
||||
$redirect = $request->variable('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=reports');
|
||||
}
|
||||
else if ($action == 'delete' && strpos($user->data['session_page'], 'mode=pm_report_details') !== false)
|
||||
{
|
||||
$redirect = $request->variable('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=pm_reports');
|
||||
}
|
||||
else if ($action == 'close' && !$request->variable('r', 0))
|
||||
{
|
||||
$redirect = $request->variable('redirect', build_url(array('mode', 'p', 'quickmod')) . '&mode=' . $module);
|
||||
}
|
||||
else
|
||||
{
|
||||
$redirect = $request->variable('redirect', build_url(array('quickmod')));
|
||||
}
|
||||
$success_msg = '';
|
||||
$forum_ids = array();
|
||||
$topic_ids = array();
|
||||
|
||||
$s_hidden_fields = build_hidden_fields(array(
|
||||
'i' => $module,
|
||||
'mode' => $mode,
|
||||
'report_id_list' => $report_id_list,
|
||||
'action' => $action,
|
||||
'redirect' => $redirect)
|
||||
);
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
$post_info = ($pm) ? phpbb_get_pm_data($post_id_list) : phpbb_get_post_data($post_id_list, 'm_report');
|
||||
|
||||
$sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type
|
||||
FROM " . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u
|
||||
WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . '
|
||||
' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . '
|
||||
AND r.user_id = u.user_id' . $pm_where;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$reports = $close_report_posts = $close_report_topics = $notify_reporters = $report_id_list = array();
|
||||
while ($report = $db->sql_fetchrow($result))
|
||||
{
|
||||
$reports[$report['report_id']] = $report;
|
||||
$report_id_list[] = $report['report_id'];
|
||||
|
||||
if (!$report['report_closed'])
|
||||
{
|
||||
$close_report_posts[] = $report[$id_column];
|
||||
|
||||
if (!$pm)
|
||||
{
|
||||
$close_report_topics[] = $post_info[$report['post_id']]['topic_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($report['user_notify'] && !$report['report_closed'])
|
||||
{
|
||||
$notify_reporters[$report['report_id']] = &$reports[$report['report_id']];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (count($reports))
|
||||
{
|
||||
$close_report_posts = array_unique($close_report_posts);
|
||||
$close_report_topics = array_unique($close_report_topics);
|
||||
|
||||
if (!$pm && count($close_report_posts))
|
||||
{
|
||||
// Get a list of topics that still contain reported posts
|
||||
$sql = 'SELECT DISTINCT topic_id
|
||||
FROM ' . POSTS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . '
|
||||
AND post_reported = 1
|
||||
AND ' . $db->sql_in_set('post_id', $close_report_posts, true);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$keep_report_topics = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$keep_report_topics[] = $row['topic_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$close_report_topics = array_diff($close_report_topics, $keep_report_topics);
|
||||
unset($keep_report_topics);
|
||||
}
|
||||
|
||||
$db->sql_transaction('begin');
|
||||
|
||||
if ($action == 'close')
|
||||
{
|
||||
$sql = 'UPDATE ' . REPORTS_TABLE . '
|
||||
SET report_closed = 1
|
||||
WHERE ' . $db->sql_in_set('report_id', $report_id_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'DELETE FROM ' . REPORTS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('report_id', $report_id_list);
|
||||
}
|
||||
$db->sql_query($sql);
|
||||
|
||||
if (count($close_report_posts))
|
||||
{
|
||||
if ($pm)
|
||||
{
|
||||
$sql = 'UPDATE ' . PRIVMSGS_TABLE . '
|
||||
SET message_reported = 0
|
||||
WHERE ' . $db->sql_in_set('msg_id', $close_report_posts);
|
||||
$db->sql_query($sql);
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
delete_pm(ANONYMOUS, $close_report_posts, PRIVMSGS_INBOX);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'UPDATE ' . POSTS_TABLE . '
|
||||
SET post_reported = 0
|
||||
WHERE ' . $db->sql_in_set('post_id', $close_report_posts);
|
||||
$db->sql_query($sql);
|
||||
|
||||
if (count($close_report_topics))
|
||||
{
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
||||
SET topic_reported = 0
|
||||
WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . '
|
||||
OR ' . $db->sql_in_set('topic_moved_id', $close_report_topics);
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
}
|
||||
unset($close_report_posts, $close_report_topics);
|
||||
|
||||
/* @var $phpbb_notifications \phpbb\notification\manager */
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
foreach ($reports as $report)
|
||||
{
|
||||
if ($pm)
|
||||
{
|
||||
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_PM_REPORT_' . strtoupper($action) . 'D', false, array(
|
||||
'forum_id' => 0,
|
||||
'topic_id' => 0,
|
||||
$post_info[$report['pm_id']]['message_subject']
|
||||
));
|
||||
$phpbb_notifications->delete_notifications('notification.type.report_pm', $report['pm_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_REPORT_' . strtoupper($action) . 'D', false, array(
|
||||
'forum_id' => $post_info[$report['post_id']]['forum_id'],
|
||||
'topic_id' => $post_info[$report['post_id']]['topic_id'],
|
||||
'post_id' => $report['post_id'],
|
||||
$post_info[$report['post_id']]['post_subject']
|
||||
));
|
||||
$phpbb_notifications->delete_notifications('notification.type.report_post', $report['post_id']);
|
||||
}
|
||||
}
|
||||
|
||||
// Notify reporters
|
||||
if (count($notify_reporters))
|
||||
{
|
||||
foreach ($notify_reporters as $report_id => $reporter)
|
||||
{
|
||||
if ($reporter['user_id'] == ANONYMOUS)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$post_id = $reporter[$id_column];
|
||||
|
||||
if ($pm)
|
||||
{
|
||||
$phpbb_notifications->add_notifications('notification.type.report_pm_closed', array_merge($post_info[$post_id], array(
|
||||
'reporter' => $reporter['user_id'],
|
||||
'closer_id' => $user->data['user_id'],
|
||||
'from_user_id' => $post_info[$post_id]['author_id'],
|
||||
)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpbb_notifications->add_notifications('notification.type.report_post_closed', array_merge($post_info[$post_id], array(
|
||||
'reporter' => $reporter['user_id'],
|
||||
'closer_id' => $user->data['user_id'],
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$pm)
|
||||
{
|
||||
foreach ($post_info as $post)
|
||||
{
|
||||
$forum_ids[$post['forum_id']] = $post['forum_id'];
|
||||
$topic_ids[$post['topic_id']] = $post['topic_id'];
|
||||
}
|
||||
}
|
||||
|
||||
unset($notify_reporters, $post_info, $reports);
|
||||
|
||||
$success_msg = (count($report_id_list) == 1) ? "{$pm_prefix}REPORT_" . strtoupper($action) . 'D_SUCCESS' : "{$pm_prefix}REPORTS_" . strtoupper($action) . 'D_SUCCESS';
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm_box(false, $user->lang[strtoupper($action) . "_{$pm_prefix}REPORT" . ((count($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields);
|
||||
}
|
||||
|
||||
$redirect = $request->variable('redirect', "index.$phpEx");
|
||||
$redirect = reapply_sid($redirect);
|
||||
|
||||
if (!$success_msg)
|
||||
{
|
||||
redirect($redirect);
|
||||
}
|
||||
else
|
||||
{
|
||||
meta_refresh(3, $redirect);
|
||||
|
||||
$return_forum = '';
|
||||
$return_topic = '';
|
||||
|
||||
if (!$pm)
|
||||
{
|
||||
if (count($forum_ids) === 1)
|
||||
{
|
||||
$return_forum = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';
|
||||
}
|
||||
|
||||
if (count($topic_ids) === 1)
|
||||
{
|
||||
$return_topic = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . current($topic_ids) . '&f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';
|
||||
}
|
||||
}
|
||||
|
||||
trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>'));
|
||||
}
|
||||
}
|
808
msd2/phpBB3/includes/mcp/mcp_topic.php
Normal file
808
msd2/phpBB3/includes/mcp/mcp_topic.php
Normal file
@ -0,0 +1,808 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* View topic in MCP
|
||||
*/
|
||||
function mcp_topic_view($id, $mode, $action)
|
||||
{
|
||||
global $phpEx, $phpbb_root_path, $config, $request;
|
||||
global $template, $db, $user, $auth, $phpbb_container, $phpbb_dispatcher;
|
||||
|
||||
$url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . phpbb_extra_url());
|
||||
|
||||
/* @var $pagination \phpbb\pagination */
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
$user->add_lang('viewtopic');
|
||||
|
||||
$topic_id = $request->variable('t', 0);
|
||||
$topic_info = phpbb_get_topic_data(array($topic_id), false, true);
|
||||
|
||||
if (!count($topic_info))
|
||||
{
|
||||
trigger_error('TOPIC_NOT_EXIST');
|
||||
}
|
||||
|
||||
$topic_info = $topic_info[$topic_id];
|
||||
|
||||
// Set up some vars
|
||||
$icon_id = $request->variable('icon', 0);
|
||||
$subject = $request->variable('subject', '', true);
|
||||
$start = $request->variable('start', 0);
|
||||
$sort_days_old = $request->variable('st_old', 0);
|
||||
$forum_id = $request->variable('f', 0);
|
||||
$to_topic_id = $request->variable('to_topic_id', 0);
|
||||
$to_forum_id = $request->variable('to_forum_id', 0);
|
||||
$sort = isset($_POST['sort']) ? true : false;
|
||||
$submitted_id_list = $request->variable('post_ids', array(0));
|
||||
$checked_ids = $post_id_list = $request->variable('post_id_list', array(0));
|
||||
|
||||
// Resync Topic?
|
||||
if ($action == 'resync')
|
||||
{
|
||||
if (!function_exists('mcp_resync_topics'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx);
|
||||
}
|
||||
mcp_resync_topics(array($topic_id));
|
||||
}
|
||||
|
||||
// Split Topic?
|
||||
if ($action == 'split_all' || $action == 'split_beyond')
|
||||
{
|
||||
if (!$sort)
|
||||
{
|
||||
split_topic($action, $topic_id, $to_forum_id, $subject);
|
||||
}
|
||||
$action = 'split';
|
||||
}
|
||||
|
||||
// Merge Posts?
|
||||
if ($action == 'merge_posts')
|
||||
{
|
||||
if (!$sort)
|
||||
{
|
||||
merge_posts($topic_id, $to_topic_id);
|
||||
}
|
||||
$action = 'merge';
|
||||
}
|
||||
|
||||
if ($action == 'split' && !$subject)
|
||||
{
|
||||
$subject = $topic_info['topic_title'];
|
||||
}
|
||||
|
||||
// Restore or pprove posts?
|
||||
if (($action == 'restore' || $action == 'approve') && $auth->acl_get('m_approve', $topic_info['forum_id']))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx);
|
||||
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
||||
|
||||
if (!count($post_id_list))
|
||||
{
|
||||
trigger_error('NO_POST_SELECTED');
|
||||
}
|
||||
|
||||
if (!$sort)
|
||||
{
|
||||
mcp_queue::approve_posts($action, $post_id_list, $id, $mode);
|
||||
}
|
||||
}
|
||||
|
||||
// Jumpbox, sort selects and that kind of things
|
||||
make_jumpbox($url . "&i=$id&mode=forum_view", $topic_info['forum_id'], false, 'm_', true);
|
||||
$where_sql = ($action == 'reports') ? 'WHERE post_reported = 1 AND ' : 'WHERE';
|
||||
|
||||
$sort_days = $total = 0;
|
||||
$sort_key = $sort_dir = '';
|
||||
$sort_by_sql = $sort_order_sql = array();
|
||||
phpbb_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql);
|
||||
|
||||
/* @var $phpbb_content_visibility \phpbb\content_visibility */
|
||||
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
|
||||
$limit_time_sql = ($sort_days) ? 'AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
|
||||
|
||||
if ($total == -1)
|
||||
{
|
||||
$total = $phpbb_content_visibility->get_count('topic_posts', $topic_info, $topic_info['forum_id']);
|
||||
}
|
||||
|
||||
$posts_per_page = max(0, $request->variable('posts_per_page', intval($config['posts_per_page'])));
|
||||
if ($posts_per_page == 0)
|
||||
{
|
||||
$posts_per_page = $total;
|
||||
}
|
||||
|
||||
if ((!empty($sort_days_old) && $sort_days_old != $sort_days) || $total <= $posts_per_page)
|
||||
{
|
||||
$start = 0;
|
||||
}
|
||||
$start = $pagination->validate_start($start, $posts_per_page, $total);
|
||||
|
||||
$sql = 'SELECT u.username, u.username_clean, u.user_colour, p.*
|
||||
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
|
||||
WHERE ' . (($action == 'reports') ? 'p.post_reported = 1 AND ' : '') . '
|
||||
p.topic_id = ' . $topic_id . '
|
||||
AND ' . $phpbb_content_visibility->get_visibility_sql('post', $topic_info['forum_id'], 'p.') . '
|
||||
AND p.poster_id = u.user_id ' .
|
||||
$limit_time_sql . '
|
||||
ORDER BY ' . $sort_order_sql;
|
||||
$result = $db->sql_query_limit($sql, $posts_per_page, $start);
|
||||
|
||||
$rowset = $post_id_list = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rowset[] = $row;
|
||||
$post_id_list[] = $row['post_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Get topic tracking info
|
||||
if ($config['load_db_lastread'])
|
||||
{
|
||||
$tmp_topic_data = array($topic_id => $topic_info);
|
||||
$topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time']));
|
||||
unset($tmp_topic_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id);
|
||||
}
|
||||
|
||||
$has_unapproved_posts = $has_deleted_posts = false;
|
||||
|
||||
// Grab extensions
|
||||
$attachments = array();
|
||||
if ($topic_info['topic_attachment'] && count($post_id_list))
|
||||
{
|
||||
// Get attachments...
|
||||
if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id']))
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . '
|
||||
AND in_message = 0
|
||||
ORDER BY filetime DESC, post_msg_id ASC';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$attachments[$row['post_msg_id']][] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event to modify the post data for the MCP topic review before assigning the posts
|
||||
*
|
||||
* @event core.mcp_topic_modify_post_data
|
||||
* @var array attachments List of attachments post_id => array of attachments
|
||||
* @var int forum_id The forum ID we are currently in
|
||||
* @var int id ID of the tab we are displaying
|
||||
* @var string mode Mode of the MCP page we are displaying
|
||||
* @var array post_id_list Array with post ids we are going to display
|
||||
* @var array rowset Array with the posts data
|
||||
* @var int topic_id The topic ID we are currently reviewing
|
||||
* @since 3.1.7-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'attachments',
|
||||
'forum_id',
|
||||
'id',
|
||||
'mode',
|
||||
'post_id_list',
|
||||
'rowset',
|
||||
'topic_id',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_topic_modify_post_data', compact($vars)));
|
||||
|
||||
foreach ($rowset as $i => $row)
|
||||
{
|
||||
$message = $row['post_text'];
|
||||
$post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : $topic_info['topic_title'];
|
||||
|
||||
$parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
|
||||
$message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false);
|
||||
|
||||
if (!empty($attachments[$row['post_id']]))
|
||||
{
|
||||
$update_count = array();
|
||||
parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count);
|
||||
}
|
||||
|
||||
if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE)
|
||||
{
|
||||
$has_unapproved_posts = true;
|
||||
}
|
||||
|
||||
if ($row['post_visibility'] == ITEM_DELETED)
|
||||
{
|
||||
$has_deleted_posts = true;
|
||||
}
|
||||
|
||||
$post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
||||
|
||||
$post_row = array(
|
||||
'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
||||
'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
||||
'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
||||
'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
||||
|
||||
'POST_DATE' => $user->format_date($row['post_time']),
|
||||
'POST_SUBJECT' => $post_subject,
|
||||
'MESSAGE' => $message,
|
||||
'POST_ID' => $row['post_id'],
|
||||
'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id) . '">', '</a>'),
|
||||
|
||||
'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'),
|
||||
|
||||
'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id'])),
|
||||
'S_POST_UNAPPROVED' => (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $topic_info['forum_id'])),
|
||||
'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED && $auth->acl_get('m_approve', $topic_info['forum_id'])),
|
||||
'S_CHECKED' => (($submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list)) || in_array(intval($row['post_id']), $checked_ids)) ? true : false,
|
||||
'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
|
||||
|
||||
'U_POST_DETAILS' => "$url&i=$id&p={$row['post_id']}&mode=post_details" . (($forum_id) ? "&f=$forum_id" : ''),
|
||||
'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '',
|
||||
'U_MCP_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '',
|
||||
);
|
||||
|
||||
/**
|
||||
* Event to modify the template data block for topic reviews in the MCP
|
||||
*
|
||||
* @event core.mcp_topic_review_modify_row
|
||||
* @var int id ID of the tab we are displaying
|
||||
* @var string mode Mode of the MCP page we are displaying
|
||||
* @var int topic_id The topic ID we are currently reviewing
|
||||
* @var int forum_id The forum ID we are currently in
|
||||
* @var int start Start item of this page
|
||||
* @var int current_row_number Number of the post on this page
|
||||
* @var array post_row Template block array of the current post
|
||||
* @var array row Array with original post and user data
|
||||
* @var array topic_info Array with topic data
|
||||
* @var int total Total posts count
|
||||
* @since 3.1.4-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'id',
|
||||
'mode',
|
||||
'topic_id',
|
||||
'forum_id',
|
||||
'start',
|
||||
'current_row_number',
|
||||
'post_row',
|
||||
'row',
|
||||
'topic_info',
|
||||
'total',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_topic_review_modify_row', compact($vars)));
|
||||
|
||||
$template->assign_block_vars('postrow', $post_row);
|
||||
|
||||
// Display not already displayed Attachments for this post, we already parsed them. ;)
|
||||
if (!empty($attachments[$row['post_id']]))
|
||||
{
|
||||
foreach ($attachments[$row['post_id']] as $attachment)
|
||||
{
|
||||
$template->assign_block_vars('postrow.attachment', array(
|
||||
'DISPLAY_ATTACHMENT' => $attachment)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
unset($rowset[$i]);
|
||||
}
|
||||
|
||||
// Display topic icons for split topic
|
||||
$s_topic_icons = false;
|
||||
|
||||
if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id']))
|
||||
{
|
||||
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
||||
$s_topic_icons = posting_gen_topic_icons('', $icon_id);
|
||||
|
||||
// Has the user selected a topic for merge?
|
||||
if ($to_topic_id)
|
||||
{
|
||||
$to_topic_info = phpbb_get_topic_data(array($to_topic_id), 'm_merge');
|
||||
|
||||
if (!count($to_topic_info))
|
||||
{
|
||||
$to_topic_id = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$to_topic_info = $to_topic_info[$to_topic_id];
|
||||
|
||||
if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id']))
|
||||
{
|
||||
$s_topic_icons = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$s_hidden_fields = build_hidden_fields(array(
|
||||
'st_old' => $sort_days,
|
||||
'post_ids' => $post_id_list,
|
||||
));
|
||||
|
||||
$base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&t={$topic_info['topic_id']}&mode=$mode&action=$action&to_topic_id=$to_topic_id&posts_per_page=$posts_per_page&st=$sort_days&sk=$sort_key&sd=$sort_dir");
|
||||
if ($posts_per_page)
|
||||
{
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $posts_per_page, $start);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'TOPIC_TITLE' => $topic_info['topic_title'],
|
||||
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']),
|
||||
|
||||
'TO_TOPIC_ID' => $to_topic_id,
|
||||
'TO_TOPIC_INFO' => ($to_topic_id) ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_topic_info['forum_id'] . '&t=' . $to_topic_id) . '">' . $to_topic_info['topic_title'] . '</a>') : '',
|
||||
|
||||
'SPLIT_SUBJECT' => $subject,
|
||||
'POSTS_PER_PAGE' => $posts_per_page,
|
||||
'ACTION' => $action,
|
||||
|
||||
'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'),
|
||||
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'),
|
||||
'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'),
|
||||
'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'),
|
||||
|
||||
'S_MCP_ACTION' => "$url&i=$id&mode=$mode&action=$action&start=$start",
|
||||
'S_FORUM_SELECT' => ($to_forum_id) ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true),
|
||||
'S_CAN_SPLIT' => ($auth->acl_get('m_split', $topic_info['forum_id'])) ? true : false,
|
||||
'S_CAN_MERGE' => ($auth->acl_get('m_merge', $topic_info['forum_id'])) ? true : false,
|
||||
'S_CAN_DELETE' => ($auth->acl_get('m_delete', $topic_info['forum_id'])) ? true : false,
|
||||
'S_CAN_APPROVE' => ($has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false,
|
||||
'S_CAN_RESTORE' => ($has_deleted_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false,
|
||||
'S_CAN_LOCK' => ($auth->acl_get('m_lock', $topic_info['forum_id'])) ? true : false,
|
||||
'S_CAN_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? true : false,
|
||||
'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']),
|
||||
'S_REPORT_VIEW' => ($action == 'reports') ? true : false,
|
||||
'S_MERGE_VIEW' => ($action == 'merge') ? true : false,
|
||||
'S_SPLIT_VIEW' => ($action == 'split') ? true : false,
|
||||
|
||||
'S_HIDDEN_FIELDS' => $s_hidden_fields,
|
||||
|
||||
'S_SHOW_TOPIC_ICONS' => $s_topic_icons,
|
||||
'S_TOPIC_ICON' => $icon_id,
|
||||
|
||||
'U_SELECT_TOPIC' => "$url&i=$id&mode=forum_view&action=merge_select" . (($forum_id) ? "&f=$forum_id" : ''),
|
||||
|
||||
'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_info['forum_id']}&t={$topic_info['topic_id']}&start=$start") . '">', '</a>'),
|
||||
'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$topic_info['forum_id']}&start=$start") . '">', '</a>'),
|
||||
|
||||
'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Split topic
|
||||
*/
|
||||
function split_topic($action, $topic_id, $to_forum_id, $subject)
|
||||
{
|
||||
global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config, $phpbb_log, $request, $phpbb_dispatcher;
|
||||
|
||||
$post_id_list = $request->variable('post_id_list', array(0));
|
||||
$forum_id = $request->variable('forum_id', 0);
|
||||
$start = $request->variable('start', 0);
|
||||
|
||||
if (!count($post_id_list))
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_split')))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$post_id = $post_id_list[0];
|
||||
$post_info = phpbb_get_post_data(array($post_id));
|
||||
|
||||
if (!count($post_info))
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
|
||||
return;
|
||||
}
|
||||
|
||||
$post_info = $post_info[$post_id];
|
||||
$subject = trim($subject);
|
||||
|
||||
// Make some tests
|
||||
if (!$subject)
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['EMPTY_SUBJECT']);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($to_forum_id <= 0)
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['NO_DESTINATION_FORUM']);
|
||||
return;
|
||||
}
|
||||
|
||||
$forum_info = phpbb_get_forum_data(array($to_forum_id), 'f_post');
|
||||
|
||||
if (!count($forum_info))
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['USER_CANNOT_POST']);
|
||||
return;
|
||||
}
|
||||
|
||||
$forum_info = $forum_info[$to_forum_id];
|
||||
|
||||
if ($forum_info['forum_type'] != FORUM_POST)
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['FORUM_NOT_POSTABLE']);
|
||||
return;
|
||||
}
|
||||
|
||||
$redirect = $request->variable('redirect', build_url(array('quickmod')));
|
||||
|
||||
$s_hidden_fields = build_hidden_fields(array(
|
||||
'i' => 'main',
|
||||
'post_id_list' => $post_id_list,
|
||||
'f' => $forum_id,
|
||||
'mode' => 'topic_view',
|
||||
'start' => $start,
|
||||
'action' => $action,
|
||||
't' => $topic_id,
|
||||
'redirect' => $redirect,
|
||||
'subject' => $subject,
|
||||
'to_forum_id' => $to_forum_id,
|
||||
'icon' => $request->variable('icon', 0))
|
||||
);
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
if ($action == 'split_beyond')
|
||||
{
|
||||
$sort_days = $total = 0;
|
||||
$sort_key = $sort_dir = '';
|
||||
$sort_by_sql = $sort_order_sql = array();
|
||||
phpbb_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id);
|
||||
|
||||
$limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
|
||||
|
||||
if ($sort_order_sql[0] == 'u')
|
||||
{
|
||||
$sql = 'SELECT p.post_id, p.forum_id, p.post_visibility
|
||||
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
|
||||
WHERE p.topic_id = $topic_id
|
||||
AND p.poster_id = u.user_id
|
||||
$limit_time_sql
|
||||
ORDER BY $sort_order_sql";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT p.post_id, p.forum_id, p.post_visibility
|
||||
FROM ' . POSTS_TABLE . " p
|
||||
WHERE p.topic_id = $topic_id
|
||||
$limit_time_sql
|
||||
ORDER BY $sort_order_sql";
|
||||
}
|
||||
$result = $db->sql_query_limit($sql, 0, $start);
|
||||
|
||||
$store = false;
|
||||
$post_id_list = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
// If split from selected post (split_beyond), we split the unapproved items too.
|
||||
if (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $row['forum_id']))
|
||||
{
|
||||
// continue;
|
||||
}
|
||||
|
||||
// Start to store post_ids as soon as we see the first post that was selected
|
||||
if ($row['post_id'] == $post_id)
|
||||
{
|
||||
$store = true;
|
||||
}
|
||||
|
||||
if ($store)
|
||||
{
|
||||
$post_id_list[] = $row['post_id'];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
if (!count($post_id_list))
|
||||
{
|
||||
trigger_error('NO_POST_SELECTED');
|
||||
}
|
||||
|
||||
$icon_id = $request->variable('icon', 0);
|
||||
|
||||
$sql_ary = array(
|
||||
'forum_id' => $to_forum_id,
|
||||
'topic_title' => $subject,
|
||||
'icon_id' => $icon_id,
|
||||
'topic_visibility' => 1
|
||||
);
|
||||
|
||||
$sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
||||
$db->sql_query($sql);
|
||||
|
||||
$to_topic_id = $db->sql_nextid();
|
||||
move_posts($post_id_list, $to_topic_id);
|
||||
|
||||
$topic_info = phpbb_get_topic_data(array($topic_id));
|
||||
$topic_info = $topic_info[$topic_id];
|
||||
|
||||
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SPLIT_DESTINATION', false, array(
|
||||
'forum_id' => $to_forum_id,
|
||||
'topic_id' => $to_topic_id,
|
||||
$subject
|
||||
));
|
||||
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SPLIT_SOURCE', false, array(
|
||||
'forum_id' => $forum_id,
|
||||
'topic_id' => $topic_id,
|
||||
$topic_info['topic_title']
|
||||
));
|
||||
|
||||
// Change topic title of first post
|
||||
$sql = 'UPDATE ' . POSTS_TABLE . "
|
||||
SET post_subject = '" . $db->sql_escape($subject) . "'
|
||||
WHERE post_id = {$post_id_list[0]}";
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Grab data for first post in split topic
|
||||
$sql_array = array(
|
||||
'SELECT' => 'p.post_id, p.forum_id, p.poster_id, p.post_text, f.enable_indexing',
|
||||
'FROM' => array(
|
||||
POSTS_TABLE => 'p',
|
||||
),
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(FORUMS_TABLE => 'f'),
|
||||
'ON' => 'p.forum_id = f.forum_id',
|
||||
)
|
||||
),
|
||||
'WHERE' => "post_id = {$post_id_list[0]}",
|
||||
);
|
||||
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
$result = $db->sql_query($sql);
|
||||
$first_post_data = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Index first post as if it were edited
|
||||
if ($first_post_data['enable_indexing'])
|
||||
{
|
||||
// Select the search method and do some additional checks to ensure it can actually be utilised
|
||||
$search_type = $config['search_type'];
|
||||
|
||||
if (!class_exists($search_type))
|
||||
{
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
|
||||
$error = false;
|
||||
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
|
||||
|
||||
if ($error)
|
||||
{
|
||||
trigger_error($error);
|
||||
}
|
||||
|
||||
$search->index('edit', $first_post_data['post_id'], $first_post_data['post_text'], $subject, $first_post_data['poster_id'], $first_post_data['forum_id']);
|
||||
}
|
||||
|
||||
// Copy topic subscriptions to new topic
|
||||
$sql = 'SELECT user_id, notify_status
|
||||
FROM ' . TOPICS_WATCH_TABLE . '
|
||||
WHERE topic_id = ' . $topic_id;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$sql_ary = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$sql_ary[] = array(
|
||||
'topic_id' => (int) $to_topic_id,
|
||||
'user_id' => (int) $row['user_id'],
|
||||
'notify_status' => (int) $row['notify_status'],
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (count($sql_ary))
|
||||
{
|
||||
$db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary);
|
||||
}
|
||||
|
||||
// Copy bookmarks to new topic
|
||||
$sql = 'SELECT user_id
|
||||
FROM ' . BOOKMARKS_TABLE . '
|
||||
WHERE topic_id = ' . $topic_id;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$sql_ary = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$sql_ary[] = array(
|
||||
'topic_id' => (int) $to_topic_id,
|
||||
'user_id' => (int) $row['user_id'],
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (count($sql_ary))
|
||||
{
|
||||
$db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary);
|
||||
}
|
||||
|
||||
$success_msg = 'TOPIC_SPLIT_SUCCESS';
|
||||
|
||||
// Update forum statistics
|
||||
$config->increment('num_topics', 1, false);
|
||||
|
||||
// Link back to both topics
|
||||
$return_link = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']) . '">', '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>');
|
||||
$redirect = $request->variable('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id");
|
||||
$redirect = reapply_sid($redirect);
|
||||
|
||||
meta_refresh(3, $redirect);
|
||||
trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm_box(false, ($action == 'split_all') ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge selected posts into selected topic
|
||||
*/
|
||||
function merge_posts($topic_id, $to_topic_id)
|
||||
{
|
||||
global $db, $template, $user, $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher;
|
||||
|
||||
if (!$to_topic_id)
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
|
||||
return;
|
||||
}
|
||||
|
||||
$sync_topics = array($topic_id, $to_topic_id);
|
||||
|
||||
$topic_data = phpbb_get_topic_data($sync_topics, 'm_merge');
|
||||
|
||||
if (!count($topic_data) || empty($topic_data[$to_topic_id]))
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
|
||||
return;
|
||||
}
|
||||
|
||||
$sync_forums = array();
|
||||
foreach ($topic_data as $data)
|
||||
{
|
||||
$sync_forums[$data['forum_id']] = $data['forum_id'];
|
||||
}
|
||||
|
||||
$topic_data = $topic_data[$to_topic_id];
|
||||
|
||||
$post_id_list = $request->variable('post_id_list', array(0));
|
||||
$start = $request->variable('start', 0);
|
||||
|
||||
if (!count($post_id_list))
|
||||
{
|
||||
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge')))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$redirect = $request->variable('redirect', build_url(array('quickmod')));
|
||||
|
||||
$s_hidden_fields = build_hidden_fields(array(
|
||||
'i' => 'main',
|
||||
'post_id_list' => $post_id_list,
|
||||
'to_topic_id' => $to_topic_id,
|
||||
'mode' => 'topic_view',
|
||||
'action' => 'merge_posts',
|
||||
'start' => $start,
|
||||
'redirect' => $redirect,
|
||||
't' => $topic_id)
|
||||
);
|
||||
$return_link = '';
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
$to_forum_id = $topic_data['forum_id'];
|
||||
|
||||
move_posts($post_id_list, $to_topic_id, false);
|
||||
|
||||
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MERGE', false, array(
|
||||
'forum_id' => $to_forum_id,
|
||||
'topic_id' => $to_topic_id,
|
||||
$topic_data['topic_title']
|
||||
));
|
||||
|
||||
// Message and return links
|
||||
$success_msg = 'POSTS_MERGED_SUCCESS';
|
||||
|
||||
// Does the original topic still exist? If yes, link back to it
|
||||
$sql = 'SELECT forum_id
|
||||
FROM ' . POSTS_TABLE . '
|
||||
WHERE topic_id = ' . $topic_id;
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
$return_link .= sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $topic_id) . '">', '</a>');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx);
|
||||
}
|
||||
|
||||
// If the topic no longer exist, we will update the topic watch table.
|
||||
phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', array($topic_id), $to_topic_id);
|
||||
|
||||
// If the topic no longer exist, we will update the bookmarks table.
|
||||
phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', array($topic_id), $to_topic_id);
|
||||
}
|
||||
|
||||
// Re-sync the topics and forums because the auto-sync was deactivated in the call of move_posts()
|
||||
sync('topic_reported', 'topic_id', $sync_topics);
|
||||
sync('topic_attachment', 'topic_id', $sync_topics);
|
||||
sync('topic', 'topic_id', $sync_topics, true);
|
||||
sync('forum', 'forum_id', $sync_forums, true, true);
|
||||
|
||||
// Link to the new topic
|
||||
$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>');
|
||||
$redirect = $request->variable('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id");
|
||||
$redirect = reapply_sid($redirect);
|
||||
|
||||
/**
|
||||
* Perform additional actions after merging posts.
|
||||
*
|
||||
* @event core.mcp_topics_merge_posts_after
|
||||
* @var int topic_id The topic ID from which posts are being moved
|
||||
* @var int to_topic_id The topic ID to which posts are being moved
|
||||
* @since 3.1.11-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'topic_id',
|
||||
'to_topic_id',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_topics_merge_posts_after', compact($vars)));
|
||||
|
||||
meta_refresh(3, $redirect);
|
||||
trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm_box(false, 'MERGE_POSTS', $s_hidden_fields);
|
||||
}
|
||||
}
|
610
msd2/phpBB3/includes/mcp/mcp_warn.php
Normal file
610
msd2/phpBB3/includes/mcp/mcp_warn.php
Normal file
@ -0,0 +1,610 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* mcp_warn
|
||||
* Handling warning the users
|
||||
*/
|
||||
class mcp_warn
|
||||
{
|
||||
var $p_master;
|
||||
var $u_action;
|
||||
|
||||
function __construct(&$p_master)
|
||||
{
|
||||
$this->p_master = &$p_master;
|
||||
}
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $request;
|
||||
|
||||
$action = $request->variable('action', array('' => ''));
|
||||
|
||||
if (is_array($action))
|
||||
{
|
||||
list($action, ) = each($action);
|
||||
}
|
||||
|
||||
$this->page_title = 'MCP_WARN';
|
||||
|
||||
add_form_key('mcp_warn');
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case 'front':
|
||||
$this->mcp_warn_front_view();
|
||||
$this->tpl_name = 'mcp_warn_front';
|
||||
break;
|
||||
|
||||
case 'list':
|
||||
$this->mcp_warn_list_view($action);
|
||||
$this->tpl_name = 'mcp_warn_list';
|
||||
break;
|
||||
|
||||
case 'warn_post':
|
||||
$this->mcp_warn_post_view($action);
|
||||
$this->tpl_name = 'mcp_warn_post';
|
||||
break;
|
||||
|
||||
case 'warn_user':
|
||||
$this->mcp_warn_user_view($action);
|
||||
$this->tpl_name = 'mcp_warn_user';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the summary on the main page of the warning module
|
||||
*/
|
||||
function mcp_warn_front_view()
|
||||
{
|
||||
global $phpEx, $phpbb_root_path;
|
||||
global $template, $db, $user;
|
||||
|
||||
$template->assign_vars(array(
|
||||
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp&field=username&select_single=true'),
|
||||
'U_POST_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user'),
|
||||
));
|
||||
|
||||
// Obtain a list of the 5 naughtiest users....
|
||||
// These are the 5 users with the highest warning count
|
||||
$highest = array();
|
||||
$count = 0;
|
||||
|
||||
view_warned_users($highest, $count, 5);
|
||||
|
||||
foreach ($highest as $row)
|
||||
{
|
||||
$template->assign_block_vars('highest', array(
|
||||
'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),
|
||||
|
||||
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
|
||||
'WARNING_TIME' => $user->format_date($row['user_last_warning']),
|
||||
'WARNINGS' => $row['user_warnings'],
|
||||
));
|
||||
}
|
||||
|
||||
// And now the 5 most recent users to get in trouble
|
||||
$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_warnings, w.warning_time
|
||||
FROM ' . USERS_TABLE . ' u, ' . WARNINGS_TABLE . ' w
|
||||
WHERE u.user_id = w.user_id
|
||||
ORDER BY w.warning_time DESC';
|
||||
$result = $db->sql_query_limit($sql, 5);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_block_vars('latest', array(
|
||||
'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),
|
||||
|
||||
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
|
||||
'WARNING_TIME' => $user->format_date($row['warning_time']),
|
||||
'WARNINGS' => $row['user_warnings'],
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all users with warnings
|
||||
*/
|
||||
function mcp_warn_list_view($action)
|
||||
{
|
||||
global $phpEx, $phpbb_root_path, $config, $phpbb_container;
|
||||
global $template, $user, $auth, $request;
|
||||
|
||||
/* @var $pagination \phpbb\pagination */
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
$user->add_lang('memberlist');
|
||||
|
||||
$start = $request->variable('start', 0);
|
||||
$st = $request->variable('st', 0);
|
||||
$sk = $request->variable('sk', 'b');
|
||||
$sd = $request->variable('sd', 'd');
|
||||
|
||||
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_WARNINGS']);
|
||||
$sort_by_sql = array('a' => 'username_clean', 'b' => 'user_last_warning', 'c' => 'user_warnings');
|
||||
|
||||
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
|
||||
gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
|
||||
|
||||
// Define where and sort sql for use in displaying logs
|
||||
$sql_where = ($st) ? (time() - ($st * 86400)) : 0;
|
||||
$sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC');
|
||||
|
||||
$users = array();
|
||||
$user_count = 0;
|
||||
|
||||
view_warned_users($users, $user_count, $config['topics_per_page'], $start, $sql_where, $sql_sort);
|
||||
|
||||
foreach ($users as $row)
|
||||
{
|
||||
$template->assign_block_vars('user', array(
|
||||
'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),
|
||||
|
||||
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
|
||||
'WARNING_TIME' => $user->format_date($row['user_last_warning']),
|
||||
'WARNINGS' => $row['user_warnings'],
|
||||
));
|
||||
}
|
||||
|
||||
$base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&mode=list&st=$st&sk=$sk&sd=$sd");
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $user_count, $config['topics_per_page'], $start);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'U_POST_ACTION' => $this->u_action,
|
||||
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
|
||||
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
||||
'S_SELECT_SORT_KEY' => $s_sort_key,
|
||||
'S_SELECT_SORT_DAYS' => $s_limit_days,
|
||||
|
||||
'TOTAL_USERS' => $user->lang('LIST_USERS', (int) $user_count),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles warning the user when the warning is for a specific post
|
||||
*/
|
||||
function mcp_warn_post_view($action)
|
||||
{
|
||||
global $phpEx, $phpbb_root_path, $config, $request;
|
||||
global $template, $db, $user, $phpbb_dispatcher;
|
||||
|
||||
$post_id = $request->variable('p', 0);
|
||||
$forum_id = $request->variable('f', 0);
|
||||
$notify = (isset($_REQUEST['notify_user'])) ? true : false;
|
||||
$warning = $request->variable('warning', '', true);
|
||||
|
||||
$sql = 'SELECT u.*, p.*
|
||||
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
|
||||
WHERE p.post_id = $post_id
|
||||
AND u.user_id = p.poster_id";
|
||||
$result = $db->sql_query($sql);
|
||||
$user_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$user_row)
|
||||
{
|
||||
trigger_error('NO_POST');
|
||||
}
|
||||
|
||||
// There is no point issuing a warning to ignored users (ie anonymous and bots)
|
||||
if ($user_row['user_type'] == USER_IGNORE)
|
||||
{
|
||||
trigger_error('CANNOT_WARN_ANONYMOUS');
|
||||
}
|
||||
|
||||
// Prevent someone from warning themselves
|
||||
if ($user_row['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
trigger_error('CANNOT_WARN_SELF');
|
||||
}
|
||||
|
||||
// Check if there is already a warning for this post to prevent multiple
|
||||
// warnings for the same offence
|
||||
$sql = 'SELECT post_id
|
||||
FROM ' . WARNINGS_TABLE . "
|
||||
WHERE post_id = $post_id";
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
trigger_error('ALREADY_WARNED');
|
||||
}
|
||||
|
||||
$user_id = $user_row['user_id'];
|
||||
|
||||
if (strpos($this->u_action, "&f=$forum_id&p=$post_id") === false)
|
||||
{
|
||||
$this->p_master->adjust_url("&f=$forum_id&p=$post_id");
|
||||
$this->u_action .= "&f=$forum_id&p=$post_id";
|
||||
}
|
||||
|
||||
// Check if can send a notification
|
||||
if ($config['allow_privmsg'])
|
||||
{
|
||||
$auth2 = new \phpbb\auth\auth();
|
||||
$auth2->acl($user_row);
|
||||
$s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false;
|
||||
unset($auth2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$s_can_notify = false;
|
||||
}
|
||||
|
||||
// Prevent against clever people
|
||||
if ($notify && !$s_can_notify)
|
||||
{
|
||||
$notify = false;
|
||||
}
|
||||
|
||||
if ($warning && $action == 'add_warning')
|
||||
{
|
||||
if (check_form_key('mcp_warn'))
|
||||
{
|
||||
$s_mcp_warn_post = true;
|
||||
|
||||
/**
|
||||
* Event for before warning a user for a post.
|
||||
*
|
||||
* @event core.mcp_warn_post_before
|
||||
* @var array user_row The entire user row
|
||||
* @var string warning The warning message
|
||||
* @var bool notify If true, we notify the user for the warning
|
||||
* @var int post_id The post id for which the warning is added
|
||||
* @var bool s_mcp_warn_post If true, we add the warning else we omit it
|
||||
* @since 3.1.0-b4
|
||||
*/
|
||||
$vars = array(
|
||||
'user_row',
|
||||
'warning',
|
||||
'notify',
|
||||
'post_id',
|
||||
's_mcp_warn_post',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_warn_post_before', compact($vars)));
|
||||
|
||||
if ($s_mcp_warn_post)
|
||||
{
|
||||
add_warning($user_row, $warning, $notify, $post_id);
|
||||
$message = $user->lang['USER_WARNING_ADDED'];
|
||||
|
||||
/**
|
||||
* Event for after warning a user for a post.
|
||||
*
|
||||
* @event core.mcp_warn_post_after
|
||||
* @var array user_row The entire user row
|
||||
* @var string warning The warning message
|
||||
* @var bool notify If true, the user was notified for the warning
|
||||
* @var int post_id The post id for which the warning is added
|
||||
* @var string message Message displayed to the moderator
|
||||
* @since 3.1.0-b4
|
||||
*/
|
||||
$vars = array(
|
||||
'user_row',
|
||||
'warning',
|
||||
'notify',
|
||||
'post_id',
|
||||
'message',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_warn_post_after', compact($vars)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $user->lang['FORM_INVALID'];
|
||||
}
|
||||
|
||||
if (!empty($message))
|
||||
{
|
||||
$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id");
|
||||
meta_refresh(2, $redirect);
|
||||
trigger_error($message . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
|
||||
}
|
||||
}
|
||||
|
||||
// OK, they didn't submit a warning so lets build the page for them to do so
|
||||
|
||||
// We want to make the message available here as a reminder
|
||||
// Parse the message and subject
|
||||
$parse_flags = OPTION_FLAG_SMILIES | ($user_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0);
|
||||
$message = generate_text_for_display($user_row['post_text'], $user_row['bbcode_uid'], $user_row['bbcode_bitfield'], $parse_flags, true);
|
||||
|
||||
// Generate the appropriate user information for the user we are looking at
|
||||
if (!function_exists('phpbb_get_user_rank'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||
}
|
||||
|
||||
$user_rank_data = phpbb_get_user_rank($user_row, $user_row['user_posts']);
|
||||
$avatar_img = phpbb_get_user_avatar($user_row);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'U_POST_ACTION' => $this->u_action,
|
||||
|
||||
'POST' => $message,
|
||||
'USERNAME' => $user_row['username'],
|
||||
'USER_COLOR' => (!empty($user_row['user_colour'])) ? $user_row['user_colour'] : '',
|
||||
'RANK_TITLE' => $user_rank_data['title'],
|
||||
'JOINED' => $user->format_date($user_row['user_regdate']),
|
||||
'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0,
|
||||
'WARNINGS' => ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0,
|
||||
|
||||
'AVATAR_IMG' => $avatar_img,
|
||||
'RANK_IMG' => $user_rank_data['img'],
|
||||
|
||||
'L_WARNING_POST_DEFAULT' => sprintf($user->lang['WARNING_POST_DEFAULT'], generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&p=$post_id#p$post_id"),
|
||||
|
||||
'S_CAN_NOTIFY' => $s_can_notify,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles warning the user
|
||||
*/
|
||||
function mcp_warn_user_view($action)
|
||||
{
|
||||
global $phpEx, $phpbb_root_path, $config, $request;
|
||||
global $template, $db, $user, $phpbb_dispatcher;
|
||||
|
||||
$user_id = $request->variable('u', 0);
|
||||
$username = $request->variable('username', '', true);
|
||||
$notify = (isset($_REQUEST['notify_user'])) ? true : false;
|
||||
$warning = $request->variable('warning', '', true);
|
||||
|
||||
$sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE ' . $sql_where;
|
||||
$result = $db->sql_query($sql);
|
||||
$user_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$user_row)
|
||||
{
|
||||
trigger_error('NO_USER');
|
||||
}
|
||||
|
||||
// Prevent someone from warning themselves
|
||||
if ($user_row['user_id'] == $user->data['user_id'])
|
||||
{
|
||||
trigger_error('CANNOT_WARN_SELF');
|
||||
}
|
||||
|
||||
$user_id = $user_row['user_id'];
|
||||
|
||||
if (strpos($this->u_action, "&u=$user_id") === false)
|
||||
{
|
||||
$this->p_master->adjust_url('&u=' . $user_id);
|
||||
$this->u_action .= "&u=$user_id";
|
||||
}
|
||||
|
||||
// Check if can send a notification
|
||||
if ($config['allow_privmsg'])
|
||||
{
|
||||
$auth2 = new \phpbb\auth\auth();
|
||||
$auth2->acl($user_row);
|
||||
$s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false;
|
||||
unset($auth2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$s_can_notify = false;
|
||||
}
|
||||
|
||||
// Prevent against clever people
|
||||
if ($notify && !$s_can_notify)
|
||||
{
|
||||
$notify = false;
|
||||
}
|
||||
|
||||
if ($warning && $action == 'add_warning')
|
||||
{
|
||||
if (check_form_key('mcp_warn'))
|
||||
{
|
||||
$s_mcp_warn_user = true;
|
||||
|
||||
/**
|
||||
* Event for before warning a user from MCP.
|
||||
*
|
||||
* @event core.mcp_warn_user_before
|
||||
* @var array user_row The entire user row
|
||||
* @var string warning The warning message
|
||||
* @var bool notify If true, we notify the user for the warning
|
||||
* @var bool s_mcp_warn_user If true, we add the warning else we omit it
|
||||
* @since 3.1.0-b4
|
||||
*/
|
||||
$vars = array(
|
||||
'user_row',
|
||||
'warning',
|
||||
'notify',
|
||||
's_mcp_warn_user',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_before', compact($vars)));
|
||||
|
||||
if ($s_mcp_warn_user)
|
||||
{
|
||||
add_warning($user_row, $warning, $notify);
|
||||
$message = $user->lang['USER_WARNING_ADDED'];
|
||||
|
||||
/**
|
||||
* Event for after warning a user from MCP.
|
||||
*
|
||||
* @event core.mcp_warn_user_after
|
||||
* @var array user_row The entire user row
|
||||
* @var string warning The warning message
|
||||
* @var bool notify If true, the user was notified for the warning
|
||||
* @var string message Message displayed to the moderator
|
||||
* @since 3.1.0-b4
|
||||
*/
|
||||
$vars = array(
|
||||
'user_row',
|
||||
'warning',
|
||||
'notify',
|
||||
'message',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_after', compact($vars)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $user->lang['FORM_INVALID'];
|
||||
}
|
||||
|
||||
if (!empty($message))
|
||||
{
|
||||
$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id");
|
||||
meta_refresh(2, $redirect);
|
||||
trigger_error($message . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
|
||||
}
|
||||
}
|
||||
|
||||
// Generate the appropriate user information for the user we are looking at
|
||||
if (!function_exists('phpbb_get_user_rank'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||
}
|
||||
$user_rank_data = phpbb_get_user_rank($user_row, $user_row['user_posts']);
|
||||
$avatar_img = phpbb_get_user_avatar($user_row);
|
||||
|
||||
// OK, they didn't submit a warning so lets build the page for them to do so
|
||||
$template->assign_vars(array(
|
||||
'U_POST_ACTION' => $this->u_action,
|
||||
|
||||
'RANK_TITLE' => $user_rank_data['title'],
|
||||
'JOINED' => $user->format_date($user_row['user_regdate']),
|
||||
'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0,
|
||||
'WARNINGS' => ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0,
|
||||
|
||||
'USERNAME_FULL' => get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']),
|
||||
'USERNAME_COLOUR' => get_username_string('colour', $user_row['user_id'], $user_row['username'], $user_row['user_colour']),
|
||||
'USERNAME' => get_username_string('username', $user_row['user_id'], $user_row['username'], $user_row['user_colour']),
|
||||
'U_PROFILE' => get_username_string('profile', $user_row['user_id'], $user_row['username'], $user_row['user_colour']),
|
||||
|
||||
'AVATAR_IMG' => $avatar_img,
|
||||
'RANK_IMG' => $user_rank_data['img'],
|
||||
|
||||
'S_CAN_NOTIFY' => $s_can_notify,
|
||||
));
|
||||
|
||||
return $user_id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the warning into the database
|
||||
*/
|
||||
function add_warning($user_row, $warning, $send_pm = true, $post_id = 0)
|
||||
{
|
||||
global $phpEx, $phpbb_root_path, $config, $phpbb_log;
|
||||
global $db, $user;
|
||||
|
||||
if ($send_pm)
|
||||
{
|
||||
include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
|
||||
include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx);
|
||||
|
||||
// Attempt to translate warning to language of user being warned if user's language differs from issuer's language
|
||||
if ($user_row['user_lang'] != $user->lang_name)
|
||||
{
|
||||
$lang = array();
|
||||
|
||||
$user_row['user_lang'] = (file_exists($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp." . $phpEx)) ? $user_row['user_lang'] : $config['default_lang'];
|
||||
include($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp." . $phpEx);
|
||||
|
||||
$warn_pm_subject = $lang['WARNING_PM_SUBJECT'];
|
||||
$warn_pm_body = sprintf($lang['WARNING_PM_BODY'], $warning);
|
||||
|
||||
unset($lang);
|
||||
}
|
||||
else
|
||||
{
|
||||
$warn_pm_subject = $user->lang('WARNING_PM_SUBJECT');
|
||||
$warn_pm_body = $user->lang('WARNING_PM_BODY', $warning);
|
||||
}
|
||||
|
||||
$message_parser = new parse_message();
|
||||
|
||||
$message_parser->message = $warn_pm_body;
|
||||
$message_parser->parse(true, true, true, false, false, true, true);
|
||||
|
||||
$pm_data = array(
|
||||
'from_user_id' => $user->data['user_id'],
|
||||
'from_user_ip' => $user->ip,
|
||||
'from_username' => $user->data['username'],
|
||||
'enable_sig' => false,
|
||||
'enable_bbcode' => true,
|
||||
'enable_smilies' => true,
|
||||
'enable_urls' => false,
|
||||
'icon_id' => 0,
|
||||
'bbcode_bitfield' => $message_parser->bbcode_bitfield,
|
||||
'bbcode_uid' => $message_parser->bbcode_uid,
|
||||
'message' => $message_parser->message,
|
||||
'address_list' => array('u' => array($user_row['user_id'] => 'to')),
|
||||
);
|
||||
|
||||
submit_pm('post', $warn_pm_subject, $pm_data, false);
|
||||
}
|
||||
|
||||
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_WARNING', false, array($user_row['username']));
|
||||
$log_id = $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_WARNING_BODY', false, array(
|
||||
'reportee_id' => $user_row['user_id'],
|
||||
$warning
|
||||
));
|
||||
|
||||
$sql_ary = array(
|
||||
'user_id' => $user_row['user_id'],
|
||||
'post_id' => $post_id,
|
||||
'log_id' => $log_id,
|
||||
'warning_time' => time(),
|
||||
);
|
||||
|
||||
$db->sql_query('INSERT INTO ' . WARNINGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_warnings = user_warnings + 1,
|
||||
user_last_warning = ' . time() . '
|
||||
WHERE user_id = ' . $user_row['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
// We add this to the mod log too for moderators to see that a specific user got warned.
|
||||
$sql = 'SELECT forum_id, topic_id
|
||||
FROM ' . POSTS_TABLE . '
|
||||
WHERE post_id = ' . $post_id;
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_WARNING', false, array(
|
||||
'forum_id' => $row['forum_id'],
|
||||
'topic_id' => $row['topic_id'],
|
||||
'post_id' => $post_id,
|
||||
$user_row['username']
|
||||
));
|
||||
}
|
Reference in New Issue
Block a user