1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 16:56:44 +02:00

- viewtopic/forum search boxes should also use search config option and u_search permission [Bug #9850]

- mcp_reports was still using some of the mcp_queue post_id logic, changed enough to report_id logic to make it work properly now. I hope I didn't miss any external places referring to mcp_reports which send it a post_id_list. I really wonder whether people don't test the MCP at all? Good that I noticed this myself when fixing an incorrect language string (No reports selected) message [Bug #9741]
- forgot to check in the changed mcp/info file for mcp_warn with global m_warn option
- mcp_post.html was missing a submit button for changing the poster in prosilver [Bug #9771]
- language variables in javascript in templates should use LA_ not L_ for proper escaping of single quotes


git-svn-id: file:///svn/phpbb/trunk@7361 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Nils Adermann
2007-04-15 21:40:25 +00:00
parent 6e92276b87
commit c76a2cdfe8
10 changed files with 102 additions and 77 deletions

View File

@@ -41,14 +41,14 @@ class mcp_reports
case 'delete':
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
$post_id_list = request_var('post_id_list', array(0));
$report_id_list = request_var('report_id_list', array(0));
if (!sizeof($post_id_list))
if (!sizeof($report_id_list))
{
trigger_error('NO_POST_SELECTED');
trigger_error('NO_REPORT_SELECTED');
}
close_report($post_id_list, $mode, $action);
close_report($report_id_list, $mode, $action);
break;
}
@@ -64,7 +64,7 @@ class mcp_reports
// closed reports are accessed by report id
$report_id = request_var('r', 0);
$sql = 'SELECT r.post_id, r.user_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour
$sql = 'SELECT r.post_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 ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id AND r.report_closed = 0") . '
AND rr.reason_id = r.reason_id
@@ -75,19 +75,17 @@ class mcp_reports
if (!$report)
{
trigger_error('NO_POST_REPORT');
trigger_error('NO_REPORT_REPORT');
}
if ($report_id)
{
$post_id = $report['post_id'];
}
$post_id = $report['post_id'];
$report_id = $report['report_id'];
$post_info = get_post_data(array($post_id), 'm_report', true);
if (!sizeof($post_info))
{
trigger_error('NO_POST_SELECTED');
trigger_error('NO_REPORT_SELECTED');
}
$post_info = $post_info[$post_id];
@@ -158,9 +156,10 @@ class mcp_reports
'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports' . (($post_info['post_reported']) ? '&amp;mode=reports' : '&amp;mode=reports_closed') . '&amp;start=' . $start . '&amp;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_DATE' => $user->format_date($report['report_time']),
'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']),
@@ -335,6 +334,7 @@ class mcp_reports
'POST_ID' => $row['post_id'],
'POST_SUBJECT' => $row['post_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'])
);
@@ -370,11 +370,23 @@ class mcp_reports
/**
* Closes a report
*/
function close_report($post_id_list, $mode, $action)
function close_report($report_id_list, $mode, $action)
{
global $db, $template, $user, $config;
global $phpEx, $phpbb_root_path;
$sql = 'SELECT r.post_id
FROM ' . REPORTS_TABLE . ' r
WHERE ' . $db->sql_in_set('r.report_id', $report_id_list);
$result = $db->sql_query($sql);
$post_id_list = array();
while ($row = $db->sql_fetchrow($result))
{
$post_id_list[] = $row['post_id'];
}
$post_id_list = array_unique($post_id_list);
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report')))
{
trigger_error('NOT_AUTHORISED');
@@ -395,67 +407,68 @@ function close_report($post_id_list, $mode, $action)
$success_msg = '';
$s_hidden_fields = build_hidden_fields(array(
'i' => 'reports',
'mode' => $mode,
'post_id_list' => $post_id_list,
'action' => $action,
'redirect' => $redirect)
'i' => 'reports',
'mode' => $mode,
'report_id_list' => $report_id_list,
'action' => $action,
'redirect' => $redirect)
);
if (confirm_box(true))
{
$post_info = get_post_data($post_id_list, 'm_report');
$sql = 'SELECT r.post_id, 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
$sql = 'SELECT r.report_id, r.post_id, 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.post_id', array_keys($post_info)) . '
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';
$result = $db->sql_query($sql);
$reports = array();
$reports = $close_report_posts = $close_report_topics = $notify_reporters = $report_id_list = array();
while ($report = $db->sql_fetchrow($result))
{
$reports[$report['post_id']] = $report;
$reports[$report['report_id']] = $report;
$report_id_list[] = $report['report_id'];
if (!$report['report_closed'])
{
$close_report_posts[] = $report['post_id'];
$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);
$close_report_posts = $close_report_topics = $notify_reporters = array();
foreach ($post_info as $post_id => $post_data)
{
if (isset($reports[$post_id]))
{
$close_report_posts[] = $post_id;
$close_report_topics[] = $post_data['topic_id'];
if ($reports[$post_id]['user_notify'] && !$reports[$post_id]['report_closed'])
{
$notify_reporters[$post_id] = $reports[$post_id];
}
}
}
if (sizeof($close_report_posts))
if (sizeof($reports))
{
$close_report_posts = array_unique($close_report_posts);
$close_report_topics = array_unique($close_report_topics);
// 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))
if (sizeof($close_report_posts))
{
$keep_report_topics[] = $row['topic_id'];
}
$db->sql_freeresult($result);
// 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);
$close_report_topics = array_diff($close_report_topics, $keep_report_topics);
unset($keep_report_topics);
$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');
@@ -463,26 +476,30 @@ function close_report($post_id_list, $mode, $action)
{
$sql = 'UPDATE ' . REPORTS_TABLE . '
SET report_closed = 1
WHERE ' . $db->sql_in_set('post_id', $close_report_posts);
WHERE ' . $db->sql_in_set('report_id', $report_id_list);
}
else
{
$sql = 'DELETE FROM ' . REPORTS_TABLE . '
WHERE ' . $db->sql_in_set('post_id', $close_report_posts);
WHERE ' . $db->sql_in_set('report_id', $report_id_list);
}
$db->sql_query($sql);
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 0
WHERE ' . $db->sql_in_set('post_id', $close_report_posts);
$db->sql_query($sql);
if (sizeof($close_report_topics))
if (sizeof($close_report_posts))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0
WHERE ' . $db->sql_in_set('topic_id', $close_report_topics);
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 0
WHERE ' . $db->sql_in_set('post_id', $close_report_posts);
$db->sql_query($sql);
if (sizeof($close_report_topics))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0
WHERE ' . $db->sql_in_set('topic_id', $close_report_topics);
$db->sql_query($sql);
}
}
$db->sql_transaction('commit');
@@ -494,13 +511,15 @@ function close_report($post_id_list, $mode, $action)
// Notify reporters
if (sizeof($notify_reporters))
{
foreach ($notify_reporters as $post_id => $reporter)
foreach ($notify_reporters as $report_id => $reporter)
{
if ($reporter['user_id'] == ANONYMOUS)
{
continue;
}
$post_id = $reporter['post_id'];
$messenger->template('report_' . $action . 'd', $reporter['user_lang']);
$messenger->to($reporter['user_email'], $reporter['username']);
@@ -516,15 +535,15 @@ function close_report($post_id_list, $mode, $action)
$messenger->send($reporter['user_notify_type']);
}
}
unset($notify_reporters, $post_info);
unset($notify_reporters, $post_info, $reports);
$messenger->save_queue();
$success_msg = (sizeof($post_id_list) == 1) ? 'REPORT_' . strtoupper($action) . 'D_SUCCESS' : 'REPORTS_' . strtoupper($action) . 'D_SUCCESS';
$success_msg = (sizeof($report_id_list) == 1) ? 'REPORT_' . strtoupper($action) . 'D_SUCCESS' : 'REPORTS_' . strtoupper($action) . 'D_SUCCESS';
}
else
{
confirm_box(false, $user->lang[strtoupper($action) . '_REPORT' . ((sizeof($post_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields);
confirm_box(false, $user->lang[strtoupper($action) . '_REPORT' . ((sizeof($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields);
}
$redirect = request_var('redirect', "index.$phpEx");