<?php

class Ec_Controller_Action extends Zend_Controller_Action
{
    public $_userAuth = '';
    protected $tplDirectory;
    public function init()
    {
        $this->view = Zend_Registry::get('EcView');
        $this->_userAuth = new Zend_Session_Namespace('userAuthorization');
       // $this->_userAuth->warehouseId;
        if (!$this->_userAuth->userId || !$this->_userAuth->isLogin) {
            $this->_redirect('/default/index/login');
            exit();
        }
        if(!isset($this->_userAuth->Acl_all)){
            $userRights = Common_DataCache::getUserRight(1);
            $this->_userAuth->Acl_all = $userRights;
            //print_r($this->_userAuth->Acl_all);
        }else{
            $userRights = $this->_userAuth->Acl_all;
        }
        $request = Zend_Controller_Front::getInstance();
        $param = $request->getRequest()->getParams();
        $url = '/'.$param['module'].'/'.$param['controller'].'/'.$param['action'];
        $check = Service_Permission::verifypermission($url,$userRights,$this->_userAuth->Acl['menuArr'],$this->_userAuth->userId);
        /*var_dump($this->_userAuth->userId);
        var_dump($check);
        exit;*/
        if(!$check){
            echo "<script>alert('You Have No Authority To Access This Page...');</script>";
            $this->_redirect('/default/error/deny');
            exit;
        }
    }

    public function indexAction()
    {
        $this->listAction();
    }

    public function listAction()
    {
    }

    //当不存在的方法时调用
    public function __call($methodName, $args)
    {
        $this->_forward('error', 'error', 'default');
    }

}