<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 11/11/2009	ELL
// Revised: 11/11/2009	ELL
// Added menu item classes and styles for individual item control.
// Revised: 1/8/2011	ELL
// Added code to remove JavaScript from HTML record if necessary.
// Revised: 2/8/2012	ELL
// Added table prefix handling.
// Revised: 3/23/2015	ELL
// Added deletion of mobile menus.
// Modified: 12/2/2016	ELL
// Consolidated all class tables into site_classes table indexed by style_sheet field.
// Consolidated all CSS tables into site_css table indexed by style_sheet field.
// Consolidated all menu items tables into menu_items.
// 
	include ("check_session.php");
	
	$menu = $_GET['menu'];
	
	if ($menu != "menu1")
	{	
		$query = "DELETE FROM `" . BWB_TABLE_PREFIX . "menu_assignments` WHERE `menu_name`='" . $menu . "'";
		$cnt = $bwb_dbh->exec($query);

		$query = "DELETE FROM `" . BWB_TABLE_PREFIX . "menus` WHERE `menu_name`='" . $menu . "'";
		$cnt = $bwb_dbh->exec($query);
		$query = "DELETE FROM `" . BWB_TABLE_PREFIX . "menus` WHERE `menu_name`='" . $menu . "_mobile'";
		$cnt = $bwb_dbh->exec($query);
		
		$query = "DELETE FROM `" . BWB_TABLE_PREFIX . "style_sheets` WHERE `name`='" . $menu . "'";
		$cnt = $bwb_dbh->exec($query);
		$query = "DELETE FROM `" . BWB_TABLE_PREFIX . "style_sheets` WHERE `name`='" . $menu . "_mobile'";
		$cnt = $bwb_dbh->exec($query);
		
		$query = "DELETE FROM `" . BWB_TABLE_PREFIX . "style_sheets` WHERE `name`='" . $menu . "_item'";
		$cnt = $bwb_dbh->exec($query);
		$query = "DELETE FROM `" . BWB_TABLE_PREFIX . "style_sheets` WHERE `name`='" . $menu . "_mobile_item'";
		$cnt = $bwb_dbh->exec($query);
			
		$query = "DELETE FROM " . BWB_TABLE_PREFIX . "site_classes WHERE style_sheet = '" . $menu . "'";
		$cnt = $bwb_dbh->exec($query);
		$query = "DELETE FROM " . BWB_TABLE_PREFIX . "site_classes WHERE style_sheet = '" . $menu . "_mobile'";
		$cnt = $bwb_dbh->exec($query);
		
		$query = "DELETE FROM " . BWB_TABLE_PREFIX . "site_css WHERE style_sheet = '" . $menu . "'";
		$cnt = $bwb_dbh->exec($query);
		$query = "DELETE FROM " . BWB_TABLE_PREFIX . "site_css WHERE style_sheet = '" . $menu . "'";
		$cnt = $bwb_dbh->exec($query);
		
		$query = "DELETE FROM " . BWB_TABLE_PREFIX . "menu_items WHERE menu = '" . $menu . "'";
		$cnt = $bwb_dbh->exec($query);
		$query = "DELETE FROM " . BWB_TABLE_PREFIX . "menu_items WHERE menu = '" . $menu . "_mobile'";
		$cnt = $bwb_dbh->exec($query);
		
		$query = "DELETE FROM " . BWB_TABLE_PREFIX . "site_classes WHERE style_sheet = '" . $menu . "_item'";
		$cnt = $bwb_dbh->exec($query);
		$query = "DELETE FROM " . BWB_TABLE_PREFIX . "site_classes WHERE style_sheet = '" . $menu . "_mobile_item'";
		$cnt = $bwb_dbh->exec($query);
		
		$query = "DELETE FROM " . BWB_TABLE_PREFIX . "site_css WHERE style_sheet = '" . $menu . "_item'";
		$cnt = $bwb_dbh->exec($query);
		$query = "DELETE FROM " . BWB_TABLE_PREFIX . "site_css WHERE style_sheet = '" . $menu . "_mobile_item'";
		$cnt = $bwb_dbh->exec($query);
	}
	
	header("Location: manage_menu.php");
?>
