6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 if (!defined('IN_PHPBB'))
22 function mcp_front_view($id, $mode, $action)
24 global $phpEx, $phpbb_root_path, $config;
25 global $template, $db, $user, $auth, $module;
27 // Latest 5 unapproved
28 if ($module->loaded('queue'))
30 $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_approve')));
32 $forum_names = array();
34 $forum_id = request_var('f', 0);
36 $template->assign_var('S_SHOW_UNAPPROVED', (!empty($forum_list)) ? true : false);
38 if (!empty($forum_list))
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);
50 $global_id = $forum_list[0];
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);
57 while ($row = $db->sql_fetchrow($result))
59 $forum_names[$row['forum_id']] = $row['forum_name'];
61 $db->sql_freeresult($result);
63 $sql = 'SELECT post_id
64 FROM ' . POSTS_TABLE . '
65 WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ')
67 ORDER BY post_time DESC';
68 $result = $db->sql_query_limit($sql, 5);
70 while ($row = $db->sql_fetchrow($result))
72 $post_list[] = $row['post_id'];
74 $db->sql_freeresult($result);
76 if (empty($post_list))
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);
92 while ($row = $db->sql_fetchrow($result))
94 $global_topic = ($row['forum_id']) ? false : true;
97 $row['forum_id'] = $global_id;
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']),
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']),
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']))
119 $db->sql_freeresult($result);
122 $s_hidden_fields = build_hidden_fields(array(
123 'redirect' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main' . (($forum_id) ? '&f=' . $forum_id : ''))
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"),
133 $template->assign_vars(array(
134 'L_UNAPPROVED_TOTAL' => $user->lang['UNAPPROVED_POSTS_ZERO_TOTAL'],
135 'S_HAS_UNAPPROVED_POSTS' => false)
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)
149 if ($module->loaded('reports'))
151 $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_report')));
153 $template->assign_var('S_SHOW_REPORTS', (!empty($forum_list)) ? true : false);
155 if (!empty($forum_list))
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
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);
169 $global_id = $forum_list[0];
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',
175 REPORTS_TABLE => 'r',
176 REPORTS_REASONS_TABLE => 'rr',
178 USERS_TABLE => array('u', 'u2'),
182 'LEFT_JOIN' => array(
184 'FROM' => array(FORUMS_TABLE => 'f'),
185 'ON' => 'f.forum_id = p.forum_id'
189 'WHERE' => 'r.post_id = p.post_id
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) . ')',
198 'ORDER_BY' => 'p.post_time DESC'
200 $result = $db->sql_query_limit($sql, 5);
202 while ($row = $db->sql_fetchrow($result))
204 $global_topic = ($row['forum_id']) ? false : true;
207 $row['forum_id'] = $global_id;
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']),
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']),
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']),
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']),
238 $template->assign_vars(array(
239 'L_REPORTS_TOTAL' => $user->lang['REPORTS_ZERO_TOTAL'],
240 'S_HAS_REPORTS' => false)
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)
253 // Latest 5 reported PMs
254 if ($module->loaded('pm_reports') && $auth->acl_getf_global('m_report'))
256 $template->assign_var('S_SHOW_PM_REPORTS', true);
257 $user->add_lang(array('ucp'));
259 $sql = 'SELECT COUNT(r.report_id) AS total
260 FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p
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);
270 include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
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',
276 REPORTS_TABLE => 'r',
277 REPORTS_REASONS_TABLE => 'rr',
278 USERS_TABLE => array('u', 'u2'),
279 PRIVMSGS_TABLE => 'p'
282 'WHERE' => 'r.pm_id = p.msg_id
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',
289 'ORDER_BY' => 'p.message_time DESC'
291 $result = $db->sql_query_limit($sql, 5);
293 $pm_by_id = $pm_list = array();
294 while ($row = $db->sql_fetchrow($result))
296 $pm_by_id[(int) $row['msg_id']] = $row;
297 $pm_list[] = (int) $row['msg_id'];
300 $address_list = get_recipient_strings($pm_by_id);
302 foreach ($pm_list as $message_id)
304 $row = $pm_by_id[$message_id];
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"),
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']),
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']),
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']]),
329 $template->assign_vars(array(
330 'L_PM_REPORTS_TOTAL' => $user->lang['PM_REPORTS_ZERO_TOTAL'],
331 'S_HAS_PM_REPORTS' => false)
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)
344 if ($module->loaded('logs'))
346 $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
348 if (!empty($forum_list))
350 // Add forum_id 0 for global announcements
355 view_log('mod', $log, $log_count, 5, 0, $forum_list);
357 foreach ($log as $row)
359 $template->assign_block_vars('log', array(
360 'USERNAME' => $row['username_full'],
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'] : '')
370 $template->assign_vars(array(
371 'S_SHOW_LOGS' => (!empty($forum_list)) ? true : false,
372 'S_HAS_LOGS' => (!empty($log)) ? true : false)
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);