protected function _initAcl() { $isRedirect = false; if (!parent::_initAcl()) { $isRedirect = true; } else { $username = $this->auth->getUsername(); $this->aclAdmin = new Vi_Acl($username); Vi_Registry::set('aclAdmin', $this->aclAdmin); // echo '<pre>';print_r($this->aclAdmin);die; $isRedirect = !$this->aclAdmin->checkPermission('access', 'application::' . Vi_Registry::getAppName()); } if ($isRedirect && Vi_Registry::getModuleName() != 'access') { $url = ""; $module = Vi_Registry::getModuleName(); $controller = Vi_Registry::getControllerName(); $action = Vi_Registry::getActionName(); $params = $this->_request->getParams(); $url .= $module . '/' . $controller . '/' . $action . '/'; unset($params[Vi_Registry::getModuleKey()]); unset($params[Vi_Registry::getControllerKey()]); unset($params[Vi_Registry::getActionKey()]); // echo "<pre>";print_r($params);die; foreach ($params as $key => $param) { $url .= @urlencode($key) . '/' . @urlencode($param); } $this->_setCallBackUrl($url); if (null != $this->auth->getUsername()) { $this->session->accessMessage = Vi_Language::translate("You don't have permission to access this application"); } $this->_redirect("access/admin/login"); } return true; }
/** * Initialize Controller paths * * @return void */ public function initControllers() { /** * Controller directory will be: * * 'aliasName' => 'moduleName' * 'moduleName' => 'moduleName' * * Alias-name will have higher priority than module-name */ $arrayModule = Vi_Initializer::$_config['module']; $arrayModule = array_merge(Vi_Initializer::$_config['requiredModule'], $arrayModule); $moduleAlisases = $arrayModule; foreach ($arrayModule as $key => $item) { $arrayModule[$key] = 'modules/' . $item . '/controllers/'; if (array_key_exists($item, $arrayModule)) { continue; } $arrayModule[$item] = 'modules/' . $item . '/controllers/'; $moduleAlisases[$item] = $item; } // echo Vi_Registry::get('APP_BASE_URL');die; Vi_Registry::set('moduleAliases', $moduleAlisases); $this->_front->setDefaultModule(Vi_Initializer::$_config['defaultModule']); $this->_front->setDefaultControllerName(Vi_Initializer::$_config['defaultController']); $this->_front->setDefaultAction(Vi_Initializer::$_config['defaultAction']); $this->_front->setControllerDirectory($arrayModule); $this->_front->setBaseUrl(Vi_Registry::get('APP_BASE_URL')); $this->_front->setParam('prefixDefaultModule', true); }
public function checkPermission($username, $module) { if (null == $this->acl && false == Vi_Registry::getAcl()) { /** * Load permission */ require_once 'Vi/Acl.php'; if ($this->auth->hasIdentity()) { $username = $this->auth->getUsername(); $this->acl = new Vi_Acl($username); Vi_Registry::set('acl', $this->acl); } else { return false; } } return $this->acl->checkPermission($username, $module); }
/** * init access control list * @return void */ protected function _initAcl() { require_once 'Vi/Acl.php'; if ($this->auth->hasIdentity()) { $username = $this->auth->getUsername(); $this->acl = new Vi_Acl($username); Vi_Registry::set('acl', $this->acl); return true; } return false; }
/** * Called before Zend_Controller_Front begins evaluating the * request against its routes. * * @param Zend_Controller_Request_Abstract $request * @return void */ public function routeStartup(Zend_Controller_Request_Abstract $request) { $objStatistic = new Objects_Statistic(); Vi_Registry::set('statistic', $objStatistic); }