<?php
class admin_commentControl extends skymvc{

	public function __construct(){
		parent::__construct();
		$this->loadModel(array("comment"));
	}
	
	public function onDefault(){
		$url=APPADMIN."?m=admin_comment";
		$limit=20;
		$start=get('per_page','i');
		$status=get('status','i');
		$where=" status=$status ";
		$id=get('id','i');
		if($id){
			$where.=" AND id=$id";
		}
		$content=get('content');
		if($content){
			$where.=" AND content like '%".$content."%' ";
			$url.="&content=".urlencode($content);
		}
		$option=array(
			"start"=>$start,
			"limit"=>$limit,
			"order"=>"id DESC",
			"where"=>$where
		);
		$rscount=true;
		$data=$this->comment->select($option,$rscount);
		$pagelist=$this->pagelist($rscount,$limit,$url);
		$this->smarty->assign(array(
			"data"=>$data,
			"rscount"=>$rscount,
			"pagelist"=>$pagelist,
			"status_list"=>array(0=>"未审核",1=>"已通过",98=>"已禁止",99=>"已删除")
		));
		$this->smarty->display("comment/index.html");
	}
	
	public function onStatus(){
		$id=get('id','i');
		$data['status']=get('status','i');
		$this->comment->update($data,"id=$id");
		$this->comment->setTable("comment_10")->update($data,"id=$id");
	}
	
	 
	
}
?>