mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 13:03:20 +00:00
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Repositories;
|
|
|
|
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 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_on DESC';
|
|
|
|
$query = $this->_em->createQuery($dql);
|
|
$feeds = $query->getResult();
|
|
|
|
return $feeds;
|
|
}
|
|
|
|
public function find($id)
|
|
{
|
|
$dql = 'SELECT f FROM Entities\Feed f
|
|
WHERE f.id = :id ';
|
|
|
|
$query = $this->_em->createQuery($dql);
|
|
$query->setParameter('id', $id);
|
|
$feed = $query->getResult();
|
|
|
|
return $feed[0];
|
|
}
|
|
}
|