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

 Mod_LinksManagement.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 (allowedTo('edit_forum'))
	LinksManageHub();
else
	redirectexit();

function LinksManageHub()
{
	global $context, $user_info, $txt;

	isAllowedTo('edit_forum');

	loadMTemplate('LinksManagement');
	loadMLanguage('Links');

	$context['page_title'] = $txt['links_52'];

	// Load the common admin stuff... select 'Block_Management'.
	if ($user_info['is_admin'])
		adminIndex('Links_Management');

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

	$subActions = array(
			'alcat2',
			'dellcat',
			'elcat',
			'elcat2',
		);

	if (in_array($sa, $subActions))
		$sa();
	elseif (isset($subActions[$sa]))
		$subActions[$sa]();
	else
		alcat();
		
	unset($subActions);
}

function alcat()
{
	global $db_prefix, $txt, $context, $settings;

	$context['page_title'] = $txt['links_52'];

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

	$request = db_query("
		SELECT *
		FROM {$db_prefix}links_cats
		ORDER BY name", __FILE__, __LINE__);

	while ($result = mysql_fetch_assoc($request))
	{
		$request2 = db_query("
			SELECT COUNT(*)
			FROM {$db_prefix}links_items
			WHERE catID = " . $result['catID'] , __FILE__, __LINE__);
		$num = mysql_fetch_row($request2);

		$context['lcat'][] = array(
			'catID'	=> $result['catID'],
			'name'	=> $result['name'],
			'desc'	=> $result['description'],
			'count'	=> $num[0],
		);
	}

	if (!$context['lcat'])
		$context['lcat'] = $txt['links_55'];
	mysql_free_result ($request);

	$context['sub_template'] = 'Links_alcat';
}

function elcat()
{
	global $txt, $db_prefix, $context, $_REQUEST;

	$context['page_title'] = $txt['links_59'];

	$context['elcat'] = array();
	$context['id'] = (int) $_REQUEST['id'];

	$request = db_query("
			SELECT *
			FROM {$db_prefix}links_cats
			WHERE catID = '$context[id]'", __FILE__, __LINE__);

	$context['elcat'] = mysql_fetch_assoc($request);
	mysql_free_result ($request);

	$context['sub_template'] = 'Links_elcat';
}

function alcat2()
{
	global $db_prefix, $_POST;

	db_query("
		INSERT INTO {$db_prefix}links_cats
		(name, description)
		VALUES ('$_POST[name]','$_POST[desc]')", __FILE__, __LINE__);
	
	redirectexit('module=LinksManagement');
}

function dellcat()
{
	global $db_prefix, $_REQUEST;

	db_query("
		DELETE FROM {$db_prefix}links_cats
		WHERE catID = '$_REQUEST[id]'", __FILE__, __LINE__);
	
	redirectexit('module=LinksManagement');
}

function elcat2()
{
	global $db_prefix, $_POST;

	$id = (int) $_POST['id'];

	db_query("
		UPDATE {$db_prefix}links_cats
		SET name='$_POST[name]',description='$_POST[desc]'
		WHERE catID = '$id'", __FILE__, __LINE__);

	redirectexit('module=LinksManagement');
}

?>
Return current item: Enigma