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


PHP Acl::inheritsRole方法代码示例

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


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

示例1: createQuery

 /**
  * for people
  * following parameter are relevant
  * by     => 'all', 'me', 'guest'
  * status => Status::CREATED, 'all'
  * user   => User::ROLE_RECRUITER, User::ROLE_ADMIN, User::ROLE_USER
  *
  * @param $params
  * @param $queryBuilder
  * @return mixed
  */
 public function createQuery($params, $queryBuilder)
 {
     $this->value = $params->toArray();
     $this->user = $this->auth->getUser();
     $isRecruiter = $this->user->getRole() == User::ROLE_RECRUITER || $this->acl->inheritsRole($this->user, User::ROLE_RECRUITER);
     if ($isRecruiter && (!isset($this->value['by']) || $this->value['by'] != 'guest')) {
         /*
          * a recruiter can see his jobs and jobs from users who gave permissions to do so
          */
         if (isset($this->value['params']['by']) && 'me' == $this->value['params']['by']) {
             $queryBuilder->field('user')->equals($this->user->id);
         } else {
             $queryBuilder->field('permissions.view')->equals($this->user->id);
         }
         if (isset($this->value['params']['status']) && !empty($this->value['params']['status']) && $this->value['params']['status'] != 'all') {
             $queryBuilder->field('status.name')->equals((string) $this->value['params']['status']);
         }
     } else {
         /*
          * an applicants or guests can see all active jobs
          */
         $queryBuilder->field('status.name')->equals(Status::ACTIVE);
     }
     /*
      * search jobs by keywords
      */
     if (isset($this->value['params']['search']) && !empty($this->value['params']['search'])) {
         $search = strtolower($this->value['params']['search']);
         $searchPatterns = array();
         foreach (explode(' ', $search) as $searchItem) {
             $searchPatterns[] = new \MongoRegex('/^' . $searchItem . '/');
         }
         $queryBuilder->field('keywords')->all($searchPatterns);
     }
     if (isset($this->value['location'])) {
         $loc = $this->value['location'];
         $queryBuilder->field('locations.coordinates')->near($loc->getCoordinates())->maxDistance($this->value['d'] * 1000);
     }
     if (isset($this->value['sort'])) {
         foreach (explode(",", $this->value['sort']) as $sort) {
             $queryBuilder->sort($this->filterSort($sort));
         }
     }
     return $queryBuilder;
 }
开发者ID:webpants,项目名称:YAWIK,代码行数:56,代码来源:PaginationQuery.php

示例2: createQuery

 /**
  * for people
  * following parameter are relevant
  * by     => 'all', 'me', 'guest'
  * status => Status::CREATED, 'all'
  * user   => User::ROLE_RECRUITER, User::ROLE_ADMIN, User::ROLE_USER
  *
  * @param $params Parameters
  * @param $queryBuilder \Doctrine\ODM\MongoDB\Query\Builder
  * @return mixed
  */
 public function createQuery($params, $queryBuilder)
 {
     $this->value = $params;
     /*
      * search jobs by keywords
      */
     if (isset($params['search']) && !empty($params['search'])) {
         $search = strtolower($params['search']);
         $expression = $queryBuilder->expr()->operator('$text', ['$search' => $search]);
         $queryBuilder->field(null)->equals($expression->getQuery());
     }
     if (isset($this->value['location']->coordinates)) {
         $coordinates = $this->value['location']->coordinates->getCoordinates();
         $queryBuilder->field('locations.coordinates')->geoWithinCenter($coordinates[0], $coordinates[1], (double) $this->value['d'] / 100);
     }
     if (isset($params['channel']) && !empty($params['channel']) && $params['channel'] != "default") {
         $queryBuilder->field('portals')->equals($params['channel']);
     }
     $this->user = $this->auth->getUser();
     $isRecruiter = $this->user->getRole() == User::ROLE_RECRUITER || $this->acl->inheritsRole($this->user, User::ROLE_RECRUITER);
     if ($isRecruiter && (!isset($this->value['by']) || $this->value['by'] != 'guest')) {
         /*
          * a recruiter can see his jobs and jobs from users who gave permissions to do so
          */
         if (isset($params['by']) && 'me' == $params['by']) {
             $queryBuilder->field('user')->equals($this->user->id);
         } else {
             $queryBuilder->field('permissions.view')->equals($this->user->id);
         }
         if (isset($params['status']) && !empty($params['status']) && $params['status'] != 'all') {
             $queryBuilder->field('status.name')->equals((string) $params['status']);
         }
     } else {
         /*
          * an applicants or guests can see all active jobs
          */
         $queryBuilder->field('status.name')->equals(Status::ACTIVE);
     }
     if (isset($this->value['sort'])) {
         foreach (explode(",", $this->value['sort']) as $sort) {
             $queryBuilder->sort($this->filterSort($sort));
         }
     }
     return $queryBuilder;
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:56,代码来源:PaginationQuery.php

示例3: __construct

 public function __construct($roleName, array $permissions, Acl $acl)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $roles = $acl->getRoles();
     $parentPermissions = [];
     foreach ($roles as $role) {
         if ($acl->inheritsRole($roleName, $role, true)) {
             foreach ($permissions as $permissionId => $permission) {
                 if ($acl->isAllowed($role, $permission)) {
                     $parentPermissions[$permissionId] = $permissionId;
                 }
             }
         }
     }
     $permissionGroups = [];
     foreach ($permissions as $permissionId => $permission) {
         $fragments = explode('/', $permission);
         $groupName = reset($fragments);
         if (!array_key_exists($groupName, $permissionGroups)) {
             $permissionGroups[$groupName] = [];
         }
         $permissionGroups[$groupName][] = $permissionId;
     }
     foreach ($permissionGroups as $groupName => $groupPermissions) {
         foreach ($groupPermissions as $permission) {
             $permissionCheck = new Checkbox($permission);
             $permissionCheck->setLabel($permissions[$permission]);
             if (array_key_exists($permission, $parentPermissions)) {
                 $permissionCheck->setValue(true);
                 $permissionCheck->setAttribute('disabled', true);
             }
             $this->add($permissionCheck);
             if (!array_key_exists($groupName, $this->permissionGroups)) {
                 $this->permissionGroups[$groupName] = [];
             }
             $this->permissionGroups[$groupName][] = $permissionCheck;
         }
     }
     $submit = new Submit('save');
     $submit->setValue('save');
     $submit->setAttribute('class', 'btn btn-primary');
     $this->add($submit);
 }
开发者ID:zend-bricks,项目名称:bricks-user,代码行数:44,代码来源:PermissionAssignmentForm.php

示例4: testRoleInheritanceSupportsCheckingOnlyParents

 /**
  * Ensures that the $onlyParents argument to inheritsRole() works
  *
  * @return void
  * @group  ZF-2502
  */
 public function testRoleInheritanceSupportsCheckingOnlyParents()
 {
     $this->_acl->addRole(new Role\GenericRole('grandparent'))->addRole(new Role\GenericRole('parent'), 'grandparent')->addRole(new Role\GenericRole('child'), 'parent');
     $this->assertFalse($this->_acl->inheritsRole('child', 'grandparent', true));
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:11,代码来源:AclTest.php


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