当前位置: 首页>>代码示例>>PHP>>正文


PHP Authentication::getAllAllows方法代码示例

本文整理汇总了PHP中Authentication::getAllAllows方法的典型用法代码示例。如果您正苦于以下问题:PHP Authentication::getAllAllows方法的具体用法?PHP Authentication::getAllAllows怎么用?PHP Authentication::getAllAllows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Authentication的用法示例。


在下文中一共展示了Authentication::getAllAllows方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetAllAllows

 /**
  * @covers Authentication::getAllAllows
  * @todo Implement testGetAllAllows().
  */
 public function testGetAllAllows()
 {
     $aclxml = dirname(dirname(dirname(dirname(__FILE__)))) . '/testfiles/test_aclxml.xml';
     Authentication::setAclXml($aclxml);
     $result = Authentication::getAllAllows("test_module2");
     $compare = array("Demo" => "ALL_ACTIONS");
     $this->assertEquals($result['Demo'], $compare['Demo']);
 }
开发者ID:airymvc,项目名称:airymvc_archive,代码行数:12,代码来源:AuthenticationTest.php

示例2: forward

 /**
  * The forward function is to call the action according to the module, controller and action.
  * The function needs to consider all the forward restrictions and rules.
  *
  * @param string $moduleName the forwarding module name
  * @param string $controllerName the forwarding controller name
  * @param string $actionName the forwarding action name
  * @param array  $params the url params
  * @param object $router an instance of Router the default value = null
  * 
  */
 public static function forward($moduleName, $controllerName, $actionName, $params, $router = null)
 {
     $Router = is_null($router) ? new Router() : $router;
     $Router->setDefaultModelView($controllerName);
     $controller = $controllerName . self::CONTROLLER_POSTFIX;
     $action = $actionName . self::ACTION_POSTFIX;
     $controllerfile = RouterHelper::getControllerFile($moduleName, $controller);
     try {
         if (file_exists($controllerfile)) {
             require_once $controllerfile;
             //Check special Authentication controller
             /*
              *  If status       
              */
             $Config = Config::getInstance();
             $auth_array = $Config->getAuthenticationConfig();
             if ($auth_array['use_authentication'] == "enable") {
                 /**
                  * if the controller and actions are those login related ones, 
                  * we exclude them, let them dispatch. 
                  */
                 if (Authentication::isLogin($moduleName)) {
                     // need to acl rule after login
                     // put them here
                     //
                     if (Authentication::getSuccessController($moduleName) == $controllerName && Authentication::getSuccessAction($moduleName) == $actionName) {
                         Dispatcher::setRoute($moduleName, $controllerName, $actionName);
                     }
                     Dispatcher::toMVC($controller, $action, $params);
                     return;
                 } else {
                     //all allowed actions that are defined in acl.xml
                     $allows = Authentication::getAllAllows($moduleName);
                     //Change the controllerName to ControllerName
                     //because the router already transform the value
                     $controllerName = ucfirst($controllerName);
                     //Dispatch sequence - checking allowing actions before checking login related actions
                     //(1) Check acl access exclusions
                     //Case #1: allow all controllers in the module
                     if ($allows == self::ALL_CONTROLLERS) {
                         Dispatcher::toMVC($controller, $action, $params);
                         return;
                     }
                     //Case #2: allow all actions in a specific controller
                     if (isset($allows[$controllerName]) && $allows[$controllerName] == self::ALL_ACTIONS) {
                         Dispatcher::toMVC($controller, $action, $params);
                         return;
                     }
                     //Case #3: allow a specific action in a specific controller
                     if (isset($allows[$controllerName])) {
                         $allowActions = $allows[$controllerName];
                         foreach ($allowActions as $idx => $allowAction) {
                             //echo "{$allowAction}=={$actionName}";
                             if ($allowAction == $actionName) {
                                 Dispatcher::toMVC($controller, $action, $params);
                                 return;
                             }
                         }
                     }
                     //Case #4: Special cases, passing the actions in layout (due to using http request to get view)
                     if (isset(Authentication::$layoutAllows[$moduleName][$controllerName])) {
                         $allowActions = Authentication::$layoutAllows[$moduleName][$controllerName];
                         foreach ($allowActions as $idx => $allowAction) {
                             if ($allowAction == $actionName) {
                                 //unset the action
                                 Authentication::removeLayoutAllowAction($moduleName, $controllerName, $actionName);
                                 Dispatcher::toMVC($controller, $action, $params);
                                 return;
                             }
                         }
                     }
                     //(2) Check login related actions
                     $loginActions = Authentication::getLoginExcludeActions($moduleName);
                     if (isset($loginActions[$controllerName][$actionName])) {
                         Dispatcher::toMVC($controller, $action, $params);
                         return;
                     }
                     //(3) None of above satisfies, forward to login controller action
                     $loginControllerName = Authentication::getLoginController($moduleName);
                     $loginController = Authentication::getLoginController($moduleName) . self::CONTROLLER_POSTFIX;
                     $loginActionName = Authentication::getLoginAction($moduleName);
                     $loginAction = Authentication::getLoginAction($moduleName) . self::ACTION_POSTFIX;
                     Dispatcher::setRoute($moduleName, $loginControllerName, $loginActionName);
                     Dispatcher::toMVC($loginController, $loginAction, $params);
                 }
             } else {
                 Dispatcher::toMVC($controller, $action, $params);
             }
         } else {
//.........这里部分代码省略.........
开发者ID:airymvc,项目名称:airymvc2,代码行数:101,代码来源:Dispatcher.php


注:本文中的Authentication::getAllAllows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。