<?php
/**
 *	Generated by miceCMS
 *	http://www.miceCMS.com/
 */
class menu_deleteAction extends security_login {
	function action(){
		ModuleLimit(__CLASS__);
		global $conn;
		$msg='未删除任何内容';
		$num=0;
		$menu_id=$this->_getParam('menu_id');
		if($menu_id > 0){
			$category=new model_Menu();
			$category->setSubsection('WHERE menu_id='.$menu_id);
			$results=$category->doSelectOne();
			$results2=$category->doDelete();
			
			//上级分类的childcount-1
			$category3=new model_Menu();
			$category3->setSubsection('WHERE menu_id='.$results->getParentid());
			$results3=$category3->doSelectOne();
			if($results3){
				$category3->setChildcount($results3->getChildcount()-1);
				$category3->doUpdate();
			}

			$num++;
		}elseif(sizeof($_POST['checkbox'])){
			foreach($_POST['checkbox'] as $cid){
				$category=new model_Menu();
				$category->setSubsection('WHERE menu_id='.$cid);
				$results=$category->doSelectOne();
				$results2=$category->doDelete();

				//上级分类的childcount-1
				$category3=new model_Menu();
				$category3->setSubsection('WHERE menu_id='.$results->getParentid());
				$results3=$category3->doSelectOne();
				if($results3){
					$category3->setChildcount($results3->getChildcount()-1);
					$category3->doUpdate();
				}

				$num++;
			}
		}

		if($num>0){
			$msg='成功删除'.$num.'条记录';
		}

		

		$jsstring='Dialog.alert(\''.$msg.'\',function(){window.location.href="'.MICE_URL.'admin.php/menu";window.event.returnValue = false;},300,100,"返回菜单列表");';
		MessageBox($jsstring);
		exit;
	}
}
?>