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

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

				//上级分类的childcount-1
				$filecategory3=new model_Filecategory();
				$filecategory3->setSubsection('WHERE filecategory_id='.$results->getParentid());
				$results3=$filecategory3->doSelectOne();
				$filecategory3->setChildcount($results3->getChildcount()-1);
				$filecategory3->doUpdate();

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

		$jsstring='Dialog.alert(\''.$msg.'\',function(){window.location.href="'.MICE_URL.'admin.php/filecategory";window.event.returnValue = false;},300,100,"返回分类列表");';
		MessageBox($jsstring);

		exit;
	}
}
?>