<?php
/**
 *	Generated by miceCMS
 *	http://www.miceCMS.com/
 */
class article_deleteAction extends security_login {
	function action(){
		ModuleLimit(__CLASS__);
		global $conn;
		$msg='未删除任何内容';
		$num=0;
		$article_id=$this->_getParam('article_id');
		if($article_id > 0){
			$article=new model_Article();
			$article->setSubsection('WHERE article_id='.$article_id);
			$results1=$article->doSelectOne();
			$results=$article->doDelete();			

			//作者的文章数减1
			$user=new model_User();
			$user->setSubsection('WHERE user_id='.$results1->getUserId());
			$results2=$user->doSelectOne();
			$user->setPostnums($results2->getPostnums()-1);
			$user->doUpdate();

			$num++;
		}elseif(sizeof($_POST['checkbox'])){
			foreach($_POST['checkbox'] as $aid){
				$article=new model_Article();
				$article->setSubsection('WHERE article_id='.$aid);
				$results1=$article->doSelectOne();
				$results=$article->doDelete();				

				//作者的文章数减1
				$user=new model_User();
				$user->setSubsection('WHERE user_id='.$results1->getUserId());
				$results2=$user->doSelectOne();
				$user->setPostnums($results2->getPostnums()-1);
				$user->doUpdate();

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

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

		exit;
	}
}
?>