From 1054483ae9108afbedd5e0a13e1135e7260dc9d3 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Sun, 30 Mar 2014 21:17:46 +0200 Subject: [PATCH] Fix latest merge --- composer.lock | 1 - lib/Alchemy/Phrasea/Controller/Api/V1.php | 4 +++- lib/Alchemy/Phrasea/Controller/Report/Informations.php | 2 +- lib/Alchemy/Phrasea/Feed/Aggregate.php | 2 +- lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php | 6 +++++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index a3e26ca189..ee3ca8c62d 100644 --- a/composer.lock +++ b/composer.lock @@ -1426,7 +1426,6 @@ "export", "import" ], - "time": "2013-11-22 19:10:34" "time": "2014-01-12 16:34:06" }, { diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1.php b/lib/Alchemy/Phrasea/Controller/Api/V1.php index 030963df9c..e116be8706 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1.php @@ -1426,7 +1426,9 @@ class V1 implements ControllerProviderInterface public function get_publications(Application $app, Request $request) { $user = $app['authentication']->getUser(); - $feed = Aggregate::createFromUser($app, $user); + $restrictions = (array) ($request->get('feeds') ? : array()); + + $feed = Aggregate::createFromUser($app, $user, $restrictions); $offset_start = (int) ($request->get('offset_start') ? : 0); $per_page = (int) ($request->get('per_page') ? : 5); diff --git a/lib/Alchemy/Phrasea/Controller/Report/Informations.php b/lib/Alchemy/Phrasea/Controller/Report/Informations.php index b593cc8fe9..1dafb005ce 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Informations.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Informations.php @@ -495,7 +495,7 @@ class Informations implements ControllerProviderInterface 'rs' => $html, 'display_nav' => false, 'title' => $title - )); + ]); } /** diff --git a/lib/Alchemy/Phrasea/Feed/Aggregate.php b/lib/Alchemy/Phrasea/Feed/Aggregate.php index 7c490979b6..dce43cbd95 100644 --- a/lib/Alchemy/Phrasea/Feed/Aggregate.php +++ b/lib/Alchemy/Phrasea/Feed/Aggregate.php @@ -76,7 +76,7 @@ class Aggregate implements FeedInterface * * @return Aggregate */ - public static function createFromUser(Application $app, User $user) + public static function createFromUser(Application $app, User $user, array $restrictions = []) { $feeds = $app['repo.feeds']->getAllForUser($app['acl']->get($user)); $token = $app['repo.aggregate-tokens']->findOneBy(['user' => $user]); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php index ac852df021..ee9b40ac4f 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php @@ -26,7 +26,7 @@ class FeedRepository extends EntityRepository * * @return \Doctrine\Common\Collections\Collection */ - public function getAllForUser(\ACL $userACL) + public function getAllForUser(\ACL $userACL, array $restrictions = []) { $base_ids = array_keys($userACL->get_granted_base()); @@ -40,6 +40,10 @@ class FeedRepository extends EntityRepository $qb->orWhere($qb->expr()->in('f.baseId', $base_ids)); } + if (count($restrictions) > 0) { + $qb->andWhere($qb->expr()->in('f.id', $restrictions)); + } + $qb->orderBy('f.updatedOn', 'DESC'); return $qb->getQuery()->getResult();