Invitation.class.php 2.7 KB
<?php
class Controller_Invitation extends Controller_Abstract
{
	public function indexAction()
	{
        ;
	}
	
    /**
     * 提交
     */
    public function submitAction()
    {
        $category = $this->_request->query('category', 'media');
        $sub = $this->_request->query('sub', 0);
        $name = $this->_request->query('name','');
        $contacter = $this->_request->query('contacter','');
        $phone = $this->_request->query('phone', '');
        $email = $this->_request->query('email', '');
        
        $ret = false;
        if($category && $sub && $name && $contacter && $phone && $email)
        {
            $ret = Facade_Invitation::add(1, $category, $sub, $name, $contacter, $phone, $email);
        }
        if($ret)
        {
            $return = $this->returnJson(true,200,null,'申请成功');
        }
        else
        {
            $return = $this->returnJson(false,404,null,'申请失败');
        }
        
        if ($callback = $this->_request->query('callback')){
            exit("{$callback}({$return})");
        }
        return $return;
    }
    
    /**
     * 申请列表
     */
    public function applylistAction()
    {
        if ($this->_request->query('page'))
        {
            list($offset, $limit) = $this->getLimit();
            $data = Facade_Invitation::getApplyList($offset, $limit);
        }else
        {
            $data = Facade_Invitation::getApplyList();
        }
        
        foreach ($data as $k=>$row){
            $row['category'] = Config_Admin_Var::$invitation_category[$row['category']];
            $row['sub'] = Config_Admin_Var::$invitation_sub[$row['sub']];
            $data[$k] = $row;
        }
        
        $return = $this->returnJson(true,200,$data,'邀请函申请列表');
        if ($callback = $this->_request->query('callback')){
            exit("{$callback}({$return})");
        }
        return $return;
    }
    
    /**
     * 通过列表
     */
    public function passlistAction()
    {
        if ($this->_request->query('page'))
        {
            list($offset, $limit) = $this->getLimit();
            $data = Facade_Invitation::getPassList($offset, $limit);
        }else
        {
            $data = Facade_Invitation::getPassList();
        }
        
        foreach ($data as $k=>$row){
            $row['category'] = Config_Admin_Var::$invitation_category[$row['category']];
            $row['sub'] = Config_Admin_Var::$invitation_sub[$row['sub']];
            $data[$k] = $row;
        }
        $return = $this->returnJson(true,200,$data,'邀请函通过列表');
        if ($callback = $this->_request->query('callback')){
            exit("{$callback}({$return})");
        }
        return $return;
    }
}