5
* @version $Id: mcp_notes.php,v 1.43 2007/10/05 14:36:33 acydburn Exp $
6
* @copyright (c) 2005 phpBB Group
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
14
if (!defined('IN_PHPBB'))
21
* Displays notes about a user
29
function mcp_notes(&$p_master)
31
$this->p_master = &$p_master;
34
function main($id, $mode)
36
global $auth, $db, $user, $template;
37
global $config, $phpbb_root_path, $phpEx;
39
$action = request_var('action', array('' => ''));
41
if (is_array($action))
43
list($action, ) = each($action);
46
$this->page_title = 'MCP_NOTES';
51
$template->assign_vars(array(
52
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp&field=username&select_single=true'),
53
'U_POST_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes'),
55
'L_TITLE' => $user->lang['MCP_NOTES'],
58
$this->tpl_name = 'mcp_notes_front';
62
$user->add_lang('acp/common');
64
$this->mcp_notes_user_view($action);
65
$this->tpl_name = 'mcp_notes_user';
73
function mcp_notes_user_view($action)
75
global $phpEx, $phpbb_root_path, $config;
76
global $template, $db, $user, $auth;
78
$user_id = request_var('u', 0);
79
$username = request_var('username', '', true);
80
$start = request_var('start', 0);
81
$st = request_var('st', 0);
82
$sk = request_var('sk', 'b');
83
$sd = request_var('sd', 'd');
85
add_form_key('mcp_notes');
87
$sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
90
FROM ' . USERS_TABLE . "
92
$result = $db->sql_query($sql);
93
$userrow = $db->sql_fetchrow($result);
94
$db->sql_freeresult($result);
98
trigger_error('NO_USER');
101
$user_id = $userrow['user_id'];
103
// Populate user id to the currently active module (this module)
104
// The following method is another way of adjusting module urls. It is the easy variant if we want
105
// to directly adjust the current module url based on data retrieved within the same module.
106
if (strpos($this->u_action, "&u=$user_id") === false)
108
$this->p_master->adjust_url('&u=' . $user_id);
109
$this->u_action .= "&u=$user_id";
112
$deletemark = ($action == 'del_marked') ? true : false;
113
$deleteall = ($action == 'del_all') ? true : false;
114
$marked = request_var('marknote', array(0));
115
$usernote = utf8_normalize_nfc(request_var('usernote', '', true));
117
// Handle any actions
118
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
121
if ($deletemark && $marked)
124
foreach ($marked as $mark)
128
$where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in);
132
if ($where_sql || $deleteall)
134
if (check_form_key('mcp_notes'))
136
$sql = 'DELETE FROM ' . LOG_TABLE . '
137
WHERE log_type = ' . LOG_USERS . "
138
AND reportee_id = $user_id
140
$db->sql_query($sql);
142
add_log('admin', 'LOG_CLEAR_USER', $userrow['username']);
144
$msg = ($deletemark) ? 'MARKED_NOTES_DELETED' : 'ALL_NOTES_DELETED';
148
$msg = 'FORM_INVALID';
150
$redirect = $this->u_action . '&u=' . $user_id;
151
meta_refresh(3, $redirect);
152
trigger_error($user->lang[$msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
156
if ($usernote && $action == 'add_feedback')
158
if (check_form_key('mcp_notes'))
160
add_log('admin', 'LOG_USER_FEEDBACK', $userrow['username']);
161
add_log('mod', 0, 0, 'LOG_USER_FEEDBACK', $userrow['username']);
163
add_log('user', $user_id, 'LOG_USER_GENERAL', $usernote);
164
$msg = $user->lang['USER_FEEDBACK_ADDED'];
168
$msg = $user->lang['FORM_INVALID'];
170
$redirect = $this->u_action;
171
meta_refresh(3, $redirect);
173
trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
176
// Generate the appropriate user information for the user we are looking at
177
if (!function_exists('get_user_avatar'))
179
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
182
$rank_title = $rank_img = '';
183
$avatar_img = get_user_avatar($userrow['user_avatar'], $userrow['user_avatar_type'], $userrow['user_avatar_width'], $userrow['user_avatar_height']);
185
$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']);
186
$sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']);
187
$sort_by_sql = array('a' => 'u.username_clean', 'b' => 'l.log_time', 'c' => 'l.log_ip', 'd' => 'l.log_operation');
189
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
190
gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
192
// Define where and sort sql for use in displaying logs
193
$sql_where = ($st) ? (time() - ($st * 86400)) : 0;
194
$sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC');
198
view_log('user', $log_data, $log_count, $config['posts_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort);
202
$template->assign_var('S_USER_NOTES', true);
204
foreach ($log_data as $row)
206
$template->assign_block_vars('usernotes', array(
207
'REPORT_BY' => $row['username_full'],
208
'REPORT_AT' => $user->format_date($row['time']),
209
'ACTION' => $row['action'],
216
$template->assign_vars(array(
217
'U_POST_ACTION' => $this->u_action,
218
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
219
'S_SELECT_SORT_DIR' => $s_sort_dir,
220
'S_SELECT_SORT_KEY' => $s_sort_key,
221
'S_SELECT_SORT_DAYS' => $s_limit_days,
223
'L_TITLE' => $user->lang['MCP_NOTES_USER'],
225
'PAGE_NUMBER' => on_page($log_count, $config['posts_per_page'], $start),
226
'PAGINATION' => generate_pagination($this->u_action . "&st=$st&sk=$sk&sd=$sd", $log_count, $config['posts_per_page'], $start),
227
'TOTAL_REPORTS' => ($log_count == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $log_count),
229
'USERNAME' => $userrow['username'],
230
'USER_COLOR' => (!empty($userrow['user_colour'])) ? $userrow['user_colour'] : '',
231
'RANK_TITLE' => $rank_title,
232
'JOINED' => $user->format_date($userrow['user_regdate']),
233
'POSTS' => ($userrow['user_posts']) ? $userrow['user_posts'] : 0,
234
'WARNINGS' => ($userrow['user_warnings']) ? $userrow['user_warnings'] : 0,
236
'AVATAR_IMG' => $avatar_img,
237
'RANK_IMG' => $rank_img,
b'\\ No newline at end of file'