aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/mcp/mcp_post.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/mcp/mcp_post.php')
-rw-r--r--phpBB/includes/mcp/mcp_post.php214
1 files changed, 81 insertions, 133 deletions
diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php
index 65ef3f7805..cbdf6d4f6a 100644
--- a/phpBB/includes/mcp/mcp_post.php
+++ b/phpBB/includes/mcp/mcp_post.php
@@ -11,7 +11,7 @@
/**
* Handling actions in post details screen
*/
-function mcp_post_details($id, $mode, $action, $url)
+function mcp_post_details($id, $mode, $action)
{
global $SID, $phpEx, $phpbb_root_path, $config;
global $template, $db, $user, $auth;
@@ -30,135 +30,55 @@ function mcp_post_details($id, $mode, $action, $url)
}
$post_info = $post_info[$post_id];
+ $url = "{$phpbb_root_path}mcp.$phpEx$SID" . extra_url();
switch ($action)
{
- case 'chgposter_search':
-
+ case 'chgposter':
+
$username = request_var('username', '');
- if ($username)
+ $sql = 'SELECT user_id
+ FROM ' . USERS_TABLE . '
+ WHERE username = \'' . $db->sql_escape($username) . '\'';
+ $result = $db->sql_query($sql);
+
+ if (!($row = $db->sql_fetchrow($result)))
{
- $users_ary = array();
-
- if (strpos($username, '*') === false)
- {
- $username = "*$username*";
- }
- $username = str_replace('*', '%', str_replace('%', '\%', $username));
-
- $sql = 'SELECT user_id, username
- FROM ' . USERS_TABLE . "
- WHERE username LIKE '" . $db->sql_escape($username) . "'
- AND user_type NOT IN (" . USER_INACTIVE . ', ' . USER_IGNORE . ')
- AND user_id <> ' . $post_info['user_id'];
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $users_ary[strtolower($row['username'])] = $row;
- }
-
- $user_select = '';
- ksort($users_ary);
- foreach ($users_ary as $row)
- {
- $user_select .= '<option value="' . $row['user_id'] . '">' . $row['username'] . "</option>\n";
- }
+ trigger_error($user->lang['NO_USER']);
}
+ $new_user = $row['user_id'];
- if (!$user_select)
+ if ($auth->acl_get('m_', $post_info['forum_id']))
{
- $template->assign_var('MESSAGE', $user->lang['NO_MATCHES_FOUND']);
+ change_poster($post_info, $new_user);
}
+ break;
- $template->assign_vars(array(
- 'S_USER_SELECT' => $user_select,
- 'SEARCH_USERNAME' => request_var('username', ''))
- );
- break;
-
- case 'chgposter':
+ case 'chgposter_ip':
$new_user = request_var('u', 0);
- if ($new_user && $auth->acl_get('m_', $post_info['forum_id']) && $new_user != $post_info['user_id'])
- {
- $sql = 'UPDATE ' . POSTS_TABLE . "
- SET poster_id = $new_user
- WHERE post_id = $post_id";
- $db->sql_query($sql);
-
- if ($post_info['topic_last_post_id'] == $post_info['post_id'] || $post_info['forum_last_post_id'] == $post_info['post_id'])
- {
- sync('topic', 'topic_id', $post_info['topic_id'], false, false);
- sync('forum', 'forum_id', $post_info['forum_id'], false, false);
- }
-
- // Renew post info
- $post_info = get_post_data(array($post_id));
-
- if (!sizeof($post_info))
- {
- trigger_error($user->lang['POST_NOT_EXIST']);
- }
-
- $post_info = $post_info[$post_id];
- }
- break;
-
- case 'del_marked':
- case 'del_all':
- case 'add_feedback':
-
- $deletemark = ($action == 'del_marked') ? true : false;
- $deleteall = ($action == 'del_all') ? true : false;
- $marked = request_var('marknote', 0);
- $usernote = request_var('usernote', '');
-
- if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
+ $sql = 'SELECT user_id
+ FROM ' . USERS_TABLE . '
+ WHERE user_id = ' . $new_user;
+ $result = $db->sql_query($sql);
+
+ if (!($row = $db->sql_fetchrow($result)))
{
- $where_sql = '';
- if ($deletemark && $marked)
- {
- $sql_in = array();
- foreach ($marked as $mark)
- {
- $sql_in[] = $mark;
- }
- $where_sql = ' AND log_id IN (' . implode(', ', $sql_in) . ')';
- unset($sql_in);
- }
-
- $sql = 'DELETE FROM ' . LOG_TABLE . '
- WHERE log_type = ' . LOG_USERS . "
- $where_sql";
- $db->sql_query($sql);
-
- add_log('admin', 'LOG_USERS_CLEAR');
-
- $msg = ($deletemark) ? 'MARKED_DELETED' : 'ALL_DELETED';
- $redirect = "$url&amp;i=$id&amp;mode=post_details";
- meta_refresh(2, $redirect);
- trigger_error($user->lang[$msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
+ trigger_error($user->lang['NO_USER']);
}
- if ($usernote && $action == 'add_feedback')
+ if ($auth->acl_get('m_', $post_info['forum_id']))
{
- add_log('admin', 'LOG_USER_FEEDBACK', $post_info['username']);
- add_log('user', $post_info['user_id'], 'LOG_USER_GENERAL', $usernote);
-
- $redirect = "$url&amp;i=$id&amp;mode=post_details";
- meta_refresh(2, $redirect);
- trigger_error($user->lang['USER_FEEDBACK_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
+ change_poster($post_info, $new_user);
}
- break;
-
- default:
+ break;
}
// Set some vars
$users_ary = array();
+ $post_id = $post_info['post_id'];
$poster = ($post_info['user_colour']) ? '<span style="color:#' . $post_info['user_colour'] . '">' . $post_info['username'] . '</span>' : $post_info['username'];
// Process message, leave it uncensored
@@ -184,17 +104,17 @@ function mcp_post_details($id, $mode, $action, $url)
'S_POST_REPORTED' => $post_info['post_reported'],
'S_POST_UNAPPROVED' => !$post_info['post_approved'],
'S_POST_LOCKED' => $post_info['post_edit_locked'],
- 'S_USER_WARNINGS' => ($post_info['user_warnings']) ? true : false,
- 'S_SHOW_USER_NOTES' => true,
+ 'S_USER_NOTES' => $auth->acl_gets('m_', 'a_') ? true : false,
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
- 'U_VIEW_PROFILE' => "memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $post_info['user_id'],
-// 'U_MCP_USERNOTES' => "mcp.$phpEx$SID&amp;i=notes&amp;mode=user_notes&amp;u=" . $post_info['user_id'],
-// 'U_MCP_WARNINGS' => "mcp.$phpEx$SID&amp;i=warnings&amp;mode=view_user&amp;u=" . $post_info['user_id'],
+ 'U_FIND_MEMBER' => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=searchuser&amp;form=mcp_chgposter&amp;field=username",
+ 'U_VIEW_PROFILE' => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $post_info['user_id'],
+ 'U_MCP_USER_NOTES' => $auth->acl_gets('m_', 'a_') ? "{$phpbb_root_path}mcp.$phpEx$SID&amp;i=notes&amp;mode=user_notes&amp;u=" . $post_info['user_id'] : '',
+ 'U_MCP_WARN_USER' => "{$phpbb_root_path}mcp.$phpEx$SID&amp;i=warn&amp;mode=warn_user&amp;u=" . $post_info['user_id'],
'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? "{$phpbb_root_path}posting.$phpEx$SID&amp;mode=edit&amp;f={$post_info['forum_id']}&amp;p={$post_info['post_id']}" : '',
- 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], "<a href=\"viewtopic.$phpEx$SID&amp;p=$post_id#$post_id\">", '</a>'),
- 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], "<a href=\"viewforum.$phpEx$SID&amp;f={$post_info['forum_id']}&amp;start={$start}\">", '</a>'),
+ 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], "<a href=\"{$phpbb_root_path}viewtopic.$phpEx$SID&amp;p=$post_id#$post_id\">", '</a>'),
+ 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], "<a href=\"{$phpbb_root_path}viewforum.$phpEx$SID&amp;f={$post_info['forum_id']}&amp;start={$start}\">", '</a>'),
'REPORTED_IMG' => $user->img('icon_reported', $user->lang['POST_REPORTED']),
'UNAPPROVED_IMG' => $user->img('icon_unapproved', $user->lang['POST_UNAPPROVED']),
'EDIT_IMG' => $user->img('btn_edit', $user->lang['EDIT_POST']),
@@ -231,7 +151,7 @@ function mcp_post_details($id, $mode, $action, $url)
// Get Reports
if ($auth->acl_get('m_', $post_info['forum_id']))
{
- $sql = 'SELECT r.*, re.*, u.user_id, u.username
+ $sql = 'SELECT r.*, re.*, u.user_id, u.username
FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u, ' . REASONS_TABLE . " re
WHERE r.post_id = $post_id
AND r.reason_id = re.reason_id
@@ -250,7 +170,7 @@ function mcp_post_details($id, $mode, $action, $url)
'REASON_TITLE' => $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_name'])],
'REASON_DESC' => $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_name'])],
'REPORTER' => ($row['user_id'] != ANONYMOUS) ? $row['username'] : $user->lang['GUEST'],
- 'U_REPORTER' => ($row['user_id'] != ANONYMOUS) ? "memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u={$row['user_id']}" : '',
+ 'U_REPORTER' => ($row['user_id'] != ANONYMOUS) ? "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u={$row['user_id']}" : '',
'USER_NOTIFY' => ($row['user_notify']) ? true : false,
'REPORT_TIME' => $user->format_date($row['report_time']),
'REPORT_TEXT' => str_replace("\n", '<br />', trim($row['report_text'])))
@@ -260,7 +180,7 @@ function mcp_post_details($id, $mode, $action, $url)
}
$db->sql_freeresult($result);
}
-
+
// Get IP
if ($auth->acl_get('m_ip', $post_info['forum_id']))
{
@@ -294,11 +214,11 @@ function mcp_post_details($id, $mode, $action, $url)
$template->assign_block_vars('userrow', array(
'USERNAME' => ($row['user_id'] == ANONYMOUS) ? $user->lang['GUEST'] : $row['username'],
- 'NUM_POSTS' => $row['postings'],
+ 'NUM_POSTS' => $row['postings'],
'L_POST_S' => ($row['postings'] == 1) ? $user->lang['POST'] : $user->lang['POSTS'],
- 'U_PROFILE' => ($row['user_id'] == ANONYMOUS) ? '' : "memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $row['user_id'],
- 'U_SEARCHPOSTS' => "search.$phpEx$SID&amp;search_author=" . urlencode($row['username']) . "&amp;showresults=topics")
+ 'U_PROFILE' => ($row['user_id'] == ANONYMOUS) ? '' : "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $row['user_id'],
+ 'U_SEARCHPOSTS' => "{$phpbb_root_path}search.$phpEx$SID&amp;author=" . urlencode($row['username']) . "&amp;sr=topics")
);
}
$db->sql_freeresult($result);
@@ -318,30 +238,58 @@ function mcp_post_details($id, $mode, $action, $url)
$template->assign_block_vars('iprow', array(
'IP' => $row['poster_ip'],
'HOSTNAME' => $hostname,
- 'NUM_POSTS' => $row['postings'],
+ '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&amp;i=$id&amp;mode=post_details&amp;rdns={$row['poster_ip']}#ip",
- 'U_WHOIS' => "mcp.$phpEx$SID&amp;i=$id&amp;mode=whois&amp;ip={$row['poster_ip']}")
+ 'U_WHOIS' => "{$phpbb_root_path}mcp.$phpEx$SID&amp;i=$id&amp;mode=whois&amp;ip={$row['poster_ip']}")
);
}
$db->sql_freeresult($result);
- // If we were not searching for a specific username fill
- // the user_select box with users who have posted under
- // the same IP
- if ($action != 'chgposter_search')
+ $user_select = '';
+ ksort($users_ary);
+ foreach ($users_ary as $row)
{
- $user_select = '';
- ksort($users_ary);
- foreach ($users_ary as $row)
- {
- $user_select .= '<option value="' . $row['user_id'] . '">' . $row['username'] . "</option>\n";
- }
- $template->assign_var('S_USER_SELECT', $user_select);
+ $user_select .= '<option value="' . $row['user_id'] . '">' . $row['username'] . "</option>\n";
}
+ $template->assign_var('S_USER_SELECT', $user_select);
}
}
+/**
+* Changes a post's poster_id
+*/
+function change_poster(&$post_info, $new_user)
+{
+ global $auth, $db;
+
+ if ($new_user && $new_user != $post_info['user_id'])
+ {
+ $post_id = $post_info['post_id'];
+
+ $sql = 'UPDATE ' . POSTS_TABLE . "
+ SET poster_id = $new_user
+ WHERE post_id = " . $post_id;
+ $db->sql_query($sql);
+
+ if ($post_info['topic_last_post_id'] == $post_id || $post_info['forum_last_post_id'] == $post_id)
+ {
+ sync('topic', 'topic_id', $post_info['topic_id'], false, false);
+ sync('forum', 'forum_id', $post_info['forum_id'], false, false);
+ }
+
+ // Renew post info
+ $post_info = get_post_data(array($post_id));
+
+ if (!sizeof($post_info))
+ {
+ trigger_error($user->lang['POST_NOT_EXIST']);
+ }
+
+ $post_info = $post_info[$post_id];
+ }
+}
+
?> \ No newline at end of file