Location: PHPKode > projects > Enigma > Enigma2/Enigma2_Install/modules/Mod_Faq.php
<?php
/*
*****************************************************************

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

if ($modSettings['enablefaq'] == '1')
	FAQHub();
else
	redirectexit();

function FaqHub()
{
	global $db_prefix, $context, $txt;

	loadMLanguage('Faq');
	loadMTemplate('Faq');

	if (!isset($context['page_title']))
		$context['page_title'] = &$txt['faq25'];

	$context['id_cat'] = (int) !empty($_REQUEST['id_cat']) ? $_REQUEST['id_cat'] : '0';

	$sa = empty($_REQUEST['sa']) ? '' : $_REQUEST['sa'];

	$result = db_query("
		SELECT c.id_cat, c.categories, count(a.id_cat) AS answers
		FROM ({$db_prefix}faqcategories AS c)
		LEFT JOIN {$db_prefix}faqanswer AS a ON (c.id_cat = a.id_cat)
		GROUP BY c.id_cat", __FILE__, __LINE__);

	while ($cat = mysql_fetch_assoc($result))
		$context['cat'][$cat['id_cat']] = array(
			'id_cat'	=> $cat['id_cat'],
			'categories'	=> $cat['categories'],
			'count'		=> $cat['answers'],
		);

	mysql_free_result ($result);

	if ($sa == 'ShowFaq')
	{
		ShowFaq();
	}
	else
	{
		$context['sub_template'] = 'Show_new';
	}

	$context['template_layers'][] = 'Faq';
}

function ShowFaq()
{
	global $db_prefix, $context, $txt;

	$context['questions'] = array();

	$result = db_query("
		SELECT *
		FROM {$db_prefix}faqanswer
		WHERE id_cat='$context[id_cat]'
		ORDER BY question", __FILE__, __LINE__);

	while($asw = mysql_fetch_assoc($result))
		$context['questions'][] = array(
			'id'		=> $asw['id'],
			'id_cat'	=> $asw['id_cat'],
			'question'	=> $asw['question'],
			'answer'	=> $asw['answer'],
		);

	mysql_free_result ($result);
			
	$context['sub_template'] = 'Show_Faq';
}

?>
Return current item: Enigma