Location: PHPKode > projects > Enigma > Enigma2/Enigma2_Install/Blocks/Block_newSubmissions.php
<?php
/*
*****************************************************************

 Block_newSubmissions.php
 
*****************************************************************
LSP: Lunabyte Systems Portal
Open-Source Project Inspired by Zef Hemel (hide@address.com)
*****************************************************************
Software Version:                  LSP 2.0 "Enigma 2"
Software by:                         Lunabyte Systems (http://www.lunabyte.net)
Copyright 2002-2005 by:       Lunabyte Systems (http://www.lunabyte.net)
Support, News, Updates at:    http://www.lunabyte.net
*****************************************************************
This program is free software; you may redistribute it and/or modify it 
under the terms of the provided license as published by Lunabyte Systems.

This program is distributed in the hope that it is and will be useful,                  
but WITHOUT ANY WARRANTIES; without even any implied warranty of           
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                        

See the "LSP_license.txt" file for details of the LSP license.
The latest version can always be found at http://www.lunabyte.net.
*****************************************************************
*/

if (!defined('ENIGMA'))
	die('<b>Access Violation</b><br />Direct Access to this location is not allowed.');

// new submissions check functions
function Block_newSubmissions ()
{
	global $context, $txt, $scripturl;
	// run a query to count new submissions in each table
	$numNews = checkSubmissions('news');
	$numLinks = checkSubmissions('links_items');
	$numArticles = checkSubmissions('articles');
//	$numArticles = 0;  // TEMPORARY!  Until articles is added in.
	// if there are ANY submissions, set a variable for later checking
	if ($numNews > 0 || $numLinks > 0 || $numArticles > 0)
		$new = true;
	else
		$new = false;

	// set up initial values for newSubs and noNewSubs as empty.
	$context['newSubs'] = '';
	$context['noNewSubs'] = '';
	// go through each submission type and set the correct message, depending on 1 or more new submissions
	if ($numNews == 1 && allowedTo('review_news'))
		$context['newSubs'] .= '<a href="' . $scripturl . '?op=News;sa=newsIndex"><strong>' . $txt['newsubs_1'] . ' ' . $numNews . ' ' . $txt['newsubs_3'] . '</strong></a><br />';
	elseif ($numNews > 1 && allowedTo('review_news'))
		$context['newSubs'] .= '<a href="' . $scripturl . '?op=News;sa=newsIndex"><strong>' . $txt['newsubs_2'] . ' ' . $numNews . ' ' . $txt['newsubs_6'] . '</strong></a><br />';

	if ($numArticles == 1 && allowedTo('review_articles'))
		$context['newSubs'] .= '<a href="' . $scripturl . '?op=Articles;sa=articleIndex"><strong>' . $txt['newsubs_1'] . ' ' . $numArticles . ' ' . $txt['newsubs_5'] . '</strong></a><br />';
	elseif ($numArticles > 1 && allowedTo('review_articles'))
		$context['newSubs'] .= '<a href="' . $scripturl . '?op=Articles;sa=articleIndex"><strong>' . $txt['newsubs_2'] . ' ' . $numArticles . ' ' . $txt['newsubs_8'] . '</strong></a><br />';

	if ($numLinks == 1 && allowedTo('review_link'))
		$context['newSubs'] .= '<a href="' . $scripturl . '?module=Links;sa=linkIndex"><strong>' . $txt['newsubs_1'] . ' ' . $numLinks . ' ' . $txt['newsubs_4'] . '</strong></a><br />';
	elseif ($numLinks > 1 && allowedTo('review_link'))
		$context['newSubs'] .= '<a href="' . $scripturl . '?module=Links;sa=linkIndex"><strong>' . $txt['newsubs_2'] . ' ' . $numLinks . ' ' . $txt['newsubs_7'] . '</strong></a><br />';
	// if no new submissions, setup the message saying so
	if (!$new)
		$context['noNewSubs'] = $txt['newsubs_9'];

// a $context variable was set, so we don't need to do anything else
}

function checkSubmissions ($table)
{
	global $db_prefix;

	$request = db_query("
		SELECT COUNT(*)
		FROM {$db_prefix}$table
		WHERE reviewFlag = '1'", __FILE__, __LINE__);
	
	$result = mysql_fetch_array($request);
	mysql_free_result($request);

	return $result[0];
}
// end new submissions functions
?>
Return current item: Enigma