<?php 

/**
 * 名称：留言板控制器
 * 作者：荷塘月色
 * 邮箱：kujiw@qq.com
 * 说明：
 */

namespace Qiye\Controller;
class GuestbookController extends ProjectController {

	public function index(){
		if (IS_POST) {
			$this -> ajaxReturn($this -> getData());
		}elseif (IS_GET) {
			$this -> display();
		}
	}

	// 回复
	public function reply(){
		if (IS_GET) {
			$id = I('id','','intval');
			$this -> assign(M('Guestbook') -> find($id));
			$this -> display();
		}elseif (IS_POST) {
			$id = I('id','','intval');
			$m = M('Guestbook');
			$data = array(
				'id'			=>	$id,
				'reply'			=>	I('reply'),
				'reply_time'	=>	time(),
				);
			if (false !== $m -> save($data)) {
				$this -> success($m -> find($id),'',true);
			}else{
				$this -> error($m -> getDbError(),'',true);
			}
		}
	}

	// 修改状态
	public function status(){
		if (IS_POST) {
			$this -> ebStatus();
		}
	}

	public function delete(){
		$this -> ebDelete();
	}
}