Blame Extras/phpBB/3.0.4/includes/mcp/mcp_front.php

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