本文整理汇总了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');
}
}
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}