<?php

class guestbookAction extends CommonAction {

	private $guestbook;
	function __construct(){
			parent::__construct();
			$this->guestbook = new guestbookModel();
		}

	function guestbook_mod(){
		if($_REQUEST[channelid]){
			$where="where channelid=$_REQUEST[channelid]";
		}
		$total = count( $this->guestbook->total($where));
		$this->page = new page($total,10,'');
		$val = $this->guestbook->findAll("",$this->page->getOffset(),10,$where,"id");
		$fpage =$this->page->fpage();
		$this->assign("app_name",APP_NAME);
		$this->assign("fpage",$fpage);
		$this->assign("guestbook",$val);
		$this->assign("channelid",$_REQUEST['channelid']);
		$this->display('admin/guestbook/guestbookmod.html');

	}

	function guestbook_reply(){
		$_POST['reply_time']=time();

		$_POST['reply']=Common::HTMLEncode($_POST['reply']);
		if($this->guestbook->mod($_POST)){
			$this->showMsg("回复成功","admin.php?m=guestbook&a=guestbook_mod&channelid=".$_REQUEST[channelid]."");
		}else{
			$this->showMsg("回复失败","admin.php?m=guestbook&a=guestbook_mod&channelid=".$_REQUEST[channelid]."");
		}
	}






	function guestbook_del(){
		if($_REQUEST["id"]=="data"){
			$_REQUEST["id"]=$_REQUEST["xm"];
		}
		if($this->guestbook->del($_REQUEST["id"])){
			$this->showMsg("成功删除留言","admin.php?m=guestbook&a=guestbook_mod&channelid=".$_REQUEST[channelid]."");
		}else{
			$this->showMsg("删除留言失败","admin.php?m=guestbook&a=guestbook_mod&channelid=".$_REQUEST[channelid]."");
		}

	}


}
?>
