1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
<?php
/**
*
* @package mcp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @package mcp
* mcp_notes
* Displays notes about a user
*/
class mcp_notes
{
var $p_master;
function mcp_main(&$p_master)
{
$this->p_master = &$p_master;
}
function main($id, $mode)
{
global $auth, $db, $user, $template;
global $config, $phpbb_root_path, $phpEx, $SID;
$action = request_var('action', array('' => ''));
if (is_array($action))
{
list($action, ) = each($action);
}
switch ($mode)
{
case 'front':
$template->assign_vars(array(
'U_FIND_MEMBER' => "memberlist.$phpEx$SID&mode=searchuser&form=mcp&field=username",
'U_POST_ACTION' => "mcp.$phpEx$SID&i=notes&mode=user_notes",
)
);
$this->tpl_name = 'mcp_notes_front';
break;
case 'user_notes':
$user->add_lang('acp/common');
mcp_notes_user_view($id, $mode, $action);
$this->tpl_name = 'mcp_notes_user';
break;
}
}
}
//
// Functions
//
function mcp_notes_user_view($id, $mode, $action)
{
global $SID, $phpEx, $phpbb_root_path, $config;
global $template, $db, $user, $auth;
$user_id = request_var('u', 0);
$username = request_var('username', '', true);
$start = request_var('start', 0);
$st = request_var('st', 0);
$sk = request_var('sk', 'b');
$sd = request_var('sd', 'd');
$sql_where = ($user_id) ? "user_id = $user_id" : "username = '" . $db->sql_escape($username) . "'";
$sql = 'SELECT * FROM ' . USERS_TABLE . " WHERE $sql_where";
$result = $db->sql_query($sql);
if (!$userrow = $db->sql_fetchrow($result))
{
trigger_error($user->lang['NO_USER']);
}
$db->sql_freeresult($result);
$user_id = $userrow['user_id'];
$deletemark = ($action == 'del_marked') ? true : false;
$deleteall = ($action == 'del_all') ? true : false;
$marked = request_var('marknote', array(0));
$usernote = request_var('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 log_id IN (' . implode(', ', $sql_in) . ')';
unset($sql_in);
}
if ($where_sql || $deleteall)
{
$sql = 'DELETE FROM ' . LOG_TABLE . '
WHERE log_type = ' . LOG_USERS . "
AND reportee_id = $user_id
$where_sql";
$db->sql_query($sql);
add_log('admin', 'LOG_CLEAR_USER', $userrow['username']);
$msg = ($deletemark) ? 'MARKED_DELETED' : 'ALL_DELETED';
$redirect = "mcp.$phpEx$SID&i=$id&mode=$mode&u=$user_id";
meta_refresh(2, $redirect);
trigger_error($user->lang[$msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
}
}
if ($usernote && $action == 'add_feedback')
{
add_log('admin', 'LOG_USER_FEEDBACK', $userrow['username']);
add_log('user', $user_id, 'LOG_USER_GENERAL', $usernote);
$redirect = "mcp.$phpEx$SID&i=$id&mode=$mode&u=$user_id";
meta_refresh(2, $redirect);
trigger_error($user->lang['USER_FEEDBACK_ADDED'] . '<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 = '';
// get_user_rank($userrow['user_rank'], $userrow['user_posts'], $rank_title, $rank_img);
$avatar_img = '';
if (!empty($userrow['user_avatar']))
{
switch ($userrow['user_avatar_type'])
{
case AVATAR_UPLOAD:
$avatar_img = $config['avatar_path'] . '/';
break;
case AVATAR_GALLERY:
$avatar_img = $config['avatar_gallery_path'] . '/';
break;
}
$avatar_img .= $userrow['user_avatar'];
$avatar_img = '<img src="' . $avatar_img . '" width="' . $userrow['user_avatar_width'] . '" height="' . $userrow['user_avatar_height'] . '" border="0" alt="" />';
}
else
{
$avatar_img = '<img src="adm/images/no_avatar.gif" alt="" />';
}
$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' => 'l.user_id', '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');
$log_data = array();
$log_count = 0;
view_log('user', $log_data, $log_count, $config['posts_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort);
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'],
'REPORT_AT' => $user->format_date($row['time']),
'ACTION' => $row['action'],
'ID' => $row['id'])
);
}
}
$template->assign_vars(array(
'U_POST_ACTION' => "mcp.$phpEx$SID&i=$id&mode=$mode&u=$user_id",
'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,
'PAGE_NUMBER' => on_page($log_count, $config['posts_per_page'], $start),
'PAGINATION' => generate_pagination("mcp.$phpEx$SID&i=$id&mode=$mode&u=$user_id&st=$st&sk=$sk&sd=$sd", $log_count, $config['posts_per_page'], $start),
'TOTAL_REPORTS' => ($log_count == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $log_count),
'USERNAME' => $userrow['username'],
'USER_COLOR' => (!empty($userrow['user_colour'])) ? $userrow['user_colour'] : '',
'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,
'AVATAR_IMG' => $avatar_img,
'RANK_IMG' => $rank_img,
)
);
}
?>
|