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

 Block_featuredarticles.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.');

function Block_featuredarticles()
{
	global $scripturl, $db_prefix, $txt, $settings, $context, $modSettings;

	loadPLanguage('Articles');

	$sect = array();
	$perm = array();
	$alimit = $modSettings['featuredarticles'];

	$get_sections = db_query("
		SELECT *
		FROM {$db_prefix}art_sections", __FILE__, __LINE__);

	while ($asect = mysql_fetch_assoc($get_sections))
	{
		$sect[$asect['ID_SECTION']] = '<a href="' . $scripturl . '?op=Articles;section=' . $asect['ID_SECTION'] . '"><img src="' . $settings['images_url'] . '/Articles/' . $asect['banner'] . '" border="0" alt="' . $asect['title'] . '" /></a>';
		$perm[$asect['ID_SECTION']] = $asect['memberGroups'];
	}
	mysql_free_result ($get_sections);

	$request = db_query("
		SELECT *, IFNULL(dateModified, dateEntered) AS time
		FROM {$db_prefix}articles
		WHERE publish = 1
			AND featureFlag=1
			AND (reviewFlag = 0 OR stage = 1)
		ORDER BY time DESC
		LIMIT $alimit", __FILE__, __LINE__);

	$art=0;
	while ($row = mysql_fetch_assoc($request))
	{
		//first make sure they have access to this section, otherwise, you can't show it
		if (groupPermissions($perm[$row['ID_SECTION']]))
		{
			//setup the section header
			$article['title'] = $sect[$row['ID_SECTION']];

			$article['heading'] = $row['heading'];
			$article['sub_heading'] = $row['sub_heading'];

			//if a member posted this, then create a link to their profile
			if ($row['ID_POSTER'] > 0)
			{
				$request2 = db_query("
					SELECT memberName, IFNULL(realName, memberName) AS postname
					FROM {$db_prefix}members
					WHERE ID_MEMBER = $row[ID_POSTER]
					LIMIT 1", __FILE__, __LINE__);

				$tmp = mysql_fetch_assoc($request2);
				$article['byline'] = $txt['art528'] . '<a href="' . $scripturl . '?action=profile;u=' . $tmp['memberName'] . '">' . $tmp['postname'] . '</a>';
				mysql_free_result ($request2);
			}
			//otherwise, just create a link to their email address
			else
			{
				$article['byline'] = $txt['art528'] . '<a href="mailto:' . $row['posterEmail'] . '">' . $row['byline'] . '</a>';
			}

			$article['time'] = $txt['art529'] . ' ' . timeformat($row['time']);
			$article['story'] = DoUBBC($row['summary']);
			$article['readmore'] = '<a href="' . $scripturl . '?op=Articles;article=' . $row['ID_ARTICLE'] . '">' . $txt['art158'] . '</a>';

			echo '
	<div class="tborder">
		<table border="0" cellpadding="3" cellspacing="2" width="100%">
			<tr>
				<th class="catbg" width="100%"><small>' . $article['title'] . '</small></th>
			</tr><tr>
				<td class="windowbg2" width="100%"><small>' . $article['heading'] . '</small></td>
			</tr><tr>
				<td class="windowbg2" width="100%"><small>' . $article['byline'] . '</small></td>
			</tr><tr>
				<td class="windowbg2" width="100%"><small>' . $article['sub_heading'] . '</small></td>
			</tr><tr>
				<td class="windowbg2" width="100%"><small>' . $article['story'] . '</small></td>
			</tr><tr>
				<td class="windowbg2" width="100%">' . $article['readmore']. '</td>
			</tr>
		</table>
	</div>
	<br />';
			$art++;
		}
	}
	mysql_free_result ($request);

	if ($art<=0)
		$context['raw_data'] .=  $txt['no_arts'];
}
?>
Return current item: Enigma