<?php
class FlinkController extends Easy_Controller_Action{
	public function init(){
		$this->_Flink = new FlinkModel();
	}
	public function indexAction(){
		$this->_View->rows = $this->_Flink->getAll();
		$this->_View->printpage = $this->_Flink->printpage;
		exit($this->_View->render('plugins/flink_index'));
	}
	public function FlinkAction(){
	}
	public function addAction(){
		if ($this->_Request->isPost()){
			if ($this->_Flink->add($this->_Request->getPost())===false){
				$this->_View->message = $this->_Flink->error;
			}else{
				$this->_View->message = _('添加成功!');
			}
			exit($this->_View->render('message'));
		}
	}
	public function modifyAction(){
		if ($this->_Request->isPost()){
			if ($this->_Flink->modify($this->_Request->getPost())===false){
				$this->_View->message = $this->_Flink->error;
			}else{
				$this->_View->message = _('修改成功!');
			}
			exit($this->_View->render('message'));
		}
		$this->_View->modify = $this->_Flink->getRow($this->_Request->getParam('id'));
		exit($this->_View->render('plugins/flink_modify'));
	}
	public function lockedAction(){
		$this->_Flink->locked($this->_Request->getParam('id'));
		$this->_View->redirect('flink/index');
		exit;
	}
	public function postAction(){
		$action = $this->_Request->getPost('action');
		$id = $this->_Request->getPost('id');
		switch($action){
			case 1:
				$this->_Flink->locked(array('state'=>1), $id);
				$this->_View->message = _('审核成功!');
			break;
			case 2:
				$this->_Flink->delete($id);
			$this->_View->message = _('删除成功!');
			break;
			case 3:
				$this->_Flink->locked(array('state'=>2), $id);
				$this->_View->message = _('禁用成功!');
			break;
		}
		
		exit($this->_View->render('message'));
	}
}?>