mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
Restored repositories
This commit is contained in:
15
lib/Doctrine/Repositories/FeedEntryRepository.php
Normal file
15
lib/Doctrine/Repositories/FeedEntryRepository.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Repositories;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FeedEntryRepository
|
||||||
|
*
|
||||||
|
* This class was generated by the Doctrine ORM. Add your own custom
|
||||||
|
* repository methods below.
|
||||||
|
*/
|
||||||
|
class FeedEntryRepository extends EntityRepository
|
||||||
|
{
|
||||||
|
}
|
15
lib/Doctrine/Repositories/FeedItemRepository.php
Normal file
15
lib/Doctrine/Repositories/FeedItemRepository.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Repositories;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FeedItemRepository
|
||||||
|
*
|
||||||
|
* This class was generated by the Doctrine ORM. Add your own custom
|
||||||
|
* repository methods below.
|
||||||
|
*/
|
||||||
|
class FeedItemRepository extends EntityRepository
|
||||||
|
{
|
||||||
|
}
|
17
lib/Doctrine/Repositories/FeedPublisherRepository.php
Normal file
17
lib/Doctrine/Repositories/FeedPublisherRepository.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Repositories;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Entities\Feed;
|
||||||
|
use Entities\FeedPublisher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FeedPublisherRepository
|
||||||
|
*
|
||||||
|
* This class was generated by the Doctrine ORM. Add your own custom
|
||||||
|
* repository methods below.
|
||||||
|
*/
|
||||||
|
class FeedPublisherRepository extends EntityRepository
|
||||||
|
{
|
||||||
|
}
|
98
lib/Doctrine/Repositories/FeedRepository.php
Normal file
98
lib/Doctrine/Repositories/FeedRepository.php
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Repositories;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Entities\Feed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FeedRepository
|
||||||
|
*
|
||||||
|
* This class was generated by the Doctrine ORM. Add your own custom
|
||||||
|
* repository methods below.
|
||||||
|
*/
|
||||||
|
class FeedRepository extends EntityRepository
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns all the feeds a user can access.
|
||||||
|
*
|
||||||
|
* @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.updated_on DESC';
|
||||||
|
|
||||||
|
$query = $this->_em->createQuery($dql);
|
||||||
|
|
||||||
|
return $query->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all the public feeds.
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function findAllPublic()
|
||||||
|
{
|
||||||
|
$dql = 'SELECT f FROM Entities\Feed f
|
||||||
|
WHERE f.public = true
|
||||||
|
ORDER BY f.updated_on DESC';
|
||||||
|
|
||||||
|
$query = $this->_em->createQuery($dql);
|
||||||
|
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @param array $feed_id
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function findByIdArray(array $feed_id)
|
||||||
|
{
|
||||||
|
$dql = 'SELECT f FROM Entities\Feed f
|
||||||
|
ORDER BY f.created_on DESC
|
||||||
|
WHERE f.id IN (' . implode(",", $feed_id) . ')';
|
||||||
|
|
||||||
|
$query = $this->_em->createQuery($dql);
|
||||||
|
|
||||||
|
return $query->getResult();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user