<?php
if(!defined('APP_PATH')||!defined('I_PATH')){exit('Access Denied');}

class ld_comment extends controllerBase
{
	function __construct(){
		parent::__construct();
		$this->Classc=syClass('ldi_comment');
		$this->gopage=$this->sysParams('page',0,1);
		$this->Get_c='?c=ld_comment';
		$this->news = array(
			'molds' => $this->sysParams('molds',1),
			'aid' => $this->sysParams('aid'),
			'isshow' => $this->sysParams('isshow'),
			'body' => $this->sysParams('body',1),
			'reply' => $this->sysParams('reply',1),
			'addtime' => strtotime($this->sysParams('addtime',1)),
			'retime' => strtotime($this->sysParams('retime',1)),
			'user' => $this->sysParams('user',1),
			'ruser' => $_SESSION['auser']['auser'],
		);
	}
	function index(){
		$this->toptxt='评论管理';
		$this->lists = $this->Classc->syPager($this->gopage,10)->findAll(null,' addtime desc,cid desc '); 
		$this->pages = pagetxt($this->Classc->syPager()->getPager());
		$this->display("comment.html");
	}
	function edit(){
		$this->d=$this->Classc->find(array('cid'=>$this->sysParams('cid')));
		if ($this->sysParams('run')==1){
			$newVerifier=$this->Classc->syVerifier($this->news);
			if(false == $newVerifier){
				if($this->Classc->update(array('cid'=>$this->d['cid']),$this->news)){
					deleteDir(func_get_iglobal(array('sp_cache')));
					message_a("评论修改成功",$this->Get_c);
				}else{message_a("评论修改失败,请重新提交");}
			}else{message_b($newVerifier);}
		}
		$this->toptxt='修改评论';
		$this->display("comment.html");
	}
	function del(){
		$this->toptxt='删除评论';
		$this->d=$this->Classc->find(array('cid'=>$this->sysParams('cid')));
		if ($this->sysParams('run')==1){
			if($this->Classc->delete(array('cid'=>$this->sysParams('cid')))){
				deleteDir(func_get_iglobal(array('sp_cache')));
				message_a("评论删除成功",$this->Get_c);
			}else{message_a("评论删除失败,请重新提交");}
		}
		$this->msgtitle='确定要删除这条评论吗？';
		$this->msg=$this->d['body'];
		$this->msggo='<a href="'.$this->Get_c.'&a=del&run=1&cid='.$this->d['cid'].'">确定删除</a><a href="'.$this->Get_c.'">取消操作</a>';
		$this->display("msg.html");
	}

}	