Augmentation vers version 3.3.0
This commit is contained in:
301
install/update/new/includes/mcp/mcp_ban.php
Normal file
301
install/update/new/includes/mcp/mcp_ban.php
Normal file
@@ -0,0 +1,301 @@
|
||||
<?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...
|
||||
if (!class_exists('acp_ban'))
|
||||
{
|
||||
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(array($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);
|
||||
}
|
||||
}
|
||||
}
|
||||
230
install/update/new/includes/mcp/mcp_logs.php
Normal file
230
install/update/new/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))
|
||||
{
|
||||
$action = key($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'],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
1717
install/update/new/includes/mcp/mcp_main.php
Normal file
1717
install/update/new/includes/mcp/mcp_main.php
Normal file
File diff suppressed because it is too large
Load Diff
258
install/update/new/includes/mcp/mcp_notes.php
Normal file
258
install/update/new/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))
|
||||
{
|
||||
$action = key($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,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
834
install/update/new/includes/mcp/mcp_topic.php
Normal file
834
install/update/new/includes/mcp/mcp_topic.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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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']))
|
||||
{
|
||||
if (!class_exists('mcp_queue'))
|
||||
{
|
||||
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_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;
|
||||
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'u.username, u.username_clean, u.user_colour, p.*',
|
||||
'FROM' => array(
|
||||
POSTS_TABLE => 'p',
|
||||
USERS_TABLE => 'u'
|
||||
),
|
||||
'LEFT_JOIN' => array(),
|
||||
'WHERE' => $sql_where,
|
||||
'ORDER_BY' => $sort_order_sql,
|
||||
);
|
||||
|
||||
/**
|
||||
* Event to modify the SQL query before the MCP topic review posts is queried
|
||||
*
|
||||
* @event core.mcp_topic_modify_sql_ary
|
||||
* @var array sql_ary The SQL array to get the data of the MCP topic review posts
|
||||
* @since 3.2.8-RC1
|
||||
*/
|
||||
$vars = array('sql_ary');
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_topic_modify_sql_ary', compact($vars)));
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
unset($sql_ary);
|
||||
|
||||
$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 $current_row_number => $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[$current_row_number]);
|
||||
}
|
||||
|
||||
// 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
install/update/new/includes/mcp/mcp_warn.php
Normal file
610
install/update/new/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))
|
||||
{
|
||||
$action = key($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