Files
Phraseanet/lib/Doctrine/Repositories/SessionRepository.php

44 lines
993 B
PHP

<?php
namespace Repositories;
use Alchemy\Phrasea\Application;
use Doctrine\ORM\EntityRepository;
/**
* SessionRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class SessionRepository extends EntityRepository
{
/**
*
* @param Application $app
* @param User_Adapter $user
* @return \Doctrine\Common\Collections\Collection
*/
public function getAllForUser(\User_Adapter $user)
{
$base_ids = array_keys($user->ACL()->get_granted_base());
$dql = 'SELECT f FROM Entities\Feed f
WHERE f.base_id IS NULL ';
if (count($base_ids) > 0) {
$dql .= ' OR f.base_id
IN (' . implode(', ', $base_ids) . ') ';
}
$dql .= ' OR f.public = true
ORDER BY f.created DESC';
$query = $this->_em->createQuery($dql);
$feeds = $query->getResult();
return $feeds;
}
}