<?php
class FeedbackController extends Easy_Controller_Action{
	public function Init(){
		$this->_View->setViewRoot('templates');
		$this->_View->skin = $this->config['template'];
		$this->_View->temporary['config'] = $this->config;
		$this->_Feedback = new FeedbackModel();
	}
	public function indexAction(){
		exit($this->_View->render('public/feedback'));
	}
	public function reportAction(){
		$movid = (int)$this->_Request->getParams('movid');
		$movie = new MovieModel();
		$this->_View->info = $movie->getRow($movid);
		$this->_View->username = $this->_Request->getCookie('username') ? $this->_Request->getCookie('username') : _('游客');
		if ($this->_Request->isPost()){
			$data = $this->_Request->getPost();
			$data['username'] = $this->_View->username;
			$data['title'] = '影片错误:'.$this->_View->info['title'];
			if ($this->_Feedback->report($data)===false){
				message($this->_Feedback->error, 'history.back()');
			}else{
				message('发布成功,感谢您的提交!');
			}
			exit;
		}
		exit($this->_View->render('public/feedback'));
	}
	/*后台错误报告查看*/
	public function viewAction(){
		$this->_View->setViewRoot('admin');
		$this->_View->rows = $this->_Feedback->getAll();
		$this->_View->printpage = $this->_Feedback->printPage;
		exit($this->_View->render('plugins/feedback_view'));
	}
	/*删除*/
	public function  deleteAction(){
		$this->_View->setViewRoot('admin');
		$this->_Feedback->delete($this->_Request->getParams('id'));
		$this->_View->message = _('删除成功!');
		exit($this->_View->render('message'));
	}
	/**/
	public function readAction(){
		$this->_View->setViewRoot('admin');
		$this->_Feedback->setRead($this->_Request->getParam('id'));
		$this->_View->feedback = $this->_Feedback->getRow($this->_Request->getParam('id'));
		exit($this->_View->render('plugins/feedback_read'));
	}
}?>