<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright EB Dynamics, Inc., Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 7/21/2009	ELL
// Added ability to operate using different class tables.  This was done to give the ability
// to style calendar grids and event grids without adding 14 more classes to the site style list.
// Renamed from set_tag_sort_order.php to set_class_sort_order.php.
// Added feed thru to show/hide custom styles.
// Revised: 2/10/2012	ELL
// Added table prefix handling.
// 
// 
// 
// 
	include ("check_session.php");
		
	$style_sheet = $_REQUEST['style_sheet'];
	$class_table = $style_sheet . "_classes";
	
	$i = 0;
	$query_tags = "SELECT * FROM `" . BWB_TABLE_PREFIX . $class_table . "` ORDER BY `sort_order`";
	$result_tags = mysql_query($query_tags);
	while ($row_tags = mysql_fetch_array($result_tags))
	{
		$class_id_string = "class_" . $i;
		$sort_order_id_string = "sort_order_" . $i;
		
		$class = $_POST[$class_id_string];
		if ($_POST[$sort_order_id_string])
			$sort_order = $_POST[$sort_order_id_string];
		else
			$sort_order = 0;
			
		//Insert new data into table.
		$query = "UPDATE `" . BWB_TABLE_PREFIX . $class_table . "` SET `sort_order` = " . $sort_order . " WHERE `class` = '" . $class . "'";
		$result = mysql_query($query, $bwb_link);
				
		$i++;
	} // end while
	
	header("Location: classes.php?style_sheet=$style_sheet&show_class_editor=1");
?>