mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 03:53:13 +00:00
83 lines
2.6 KiB
PHP
83 lines
2.6 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2013 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Alchemy\Phrasea\Helper;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Alchemy\Phrasea\Model\Entities\Basket as BasketEntity;
|
|
|
|
/**
|
|
*
|
|
* WorkZone provides methods for working with the working zone of Phraseanet
|
|
* Production. This zones handles Non-Archived baskets, stories and Validation
|
|
* people are waiting from me.
|
|
*
|
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
* @link www.phraseanet.com
|
|
*/
|
|
class WorkZone extends Helper
|
|
{
|
|
const BASKETS = 'baskets';
|
|
const STORIES = 'stories';
|
|
const VALIDATIONS = 'validations';
|
|
|
|
/**
|
|
*
|
|
* Returns an ArrayCollection containing three keys :
|
|
* - self::BASKETS : an ArrayCollection of the actives baskets
|
|
* (Non Archived)
|
|
* - self::STORIES : an ArrayCollection of working stories
|
|
* - self::VALIDATIONS : the validation people are waiting from me
|
|
*
|
|
* @return \Doctrine\Common\Collections\ArrayCollection
|
|
*/
|
|
public function getContent($sort)
|
|
{
|
|
/* @var $repo_baskets Alchemy\Phrasea\Model\Repositories\BasketRepository */
|
|
$repo_baskets = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket');
|
|
|
|
$sort = in_array($sort, array('date', 'name')) ? $sort : 'name';
|
|
|
|
$ret = new ArrayCollection();
|
|
|
|
$baskets = $repo_baskets->findActiveByUser($this->app['authentication']->getUser(), $sort);
|
|
|
|
// force creation of a default basket
|
|
if (0 === count($baskets)) {
|
|
$basket = new BasketEntity();
|
|
|
|
$basket->setName(_('Default basket'));
|
|
$basket->setOwner($this->app['authentication']->getUser());
|
|
|
|
$this->app['EM']->persist($basket);
|
|
$this->app['EM']->flush();
|
|
$baskets = array($basket);
|
|
}
|
|
|
|
$validations = $repo_baskets->findActiveValidationByUser($this->app['authentication']->getUser(), $sort);
|
|
|
|
/* @var $repo_stories Alchemy\Phrasea\Model\Repositories\StoryWZRepository */
|
|
$repo_stories = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\StoryWZ');
|
|
|
|
$stories = $repo_stories->findByUser($this->app, $this->app['authentication']->getUser(), $sort);
|
|
|
|
$ret->set(self::BASKETS, $baskets);
|
|
$ret->set(self::VALIDATIONS, $validations);
|
|
$ret->set(self::STORIES, $stories);
|
|
|
|
return $ret;
|
|
}
|
|
|
|
protected function sortBaskets(array $baskets)
|
|
{
|
|
}
|
|
}
|