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 Front Panel
|
---|
21 | */
|
---|
22 | function mcp_front_view($id, $mode, $action)
|
---|
23 | {
|
---|
24 | global $phpEx, $phpbb_root_path, $config;
|
---|
25 | global $template, $db, $user, $auth, $module;
|
---|
26 |
|
---|
27 | // Latest 5 unapproved
|
---|
28 | if ($module->loaded('queue'))
|
---|
29 | {
|
---|
30 | $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_approve')));
|
---|
31 | $post_list = array();
|
---|
32 | $forum_names = array();
|
---|
33 |
|
---|
34 | $forum_id = request_var('f', 0);
|
---|
35 |
|
---|
36 | $template->assign_var('S_SHOW_UNAPPROVED', (!empty($forum_list)) ? true : false);
|
---|
37 |
|
---|
38 | if (!empty($forum_list))
|
---|
39 | {
|
---|
40 | $sql = 'SELECT COUNT(post_id) AS total
|
---|
41 | FROM ' . POSTS_TABLE . '
|
---|
42 | WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ')
|
---|
43 | AND post_approved = 0';
|
---|
44 | $result = $db->sql_query($sql);
|
---|
45 | $total = (int) $db->sql_fetchfield('total');
|
---|
46 | $db->sql_freeresult($result);
|
---|
47 |
|
---|
48 | if ($total)
|
---|
49 | {
|
---|
50 | $global_id = $forum_list[0];
|
---|
51 |
|
---|
52 | $sql = 'SELECT forum_id, forum_name
|
---|
53 | FROM ' . FORUMS_TABLE . '
|
---|
54 | WHERE ' . $db->sql_in_set('forum_id', $forum_list);
|
---|
55 | $result = $db->sql_query($sql);
|
---|
56 |
|
---|
57 | while ($row = $db->sql_fetchrow($result))
|
---|
58 | {
|
---|
59 | $forum_names[$row['forum_id']] = $row['forum_name'];
|
---|
60 | }
|
---|
61 | $db->sql_freeresult($result);
|
---|
62 |
|
---|
63 | $sql = 'SELECT post_id
|
---|
64 | FROM ' . POSTS_TABLE . '
|
---|
65 | WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ')
|
---|
66 | AND post_approved = 0
|
---|
67 | ORDER BY post_time DESC';
|
---|
68 | $result = $db->sql_query_limit($sql, 5);
|
---|
69 |
|
---|
70 | while ($row = $db->sql_fetchrow($result))
|
---|
71 | {
|
---|
72 | $post_list[] = $row['post_id'];
|
---|
73 | }
|
---|
74 | $db->sql_freeresult($result);
|
---|
75 |
|
---|
76 | if (empty($post_list))
|
---|
77 | {
|
---|
78 | $total = 0;
|
---|
79 | }
|
---|
80 | }
|
---|
81 |
|
---|
82 | if ($total)
|
---|
83 | {
|
---|
84 | $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.username, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id
|
---|
85 | FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
|
---|
86 | WHERE ' . $db->sql_in_set('p.post_id', $post_list) . '
|
---|
87 | AND t.topic_id = p.topic_id
|
---|
88 | AND p.poster_id = u.user_id
|
---|
89 | ORDER BY p.post_time DESC';
|
---|
90 | $result = $db->sql_query($sql);
|
---|
91 |
|
---|
92 | while ($row = $db->sql_fetchrow($result))
|
---|
93 | {
|
---|
94 | $global_topic = ($row['forum_id']) ? false : true;
|
---|
95 | if ($global_topic)
|
---|
96 | {
|
---|
97 | $row['forum_id'] = $global_id;
|
---|
98 | }
|
---|
99 |
|
---|
100 | $template->assign_block_vars('unapproved', array(
|
---|
101 | 'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $row['forum_id'] . '&p=' . $row['post_id']),
|
---|
102 | 'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view&f=' . $row['forum_id']) : '',
|
---|
103 | 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
|
---|
104 | 'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
|
---|
105 | 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
|
---|
106 |
|
---|
107 | 'AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']),
|
---|
108 | 'AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour']),
|
---|
109 | 'AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour']),
|
---|
110 | 'U_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour']),
|
---|
111 |
|
---|
112 | 'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'],
|
---|
113 | 'POST_ID' => $row['post_id'],
|
---|
114 | 'TOPIC_TITLE' => $row['topic_title'],
|
---|
115 | 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
|
---|
116 | 'POST_TIME' => $user->format_date($row['post_time']))
|
---|
117 | );
|
---|
118 | }
|
---|
119 | $db->sql_freeresult($result);
|
---|
120 | }
|
---|
121 |
|
---|
122 | $s_hidden_fields = build_hidden_fields(array(
|
---|
123 | 'redirect' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main' . (($forum_id) ? '&f=' . $forum_id : ''))
|
---|
124 | ));
|
---|
125 |
|
---|
126 | $template->assign_vars(array(
|
---|
127 | 'S_HIDDEN_FIELDS' => $s_hidden_fields,
|
---|
128 | 'S_MCP_QUEUE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue"),
|
---|
129 | ));
|
---|
130 |
|
---|
131 | if ($total == 0)
|
---|
132 | {
|
---|
133 | $template->assign_vars(array(
|
---|
134 | 'L_UNAPPROVED_TOTAL' => $user->lang['UNAPPROVED_POSTS_ZERO_TOTAL'],
|
---|
135 | 'S_HAS_UNAPPROVED_POSTS' => false)
|
---|
136 | );
|
---|
137 | }
|
---|
138 | else
|
---|
139 | {
|
---|
140 | $template->assign_vars(array(
|
---|
141 | 'L_UNAPPROVED_TOTAL' => ($total == 1) ? $user->lang['UNAPPROVED_POST_TOTAL'] : sprintf($user->lang['UNAPPROVED_POSTS_TOTAL'], $total),
|
---|
142 | 'S_HAS_UNAPPROVED_POSTS' => true)
|
---|
143 | );
|
---|
144 | }
|
---|
145 | }
|
---|
146 | }
|
---|
147 |
|
---|
148 | // Latest 5 reported
|
---|
149 | if ($module->loaded('reports'))
|
---|
150 | {
|
---|
151 | $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_report')));
|
---|
152 |
|
---|
153 | $template->assign_var('S_SHOW_REPORTS', (!empty($forum_list)) ? true : false);
|
---|
154 |
|
---|
155 | if (!empty($forum_list))
|
---|
156 | {
|
---|
157 | $sql = 'SELECT COUNT(r.report_id) AS total
|
---|
158 | FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
|
---|
159 | WHERE r.post_id = p.post_id
|
---|
160 | AND r.pm_id = 0
|
---|
161 | AND r.report_closed = 0
|
---|
162 | AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')';
|
---|
163 | $result = $db->sql_query($sql);
|
---|
164 | $total = (int) $db->sql_fetchfield('total');
|
---|
165 | $db->sql_freeresult($result);
|
---|
166 |
|
---|
167 | if ($total)
|
---|
168 | {
|
---|
169 | $global_id = $forum_list[0];
|
---|
170 |
|
---|
171 | $sql = $db->sql_build_query('SELECT', array(
|
---|
172 | 'SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name',
|
---|
173 |
|
---|
174 | 'FROM' => array(
|
---|
175 | REPORTS_TABLE => 'r',
|
---|
176 | REPORTS_REASONS_TABLE => 'rr',
|
---|
177 | TOPICS_TABLE => 't',
|
---|
178 | USERS_TABLE => array('u', 'u2'),
|
---|
179 | POSTS_TABLE => 'p'
|
---|
180 | ),
|
---|
181 |
|
---|
182 | 'LEFT_JOIN' => array(
|
---|
183 | array(
|
---|
184 | 'FROM' => array(FORUMS_TABLE => 'f'),
|
---|
185 | 'ON' => 'f.forum_id = p.forum_id'
|
---|
186 | )
|
---|
187 | ),
|
---|
188 |
|
---|
189 | 'WHERE' => 'r.post_id = p.post_id
|
---|
190 | AND r.pm_id = 0
|
---|
191 | AND r.report_closed = 0
|
---|
192 | AND r.reason_id = rr.reason_id
|
---|
193 | AND p.topic_id = t.topic_id
|
---|
194 | AND r.user_id = u.user_id
|
---|
195 | AND p.poster_id = u2.user_id
|
---|
196 | AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')',
|
---|
197 |
|
---|
198 | 'ORDER_BY' => 'p.post_time DESC'
|
---|
199 | ));
|
---|
200 | $result = $db->sql_query_limit($sql, 5);
|
---|
201 |
|
---|
202 | while ($row = $db->sql_fetchrow($result))
|
---|
203 | {
|
---|
204 | $global_topic = ($row['forum_id']) ? false : true;
|
---|
205 | if ($global_topic)
|
---|
206 | {
|
---|
207 | $row['forum_id'] = $global_id;
|
---|
208 | }
|
---|
209 |
|
---|
210 | $template->assign_block_vars('report', array(
|
---|
211 | 'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id'] . "&i=reports&mode=report_details"),
|
---|
212 | 'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&i=$id&mode=forum_view") : '',
|
---|
213 | 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . "&i=$id&mode=topic_view"),
|
---|
214 | 'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
|
---|
215 | 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
|
---|
216 |
|
---|
217 | 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
---|
218 | 'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
|
---|
219 | 'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
|
---|
220 | 'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
|
---|
221 |
|
---|
222 | 'AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']),
|
---|
223 | 'AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']),
|
---|
224 | 'AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']),
|
---|
225 | 'U_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']),
|
---|
226 |
|
---|
227 | 'FORUM_NAME' => (!$global_topic) ? $row['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'],
|
---|
228 | 'TOPIC_TITLE' => $row['topic_title'],
|
---|
229 | 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
|
---|
230 | 'REPORT_TIME' => $user->format_date($row['report_time']),
|
---|
231 | 'POST_TIME' => $user->format_date($row['post_time']),
|
---|
232 | ));
|
---|
233 | }
|
---|
234 | }
|
---|
235 |
|
---|
236 | if ($total == 0)
|
---|
237 | {
|
---|
238 | $template->assign_vars(array(
|
---|
239 | 'L_REPORTS_TOTAL' => $user->lang['REPORTS_ZERO_TOTAL'],
|
---|
240 | 'S_HAS_REPORTS' => false)
|
---|
241 | );
|
---|
242 | }
|
---|
243 | else
|
---|
244 | {
|
---|
245 | $template->assign_vars(array(
|
---|
246 | 'L_REPORTS_TOTAL' => ($total == 1) ? $user->lang['REPORT_TOTAL'] : sprintf($user->lang['REPORTS_TOTAL'], $total),
|
---|
247 | 'S_HAS_REPORTS' => true)
|
---|
248 | );
|
---|
249 | }
|
---|
250 | }
|
---|
251 | }
|
---|
252 |
|
---|
253 | // Latest 5 reported PMs
|
---|
254 | if ($module->loaded('pm_reports') && $auth->acl_getf_global('m_report'))
|
---|
255 | {
|
---|
256 | $template->assign_var('S_SHOW_PM_REPORTS', true);
|
---|
257 | $user->add_lang(array('ucp'));
|
---|
258 |
|
---|
259 | $sql = 'SELECT COUNT(r.report_id) AS total
|
---|
260 | FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p
|
---|
261 | WHERE r.post_id = 0
|
---|
262 | AND r.pm_id = p.msg_id
|
---|
263 | AND r.report_closed = 0';
|
---|
264 | $result = $db->sql_query($sql);
|
---|
265 | $total = (int) $db->sql_fetchfield('total');
|
---|
266 | $db->sql_freeresult($result);
|
---|
267 |
|
---|
268 | if ($total)
|
---|
269 | {
|
---|
270 | include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
|
---|
271 |
|
---|
272 | $sql = $db->sql_build_query('SELECT', array(
|
---|
273 | 'SELECT' => 'r.report_id, r.report_time, p.msg_id, p.message_subject, p.message_time, p.to_address, p.bcc_address, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id',
|
---|
274 |
|
---|
275 | 'FROM' => array(
|
---|
276 | REPORTS_TABLE => 'r',
|
---|
277 | REPORTS_REASONS_TABLE => 'rr',
|
---|
278 | USERS_TABLE => array('u', 'u2'),
|
---|
279 | PRIVMSGS_TABLE => 'p'
|
---|
280 | ),
|
---|
281 |
|
---|
282 | 'WHERE' => 'r.pm_id = p.msg_id
|
---|
283 | AND r.post_id = 0
|
---|
284 | AND r.report_closed = 0
|
---|
285 | AND r.reason_id = rr.reason_id
|
---|
286 | AND r.user_id = u.user_id
|
---|
287 | AND p.author_id = u2.user_id',
|
---|
288 |
|
---|
289 | 'ORDER_BY' => 'p.message_time DESC'
|
---|
290 | ));
|
---|
291 | $result = $db->sql_query_limit($sql, 5);
|
---|
292 |
|
---|
293 | $pm_by_id = $pm_list = array();
|
---|
294 | while ($row = $db->sql_fetchrow($result))
|
---|
295 | {
|
---|
296 | $pm_by_id[(int) $row['msg_id']] = $row;
|
---|
297 | $pm_list[] = (int) $row['msg_id'];
|
---|
298 | }
|
---|
299 |
|
---|
300 | $address_list = get_recipient_strings($pm_by_id);
|
---|
301 |
|
---|
302 | foreach ($pm_list as $message_id)
|
---|
303 | {
|
---|
304 | $row = $pm_by_id[$message_id];
|
---|
305 |
|
---|
306 | $template->assign_block_vars('pm_report', array(
|
---|
307 | 'U_PM_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'r=' . $row['report_id'] . "&i=pm_reports&mode=pm_report_details"),
|
---|
308 |
|
---|
309 | 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
---|
310 | 'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
|
---|
311 | 'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
|
---|
312 | 'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
|
---|
313 |
|
---|
314 | 'PM_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']),
|
---|
315 | 'PM_AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']),
|
---|
316 | 'PM_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']),
|
---|
317 | 'U_PM_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']),
|
---|
318 |
|
---|
319 | 'PM_SUBJECT' => $row['message_subject'],
|
---|
320 | 'REPORT_TIME' => $user->format_date($row['report_time']),
|
---|
321 | 'PM_TIME' => $user->format_date($row['message_time']),
|
---|
322 | 'RECIPIENTS' => implode(', ', $address_list[$row['msg_id']]),
|
---|
323 | ));
|
---|
324 | }
|
---|
325 | }
|
---|
326 |
|
---|
327 | if ($total == 0)
|
---|
328 | {
|
---|
329 | $template->assign_vars(array(
|
---|
330 | 'L_PM_REPORTS_TOTAL' => $user->lang['PM_REPORTS_ZERO_TOTAL'],
|
---|
331 | 'S_HAS_PM_REPORTS' => false)
|
---|
332 | );
|
---|
333 | }
|
---|
334 | else
|
---|
335 | {
|
---|
336 | $template->assign_vars(array(
|
---|
337 | 'L_PM_REPORTS_TOTAL' => ($total == 1) ? $user->lang['PM_REPORT_TOTAL'] : sprintf($user->lang['PM_REPORTS_TOTAL'], $total),
|
---|
338 | 'S_HAS_PM_REPORTS' => true)
|
---|
339 | );
|
---|
340 | }
|
---|
341 | }
|
---|
342 |
|
---|
343 | // Latest 5 logs
|
---|
344 | if ($module->loaded('logs'))
|
---|
345 | {
|
---|
346 | $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
|
---|
347 |
|
---|
348 | if (!empty($forum_list))
|
---|
349 | {
|
---|
350 | // Add forum_id 0 for global announcements
|
---|
351 | $forum_list[] = 0;
|
---|
352 |
|
---|
353 | $log_count = 0;
|
---|
354 | $log = array();
|
---|
355 | view_log('mod', $log, $log_count, 5, 0, $forum_list);
|
---|
356 |
|
---|
357 | foreach ($log as $row)
|
---|
358 | {
|
---|
359 | $template->assign_block_vars('log', array(
|
---|
360 | 'USERNAME' => $row['username_full'],
|
---|
361 | 'IP' => $row['ip'],
|
---|
362 | 'TIME' => $user->format_date($row['time']),
|
---|
363 | 'ACTION' => $row['action'],
|
---|
364 | 'U_VIEW_TOPIC' => (!empty($row['viewtopic'])) ? $row['viewtopic'] : '',
|
---|
365 | 'U_VIEWLOGS' => (!empty($row['viewlogs'])) ? $row['viewlogs'] : '')
|
---|
366 | );
|
---|
367 | }
|
---|
368 | }
|
---|
369 |
|
---|
370 | $template->assign_vars(array(
|
---|
371 | 'S_SHOW_LOGS' => (!empty($forum_list)) ? true : false,
|
---|
372 | 'S_HAS_LOGS' => (!empty($log)) ? true : false)
|
---|
373 | );
|
---|
374 | }
|
---|
375 |
|
---|
376 | $template->assign_var('S_MCP_ACTION', append_sid("{$phpbb_root_path}mcp.$phpEx"));
|
---|
377 | make_jumpbox(append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view'), 0, false, 'm_', true);
|
---|
378 | }
|
---|
379 |
|
---|
380 | ?>
|
---|