[ Index ] |
PHP Cross Reference of phpBB 3.0 Beta 3 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * @package mcp 5 * @version $Id: mcp_front.php,v 1.22 2006/11/07 20:49:51 grahamje Exp $ 6 * @copyright (c) 2005 phpBB Group 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License 8 * 9 */ 10 11 /** 12 * MCP Front Panel 13 */ 14 function mcp_front_view($id, $mode, $action) 15 { 16 global $phpEx, $phpbb_root_path, $config; 17 global $template, $db, $user, $auth; 18 19 // Latest 5 unapproved 20 $forum_list = get_forum_list('m_approve'); 21 $post_list = array(); 22 $forum_names = array(); 23 24 $forum_id = request_var('f', 0); 25 26 $template->assign_var('S_SHOW_UNAPPROVED', (!empty($forum_list)) ? true : false); 27 28 if (!empty($forum_list)) 29 { 30 $sql = 'SELECT COUNT(post_id) AS total 31 FROM ' . POSTS_TABLE . ' 32 WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') 33 AND post_approved = 0'; 34 $result = $db->sql_query($sql); 35 $total = (int) $db->sql_fetchfield('total'); 36 $db->sql_freeresult($result); 37 38 if ($total) 39 { 40 $global_id = $forum_list[0]; 41 42 $sql = 'SELECT forum_id, forum_name 43 FROM ' . FORUMS_TABLE . ' 44 WHERE ' . $db->sql_in_set('forum_id', $forum_list); 45 $result = $db->sql_query($sql); 46 47 while ($row = $db->sql_fetchrow($result)) 48 { 49 $forum_names[$row['forum_id']] = $row['forum_name']; 50 } 51 $db->sql_freeresult($result); 52 53 $sql = 'SELECT post_id 54 FROM ' . POSTS_TABLE . ' 55 WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') 56 AND post_approved = 0 57 ORDER BY post_time DESC'; 58 $result = $db->sql_query_limit($sql, 5); 59 60 while ($row = $db->sql_fetchrow($result)) 61 { 62 $post_list[] = $row['post_id']; 63 } 64 $db->sql_freeresult($result); 65 66 $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.username, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id 67 FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u 68 WHERE ' . $db->sql_in_set('p.post_id', $post_list) . ' 69 AND t.topic_id = p.topic_id 70 AND p.poster_id = u.user_id 71 ORDER BY p.post_time DESC'; 72 $result = $db->sql_query($sql); 73 74 while ($row = $db->sql_fetchrow($result)) 75 { 76 $global_topic = ($row['forum_id']) ? false : true; 77 if ($global_topic) 78 { 79 $row['forum_id'] = $global_id; 80 } 81 82 $template->assign_block_vars('unapproved', array( 83 'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=post_details&f=' . $row['forum_id'] . '&p=' . $row['post_id']), 84 'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view&f=' . $row['forum_id']) : '', 85 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 86 'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', 87 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 88 'U_AUTHOR' => ($row['poster_id'] == ANONYMOUS) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['poster_id']), 89 90 'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], 91 'TOPIC_TITLE' => $row['topic_title'], 92 'AUTHOR' => ($row['poster_id'] == ANONYMOUS) ? (($row['post_username']) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'], 93 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 94 'POST_TIME' => $user->format_date($row['post_time'])) 95 ); 96 } 97 $db->sql_freeresult($result); 98 } 99 100 if ($total == 0) 101 { 102 $template->assign_vars(array( 103 'L_UNAPPROVED_TOTAL' => $user->lang['UNAPPROVED_POSTS_ZERO_TOTAL'], 104 'S_HAS_UNAPPROVED_POSTS' => false) 105 ); 106 } 107 else 108 { 109 $template->assign_vars(array( 110 'L_UNAPPROVED_TOTAL' => ($total == 1) ? $user->lang['UNAPPROVED_POST_TOTAL'] : sprintf($user->lang['UNAPPROVED_POSTS_TOTAL'], $total), 111 'S_HAS_UNAPPROVED_POSTS' => true) 112 ); 113 } 114 } 115 116 // Latest 5 reported 117 $forum_list = get_forum_list('m_report'); 118 119 $template->assign_var('S_SHOW_REPORTS', (!empty($forum_list)) ? true : false); 120 121 if (!empty($forum_list)) 122 { 123 $sql = 'SELECT COUNT(r.report_id) AS total 124 FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p 125 WHERE r.post_id = p.post_id 126 AND r.report_closed = 0 127 AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')'; 128 $result = $db->sql_query($sql); 129 $total = (int) $db->sql_fetchfield('total'); 130 $db->sql_freeresult($result); 131 132 if ($total) 133 { 134 $global_id = $forum_list[0]; 135 136 $sql = $db->sql_build_query('SELECT', array( 137 'SELECT' => 'r.*, p.post_id, p.post_subject, u.username, t.topic_id, t.topic_title, f.forum_id, f.forum_name', 138 139 'FROM' => array( 140 REPORTS_TABLE => 'r', 141 REPORTS_REASONS_TABLE => 'rr', 142 TOPICS_TABLE => 't', 143 USERS_TABLE => 'u', 144 POSTS_TABLE => 'p' 145 ), 146 147 'LEFT_JOIN' => array( 148 array( 149 'FROM' => array(FORUMS_TABLE => 'f'), 150 'ON' => 'f.forum_id = p.forum_id' 151 ) 152 ), 153 154 'WHERE' => 'r.post_id = p.post_id 155 AND r.report_closed = 0 156 AND r.reason_id = rr.reason_id 157 AND p.topic_id = t.topic_id 158 AND r.user_id = u.user_id 159 AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')', 160 161 'ORDER_BY' => 'p.post_time DESC' 162 )); 163 $result = $db->sql_query_limit($sql, 5); 164 165 while ($row = $db->sql_fetchrow($result)) 166 { 167 $global_topic = ($row['forum_id']) ? false : true; 168 if ($global_topic) 169 { 170 $row['forum_id'] = $global_id; 171 } 172 173 $template->assign_block_vars('report', array( 174 'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id'] . "&i=reports&mode=report_details"), 175 'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&i=$id&mode=forum_view") : '', 176 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . "&i=$id&mode=topic_view"), 177 'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', 178 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 179 'U_REPORTER' => ($row['user_id'] == ANONYMOUS) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']), 180 181 'FORUM_NAME' => (!$global_topic) ? $row['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'], 182 'TOPIC_TITLE' => $row['topic_title'], 183 'REPORTER' => ($row['user_id'] == ANONYMOUS) ? $user->lang['GUEST'] : $row['username'], 184 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 185 'REPORT_TIME' => $user->format_date($row['report_time'])) 186 ); 187 } 188 } 189 190 if ($total == 0) 191 { 192 $template->assign_vars(array( 193 'L_REPORTS_TOTAL' => $user->lang['REPORTS_ZERO_TOTAL'], 194 'S_HAS_REPORTS' => false) 195 ); 196 } 197 else 198 { 199 $template->assign_vars(array( 200 'L_REPORTS_TOTAL' => ($total == 1) ? $user->lang['REPORT_TOTAL'] : sprintf($user->lang['REPORTS_TOTAL'], $total), 201 'S_HAS_REPORTS' => true) 202 ); 203 } 204 } 205 206 // Latest 5 logs 207 $forum_list = get_forum_list(array('m_', 'a_')); 208 209 if (!empty($forum_list)) 210 { 211 // Add forum_id 0 for global announcements 212 $forum_list[] = 0; 213 214 $log_count = 0; 215 $log = array(); 216 view_log('mod', $log, $log_count, 5, 0, $forum_list); 217 218 foreach ($log as $row) 219 { 220 $template->assign_block_vars('log', array( 221 'USERNAME' => $row['username'], 222 'IP' => $row['ip'], 223 'TIME' => $user->format_date($row['time']), 224 'ACTION' => $row['action'], 225 'U_VIEWTOPIC' => (!empty($row['viewtopic'])) ? $row['viewtopic'] : '', 226 'U_VIEWLOGS' => (!empty($row['viewlogs'])) ? $row['viewlogs'] : '') 227 ); 228 } 229 } 230 231 $template->assign_vars(array( 232 'S_SHOW_LOGS' => (!empty($forum_list)) ? true : false, 233 'S_HAS_LOGS' => (!empty($log)) ? true : false) 234 ); 235 236 $template->assign_var('S_MCP_ACTION', append_sid("{$phpbb_root_path}mcp.$phpEx")); 237 make_jumpbox(append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view'), 0, false, 'm_'); 238 } 239 240 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 22 00:35:05 2006 | Cross-referenced by PHPXref 0.6 |