• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CAccessControlFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: filterAccessControl

 /**
  * Denies access if the module is successfully installed.
  * @param CFilterChain $filterChain
  * @throws CHttpException
  */
 public function filterAccessControl($filterChain)
 {
     $accesscontrol = YiiPlug::app()->hasAccessControlModulesInstalled();
     $user = YiiPlug::app()->hasUserModulesInstalled();
     if (!$accesscontrol || !$user) {
         // no access control module available
         $filter = new CAccessControlFilter();
         $rules = $this->accessRules();
         $frules = array();
         foreach ($rules as $key => $values) {
             $frule = array();
             foreach ($values as $vkey => $value) {
                 if (!$accesscontrol && $vkey !== 'roles') {
                     // do not have accesscontrol module
                     // skip role based access control (but keep other checks)
                     $frule[$vkey] = $value;
                 }
             }
             if ($user && $frule[0] === 'allow') {
                 // has user authentication module
                 // add authenticated user required for each action
                 if (isset($frule['users'])) {
                     $frule['users'][] = '@';
                 } else {
                     $frule['users'] = array('@');
                 }
             }
             $frules[$key] = $frule;
         }
         $filter->setRules($frules);
         return $filter->filter($filterChain);
     }
     // we are in normal state, just do classic access control
     return parent::filterAccessControl($filterChain);
 }
开发者ID:anastaszor,项目名称:yiipluggable,代码行数:40,代码来源:PluggableController.php


示例2: filterAccessControl

 public function filterAccessControl($filterChain)
 {
     $filter = new CAccessControlFilter();
     $rules = $this->accesRulesByAction($filterChain->action);
     $filter->setRules($rules);
     $filter->filter($filterChain);
 }
开发者ID:vman747,项目名称:virex,代码行数:7,代码来源:Controller.php


示例3: filterAccessControl

 /**
  * Filter Access Control.
  *
  * This replicates the access control module in the base controller and lets us
  * do our own special rules that insure we fail closed.
  *
  * @param CFilterChain $filterChain Yii passed object.
  *
  * @return void
  */
 public function filterAccessControl($filterChain)
 {
     $rules = $this->accessRules();
     // default deny
     $rules[] = array('deny');
     $filter = new CAccessControlFilter();
     $filter->setRules($rules);
     $filter->filter($filterChain);
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:19,代码来源:AdminBaseController.php


示例4: filterAccessControl

 public function filterAccessControl($filterChain)
 {
     $rules = $this->accessRules();
     // Fallback to denying everyone
     $rules[] = array('deny');
     $filter = new CAccessControlFilter();
     $filter->setRules($rules);
     $filter->filter($filterChain);
 }
开发者ID:code-4-england,项目名称:OpenEyes,代码行数:9,代码来源:BaseController.php


示例5: preFilter

 /**
 * Filter recursively the menu items received setting
     visibility true or
 * false according to controller/action preFilter
 *
 * @param array $items The menu items being filtered.
 * @return array The menu items with visibility
     defined by preFilter().
 */
 protected function filterItems(array $items)
 {
     $app = Yii::app();
     foreach ($items as $pos => $item) {
         if (!isset($item['visible'])) {
             // get the url parameter
             if (isset($item['url']) && is_array($item['url'])) {
                 $url = $item['url'][0];
             }
             // parse the url into controller and action
             $parts = explode("/", $url);
             if (count($parts) == 1) {
                 $controller = $app->controller;
                 $actionId = $parts[0];
             } else {
                 $controllerId = ucfirst($parts[1]);
                 $actionId = count($parts) > 2 ? $parts[2] : 'index';
                 $controllerList = $app->createController($controllerId);
                 $controller = $controllerList[0];
             }
             // generate a controller instance to access and
             //compare the rules
             $action = $controller->createAction($actionId);
             $filter = new CAccessControlFilter();
             $filter->setRules($controller->accessRules());
             $user = $app->getUser();
             $request = $app->getRequest();
             $ip = $request->getUserHostAddress();
             $item['visible'] = false;
             foreach ($filter->getRules() as $rule) {
                 // we are making an assumption for now that all
                 // menu items are GET actions
                 if ($rule->isUserAllowed($user, $controller, $action, $ip, 'GET') > 0) {
                     $item['visible'] = true;
                     break;
                 }
             }
         }
         /**
         * If current item is visible and has sub items,
                     loops recursively
         * on them.
         */
         if (isset($item['items']) && $item['visible']) {
             $item['items'] = $this->filterItems($item['items']);
         }
         $items[$pos] = $item;
     }
     return $items;
 }
开发者ID:hieuvt,项目名称:FirstYii,代码行数:59,代码来源:AuthMenu.php


示例6: filterAccessControl

 public function filterAccessControl($filterChain)
 {
     $filter = new CAccessControlFilter();
     $filter->setRules($this->accessRules());
     $filter->filter($filterChain);
 }
开发者ID:smokeelow,项目名称:faicore,代码行数:6,代码来源:yiilite.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CActiveDataProvider类代码示例发布时间:2022-05-23
下一篇:
PHP CAccess类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap