mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 13:33:14 +00:00
Restored usage of querybuilder in feedrepository
This commit is contained in:
@@ -24,59 +24,37 @@ class FeedRepository extends EntityRepository
|
|||||||
{
|
{
|
||||||
$base_ids = array_keys($user->ACL()->get_granted_base());
|
$base_ids = array_keys($user->ACL()->get_granted_base());
|
||||||
|
|
||||||
$dql = 'SELECT f FROM Entities\Feed f
|
$qb = $this
|
||||||
WHERE f.baseId IS NULL ';
|
->createQueryBuilder('f');
|
||||||
|
|
||||||
|
$qb->where($qb->expr()->isNull('f.baseId'))
|
||||||
|
->orWhere('f.public = true');
|
||||||
|
|
||||||
if (count($base_ids) > 0) {
|
if (count($base_ids) > 0) {
|
||||||
$dql .= ' OR f.baseId
|
$qb->orWhere($qb->expr()->in('f.baseId', $base_ids));
|
||||||
IN (' . implode(', ', $base_ids) . ') ';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$dql .= ' OR f.public = true
|
$qb->orderBy('f.updatedOn', 'DESC');
|
||||||
ORDER BY f.updatedOn DESC';
|
|
||||||
|
|
||||||
$query = $this->_em->createQuery($dql);
|
return $qb->getQuery()->getResult();
|
||||||
|
|
||||||
return $query->getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the given feed if the user can access to it.
|
|
||||||
*
|
|
||||||
* @param Application $app
|
|
||||||
* @param \User_Adapter $user
|
|
||||||
* @param type $id
|
|
||||||
* @return Feed
|
|
||||||
*/
|
|
||||||
public function loadWithUser(Application $app, \User_Adapter $user, $id)
|
|
||||||
{
|
|
||||||
$feed = $this->find($id);
|
|
||||||
if ($feed) {
|
|
||||||
$coll = $feed->getCollection($app);
|
|
||||||
if ($feed->isPublic()
|
|
||||||
|| $coll === null
|
|
||||||
|| in_array($coll->get_base_id(), array_keys($user->ACL()->get_granted_base()))) {
|
|
||||||
return $feed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the feeds from a given array containing their id.
|
* Returns all the feeds from a given array containing their id.
|
||||||
*
|
*
|
||||||
* @param array $feed_id
|
* @param array $feedIds
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function findByIdArray(array $feed_id)
|
public function findByIds(array $feedIds)
|
||||||
{
|
{
|
||||||
$dql = 'SELECT f FROM Entities\Feed f
|
$qb = $this->createQueryBuilder('f');
|
||||||
ORDER BY f.createdOn DESC
|
|
||||||
WHERE f.id IN (' . implode(",", $feed_id) . ')';
|
|
||||||
|
|
||||||
$query = $this->_em->createQuery($dql);
|
if (!empty($feedIds)) {
|
||||||
|
$qb->Where($qb->expr()->in('f.id', $feedIds));
|
||||||
|
}
|
||||||
|
|
||||||
return $query->getResult();
|
$qb->orderBy('f.updatedOn', 'DESC');
|
||||||
|
|
||||||
|
return $qb->getQuery()->getResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user