mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00
Add Entities repositories
This commit is contained in:
64
lib/Doctrine/Repositories/BasketRepository.php
Normal file
64
lib/Doctrine/Repositories/BasketRepository.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Repositories;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class BasketRepository extends EntityRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all basket for a given user that are not marked as archived
|
||||||
|
*
|
||||||
|
* @param \User_Adapter $user
|
||||||
|
* @return \Doctrine\Common\Collections\ArrayCollection
|
||||||
|
*/
|
||||||
|
public function findActiveByUser(\User_Adapter $user)
|
||||||
|
{
|
||||||
|
$dql = 'SELECT b FROM Entities\Basket b
|
||||||
|
WHERE b.usr_id = :usr_id AND archived = false';
|
||||||
|
|
||||||
|
$query = $this->_em->createQuery($dql);
|
||||||
|
$query->setParameters(array(':usr_id' => $user->get_id()));
|
||||||
|
|
||||||
|
return $query->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all baskets that are in validation session not expired and
|
||||||
|
* where a specified user is participant (not owner)
|
||||||
|
*
|
||||||
|
* @param \User_Adapter $user
|
||||||
|
* @return \Doctrine\Common\Collections\ArrayCollection
|
||||||
|
*/
|
||||||
|
public function findActiveValidationByUser(\User_Adapter $user)
|
||||||
|
{
|
||||||
|
$dql = 'SELECT b FROM Entities\Basket b
|
||||||
|
JOIN b.Entities\ValidationSession s
|
||||||
|
JOIN s.Entities\ValidationParticipant
|
||||||
|
WHERE b.usr_id != ?1 AND s.usr_id = ?2
|
||||||
|
AND s.expires > CURRENT_TIMESTAMP()';
|
||||||
|
|
||||||
|
$query = $this->_em->createQuery($dql);
|
||||||
|
$query->setParameters(array(1 => $user->get_id(), 2 => $user->get_id()));
|
||||||
|
|
||||||
|
return $query->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
38
lib/Doctrine/Repositories/StoryWorkZoneRepository.php
Normal file
38
lib/Doctrine/Repositories/StoryWorkZoneRepository.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Repositories;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class StoryWorkzoneRepository extends EntityRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all StoryWorkZone currently attached to a user
|
||||||
|
*
|
||||||
|
* @param \User_Adapter $user
|
||||||
|
* @return \Doctrine\Common\Collections\ArrayCollection
|
||||||
|
*/
|
||||||
|
public function findByUser(\User_Adapter $user)
|
||||||
|
{
|
||||||
|
|
||||||
|
return $this->findBy(array('usr_id'=>$user->get_id()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Repositories;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class ValidationParticipantRepository extends EntityRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user