Blame Identity/Webenv/phpBB/3.0.4/includes/mcp/mcp_front.php

ef5584
ef5584
/**
ef5584
*
ef5584
* @package mcp
ef5584
* @version $Id: mcp_front.php 9029 2008-10-18 18:44:41Z toonarmy $
ef5584
* @copyright (c) 2005 phpBB Group
ef5584
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
ef5584
*
ef5584
*/
ef5584
ef5584
/**
ef5584
* @ignore
ef5584
*/
ef5584
if (!defined('IN_PHPBB'))
ef5584
{
ef5584
	exit;
ef5584
}
ef5584
ef5584
/**
ef5584
* MCP Front Panel
ef5584
*/
ef5584
function mcp_front_view($id, $mode, $action)
ef5584
{
ef5584
	global $phpEx, $phpbb_root_path, $config;
ef5584
	global $template, $db, $user, $auth, $module;
ef5584
ef5584
	// Latest 5 unapproved
ef5584
	if ($module->loaded('queue'))
ef5584
	{
ef5584
		$forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_approve')));
ef5584
		$post_list = array();
ef5584
		$forum_names = array();
ef5584
ef5584
		$forum_id = request_var('f', 0);
ef5584
ef5584
		$template->assign_var('S_SHOW_UNAPPROVED', (!empty($forum_list)) ? true : false);
ef5584
		
ef5584
		if (!empty($forum_list))
ef5584
		{
ef5584
			$sql = 'SELECT COUNT(post_id) AS total
ef5584
				FROM ' . POSTS_TABLE . '
ef5584
				WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ')
ef5584
					AND post_approved = 0';
ef5584
			$result = $db->sql_query($sql);
ef5584
			$total = (int) $db->sql_fetchfield('total');
ef5584
			$db->sql_freeresult($result);
ef5584
ef5584
			if ($total)
ef5584
			{
ef5584
				$global_id = $forum_list[0];
ef5584
ef5584
				$sql = 'SELECT forum_id, forum_name
ef5584
					FROM ' . FORUMS_TABLE . '
ef5584
					WHERE ' . $db->sql_in_set('forum_id', $forum_list);
ef5584
				$result = $db->sql_query($sql);
ef5584
ef5584
				while ($row = $db->sql_fetchrow($result))
ef5584
				{
ef5584
					$forum_names[$row['forum_id']] = $row['forum_name'];
ef5584
				}
ef5584
				$db->sql_freeresult($result);
ef5584
ef5584
				$sql = 'SELECT post_id
ef5584
					FROM ' . POSTS_TABLE . '
ef5584
					WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ')
ef5584
						AND post_approved = 0
ef5584
					ORDER BY post_time DESC';
ef5584
				$result = $db->sql_query_limit($sql, 5);
ef5584
ef5584
				while ($row = $db->sql_fetchrow($result))
ef5584
				{
ef5584
					$post_list[] = $row['post_id'];
ef5584
				}
ef5584
				$db->sql_freeresult($result);
ef5584
ef5584
				if (empty($post_list))
ef5584
				{
ef5584
					$total = 0;
ef5584
				}
ef5584
			}
ef5584
ef5584
			if ($total)
ef5584
			{
ef5584
				$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
ef5584
					FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
ef5584
					WHERE ' . $db->sql_in_set('p.post_id', $post_list) . '
ef5584
						AND t.topic_id = p.topic_id
ef5584
						AND p.poster_id = u.user_id
ef5584
					ORDER BY p.post_time DESC';
ef5584
				$result = $db->sql_query($sql);
ef5584
ef5584
				while ($row = $db->sql_fetchrow($result))
ef5584
				{
ef5584
					$global_topic = ($row['forum_id']) ? false : true;
ef5584
					if ($global_topic)
ef5584
					{
ef5584
						$row['forum_id'] = $global_id;
ef5584
					}
ef5584
ef5584
					$template->assign_block_vars('unapproved', array(
ef5584
						'U_POST_DETAILS'	=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $row['forum_id'] . '&p=' . $row['post_id']),
ef5584
						'U_MCP_FORUM'		=> (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view&f=' . $row['forum_id']) : '',
ef5584
						'U_MCP_TOPIC'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
ef5584
						'U_FORUM'			=> (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
ef5584
						'U_TOPIC'			=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
ef5584
ef5584
						'AUTHOR_FULL'		=> get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']),
ef5584
						'AUTHOR'			=> get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour']),
ef5584
						'AUTHOR_COLOUR'		=> get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour']),
ef5584
						'U_AUTHOR'			=> get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour']),
ef5584
ef5584
						'FORUM_NAME'	=> (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'],
ef5584
						'POST_ID'		=> $row['post_id'],
ef5584
						'TOPIC_TITLE'	=> $row['topic_title'],
ef5584
						'SUBJECT'		=> ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
ef5584
						'POST_TIME'		=> $user->format_date($row['post_time']))
ef5584
					);
ef5584
				}
ef5584
				$db->sql_freeresult($result);
ef5584
			}
ef5584
ef5584
			$template->assign_vars(array(
ef5584
				'S_MCP_QUEUE_ACTION'	=> append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue"),
ef5584
			));
ef5584
ef5584
			if ($total == 0)
ef5584
			{
ef5584
				$template->assign_vars(array(
ef5584
					'L_UNAPPROVED_TOTAL'		=> $user->lang['UNAPPROVED_POSTS_ZERO_TOTAL'],
ef5584
					'S_HAS_UNAPPROVED_POSTS'	=> false)
ef5584
				);
ef5584
			}
ef5584
			else
ef5584
			{
ef5584
				$template->assign_vars(array(
ef5584
					'L_UNAPPROVED_TOTAL'		=> ($total == 1) ? $user->lang['UNAPPROVED_POST_TOTAL'] : sprintf($user->lang['UNAPPROVED_POSTS_TOTAL'], $total),
ef5584
					'S_HAS_UNAPPROVED_POSTS'	=> true)
ef5584
				);
ef5584
			}
ef5584
		}
ef5584
	}
ef5584
ef5584
	// Latest 5 reported
ef5584
	if ($module->loaded('reports'))
ef5584
	{
ef5584
		$forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_report')));
ef5584
ef5584
		$template->assign_var('S_SHOW_REPORTS', (!empty($forum_list)) ? true : false);
ef5584
ef5584
		if (!empty($forum_list))
ef5584
		{
ef5584
			$sql = 'SELECT COUNT(r.report_id) AS total
ef5584
				FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
ef5584
				WHERE r.post_id = p.post_id
ef5584
					AND r.report_closed = 0
ef5584
					AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')';
ef5584
			$result = $db->sql_query($sql);
ef5584
			$total = (int) $db->sql_fetchfield('total');
ef5584
			$db->sql_freeresult($result);
ef5584
ef5584
			if ($total)
ef5584
			{
ef5584
				$global_id = $forum_list[0];
ef5584
ef5584
				$sql = $db->sql_build_query('SELECT', array(
ef5584
					'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',
ef5584
ef5584
					'FROM'		=> array(
ef5584
						REPORTS_TABLE			=> 'r',
ef5584
						REPORTS_REASONS_TABLE	=> 'rr',
ef5584
						TOPICS_TABLE			=> 't',
ef5584
						USERS_TABLE				=> array('u', 'u2'),
ef5584
						POSTS_TABLE				=> 'p'
ef5584
					),
ef5584
ef5584
					'LEFT_JOIN'	=> array(
ef5584
						array(
ef5584
							'FROM'	=> array(FORUMS_TABLE => 'f'),
ef5584
							'ON'	=> 'f.forum_id = p.forum_id'
ef5584
						)
ef5584
					),
ef5584
ef5584
					'WHERE'		=> 'r.post_id = p.post_id
ef5584
						AND r.report_closed = 0
ef5584
						AND r.reason_id = rr.reason_id
ef5584
						AND p.topic_id = t.topic_id
ef5584
						AND r.user_id = u.user_id
ef5584
						AND p.poster_id = u2.user_id
ef5584
						AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')',
ef5584
ef5584
					'ORDER_BY'	=> 'p.post_time DESC'
ef5584
				));
ef5584
				$result = $db->sql_query_limit($sql, 5);
ef5584
ef5584
				while ($row = $db->sql_fetchrow($result))
ef5584
				{
ef5584
					$global_topic = ($row['forum_id']) ? false : true;
ef5584
					if ($global_topic)
ef5584
					{
ef5584
						$row['forum_id'] = $global_id;
ef5584
					}
ef5584
ef5584
					$template->assign_block_vars('report', array(
ef5584
						'U_POST_DETAILS'	=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id'] . "&i=reports&mode=report_details"),
ef5584
						'U_MCP_FORUM'		=> (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&i=$id&mode=forum_view") : '',
ef5584
						'U_MCP_TOPIC'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . "&i=$id&mode=topic_view"),
ef5584
						'U_FORUM'			=> (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
ef5584
						'U_TOPIC'			=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
ef5584
ef5584
						'REPORTER_FULL'		=> get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
ef5584
						'REPORTER'			=> get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
ef5584
						'REPORTER_COLOUR'	=> get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
ef5584
						'U_REPORTER'		=> get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
ef5584
ef5584
						'AUTHOR_FULL'		=> get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']),
ef5584
						'AUTHOR'			=> get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']),
ef5584
						'AUTHOR_COLOUR'		=> get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']),
ef5584
						'U_AUTHOR'			=> get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']),
ef5584
ef5584
						'FORUM_NAME'	=> (!$global_topic) ? $row['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'],
ef5584
						'TOPIC_TITLE'	=> $row['topic_title'],
ef5584
						'SUBJECT'		=> ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
ef5584
						'REPORT_TIME'	=> $user->format_date($row['report_time']),
ef5584
						'POST_TIME'		=> $user->format_date($row['post_time']),
ef5584
					));
ef5584
				}
ef5584
			}
ef5584
ef5584
			if ($total == 0)
ef5584
			{
ef5584
				$template->assign_vars(array(
ef5584
					'L_REPORTS_TOTAL'	=>	$user->lang['REPORTS_ZERO_TOTAL'],
ef5584
					'S_HAS_REPORTS'		=>	false)
ef5584
				);
ef5584
			}
ef5584
			else
ef5584
			{
ef5584
				$template->assign_vars(array(
ef5584
					'L_REPORTS_TOTAL'	=> ($total == 1) ? $user->lang['REPORT_TOTAL'] : sprintf($user->lang['REPORTS_TOTAL'], $total),
ef5584
					'S_HAS_REPORTS'		=> true)
ef5584
				);
ef5584
			}
ef5584
		}
ef5584
	}
ef5584
ef5584
	// Latest 5 logs
ef5584
	if ($module->loaded('logs'))
ef5584
	{
ef5584
		$forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
ef5584
ef5584
		if (!empty($forum_list))
ef5584
		{
ef5584
			// Add forum_id 0 for global announcements
ef5584
			$forum_list[] = 0;
ef5584
ef5584
			$log_count = 0;
ef5584
			$log = array();
ef5584
			view_log('mod', $log, $log_count, 5, 0, $forum_list);
ef5584
ef5584
			foreach ($log as $row)
ef5584
			{
ef5584
				$template->assign_block_vars('log', array(
ef5584
					'USERNAME'		=> $row['username_full'],
ef5584
					'IP'			=> $row['ip'],
ef5584
					'TIME'			=> $user->format_date($row['time']),
ef5584
					'ACTION'		=> $row['action'],
ef5584
					'U_VIEW_TOPIC'	=> (!empty($row['viewtopic'])) ? $row['viewtopic'] : '',
ef5584
					'U_VIEWLOGS'	=> (!empty($row['viewlogs'])) ? $row['viewlogs'] : '')
ef5584
				);
ef5584
			}
ef5584
		}
ef5584
ef5584
		$template->assign_vars(array(
ef5584
			'S_SHOW_LOGS'	=> (!empty($forum_list)) ? true : false,
ef5584
			'S_HAS_LOGS'	=> (!empty($log)) ? true : false)
ef5584
		);
ef5584
	}
ef5584
ef5584
	$template->assign_var('S_MCP_ACTION', append_sid("{$phpbb_root_path}mcp.$phpEx"));
ef5584
	make_jumpbox(append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view'), 0, false, 'm_', true);
ef5584
}
ef5584
ef5584
?>