Mercurial > hg > vamp-website
comparison forum/Sources/Modlog.php @ 76:e3e11437ecea website
Add forum code
author | Chris Cannam |
---|---|
date | Sun, 07 Jul 2013 11:25:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
75:72f59aa7e503 | 76:e3e11437ecea |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * Simple Machines Forum (SMF) | |
5 * | |
6 * @package SMF | |
7 * @author Simple Machines http://www.simplemachines.org | |
8 * @copyright 2011 Simple Machines | |
9 * @license http://www.simplemachines.org/about/smf/license.php BSD | |
10 * | |
11 * @version 2.0.3 | |
12 */ | |
13 | |
14 if (!defined('SMF')) | |
15 die('Hacking attempt...'); | |
16 | |
17 /* The moderation log is this file's only job. It views it, and that's about | |
18 all it does. | |
19 | |
20 void ViewModlog() | |
21 - prepares the information from the moderation log for viewing. | |
22 - disallows the deletion of events within twenty-four hours of now. | |
23 - requires the admin_forum permission. | |
24 - uses the Modlog template, main sub template. | |
25 - is accessed via ?action=moderate;area=modlog. | |
26 | |
27 int list_getModLogEntries() | |
28 //!!! | |
29 | |
30 array list_getModLogEntries($start, $items_per_page, $sort, $query_string = '', $query_params = array(), $log_type = 1) | |
31 - Gets the moderation log entries that match the specified paramaters | |
32 - limit can be an array with two values | |
33 - search_param and order should be proper SQL strings or blank. If blank they are not used. | |
34 */ | |
35 | |
36 // Show the moderation log | |
37 function ViewModlog() | |
38 { | |
39 global $txt, $modSettings, $context, $scripturl, $sourcedir, $user_info, $smcFunc, $settings; | |
40 | |
41 // Are we looking at the moderation log or the administration log. | |
42 $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; | |
43 if ($context['log_type'] == 3) | |
44 isAllowedTo('admin_forum'); | |
45 | |
46 // These change dependant on whether we are viewing the moderation or admin log. | |
47 if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') | |
48 $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; | |
49 else | |
50 $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; | |
51 | |
52 $context['can_delete'] = allowedTo('admin_forum'); | |
53 | |
54 loadLanguage('Modlog'); | |
55 | |
56 $context['page_title'] = $context['log_type'] == 3 ? $txt['modlog_admin_log'] : $txt['modlog_view']; | |
57 | |
58 // The number of entries to show per page of log file. | |
59 $context['displaypage'] = 30; | |
60 // Amount of hours that must pass before allowed to delete file. | |
61 $context['hoursdisable'] = 24; | |
62 | |
63 // Handle deletion... | |
64 if (isset($_POST['removeall']) && $context['can_delete']) | |
65 { | |
66 checkSession(); | |
67 | |
68 $smcFunc['db_query']('', ' | |
69 DELETE FROM {db_prefix}log_actions | |
70 WHERE id_log = {int:moderate_log} | |
71 AND log_time < {int:twenty_four_hours_wait}', | |
72 array( | |
73 'twenty_four_hours_wait' => time() - $context['hoursdisable'] * 3600, | |
74 'moderate_log' => $context['log_type'], | |
75 ) | |
76 ); | |
77 } | |
78 elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) | |
79 { | |
80 checkSession(); | |
81 $smcFunc['db_query']('', ' | |
82 DELETE FROM {db_prefix}log_actions | |
83 WHERE id_log = {int:moderate_log} | |
84 AND id_action IN ({array_string:delete_actions}) | |
85 AND log_time < {int:twenty_four_hours_wait}', | |
86 array( | |
87 'twenty_four_hours_wait' => time() - $context['hoursdisable'] * 3600, | |
88 'delete_actions' => array_unique($_POST['delete']), | |
89 'moderate_log' => $context['log_type'], | |
90 ) | |
91 ); | |
92 } | |
93 | |
94 // Do the column stuff! | |
95 $sort_types = array( | |
96 'action' =>'lm.action', | |
97 'time' => 'lm.log_time', | |
98 'member' => 'mem.real_name', | |
99 'group' => 'mg.group_name', | |
100 'ip' => 'lm.ip', | |
101 ); | |
102 | |
103 // Setup the direction stuff... | |
104 $context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'time'; | |
105 | |
106 // If we're coming from a search, get the variables. | |
107 if (!empty($_REQUEST['params']) && empty($_REQUEST['is_search'])) | |
108 { | |
109 $search_params = base64_decode(strtr($_REQUEST['params'], array(' ' => '+'))); | |
110 $search_params = @unserialize($search_params); | |
111 } | |
112 | |
113 // This array houses all the valid search types. | |
114 $searchTypes = array( | |
115 'action' => array('sql' => 'lm.action', 'label' => $txt['modlog_action']), | |
116 'member' => array('sql' => 'mem.real_name', 'label' => $txt['modlog_member']), | |
117 'group' => array('sql' => 'mg.group_name', 'label' => $txt['modlog_position']), | |
118 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) | |
119 ); | |
120 | |
121 if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) | |
122 $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; | |
123 else | |
124 $search_params_string = $search_params['string']; | |
125 | |
126 if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) | |
127 $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); | |
128 else | |
129 $search_params_type = $search_params['type']; | |
130 | |
131 $search_params_column = $searchTypes[$search_params_type]['sql']; | |
132 $search_params = array( | |
133 'string' => $search_params_string, | |
134 'type' => $search_params_type, | |
135 ); | |
136 | |
137 // Setup the search context. | |
138 $context['search_params'] = empty($search_params['string']) ? '' : base64_encode(serialize($search_params)); | |
139 $context['search'] = array( | |
140 'string' => $search_params['string'], | |
141 'type' => $search_params['type'], | |
142 'label' => $searchTypes[$search_params_type]['label'], | |
143 ); | |
144 | |
145 // If they are searching by action, then we must do some manual intervention to search in their language! | |
146 if ($search_params['type'] == 'action' && !empty($search_params['string'])) | |
147 { | |
148 // For the moment they can only search for ONE action! | |
149 foreach ($txt as $key => $text) | |
150 { | |
151 if (substr($key, 0, 10) == 'modlog_ac_' && strpos($text, $search_params['string']) !== false) | |
152 { | |
153 $search_params['string'] = substr($key, 10); | |
154 break; | |
155 } | |
156 } | |
157 } | |
158 | |
159 require_once($sourcedir . '/Subs-List.php'); | |
160 | |
161 // This is all the information required for a watched user listing. | |
162 $listOptions = array( | |
163 'id' => 'moderation_log_list', | |
164 'title' => '<a href="' . $scripturl . '?action=helpadmin;help=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . '" onclick="return reqWin(this.href);" class="help"><img src="' . $settings['images_url'] . '/helptopics.gif" alt="' . $txt['help'] . '" align="top" /></a> ' . $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], | |
165 'width' => '100%', | |
166 'items_per_page' => $context['displaypage'], | |
167 'no_items_label' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin_log_' : '') . 'no_entries_found'], | |
168 'base_href' => $scripturl . $context['url_start'] . (!empty($context['search_params']) ? ';params=' . $context['search_params'] : ''), | |
169 'default_sort_col' => 'time', | |
170 'get_items' => array( | |
171 'function' => 'list_getModLogEntries', | |
172 'params' => array( | |
173 (!empty($search_params['string']) ? ' INSTR({raw:sql_type}, {string:search_string})' : ''), | |
174 array('sql_type' => $search_params_column, 'search_string' => $search_params['string']), | |
175 $context['log_type'], | |
176 ), | |
177 ), | |
178 'get_count' => array( | |
179 'function' => 'list_getModLogEntryCount', | |
180 'params' => array( | |
181 (!empty($search_params['string']) ? ' INSTR({raw:sql_type}, {string:search_string})' : ''), | |
182 array('sql_type' => $search_params_column, 'search_string' => $search_params['string']), | |
183 $context['log_type'], | |
184 ), | |
185 ), | |
186 // This assumes we are viewing by user. | |
187 'columns' => array( | |
188 'action' => array( | |
189 'header' => array( | |
190 'value' => $txt['modlog_action'], | |
191 'class' => 'lefttext first_th', | |
192 ), | |
193 'data' => array( | |
194 'db' => 'action_text', | |
195 'class' => 'smalltext', | |
196 ), | |
197 'sort' => array( | |
198 'default' => 'lm.action', | |
199 'reverse' => 'lm.action DESC', | |
200 ), | |
201 ), | |
202 'time' => array( | |
203 'header' => array( | |
204 'value' => $txt['modlog_date'], | |
205 'class' => 'lefttext', | |
206 ), | |
207 'data' => array( | |
208 'db' => 'time', | |
209 'class' => 'smalltext', | |
210 ), | |
211 'sort' => array( | |
212 'default' => 'lm.log_time DESC', | |
213 'reverse' => 'lm.log_time', | |
214 ), | |
215 ), | |
216 'moderator' => array( | |
217 'header' => array( | |
218 'value' => $txt['modlog_member'], | |
219 'class' => 'lefttext', | |
220 ), | |
221 'data' => array( | |
222 'db' => 'moderator_link', | |
223 'class' => 'smalltext', | |
224 ), | |
225 'sort' => array( | |
226 'default' => 'mem.real_name', | |
227 'reverse' => 'mem.real_name DESC', | |
228 ), | |
229 ), | |
230 'position' => array( | |
231 'header' => array( | |
232 'value' => $txt['modlog_position'], | |
233 'class' => 'lefttext', | |
234 ), | |
235 'data' => array( | |
236 'db' => 'position', | |
237 'class' => 'smalltext', | |
238 ), | |
239 'sort' => array( | |
240 'default' => 'mg.group_name', | |
241 'reverse' => 'mg.group_name DESC', | |
242 ), | |
243 ), | |
244 'ip' => array( | |
245 'header' => array( | |
246 'value' => $txt['modlog_ip'], | |
247 'class' => 'lefttext', | |
248 ), | |
249 'data' => array( | |
250 'db' => 'ip', | |
251 'class' => 'smalltext', | |
252 ), | |
253 'sort' => array( | |
254 'default' => 'lm.ip', | |
255 'reverse' => 'lm.ip DESC', | |
256 ), | |
257 ), | |
258 'delete' => array( | |
259 'header' => array( | |
260 'value' => '<input type="checkbox" name="all" class="input_check" onclick="invertAll(this, this.form);" />', | |
261 ), | |
262 'data' => array( | |
263 'function' => create_function('$entry', ' | |
264 return \'<input type="checkbox" class="input_check" name="delete[]" value="\' . $entry[\'id\'] . \'"\' . ($entry[\'editable\'] ? \'\' : \' disabled="disabled"\') . \' />\'; | |
265 '), | |
266 'style' => 'text-align: center;', | |
267 ), | |
268 ), | |
269 ), | |
270 'form' => array( | |
271 'href' => $scripturl . $context['url_start'], | |
272 'include_sort' => true, | |
273 'include_start' => true, | |
274 'hidden_fields' => array( | |
275 $context['session_var'] => $context['session_id'], | |
276 'params' => $context['search_params'] | |
277 ), | |
278 ), | |
279 'additional_rows' => array( | |
280 array( | |
281 'position' => 'after_title', | |
282 'value' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'], | |
283 'class' => 'smalltext', | |
284 'style' => 'padding: 2ex;', | |
285 ), | |
286 array( | |
287 'position' => 'below_table_data', | |
288 'value' => ' | |
289 ' . $txt['modlog_search'] . ' (' . $txt['modlog_by'] . ': ' . $context['search']['label'] . '): | |
290 <input type="text" name="search" size="18" value="' . $smcFunc['htmlspecialchars']($context['search']['string']) . '" class="input_text" /> <input type="submit" name="is_search" value="' . $txt['modlog_go'] . '" class="button_submit" /> | |
291 ' . ($context['can_delete'] ? ' | | |
292 <input type="submit" name="remove" value="' . $txt['modlog_remove'] . '" class="button_submit" /> | |
293 <input type="submit" name="removeall" value="' . $txt['modlog_removeall'] . '" class="button_submit" />' : ''), | |
294 ), | |
295 ), | |
296 ); | |
297 | |
298 // Create the watched user list. | |
299 createList($listOptions); | |
300 | |
301 $context['sub_template'] = 'show_list'; | |
302 $context['default_list'] = 'moderation_log_list'; | |
303 } | |
304 | |
305 // Get the number of mod log entries. | |
306 function list_getModLogEntryCount($query_string = '', $query_params = array(), $log_type = 1) | |
307 { | |
308 global $smcFunc, $user_info; | |
309 | |
310 $modlog_query = allowedTo('admin_forum') || $user_info['mod_cache']['bq'] == '1=1' ? '1=1' : ($user_info['mod_cache']['bq'] == '0=1' ? 'lm.id_board = 0 AND lm.id_topic = 0' : (strtr($user_info['mod_cache']['bq'], array('id_board' => 'b.id_board')) . ' AND ' . strtr($user_info['mod_cache']['bq'], array('id_board' => 't.id_board')))); | |
311 | |
312 $result = $smcFunc['db_query']('', ' | |
313 SELECT COUNT(*) | |
314 FROM {db_prefix}log_actions AS lm | |
315 LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lm.id_member) | |
316 LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_group_id} THEN mem.id_post_group ELSE mem.id_group END) | |
317 LEFT JOIN {db_prefix}boards AS b ON (b.id_board = lm.id_board) | |
318 LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = lm.id_topic) | |
319 WHERE id_log = {int:log_type} | |
320 AND {raw:modlog_query}' | |
321 . (!empty($query_string) ? ' | |
322 AND ' . $query_string : ''), | |
323 array_merge($query_params, array( | |
324 'reg_group_id' => 0, | |
325 'log_type' => $log_type, | |
326 'modlog_query' => $modlog_query, | |
327 )) | |
328 ); | |
329 list ($entry_count) = $smcFunc['db_fetch_row']($result); | |
330 $smcFunc['db_free_result']($result); | |
331 | |
332 return $entry_count; | |
333 } | |
334 | |
335 function list_getModLogEntries($start, $items_per_page, $sort, $query_string = '', $query_params = array(), $log_type = 1) | |
336 { | |
337 global $context, $scripturl, $txt, $smcFunc, $user_info; | |
338 | |
339 $modlog_query = allowedTo('admin_forum') || $user_info['mod_cache']['bq'] == '1=1' ? '1=1' : ($user_info['mod_cache']['bq'] == '0=1' ? 'lm.id_board = 0 AND lm.id_topic = 0' : (strtr($user_info['mod_cache']['bq'], array('id_board' => 'b.id_board')) . ' AND ' . strtr($user_info['mod_cache']['bq'], array('id_board' => 't.id_board')))); | |
340 | |
341 // Do a little bit of self protection. | |
342 if (!isset($context['hoursdisable'])) | |
343 $context['hoursdisable'] = 24; | |
344 | |
345 // Can they see the IP address? | |
346 $seeIP = allowedTo('moderate_forum'); | |
347 | |
348 // Here we have the query getting the log details. | |
349 $result = $smcFunc['db_query']('', ' | |
350 SELECT | |
351 lm.id_action, lm.id_member, lm.ip, lm.log_time, lm.action, lm.id_board, lm.id_topic, lm.id_msg, lm.extra, | |
352 mem.real_name, mg.group_name | |
353 FROM {db_prefix}log_actions AS lm | |
354 LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lm.id_member) | |
355 LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_group_id} THEN mem.id_post_group ELSE mem.id_group END) | |
356 LEFT JOIN {db_prefix}boards AS b ON (b.id_board = lm.id_board) | |
357 LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = lm.id_topic) | |
358 WHERE id_log = {int:log_type} | |
359 AND {raw:modlog_query}' | |
360 . (!empty($query_string) ? ' | |
361 AND ' . $query_string : '') . ' | |
362 ORDER BY ' . $sort . ' | |
363 LIMIT ' . $start . ', ' . $items_per_page, | |
364 array_merge($query_params, array( | |
365 'reg_group_id' => 0, | |
366 'log_type' => $log_type, | |
367 'modlog_query' => $modlog_query, | |
368 )) | |
369 ); | |
370 | |
371 // Arrays for decoding objects into. | |
372 $topics = array(); | |
373 $boards = array(); | |
374 $members = array(); | |
375 $messages = array(); | |
376 $entries = array(); | |
377 while ($row = $smcFunc['db_fetch_assoc']($result)) | |
378 { | |
379 $row['extra'] = @unserialize($row['extra']); | |
380 | |
381 // Corrupt? | |
382 $row['extra'] = is_array($row['extra']) ? $row['extra'] : array(); | |
383 | |
384 // Add on some of the column stuff info | |
385 if (!empty($row['id_board'])) | |
386 { | |
387 if ($row['action'] == 'move') | |
388 $row['extra']['board_to'] = $row['id_board']; | |
389 else | |
390 $row['extra']['board'] = $row['id_board']; | |
391 } | |
392 | |
393 if (!empty($row['id_topic'])) | |
394 $row['extra']['topic'] = $row['id_topic']; | |
395 if (!empty($row['id_msg'])) | |
396 $row['extra']['message'] = $row['id_msg']; | |
397 | |
398 // Is this associated with a topic? | |
399 if (isset($row['extra']['topic'])) | |
400 $topics[(int) $row['extra']['topic']][] = $row['id_action']; | |
401 if (isset($row['extra']['new_topic'])) | |
402 $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; | |
403 | |
404 // How about a member? | |
405 if (isset($row['extra']['member'])) | |
406 { | |
407 // Guests don't have names! | |
408 if (empty($row['extra']['member'])) | |
409 $row['extra']['member'] = $txt['modlog_parameter_guest']; | |
410 else | |
411 { | |
412 // Try to find it... | |
413 $members[(int) $row['extra']['member']][] = $row['id_action']; | |
414 } | |
415 } | |
416 | |
417 // Associated with a board? | |
418 if (isset($row['extra']['board_to'])) | |
419 $boards[(int) $row['extra']['board_to']][] = $row['id_action']; | |
420 if (isset($row['extra']['board_from'])) | |
421 $boards[(int) $row['extra']['board_from']][] = $row['id_action']; | |
422 if (isset($row['extra']['board'])) | |
423 $boards[(int) $row['extra']['board']][] = $row['id_action']; | |
424 | |
425 // A message? | |
426 if (isset($row['extra']['message'])) | |
427 $messages[(int) $row['extra']['message']][] = $row['id_action']; | |
428 | |
429 // IP Info? | |
430 if (isset($row['extra']['ip_range'])) | |
431 if ($seeIP) | |
432 $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; | |
433 else | |
434 $row['extra']['ip_range'] = $txt['logged']; | |
435 | |
436 // Email? | |
437 if (isset($row['extra']['email'])) | |
438 $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; | |
439 | |
440 // Bans are complex. | |
441 if ($row['action'] == 'ban') | |
442 { | |
443 $row['action_text'] = $txt['modlog_ac_ban']; | |
444 foreach (array('member', 'email', 'ip_range', 'hostname') as $type) | |
445 if (isset($row['extra'][$type])) | |
446 $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; | |
447 } | |
448 | |
449 // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. | |
450 $entries[$row['id_action']] = array( | |
451 'id' => $row['id_action'], | |
452 'ip' => $seeIP ? $row['ip'] : $txt['logged'], | |
453 'position' => empty($row['real_name']) && empty($row['group_name']) ? $txt['guest'] : $row['group_name'], | |
454 'moderator_link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>' : (empty($row['real_name']) ? ($txt['guest'] . (!empty($row['extra']['member_acted']) ? ' (' . $row['extra']['member_acted'] . ')' : '')) : $row['real_name']), | |
455 'time' => timeformat($row['log_time']), | |
456 'timestamp' => forum_time(true, $row['log_time']), | |
457 'editable' => time() > $row['log_time'] + $context['hoursdisable'] * 3600, | |
458 'extra' => $row['extra'], | |
459 'action' => $row['action'], | |
460 'action_text' => isset($row['action_text']) ? $row['action_text'] : '', | |
461 ); | |
462 } | |
463 $smcFunc['db_free_result']($result); | |
464 | |
465 if (!empty($boards)) | |
466 { | |
467 $request = $smcFunc['db_query']('', ' | |
468 SELECT id_board, name | |
469 FROM {db_prefix}boards | |
470 WHERE id_board IN ({array_int:board_list}) | |
471 LIMIT ' . count(array_keys($boards)), | |
472 array( | |
473 'board_list' => array_keys($boards), | |
474 ) | |
475 ); | |
476 while ($row = $smcFunc['db_fetch_assoc']($request)) | |
477 { | |
478 foreach ($boards[$row['id_board']] as $action) | |
479 { | |
480 // Make the board number into a link - dealing with moving too. | |
481 if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) | |
482 $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; | |
483 elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) | |
484 $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; | |
485 elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) | |
486 $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; | |
487 } | |
488 } | |
489 $smcFunc['db_free_result']($request); | |
490 } | |
491 | |
492 if (!empty($topics)) | |
493 { | |
494 $request = $smcFunc['db_query']('', ' | |
495 SELECT ms.subject, t.id_topic | |
496 FROM {db_prefix}topics AS t | |
497 INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg) | |
498 WHERE t.id_topic IN ({array_int:topic_list}) | |
499 LIMIT ' . count(array_keys($topics)), | |
500 array( | |
501 'topic_list' => array_keys($topics), | |
502 ) | |
503 ); | |
504 while ($row = $smcFunc['db_fetch_assoc']($request)) | |
505 { | |
506 foreach ($topics[$row['id_topic']] as $action) | |
507 { | |
508 $this_action = &$entries[$action]; | |
509 | |
510 // This isn't used in the current theme. | |
511 $this_action['topic'] = array( | |
512 'id' => $row['id_topic'], | |
513 'subject' => $row['subject'], | |
514 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0', | |
515 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>' | |
516 ); | |
517 | |
518 // Make the topic number into a link - dealing with splitting too. | |
519 if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) | |
520 $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; | |
521 elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) | |
522 $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; | |
523 } | |
524 } | |
525 $smcFunc['db_free_result']($request); | |
526 } | |
527 | |
528 if (!empty($messages)) | |
529 { | |
530 $request = $smcFunc['db_query']('', ' | |
531 SELECT id_msg, subject | |
532 FROM {db_prefix}messages | |
533 WHERE id_msg IN ({array_int:message_list}) | |
534 LIMIT ' . count(array_keys($messages)), | |
535 array( | |
536 'message_list' => array_keys($messages), | |
537 ) | |
538 ); | |
539 while ($row = $smcFunc['db_fetch_assoc']($request)) | |
540 { | |
541 foreach ($messages[$row['id_msg']] as $action) | |
542 { | |
543 $this_action = &$entries[$action]; | |
544 | |
545 // This isn't used in the current theme. | |
546 $this_action['message'] = array( | |
547 'id' => $row['id_msg'], | |
548 'subject' => $row['subject'], | |
549 'href' => $scripturl . '?msg=' . $row['id_msg'], | |
550 'link' => '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>', | |
551 ); | |
552 | |
553 // Make the message number into a link. | |
554 if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) | |
555 $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; | |
556 } | |
557 } | |
558 $smcFunc['db_free_result']($request); | |
559 } | |
560 | |
561 if (!empty($members)) | |
562 { | |
563 $request = $smcFunc['db_query']('', ' | |
564 SELECT real_name, id_member | |
565 FROM {db_prefix}members | |
566 WHERE id_member IN ({array_int:member_list}) | |
567 LIMIT ' . count(array_keys($members)), | |
568 array( | |
569 'member_list' => array_keys($members), | |
570 ) | |
571 ); | |
572 while ($row = $smcFunc['db_fetch_assoc']($request)) | |
573 { | |
574 foreach ($members[$row['id_member']] as $action) | |
575 { | |
576 // Not used currently. | |
577 $entries[$action]['member'] = array( | |
578 'id' => $row['id_member'], | |
579 'name' => $row['real_name'], | |
580 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], | |
581 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>' | |
582 ); | |
583 // Make the member number into a name. | |
584 $entries[$action]['extra']['member'] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; | |
585 } | |
586 } | |
587 $smcFunc['db_free_result']($request); | |
588 } | |
589 | |
590 // Do some formatting of the action string. | |
591 foreach ($entries as $k => $entry) | |
592 { | |
593 // Make any message info links so its easier to go find that message. | |
594 if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) | |
595 $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; | |
596 | |
597 // Mark up any deleted members, topics and boards. | |
598 foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) | |
599 if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) | |
600 $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); | |
601 | |
602 if (empty($entries[$k]['action_text'])) | |
603 $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; | |
604 $entries[$k]['action_text'] = preg_replace('~\{([A-Za-z\d_]+)\}~ie', 'isset($entries[$k][\'extra\'][\'$1\']) ? $entries[$k][\'extra\'][\'$1\'] : \'\'', $entries[$k]['action_text']); | |
605 } | |
606 | |
607 // Back we go! | |
608 return $entries; | |
609 } | |
610 | |
611 ?> |