Blame Identity/Models/Html/phpBB/3.0.4/includes/mcp/mcp_front.php

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