5
* @version $Id: mcp_front.php,v 1.34 2007/11/03 11:09:11 acydburn Exp $
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 = 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, 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']),
106
'U_AUTHOR' => ($row['poster_id'] == ANONYMOUS) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['poster_id']),
108
'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'],
109
'POST_ID' => $row['post_id'],
110
'TOPIC_TITLE' => $row['topic_title'],
111
'AUTHOR' => ($row['poster_id'] == ANONYMOUS) ? (($row['post_username']) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'],
112
'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
113
'POST_TIME' => $user->format_date($row['post_time']))
116
$db->sql_freeresult($result);
119
$template->assign_vars(array(
120
'S_MCP_QUEUE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue"),
125
$template->assign_vars(array(
126
'L_UNAPPROVED_TOTAL' => $user->lang['UNAPPROVED_POSTS_ZERO_TOTAL'],
127
'S_HAS_UNAPPROVED_POSTS' => false)
132
$template->assign_vars(array(
133
'L_UNAPPROVED_TOTAL' => ($total == 1) ? $user->lang['UNAPPROVED_POST_TOTAL'] : sprintf($user->lang['UNAPPROVED_POSTS_TOTAL'], $total),
134
'S_HAS_UNAPPROVED_POSTS' => true)
141
if ($module->loaded('reports'))
143
$forum_list = get_forum_list('m_report');
145
$template->assign_var('S_SHOW_REPORTS', (!empty($forum_list)) ? true : false);
147
if (!empty($forum_list))
149
$sql = 'SELECT COUNT(r.report_id) AS total
150
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
151
WHERE r.post_id = p.post_id
152
AND r.report_closed = 0
153
AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')';
154
$result = $db->sql_query($sql);
155
$total = (int) $db->sql_fetchfield('total');
156
$db->sql_freeresult($result);
160
$global_id = $forum_list[0];
162
$sql = $db->sql_build_query('SELECT', array(
163
'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',
166
REPORTS_TABLE => 'r',
167
REPORTS_REASONS_TABLE => 'rr',
169
USERS_TABLE => array('u', 'u2'),
173
'LEFT_JOIN' => array(
175
'FROM' => array(FORUMS_TABLE => 'f'),
176
'ON' => 'f.forum_id = p.forum_id'
180
'WHERE' => 'r.post_id = p.post_id
181
AND r.report_closed = 0
182
AND r.reason_id = rr.reason_id
183
AND p.topic_id = t.topic_id
184
AND r.user_id = u.user_id
185
AND p.poster_id = u2.user_id
186
AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')',
188
'ORDER_BY' => 'p.post_time DESC'
190
$result = $db->sql_query_limit($sql, 5);
192
while ($row = $db->sql_fetchrow($result))
194
$global_topic = ($row['forum_id']) ? false : true;
197
$row['forum_id'] = $global_id;
200
$template->assign_block_vars('report', array(
201
'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id'] . "&i=reports&mode=report_details"),
202
'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&i=$id&mode=forum_view") : '',
203
'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . "&i=$id&mode=topic_view"),
204
'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
205
'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
207
'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
208
'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
209
'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
210
'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
212
'AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']),
213
'AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']),
214
'AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']),
215
'U_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']),
217
'FORUM_NAME' => (!$global_topic) ? $row['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'],
218
'TOPIC_TITLE' => $row['topic_title'],
219
'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
220
'REPORT_TIME' => $user->format_date($row['report_time']),
221
'POST_TIME' => $user->format_date($row['post_time']),
228
$template->assign_vars(array(
229
'L_REPORTS_TOTAL' => $user->lang['REPORTS_ZERO_TOTAL'],
230
'S_HAS_REPORTS' => false)
235
$template->assign_vars(array(
236
'L_REPORTS_TOTAL' => ($total == 1) ? $user->lang['REPORT_TOTAL'] : sprintf($user->lang['REPORTS_TOTAL'], $total),
237
'S_HAS_REPORTS' => true)
244
if ($module->loaded('logs'))
246
$forum_list = get_forum_list('m_');
248
if (!empty($forum_list))
250
// Add forum_id 0 for global announcements
255
view_log('mod', $log, $log_count, 5, 0, $forum_list);
257
foreach ($log as $row)
259
$template->assign_block_vars('log', array(
260
'USERNAME' => $row['username_full'],
262
'TIME' => $user->format_date($row['time']),
263
'ACTION' => $row['action'],
264
'U_VIEW_TOPIC' => (!empty($row['viewtopic'])) ? $row['viewtopic'] : '',
265
'U_VIEWLOGS' => (!empty($row['viewlogs'])) ? $row['viewlogs'] : '')
270
$template->assign_vars(array(
271
'S_SHOW_LOGS' => (!empty($forum_list)) ? true : false,
272
'S_HAS_LOGS' => (!empty($log)) ? true : false)
276
$template->assign_var('S_MCP_ACTION', append_sid("{$phpbb_root_path}mcp.$phpEx"));
277
make_jumpbox(append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view'), 0, false, 'm_', true);
b'\\ No newline at end of file'