Location: PHPKode > projects > Enigma > Enigma2/Enigma2_Install/PortalSources/MenuManagement.php
<?php
/*
*****************************************************************

 MenuManagement.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 MenuHub ()
{
	global $context, $txt, $user_info;

	isAllowedTo('manage_menus');

	loadPLanguage('MenuManagement');
	loadPTemplate('MenuManagement');

	// Just for navigation, show some nice bar on the left.
	if ($user_info['is_admin'])
		adminIndex('Menu_Management');

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

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

	//$sa = ($sa != 'menu' && empty($_REQUEST['curmgrp'])) ? 'menu' : $sa;

	$subActions = array(
		'menu2',
		'menuitems',
		'amenucfm',
		'backmu',
		'overmu',
		'amenui',
		'emenu',
		'emenui',
		'amenu2',
		'amenugi',
		'amenusp',
		'dmenuig',
		'emenuig',
		'emenuig2',
		'emenug',
		'mcmenuitm',
		'dmenui',
	);

	// Follow the sa or just go to administration.
	if (in_array($sa, $subActions))
		$sa();
	elseif (isset($subActions[$sa]))
		$subActions[$sa]();
	else
		menu2();
}

// Function for add Groups and edit main page
function menu2()
{
	global $db_prefix, $context, $sc, $scripturl, $txt, $settings;

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

	$context['linktree'] = array(
		array(
			'url'	=> $scripturl . '?action=admin',
			'name'	=> 'Admin',
		),
		array(
			'url'	=> $scripturl . '?op=MenuManagement;sa=menu2',
			'name'	=> &$txt['menu_1'],
		),
	);

	$delgrp	= !empty($_REQUEST['delgrp']) ? $_REQUEST['delgrp'] : '0';
	$context['delgrp'] = $delgrp;
	$mend	= !empty($_REQUEST['mend']) ? $_REQUEST['mend'] : '';

	// If item was selected for delete, print a confirmation form
	if ($delgrp == '1')
	{
		foreach ($mend as $key => $value)
		{
			$del_grp = db_query("
					SELECT tagname
					FROM {$db_prefix}menugrps
					WHERE grpID='$value'", __FILE__, __LINE__);

			$current = mysql_fetch_array($del_grp);

			$context['current'][] = array(
					'tagname'	=> $current['tagname'],
					'key'		=> $key,
					'value'		=> $value,
			);

			mysql_free_result ($del_grp);
		}
	}

	// Get all menu groups from dbtable and display
	$request = db_query("
			SELECT *
			FROM {$db_prefix}menugrps
			ORDER BY grpID ASC", __FILE__, __LINE__);

	$s=0;
	while ($menugrp = mysql_fetch_array($request))
	{
		// if item separator has html tags, make sure they display correctly
		$menugrp['itemsep'] = str_replace(
			array('<', '>', '"', '&nbsp;'),
			array('&lt;', '&gt;', '&quot;', '&amp;nbsp;'),
			$menugrp['itemsep']);

		// determine if menu is text or image
		if ($menugrp['menutype'] == '0')
		{
			$menugrp['menutype'] = $txt['menu_18'];
		}
		elseif ($menugrp['menutype'] == '1')
		{
			$menugrp['menutype'] = $txt['menu_19'];
		}
		elseif ($menugrp['menutype'] == '3')
		{
			$menugrp['menutype'] = $txt['menu_67'];
		}

		$s++;
		$context['menugrp'][] = array(
				'num'		=> $s,
				'grpID'	=> $menugrp['grpID'],
				'tagname'	=> $menugrp['tagname'],
				'menutype'	=> $menugrp['menutype'],
				'itemsep'	=> $menugrp['itemsep'],
				'css'		=> $menugrp['css'],
		);
	}
	mysql_free_result ($request);

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

// list menu items
function menuitems()
{
	global $db_prefix, $context, $settings, $scripturl, $txt, $boardurl;

	$context['page_title'] = $txt['menu_1'] . ' - ' . $txt['menu_20'];

	$curmgrp = $_REQUEST['curmgrp'];
	$context['item'] = array();

	// get info for selected menu group
	$request = db_query("
			SELECT *
			FROM {$db_prefix}menugrps
			WHERE grpID='$curmgrp'", __FILE__, __LINE__);;

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

	// If any fields have special chars, convert them to display as they are
	$context['menugrp']['itemsep'] = str_replace(
			array('<', '>', '"', '&nbsp;'),
			array('&lt;', '&gt;', '&quot;', '&amp;nbsp;'),
			$context['menugrp']['itemsep']);

	$context['mgimg'] = ($context['menugrp']['menutype'] == '0') ? ' selected' : '';
	$context['mgtxt'] = ($context['menugrp']['menutype'] == '1') ? ' selected' : '';
	$context['mgcus'] = ($context['menugrp']['menutype'] == '3') ? ' selected' : '';

	$context['linktree'] = array(
		array(
			'url'	=> $scripturl . '?action=admin',
			'name'	=> 'Admin',
		),
		array(
			'url'	=> $scripturl . '?op=MenuManagement;sa=menu2',
			'name'	=> &$txt['menu_1'],
		),

		array(
			'url'	=> $scripturl . '?op=MenuManagement;sa=menu2#amig',
			'name'	=> &$txt['menu_17'],
		),
		array(
			'name'	=> ' > ' . $txt['menu_23'] . ' < ',
		),
		array(
			'url'	=> $scripturl . '?op=MenuManagement;sa=menuitems;curmgrp=' . $context['menugrp']['grpID'] . '#ami',
			'name'	=> &$txt['menu_21'],
		),
		array(
			'url'	=> $scripturl . '?op=MenuManagement;sa=menuitems;curmgrp=' . $context['menugrp']['grpID'] . '#acsp',
			'name'	=> &$txt['menu_22'],
		),
	);


	// select menu for selected group
	$request2 = db_query("
			SELECT *
			FROM {$db_prefix}menu
			WHERE grpID = '$curmgrp'
			ORDER BY position ASC", __FILE__, __LINE__);

	$d=0;
	while ($item = mysql_fetch_assoc($request2))
	{
		// display who can view item
		$item['memberGroup'] = permissionlist($item['memberGroup']);

		// allow quotes and HTML tags to be displayed in form fields
		$item['alt'] = str_replace(
				array('<', '>', '"', '&nbsp;'),
				array('&lt;', '&gt;', '&quot;', '&amp;nbsp;'),
				$item['alt']);

		$item['url'] = str_replace('"', '&quot;', $item['url']);

		if (strlen($item['url']) > 25)
			$item['url'] = (substr($item['url'], 0, 20) . '...');

		if ($item['imgloc'] == '0')
		{
			$item['itemimage'] = $settings['images_url'] . '/' . $context['user']['language'] . '/' . $item['img'];
		}
		elseif ($item['imgloc'] == '1')
		{
			// $boardurl . '/' . 
			$item['itemimage'] = $item['imgfolder'] . '/' . $item['img'];
		}

		if ($item['imgwidth'] != '' && $item['imgheight'] != '')
		{
			$item['size'] = 'width="' . $item['imgwidth'] . '" height="' . $item['imgheight'] . '"';
		}
		else
		{
			$item['size'] = '';
		}

		if (strlen($item['imgfolder']) > 15)
			$item['imgfolder'] = (substr($item['imgfolder'], 0, 15) . '...');

		$item['mspc'] = ($item['special'] == '' || $item['special'] == 'custsep') ? '' : '*';

		$item['d'] = $d++;

		$context['item'][] = $item;
	}
	mysql_free_result ($request2);

	// make selection list from current menu group names
	$request3 = db_query("
			SELECT grpID, tagname
			FROM {$db_prefix}menugrps", __FILE__, __LINE__);

	while ($grplist = mysql_fetch_assoc($request3))
		$context['grplist'][] = array(
			'grpID'	=> $grplist['grpID'],
			'tagname'	=> $grplist['tagname'],
		);

	mysql_free_result ($request3);

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

// Menu actions confirmation
function amenucfm()
{
	global $db_prefix, $context, $scripturl, $txt;

	$context['sel_delete'] = (!empty($_REQUEST['sel_delete'])) ? $_REQUEST['sel_delete'] : '';
	$context['sel_copy'] = (!empty($_REQUEST['sel_copy'])) ? $_REQUEST['sel_copy'] : '';
	$context['sel_move'] = (!empty($_REQUEST['sel_move'])) ? $_REQUEST['sel_move'] : '';
	$context['newgrp']	= (!empty($_REQUEST['newgrp'])) ? $_REQUEST['newgrp'] : '';
	$context['selitm']	= (!empty($_REQUEST['selitm'])) ? $_REQUEST['selitm'] : '';
	$context['curmgrp']	= $_REQUEST['curmgrp'];
	$context['menugrp']	= '';
	$context['current']	= '';

	$context['page_title'] = $txt['menu_1'] . ' - ' . $txt['menu_41'];

	// make sure a new menu group was selected if moving or copying an item
	if ((!empty($context['sel_copy']) || !empty($context['sel_move'])) && empty($_REQUEST['newgrp']))
		fatal_lang_error('menu_43', false);

	// get info for selected menu group
	$request = db_query("
			SELECT *
			FROM {$db_prefix}menugrps
			WHERE grpID = '$context[curmgrp]'", __FILE__, __LINE__);

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

	// If items were selected for Move, Copy or delete, print a confirmation before action
	if (!empty($_REQUEST['sel_delete']))
	{
		foreach ($context['selitm'] as $key => $value)
		{
			$del_itm = db_query("
				SELECT *
				FROM {$db_prefix}menu
				WHERE id = '$value' AND grpID = '$context[curmgrp]'", __FILE__, __LINE__);

			$current = mysql_fetch_assoc($del_itm);
			mysql_free_result ($del_itm);

			$current['alt'] = str_replace(
				array('<', '>', '"', '&nbsp;'),
				array('&lt;', '&gt;', '&quot;', '&amp;nbsp;'),
				$current['alt']);

			if (strlen($current['alt']) > 25)
				$current['alt'] = (substr($current['alt'], 0, 20) . '...');

			$current['key']	= $key;
			$current['value'] = $value;
			$context['current'][] = $current;
		}
	}

	elseif (!empty($context['sel_copy']) || !empty($context['sel_move']))
	{
		$request2 = db_query("
			SELECT tagname
			FROM {$db_prefix}menugrps
			WHERE grpID = $context[newgrp]", __FILE__, __LINE__);

		$new_grp = mysql_fetch_assoc($request2);
		$context['new_grp'] = $new_grp;
		mysql_free_result ($request2);

		if (!empty($context['newgrp']))
		{
			foreach ($context['selitm'] as $key => $value)
			{
				$cur_itm = db_query("
					SELECT *
					FROM {$db_prefix}menu
					WHERE id = '$value'", __FILE__, __LINE__);

				$current = mysql_fetch_assoc($cur_itm);
				mysql_free_result ($cur_itm);

				$current['alt'] = str_replace(
					array('<', '>', '"', '&nbsp;'),
					array('&lt;', '&gt;', '&quot;', '&amp;nbsp;'),
					$current['alt']);

				if (strlen($current['alt']) > 25)
					$current['alt'] = (substr($current['alt'], 0, 20) . '.....');

				$current['key']	= $key;
				$current['value'] = $value;
				$context['current'][] = $current;
			}
		}
	}
	$context['sub_template'] = 'actions_confirmation';
}

// edit menu items page based on selected menu group returns to menuitems() when done
function emenu()
{
	global $db_prefix, $context, $scripturl, $txt;

	$curmgrp = (int) $_REQUEST['curmgrp'];
	$ite = (int) $_REQUEST['ite'];
	$context['curgrp'] = '';
	$context['itesel'] = '';

	$context['page_title'] = $txt['menu_1'] . ' - ' . $txt['menu_48'];

	$get_mgrp = db_query("
		SELECT *
		FROM {$db_prefix}menugrps
		WHERE grpID = '$curmgrp'", __FILE__, __LINE__);

	$context['curgrp'] = mysql_fetch_assoc($get_mgrp);
	mysql_free_result ($get_mgrp);

	$context['linktree'] = array(
		array(
			'url'	=> $scripturl . '?action=admin',
			'name'	=> 'Admin',
		),
		array(
			'url'	=> $scripturl . '?op=MenuManagement;sa=menu2',
			'name'	=> &$txt['menu_1'],
		),
		array(
			'url'	=> $scripturl . '?op=MenuManagement;sa=menu2#amig',
			'name'	=> &$txt['menu_17'],
		),
		array(
			'url'	=> $scripturl . '?op=MenuManagement;sa=menuitems;curmgrp=' . $curmgrp,
			'name'	=> &$txt['menu_23'],
		),
		array(
			'name'	=> $txt['menu_49'] . ':&nbsp;&nbsp;' . $context['curgrp']['tagname'],
		),
		array(
			'url'	=> $scripturl . '?op=MenuManagement;sa=menuitems;curmgrp=' . $curmgrp . '#ami',
			'name'	=> &$txt['menu_21'],
		),
		array(
			'url'	=> $scripturl . '?op=MenuManagement;sa=menuitems;curmgrp=' . $curmgrp . '#acsp',
			'name'	=> &$txt['menu_22'],
		),
	);

	$get_ite = db_query("
		SELECT *
		FROM {$db_prefix}menu
		WHERE id = '$ite'", __FILE__, __LINE__);

	$context['itesel'] = mysql_fetch_assoc($get_ite);
	mysql_free_result ($get_ite);

	// determine whether item is a special link and which one
	$context['itesel']['msnone'] = ($context['itesel']['special'] == 'none')	? ' selected' : '';
	$context['itesel']['mslgt']  = ($context['itesel']['special'] == 'logout')	? ' selected' : '';

	// allow quotes and HTML tags to be displayed in form fields
	$context['itesel']['alt'] = str_replace(
		array('<', '>', '"', '&nbsp;'),
		array('&lt;', '&gt;', '&quot;', '&amp;nbsp;'),
		$context['itesel']['alt']);

	$context['itesel']['url'] = str_replace('"', '&quot;', $context['itesel']['url']);

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

// move menu item down/right
function overmu()
{
	global $db_prefix;

	$itm = (int) $_REQUEST['itm'];
	$curmgrp = $_REQUEST['curmgrp'];

	db_query("
		UPDATE {$db_prefix}menu
		SET position = position + 1
		WHERE id = '$itm'
		LIMIT 1", __FILE__, __LINE__);

	redirectexit('op=MenuManagement;sa=menuitems;curmgrp=' . $curmgrp);
}

// move menu item up/left
function backmu()
{
	global $db_prefix;

	$itm = (int) $_REQUEST['itm'];
	$curmgrp = $_REQUEST['curmgrp'];

	db_query("
		UPDATE {$db_prefix}menu
		SET position = position - 1
		WHERE id = '$itm'
		LIMIT 1", __FILE__, __LINE__);

	redirectexit('op=MenuManagement;sa=menuitems;curmgrp=' . $curmgrp);
}

// add menu group then return to menu2()
function amenugi()
{
	global $db_prefix;

	$newmtag	= !empty($_POST['mtag'])	? $_POST['mtag'] : '';
	$itmsep		= !empty($_POST['mitmsep'])	? $_POST['mitmsep'] : '';
	$typ		= !empty($_POST['mtyp'])	? $_POST['mtyp'] : '0';
	$css		= !empty($_POST['mcss'])	? $_POST['mcss'] : '';

	db_query("
		INSERT INTO {$db_prefix}menugrps
		(menutype, itemsep, tagname, css)
		VALUES ('$typ', '$itmsep', '$newmtag', '$css')", __FILE__, __LINE__);

	redirectexit('op=MenuManagement');
}

// add menu item then return to menuitems()
function amenu2()
{
	global $db_prefix;

	$spec	= ($_POST['mspec'] == 'none') ? '' : $_POST['mspec'];
	$img	= !empty($_POST['mimg']) ? $_POST['mimg'] : '';
	$alt	= $_POST['malt'];
	$url	= $_POST['murl'];

	$pos	= (int) $_POST['mpos'];

	$memg	= is_array($_POST['mmemg']) ? implode(',',$_POST['mmemg']): '';
	$grp		= (int) $_REQUEST['curmgrp'];
	$urlt	= !empty($_POST['murlt']) ? $_POST['murlt'] : '';
	$imgf	= !empty($_POST['mimgf']) ? $_POST['mimgf'] : '';
	$imgb	= !empty($_POST['mimgb']) ? $_POST['mimgb'] : '';

	$imgw	= !empty($_POST['mimgw']) ? $_POST['mimgw'] : '';
	$imgh	= !empty($_POST['mimgh']) ? $_POST['mimgh'] : '';

	$imgl	= !empty($_POST['mimgl']) ? $_POST['mimgl'] : '';

	db_query("
		INSERT INTO {$db_prefix}menu
		(memberGroup, img, alt, position, url, imgfolder, imgborder,
			imgwidth, imgheight, imgloc, urltarget, special, grpID)
		VALUES ('$memg', '$img', '$alt', '$pos', '$url', '$imgf',
			'$imgb', '$imgw', '$imgh', '$imgl', '$urlt', '$spec', '$grp')", __FILE__, __LINE__);

	redirectexit('op=MenuManagement;sa=menuitems;curmgrp=' . $grp);
}

// make custom separator changes then return to menuitems()
function amenusp()
{
	global $db_prefix;

	$alt	= $_POST['malt'];
	$pos	= $_POST['mpos'];
	$memg	= implode(',', $_POST['mmemg']);
	$grp	= (int) $_REQUEST['curmgrp'];

	db_query("
		INSERT INTO {$db_prefix}menu
		(memberGroup, alt, position, special, grpID)
		VALUES ('$memg', '$alt', '$pos', 'custsep', '$grp')", __FILE__, __LINE__);

	redirectexit('op=MenuManagement;sa=menuitems;curmgrp=' . $grp);
}

// edit group then return to menu2()
function emenuig()
{
	global $db_prefix;

	$tagn	= $_POST['mtag'];
	$itmsep = $_POST['mitmsep'];
	$typ	= $_POST['mtyp'];
	$css	= $_POST['mcss'];
	$mene	= $_GET['mene'];

	db_query("
		UPDATE {$db_prefix}menugrps
		SET menutype='$typ', itemsep='$itmsep', tagname='$tagn', css='$css'
		WHERE grpID = '$mene'
		LIMIT 1", __FILE__, __LINE__);

	redirectexit('op=MenuManagement');
}

// edit group from menu items page, then return to menuitems()
function emenuig2()
{
	global $db_prefix;

	$tagn	= $_POST['mtag'];
	$itmsep = $_POST['mitmsep'];
	$typ	= $_POST['mtyp'];
	$css	= $_POST['mcss'];
	$curmgrp= (int) $_REQUEST['curmgrp'];

	db_query("
		UPDATE {$db_prefix}menugrps
		SET menutype='$typ', itemsep='$itmsep', tagname='$tagn', css='$css'
		WHERE grpID = '$curmgrp'
		LIMIT 1", __FILE__, __LINE__);

	redirectexit('op=MenuManagement;sa=menuitems;curmgrp=' . $curmgrp);
}

// edit item then return to menuitems()
function emenui()
{
	global $db_prefix;

	$grp	= (int) $_REQUEST['curmgrp'];
	$ite	= (int) $_REQUEST['ite'];
	$sprtr	= !empty($_REQUEST['sprtr']) ? (int) $_REQUEST['sprtr'] : '';

	if ($sprtr == '1')
	{
		$spec = 'custsep';
	}
	elseif (!empty($_POST['mslnk']) && $_POST['mslnk'] != 'none')
	{
		$spec = $_POST['mslnk'];
	}
	else
	{
		$spec = '';
	}

	$img	= !empty($_POST['mimg']) ? $_POST['mimg'] : '' ;
	$alt	= !empty($_POST['malt']) ? $_POST['malt'] : '' ;
	$url	= !empty($_POST['murl']) ? $_POST['murl'] : '' ;
	$pos	= !empty($_POST['mpos']) ? $_POST['mpos'] : '' ;
	$memg	= is_array($_POST['mmemg']) ? implode(',',$_POST['mmemg']): '';
	$urlt	= !empty($_POST['murlt']) ? $_POST['murlt'] : '' ;
	$imgf	= !empty($_POST['mimgf']) ? $_POST['mimgf'] : '' ;
	$imgb	= !empty($_POST['mimgb']) ? $_POST['mimgb'] : '' ;
	$imgw	= !empty($_POST['mimgw']) ? $_POST['mimgw'] : '' ;
	$imgh	= !empty($_POST['mimgh']) ? $_POST['mimgh'] : '' ;
	$imgl	= !empty($_POST['mimgl']) ? $_POST['mimgl'] : '' ;

	db_query("
		UPDATE {$db_prefix}menu
		SET memberGroup='$memg', img='$img', alt='$alt', position='$pos', url='$url',
			imgfolder='$imgf', imgborder='$imgb', imgwidth='$imgw', imgheight='$imgh',
			imgloc='$imgl', urltarget='$urlt', special='$spec'
		WHERE id = '$ite'
		LIMIT 1", __FILE__, __LINE__);

	redirectexit('op=MenuManagement;sa=menuitems;curmgrp=' . $grp);
}

// move or copy menu item from one group to another
function mcmenuitm()
{
	global $db_prefix, $txt;

	$itmcfm = $_POST['itmcfm'];
	$nloc	= $_GET['nloc'];
	$curmgrp= $_GET['curmgrp'];

	if (!empty($_POST['act_cancel']))
	{
		redirectexit('op=MenuManagement;sa=menuitems;curmgrp=' . $curmgrp);
	}
	else
	{
		foreach($itmcfm as $key => $value)
		{
			if (!empty($_POST['act_copy']))
			{
				$request = db_query("
					SELECT *
					FROM {$db_prefix}menu
					WHERE id = '$value'", __FILE__, __LINE__);

				$result = mysql_fetch_assoc($request);
				mysql_free_result ($request);

				$nmgrp	= $result['memberGroup'];
				$nimg	= $result['img'];
				$nalt	= $result['alt'];
				$npos	= $result['position'];
				$nurl	= $result['url'];
				$nurlt	= $result['urltarget'];
				$nimgf	= $result['imgfolder'];
				$nimgb	= $result['imgborder'];
				$nimgw	= $result['imgwidth'];
				$nimgh	= $result['imgheight'];
				$nimgl	= $result['imgloc'];
				$nspec	= $result['special'];

				db_query("
					INSERT INTO {$db_prefix}menu
					(grpID, memberGroup, img, alt, position, url, urltarget,
						imgfolder, imgborder, imgwidth, imgheight, imgloc,
						special)
					VALUES ('$nloc', '$nmgrp', '$nimg', '$nalt', '$npos',
						'$nurl', '$nurlt', '$nimgf', '$nimgb', '$nimgw',
						'$nimgh', '$nimgl', '$nspec')", __FILE__, __LINE__);
			}

			if (!empty($_POST['act_move']))
			{
				db_query("
					UPDATE {$db_prefix}menu
					SET grpID = '$nloc'
					WHERE id = '$value'
					LIMIT 1", __FILE__, __LINE__);
			}
		}

		$curmgrp = $nloc;
		redirectexit('op=MenuManagement;sa=menuitems;curmgrp=' . $curmgrp);
	}
}

// delete menu group and all items for group
function dmenuig()
{
	global $db_prefix, $txt;

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

	if (!empty($_REQUEST['del_cancel']))
	{
		redirectexit('op=MenuManagement');
	}

	if (!empty($_REQUEST['del_delete']))
	{
		foreach($mendel as $key => $value)
		{
			db_query("
				DELETE FROM {$db_prefix}menugrps
				WHERE grpID = '$value'
				LIMIT 1", __FILE__, __LINE__);

			db_query("
				DELETE FROM {$db_prefix}menu
				WHERE grpID = '$value'", __FILE__, __LINE__);
		}

		redirectexit('op=MenuManagement');
	}
}

// delete individual menu item
function dmenui()
{
	global $db_prefix, $txt;

	$itmdel		= $_POST['itmdel'];
	$curmgrp	= $_GET['curmgrp'];

	if (!empty($_POST['itm_cancel']))
	{
		redirectexit('op=MenuManagement;sa=menuitems;curmgrp=' . $curmgrp);
	}

	elseif (!empty($_POST['itm_delete']))
	{
		foreach($itmdel as $key => $value)
		{
			db_query("
				DELETE FROM {$db_prefix}menu
				WHERE id = '$value'
				LIMIT 1", __FILE__, __LINE__);
		}
	}
	redirectexit('op=MenuManagement;sa=menuitems;curmgrp=' . $curmgrp);
}


?>
Return current item: Enigma