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


PHP ACL::get_granted_base方法代码示例

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


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

示例1: testGet_granted_base

 public function testGet_granted_base()
 {
     $base_ids = [];
     $n = 0;
     foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
         foreach ($databox->get_collections() as $collection) {
             $base_ids[] = $collection->get_base_id();
             $n++;
         }
     }
     if ($n === 0) {
         $this->fail('Not enough collection to test');
     }
     self::$object->give_access_to_base($base_ids);
     $bases = array_keys(self::$object->get_granted_base());
     $this->assertEquals(count($bases), count($base_ids));
     $this->assertEquals($n, count($base_ids));
     foreach ($bases as $base_id) {
         try {
             $collection = collection::get_from_base_id(self::$DI['app'], $base_id);
             $this->assertTrue($collection instanceof collection);
             $this->assertEquals($base_id, $collection->get_base_id());
             unset($collection);
         } catch (Exception $e) {
             $this->fail('get granted base should returned OK collection');
         }
     }
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:28,代码来源:ACLTest.php

示例2: getAllForUser

 /**
  * Returns all the feeds a user can access.
  *
  * @return \Doctrine\Common\Collections\Collection
  */
 public function getAllForUser(\ACL $userACL)
 {
     $base_ids = array_keys($userACL->get_granted_base());
     $qb = $this->createQueryBuilder('f');
     $qb->where($qb->expr()->isNull('f.baseId'))->orWhere('f.public = true');
     if (count($base_ids) > 0) {
         $qb->orWhere($qb->expr()->in('f.baseId', $base_ids));
     }
     $qb->orderBy('f.updatedOn', 'DESC');
     return $qb->getQuery()->getResult();
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:16,代码来源:FeedRepository.php

示例3: filterUserAccessibleByIds

 /**
  * Returns all the feeds from a given array containing their id.
  *
  * @param \ACL   $userACL
  * @param  array $feedIds Ids to restrict feeds, all accessible otherwise
  *
  * @return Feed[]
  */
 public function filterUserAccessibleByIds(\ACL $userACL, array $feedIds = [])
 {
     $qb = $this->createQueryBuilder('f');
     // is public feed?
     $orx = $qb->expr()->orX($qb->expr()->isNull('f.baseId'), $qb->expr()->eq('f.public', $qb->expr()->literal(true)));
     // is granted base?
     $grantedBases = array_keys($userACL->get_granted_base());
     if ($grantedBases) {
         $orx->add($qb->expr()->in('f.baseId', $grantedBases));
     }
     if ($feedIds) {
         $qb->where($qb->expr()->in('f.id', $feedIds), $orx);
     }
     $qb->orderBy('f.updatedOn', 'DESC');
     return $qb->getQuery()->getResult();
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:24,代码来源:FeedRepository.php

示例4: getAllForUser

 /**
  * Returns all the feeds a user can access.
  *
  * @return \Doctrine\Common\Collections\Collection
  */
 public function getAllForUser(\ACL $userACL, array $restrictions = [])
 {
     $base_ids = array_keys($userACL->get_granted_base());
     $qb = $this->createQueryBuilder('f');
     $qb->where($qb->expr()->isNull('f.baseId'))->orWhere($qb->expr()->eq('f.public', $qb->expr()->literal(true)));
     if (count($restrictions) > 0 && count($base_ids) > 0) {
         $base_ids = array_intersect($base_ids, $restrictions);
     }
     if (empty($base_ids) && count($restrictions) > 0) {
         $base_ids = $restrictions;
     }
     if (count($base_ids) > 0) {
         $qb->orWhere($qb->expr()->in('f.baseId', $base_ids));
     }
     $qb->orderBy('f.updatedOn', 'DESC');
     return $qb->getQuery()->getResult();
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:22,代码来源:FeedRepository.php

示例5: on_bases_where_i_am

 /**
  * Restrict users on collection with provided rights
  *
  * @param ACL   $ACL
  * @param array $rights
  *
  * @return $this
  */
 public function on_bases_where_i_am(ACL $ACL, array $rights)
 {
     $this->bases_restrictions = true;
     $collections = array_keys($ACL->get_granted_base($rights));
     if (count($this->base_ids) > 0) {
         $this->base_ids = array_intersect($this->base_ids, $collections);
     } else {
         $this->base_ids = $collections;
     }
     $this->total = $this->page = $this->total_page = null;
     return $this;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:20,代码来源:Query.php

示例6: getGrantedCollections

 /**
  * Get current user's granted collections where he can upload
  *
  * @param \ACL $acl The user's ACL.
  *
  * @return array
  */
 private function getGrantedCollections(\ACL $acl)
 {
     $collections = [];
     foreach ($acl->get_granted_base(['canaddrecord']) as $collection) {
         $databox = $collection->get_databox();
         if (!isset($collections[$databox->get_sbas_id()])) {
             $collections[$databox->get_sbas_id()] = ['databox' => $databox, 'databox_collections' => []];
         }
         $collections[$databox->get_sbas_id()]['databox_collections'][] = $collection;
     }
     return $collections;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:19,代码来源:Upload.php


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