<?php
defined('PHP168_PATH') or die();

/**
* 更新导航菜单缓存
**/

$this_system->check_manager($ACTION) or message('no_privilege');

if(REQUEST_METHOD == 'GET'){	
	$this_module->menu_cache($this_system->SITE);
	message('done',$this_router.'-menu_list');
}else if(REQUEST_METHOD == 'POST'){	
	$display_order = isset($_POST['_display_order']) && is_array($_POST['_display_order']) ? array_map('intval', $_POST['_display_order']) : array();	
	//显示
	$display = isset($_POST['display_json']) ? jsondecode((MAGIC_QUOTES ? stripcslashes($_POST['display_json']) : $_POST['display_json'])) : array();	
	foreach((array)$display_order as $id => $order){
		$DB_master->update(
			$this_module->table_menu,
			array(
				'display_order' => $order
			),
			"id = '$id'"
		);
	}	
	foreach((array)$display as $id => $v){
		$DB_master->update(
			$this_module->table_menu,
			array(
				'display' => (int)$v
			),
			"id = '$id'"
		);
	}

	$this_module->menu_cache($this_system->SITE);

	message('done',$this_router.'-menu_list');
}

