mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00

Conflicts: lib/Alchemy/Phrasea/Command/Developer/JavascriptBuilder.php lib/Alchemy/Phrasea/Controller/Prod/Basket.php lib/Alchemy/Phrasea/Core/Provider/TaskManagerServiceProvider.php lib/classes/Exception/Feed/ItemNotFound.php lib/classes/Exception/Feed/PublisherNotFound.php lib/classes/Feed/Abstract.php lib/classes/Feed/Adapter.php lib/classes/Feed/Aggregate.php lib/classes/Feed/Collection.php lib/classes/Feed/CollectionInterface.php lib/classes/Feed/Entry/Adapter.php lib/classes/Feed/Entry/Collection.php lib/classes/Feed/Entry/Interface.php lib/classes/Feed/Entry/Item.php lib/classes/Feed/Entry/ItemInterface.php lib/classes/Feed/Interface.php lib/classes/Feed/Link.php lib/classes/Feed/LinkInterface.php lib/classes/Feed/Publisher/Adapter.php lib/classes/Feed/Publisher/Interface.php lib/classes/Feed/Token.php lib/classes/Feed/TokenAggregate.php lib/classes/Feed/XML/Abstract.php lib/classes/Feed/XML/Atom.php lib/classes/Feed/XML/Cooliris.php lib/classes/Feed/XML/Interface.php lib/classes/Feed/XML/RSS.php lib/classes/Feed/XML/RSS/ImageInterface.php lib/classes/http/request.php lib/classes/module/console/schedulerStart.php lib/classes/module/console/schedulerState.php lib/classes/module/console/schedulerStop.php lib/classes/module/console/taskState.php lib/classes/module/console/tasklist.php lib/classes/module/console/taskrun.php lib/classes/registry.php lib/classes/registryInterface.php lib/classes/set/order.php lib/classes/system/url.php lib/classes/task/Scheduler.php lib/classes/task/appboxAbstract.php lib/classes/task/databoxAbstract.php lib/classes/task/manager.php lib/classes/task/period/RecordMover.php lib/classes/task/period/apibridge.php lib/classes/task/period/archive.php lib/classes/task/period/cindexer.php lib/classes/task/period/emptyColl.php lib/classes/task/period/ftp.php lib/classes/task/period/ftpPull.php lib/classes/task/period/subdef.php lib/classes/task/period/test.php lib/classes/task/period/writemeta.php lib/conf.d/PhraseaFixture/AbstractWZ.php lib/conf.d/PhraseaFixture/Basket/LoadFiveBaskets.php lib/conf.d/PhraseaFixture/Basket/LoadOneBasket.php lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php lib/conf.d/PhraseaFixture/Lazaret/LoadOneFile.php lib/conf.d/PhraseaFixture/Story/LoadOneStory.php lib/conf.d/PhraseaFixture/UsrLists/ListAbstract.php lib/conf.d/PhraseaFixture/UsrLists/UsrList.php lib/conf.d/PhraseaFixture/UsrLists/UsrListEntry.php lib/conf.d/PhraseaFixture/UsrLists/UsrListOwner.php lib/conf.d/PhraseaFixture/ValidationParticipant/LoadOneParticipant.php lib/conf.d/PhraseaFixture/ValidationParticipant/LoadParticipantWithSession.php lib/conf.d/PhraseaFixture/ValidationSession/LoadOneValidationSession.php
296 lines
6.3 KiB
PHP
296 lines
6.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2014 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Alchemy\Phrasea\Model\Entities;
|
|
|
|
use Alchemy\Phrasea\Application;
|
|
use Alchemy\Phrasea\Model\Entities\ValidationParticipant;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Gedmo\Mapping\Annotation as Gedmo;
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
|
/**
|
|
* @ORM\Table(name="ValidationSessions")
|
|
* @ORM\Entity
|
|
*/
|
|
class ValidationSession
|
|
{
|
|
/**
|
|
* @ORM\Column(type="integer")
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\Column(type="integer")
|
|
*/
|
|
private $initiator_id;
|
|
|
|
/**
|
|
* @Gedmo\Timestampable(on="create")
|
|
* @ORM\Column(type="datetime")
|
|
*/
|
|
private $created;
|
|
|
|
/**
|
|
* @Gedmo\Timestampable(on="update")
|
|
* @ORM\Column(type="datetime")
|
|
*/
|
|
private $updated;
|
|
|
|
/**
|
|
* @ORM\Column(type="datetime", nullable=true)
|
|
*/
|
|
private $expires;
|
|
|
|
/**
|
|
* @ORM\OneToOne(targetEntity="Basket", inversedBy="validation", cascade={"persist"})
|
|
* @ORM\JoinColumn(name="basket_id", referencedColumnName="id")
|
|
*/
|
|
private $basket;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="ValidationParticipant", mappedBy="session", cascade={"all"})
|
|
*/
|
|
private $participants;
|
|
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->participants = new \Doctrine\Common\Collections\ArrayCollection();
|
|
}
|
|
|
|
/**
|
|
* Get id
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function getId()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* Set initiator_id
|
|
*
|
|
* @param integer $initiatorId
|
|
* @return ValidationSession
|
|
*/
|
|
public function setInitiatorId($initiatorId)
|
|
{
|
|
$this->initiator_id = $initiatorId;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get initiator_id
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function getInitiatorId()
|
|
{
|
|
return $this->initiator_id;
|
|
}
|
|
|
|
public function isInitiator(\User_Adapter $user)
|
|
{
|
|
return $this->getInitiatorId() == $user->get_id();
|
|
}
|
|
|
|
public function setInitiator(\User_Adapter $user)
|
|
{
|
|
$this->initiator_id = $user->get_id();
|
|
|
|
return;
|
|
}
|
|
|
|
public function getInitiator(Application $app)
|
|
{
|
|
if ($this->initiator_id) {
|
|
return \User_Adapter::getInstance($this->initiator_id, $app);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Set created
|
|
*
|
|
* @param \DateTime $created
|
|
* @return ValidationSession
|
|
*/
|
|
public function setCreated(\DateTime $created)
|
|
{
|
|
$this->created = $created;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get created
|
|
*
|
|
* @return \DateTime
|
|
*/
|
|
public function getCreated()
|
|
{
|
|
return $this->created;
|
|
}
|
|
|
|
/**
|
|
* Set updated
|
|
*
|
|
* @param \DateTime $updated
|
|
* @return ValidationSession
|
|
*/
|
|
public function setUpdated(\DateTime $updated)
|
|
{
|
|
$this->updated = $updated;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get updated
|
|
*
|
|
* @return \DateTime
|
|
*/
|
|
public function getUpdated()
|
|
{
|
|
return $this->updated;
|
|
}
|
|
|
|
/**
|
|
* Set expires
|
|
*
|
|
* @param \DateTime $expires
|
|
* @return ValidationSession
|
|
*/
|
|
public function setExpires($expires)
|
|
{
|
|
$this->expires = $expires;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get expires
|
|
*
|
|
* @return \DateTime
|
|
*/
|
|
public function getExpires()
|
|
{
|
|
return $this->expires;
|
|
}
|
|
|
|
/**
|
|
* Set basket
|
|
*
|
|
* @param Basket $basket
|
|
* @return ValidationSession
|
|
*/
|
|
public function setBasket(Basket $basket = null)
|
|
{
|
|
$this->basket = $basket;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get basket
|
|
*
|
|
* @return Basket
|
|
*/
|
|
public function getBasket()
|
|
{
|
|
return $this->basket;
|
|
}
|
|
|
|
/**
|
|
* Add participants
|
|
*
|
|
* @param ValidationParticipant $participants
|
|
* @return ValidationSession
|
|
*/
|
|
public function addParticipant(ValidationParticipant $participants)
|
|
{
|
|
$this->participants[] = $participants;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Remove participants
|
|
*
|
|
* @param ValidationParticipant $participants
|
|
*/
|
|
public function removeParticipant(ValidationParticipant $participants)
|
|
{
|
|
$this->participants->removeElement($participants);
|
|
}
|
|
|
|
/**
|
|
* Get participants
|
|
*
|
|
* @return \Doctrine\Common\Collections\Collection
|
|
*/
|
|
public function getParticipants()
|
|
{
|
|
return $this->participants;
|
|
}
|
|
|
|
public function isFinished()
|
|
{
|
|
if (is_null($this->getExpires())) {
|
|
return null;
|
|
}
|
|
|
|
$date_obj = new \DateTime();
|
|
|
|
return $date_obj > $this->getExpires();
|
|
}
|
|
|
|
public function getValidationString(Application $app, \User_Adapter $user)
|
|
{
|
|
|
|
if ($this->isInitiator($user)) {
|
|
if ($this->isFinished()) {
|
|
return $app->trans('Vous aviez envoye cette demande a %n% utilisateurs', ['%n%' => count($this->getParticipants()) - 1]);
|
|
} else {
|
|
return $app->trans('Vous avez envoye cette demande a %n% utilisateurs', ['%n%' => count($this->getParticipants()) - 1]);
|
|
}
|
|
} else {
|
|
if ($this->getParticipant($user, $app)->getCanSeeOthers()) {
|
|
return $app->trans('Processus de validation recu de %user% et concernant %n% utilisateurs', ['%user%' => $this->getInitiator($app)->get_display_name(), '%n%' => count($this->getParticipants()) - 1]);
|
|
} else {
|
|
return $app->trans('Processus de validation recu de %user%', ['%user%' => $this->getInitiator($app)->get_display_name()]);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get a participant
|
|
*
|
|
* @return ValidationParticipant
|
|
*/
|
|
public function getParticipant(\User_Adapter $user, Application $app)
|
|
{
|
|
foreach ($this->getParticipants() as $participant) {
|
|
if ($participant->getUser($app)->get_id() == $user->get_id()) {
|
|
return $participant;
|
|
}
|
|
}
|
|
|
|
throw new NotFoundHttpException('Participant not found ' . $user->get_email());
|
|
}
|
|
}
|