1 | <?php
|
---|
2 | /**
|
---|
3 | *
|
---|
4 | * @package mcp
|
---|
5 | * @version $Id$
|
---|
6 | * @copyright (c) 2005 phpBB Group
|
---|
7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
---|
8 | *
|
---|
9 | */
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * @ignore
|
---|
13 | */
|
---|
14 | if (!defined('IN_PHPBB'))
|
---|
15 | {
|
---|
16 | exit;
|
---|
17 | }
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * mcp_notes
|
---|
21 | * Displays notes about a user
|
---|
22 | * @package mcp
|
---|
23 | */
|
---|
24 | class mcp_notes
|
---|
25 | {
|
---|
26 | var $p_master;
|
---|
27 | var $u_action;
|
---|
28 |
|
---|
29 | function mcp_notes(&$p_master)
|
---|
30 | {
|
---|
31 | $this->p_master = &$p_master;
|
---|
32 | }
|
---|
33 |
|
---|
34 | function main($id, $mode)
|
---|
35 | {
|
---|
36 | global $auth, $db, $user, $template;
|
---|
37 | global $config, $phpbb_root_path, $phpEx;
|
---|
38 |
|
---|
39 | $action = request_var('action', array('' => ''));
|
---|
40 |
|
---|
41 | if (is_array($action))
|
---|
42 | {
|
---|
43 | list($action, ) = each($action);
|
---|
44 | }
|
---|
45 |
|
---|
46 | $this->page_title = 'MCP_NOTES';
|
---|
47 |
|
---|
48 | switch ($mode)
|
---|
49 | {
|
---|
50 | case 'front':
|
---|
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'),
|
---|
54 |
|
---|
55 | 'L_TITLE' => $user->lang['MCP_NOTES'],
|
---|
56 | ));
|
---|
57 |
|
---|
58 | $this->tpl_name = 'mcp_notes_front';
|
---|
59 | break;
|
---|
60 |
|
---|
61 | case 'user_notes':
|
---|
62 | $user->add_lang('acp/common');
|
---|
63 |
|
---|
64 | $this->mcp_notes_user_view($action);
|
---|
65 | $this->tpl_name = 'mcp_notes_user';
|
---|
66 | break;
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Display user notes
|
---|
72 | */
|
---|
73 | function mcp_notes_user_view($action)
|
---|
74 | {
|
---|
75 | global $phpEx, $phpbb_root_path, $config;
|
---|
76 | global $template, $db, $user, $auth;
|
---|
77 |
|
---|
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');
|
---|
84 |
|
---|
85 | add_form_key('mcp_notes');
|
---|
86 |
|
---|
87 | $sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
|
---|
88 |
|
---|
89 | $sql = 'SELECT *
|
---|
90 | FROM ' . USERS_TABLE . "
|
---|
91 | WHERE $sql_where";
|
---|
92 | $result = $db->sql_query($sql);
|
---|
93 | $userrow = $db->sql_fetchrow($result);
|
---|
94 | $db->sql_freeresult($result);
|
---|
95 |
|
---|
96 | if (!$userrow)
|
---|
97 | {
|
---|
98 | trigger_error('NO_USER');
|
---|
99 | }
|
---|
100 |
|
---|
101 | $user_id = $userrow['user_id'];
|
---|
102 |
|
---|
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)
|
---|
107 | {
|
---|
108 | $this->p_master->adjust_url('&u=' . $user_id);
|
---|
109 | $this->u_action .= "&u=$user_id";
|
---|
110 | }
|
---|
111 |
|
---|
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));
|
---|
116 |
|
---|
117 | // Handle any actions
|
---|
118 | if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
|
---|
119 | {
|
---|
120 | $where_sql = '';
|
---|
121 | if ($deletemark && $marked)
|
---|
122 | {
|
---|
123 | $sql_in = array();
|
---|
124 | foreach ($marked as $mark)
|
---|
125 | {
|
---|
126 | $sql_in[] = $mark;
|
---|
127 | }
|
---|
128 | $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in);
|
---|
129 | unset($sql_in);
|
---|
130 | }
|
---|
131 |
|
---|
132 | if ($where_sql || $deleteall)
|
---|
133 | {
|
---|
134 | if (check_form_key('mcp_notes'))
|
---|
135 | {
|
---|
136 | $sql = 'DELETE FROM ' . LOG_TABLE . '
|
---|
137 | WHERE log_type = ' . LOG_USERS . "
|
---|
138 | AND reportee_id = $user_id
|
---|
139 | $where_sql";
|
---|
140 | $db->sql_query($sql);
|
---|
141 |
|
---|
142 | add_log('admin', 'LOG_CLEAR_USER', $userrow['username']);
|
---|
143 |
|
---|
144 | $msg = ($deletemark) ? 'MARKED_NOTES_DELETED' : 'ALL_NOTES_DELETED';
|
---|
145 | }
|
---|
146 | else
|
---|
147 | {
|
---|
148 | $msg = 'FORM_INVALID';
|
---|
149 | }
|
---|
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>'));
|
---|
153 | }
|
---|
154 | }
|
---|
155 |
|
---|
156 | if ($usernote && $action == 'add_feedback')
|
---|
157 | {
|
---|
158 | if (check_form_key('mcp_notes'))
|
---|
159 | {
|
---|
160 | add_log('admin', 'LOG_USER_FEEDBACK', $userrow['username']);
|
---|
161 | add_log('mod', 0, 0, 'LOG_USER_FEEDBACK', $userrow['username']);
|
---|
162 |
|
---|
163 | add_log('user', $user_id, 'LOG_USER_GENERAL', $usernote);
|
---|
164 | $msg = $user->lang['USER_FEEDBACK_ADDED'];
|
---|
165 | }
|
---|
166 | else
|
---|
167 | {
|
---|
168 | $msg = $user->lang['FORM_INVALID'];
|
---|
169 | }
|
---|
170 | $redirect = $this->u_action;
|
---|
171 | meta_refresh(3, $redirect);
|
---|
172 |
|
---|
173 | trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
|
---|
174 | }
|
---|
175 |
|
---|
176 | // Generate the appropriate user information for the user we are looking at
|
---|
177 | if (!function_exists('get_user_avatar'))
|
---|
178 | {
|
---|
179 | include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
---|
180 | }
|
---|
181 |
|
---|
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']);
|
---|
184 |
|
---|
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');
|
---|
188 |
|
---|
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);
|
---|
191 |
|
---|
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');
|
---|
195 |
|
---|
196 | $keywords = utf8_normalize_nfc(request_var('keywords', '', true));
|
---|
197 | $keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
|
---|
198 |
|
---|
199 | $log_data = array();
|
---|
200 | $log_count = 0;
|
---|
201 | view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort, $keywords);
|
---|
202 |
|
---|
203 | if ($log_count)
|
---|
204 | {
|
---|
205 | $template->assign_var('S_USER_NOTES', true);
|
---|
206 |
|
---|
207 | foreach ($log_data as $row)
|
---|
208 | {
|
---|
209 | $template->assign_block_vars('usernotes', array(
|
---|
210 | 'REPORT_BY' => $row['username_full'],
|
---|
211 | 'REPORT_AT' => $user->format_date($row['time']),
|
---|
212 | 'ACTION' => $row['action'],
|
---|
213 | 'IP' => $row['ip'],
|
---|
214 | 'ID' => $row['id'])
|
---|
215 | );
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 | $template->assign_vars(array(
|
---|
220 | 'U_POST_ACTION' => $this->u_action,
|
---|
221 | 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
|
---|
222 | 'S_SELECT_SORT_DIR' => $s_sort_dir,
|
---|
223 | 'S_SELECT_SORT_KEY' => $s_sort_key,
|
---|
224 | 'S_SELECT_SORT_DAYS' => $s_limit_days,
|
---|
225 | 'S_KEYWORDS' => $keywords,
|
---|
226 |
|
---|
227 | 'L_TITLE' => $user->lang['MCP_NOTES_USER'],
|
---|
228 |
|
---|
229 | 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start),
|
---|
230 | 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start),
|
---|
231 | 'TOTAL_REPORTS' => ($log_count == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $log_count),
|
---|
232 |
|
---|
233 | 'RANK_TITLE' => $rank_title,
|
---|
234 | 'JOINED' => $user->format_date($userrow['user_regdate']),
|
---|
235 | 'POSTS' => ($userrow['user_posts']) ? $userrow['user_posts'] : 0,
|
---|
236 | 'WARNINGS' => ($userrow['user_warnings']) ? $userrow['user_warnings'] : 0,
|
---|
237 |
|
---|
238 | 'USERNAME_FULL' => get_username_string('full', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
|
---|
239 | 'USERNAME_COLOUR' => get_username_string('colour', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
|
---|
240 | 'USERNAME' => get_username_string('username', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
|
---|
241 | 'U_PROFILE' => get_username_string('profile', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
|
---|
242 |
|
---|
243 | 'AVATAR_IMG' => $avatar_img,
|
---|
244 | 'RANK_IMG' => $rank_img,
|
---|
245 | )
|
---|
246 | );
|
---|
247 | }
|
---|
248 |
|
---|
249 | }
|
---|
250 |
|
---|
251 | ?>
|
---|