diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php index 5ad1cfdead..9acec00f3d 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php @@ -36,8 +36,8 @@ class Publications implements ControllerProviderInterface $controllers->get('/list/', function(PhraseaApplication $app) { - $feeds = \Feed_Collection::load_all( - $app, $app['authentication']->getUser() + $feeds = $app["EM"]->getRepository("Entities\Feed")->getAllForUser( + $app['authentication']->getUser() ); return $app['twig'] diff --git a/lib/Doctrine/Entities/Feed.php b/lib/Doctrine/Entities/Feed.php new file mode 100644 index 0000000000..4caf597836 --- /dev/null +++ b/lib/Doctrine/Entities/Feed.php @@ -0,0 +1,333 @@ +publishers = new \Doctrine\Common\Collections\ArrayCollection(); + $this->entries = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set public + * + * @param boolean $public + * @return Feed + */ + public function setPublic($public) + { + $this->public = $public; + + return $this; + } + + /** + * Get public + * + * @return boolean + */ + public function getPublic() + { + return $this->public; + } + + /** + * Set icon_url + * + * @param string $iconUrl + * @return Feed + */ + public function setIconUrl($iconUrl) + { + $this->icon_url = $iconUrl; + + return $this; + } + + /** + * Get icon_url + * + * @return string + */ + public function getIconUrl() + { + return $this->icon_url; + } + + /** + * Set base_id + * + * @param integer $baseId + * @return Feed + */ + public function setBaseId($baseId) + { + $this->base_id = $baseId; + + return $this; + } + + /** + * Get base_id + * + * @return integer + */ + public function getBaseId() + { + return $this->base_id; + } + + /** + * Set title + * + * @param string $title + * @return Feed + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set description + * + * @param string $description + * @return Feed + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set created + * + * @param \DateTime $created + * @return Feed + */ + public function setCreated($created) + { + $this->created = $created; + + return $this; + } + + /** + * Get created + * + * @return \DateTime + */ + public function getCreated() + { + return $this->created; + } + + /** + * Set updated + * + * @param \DateTime $updated + * @return Feed + */ + public function setUpdated($updated) + { + $this->updated = $updated; + + return $this; + } + + /** + * Get updated + * + * @return \DateTime + */ + public function getUpdated() + { + return $this->updated; + } + + /** + * Add publishers + * + * @param \Entities\FeedPublisher $publishers + * @return Feed + */ + public function addPublisher(\Entities\FeedPublisher $publishers) + { + $this->publishers[] = $publishers; + + return $this; + } + + /** + * Remove publishers + * + * @param \Entities\FeedPublisher $publishers + */ + public function removePublisher(\Entities\FeedPublisher $publishers) + { + $this->publishers->removeElement($publishers); + } + + /** + * Get publishers + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getPublishers() + { + return $this->publishers; + } + + /** + * Add entries + * + * @param \Entities\FeedEntry $entries + * @return Feed + */ + public function addEntrie(\Entities\FeedEntry $entries) + { + $this->entries[] = $entries; + + return $this; + } + + /** + * Remove entries + * + * @param \Entities\FeedEntry $entries + */ + public function removeEntrie(\Entities\FeedEntry $entries) + { + $this->entries->removeElement($entries); + } + + /** + * Get entries + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getEntries() + { + return $this->entries; + } + + public function getOwner() + { + foreach ($this->getPublishers() as $publisher) { + if ($publisher->isOwner()) { + return $publisher; + } + } + } + + public function isOwner(\User_Adapter $user) + { + $owner = $this->getOwner(); + if ($owner !== null && $user->get_id() === $owner->getId()) { + return true; + } + + return false; + } + + public function getCollection(Application $app) + { + if ($this->getBaseId() !== null) + return \collection::get_from_base_id($app, $this->getBaseId()); + } +} \ No newline at end of file diff --git a/lib/Doctrine/Repositories/SessionRepository.php b/lib/Doctrine/Repositories/SessionRepository.php index 747d99d7f3..b78db0574a 100644 --- a/lib/Doctrine/Repositories/SessionRepository.php +++ b/lib/Doctrine/Repositories/SessionRepository.php @@ -2,6 +2,7 @@ namespace Repositories; +use Alchemy\Phrasea\Application; use Doctrine\ORM\EntityRepository; /** @@ -12,4 +13,31 @@ use Doctrine\ORM\EntityRepository; */ 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; + } } diff --git a/templates/web/admin/publications/list.html.twig b/templates/web/admin/publications/list.html.twig index 875c289cb1..19c89f0b6d 100644 --- a/templates/web/admin/publications/list.html.twig +++ b/templates/web/admin/publications/list.html.twig @@ -59,35 +59,35 @@
- {% for feed in feeds.get_feeds %} + {% for feed in feeds %}