<?php
/*
 * This file is part of Web Pro Manager.
 * 
 * Web Pro Manager is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Web Pro Manager is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Web Pro Manager.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @author The Web Pro Miami, Inc. <info@thewebpro.com>
 * @copyright The Web Pro Miami, Inc. <info@thewebpro.com>, http://www.thewebpro.com/
 * @license http://www.gnu.org/licenses/gpl.html GNU GPL
 * @package WebProManager
*/

require("../inc/stop_cache.php");

// Secure and connect
require("../../inc/dbconnect.php");
require("../inc/secure_page.php");

require("../../inc/config.php");
require("../inc/lang.php");


// Accessed by AJAX froma page ordering script
// Recieves the following via POST:
// group - contains the section name (e.g. section_9)
// order - a list of items in the order chosen by user (e.g. icon_23,icon_24)

$nGroup = $_POST["group"];
$nOrderData = $_POST["order"];

$nGroup = str_replace("section_","",$nGroup);
$nOrderDataARRAY = explode(",",$nOrderData);

if($nGroup!==""){
	$nOrderNum = 1;
	// next, update the items in one by one
	foreach($nOrderDataARRAY AS $nItemID){
		$nItemID = str_replace("icon_","",$nItemID);
		if($nItemID){
			$nSQL = "UPDATE nPage SET nSectionID='$nGroup',nOrderID='$nOrderNum' WHERE nID=$nItemID LIMIT 1";
			// echo "nSQL: $nSQL";
			mysql_select_db($DBName);
			mysql_query($nSQL, $Link);
		}
		$nOrderNum++;
	}
}
?>
<?php require("../../inc/db_close.php"); ?>