adaptations for acl with tasks

This commit is contained in:
2021-10-26 18:05:06 +02:00
parent bae06fcc9c
commit 965ea528e3
22 changed files with 371 additions and 298 deletions

View File

@@ -16,10 +16,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
* AbstractTask
*
* @ORM\MappedSuperclass()
* @UserCircleConsistency(
* "CHILL_TASK_TASK_SHOW",
* getUserFunction="getAssignee"
* )
*/
abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
{
@@ -52,7 +48,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
* @ORM\Column(name="description", type="text")
*/
private $description = '';
/**
*
* @var User
@@ -61,7 +57,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
* )
*/
private $assignee;
/**
*
* @var Person
@@ -78,25 +74,25 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
*/
private $course;
/**
*
* @var Scope
* @ORM\ManyToOne(
* targetEntity="\Chill\MainBundle\Entity\Scope"
* )
* )
*/
private $circle;
/**
* @var boolean
* @ORM\Column(name="closed", type="boolean", options={ "default"=false })
*/
private $closed = false;
public function __construct()
{
}
/**
@@ -125,7 +121,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
/**
* Set currentStates
*
*
* The current states are sorted in a single array, non associative.
*
* @param $currentStates
@@ -141,8 +137,8 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
/**
* Get currentStates
*
* The states are returned as required by marking store format.
*
* The states are returned as required by marking store format.
*
* @return array
*/
@@ -198,7 +194,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
{
return $this->description;
}
public function getAssignee(): ?User
{
return $this->assignee;
@@ -218,7 +214,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
{
return $this->circle;
}
public function setAssignee(User $assignee = null)
{
$this->assignee = $assignee;
@@ -250,9 +246,9 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
} else {
return $this->getCourse()->getCenter();
}
return null;
}
public function getContext()
@@ -264,7 +260,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
// }
return $this->getPerson() ?? $this->getCourse();
}
public function getScope(): ?\Chill\MainBundle\Entity\Scope
{
return $this->getCircle();
@@ -277,9 +273,9 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
{
return $this->closed;
}
/**
*
*
* @param bool $closed
*/
public function setClosed(bool $closed)

View File

@@ -40,12 +40,12 @@ class SingleTask extends AbstractTask
*
* @ORM\Column(name="start_date", type="date", nullable=true)
* @Assert\Date()
*
*
* @Assert\Expression(
* "value === null or this.getEndDate() === null or value < this.getEndDate()",
* message="The start date must be before the end date"
* )
*
*
* @Assert\Expression(
* "value === null or this.getWarningDate() === null or this.getWarningDate() > this.getStartDate()",
* message="The start date must be before warning date"
@@ -66,16 +66,16 @@ class SingleTask extends AbstractTask
* and this.getEndDate() === null
*
* @ORM\Column(name="warning_interval", type="dateinterval", nullable=true)
*
*
* @Assert\Expression(
* "!(value != null and this.getEndDate() == null)",
* message="An end date is required if a warning interval is set"
* )
*
*
*
*
*/
private $warningInterval;
/**
*
* @var RecurringTask
@@ -85,7 +85,7 @@ class SingleTask extends AbstractTask
* )
*/
private $recurringTask;
/**
*
* @var \Doctrine\Common\Collections\Collection
@@ -96,15 +96,15 @@ class SingleTask extends AbstractTask
* )
*/
private $taskPlaceEvents;
public function __construct()
{
$this->taskPlaceEvents = $events = new \Doctrine\Common\Collections\ArrayCollection;
parent::__construct();
}
/**
* Get id
*
@@ -186,13 +186,13 @@ class SingleTask extends AbstractTask
{
return $this->warningInterval;
}
/**
* Get the Warning date, computed from the difference between the
* Get the Warning date, computed from the difference between the
* end date and the warning interval
*
*
* Return null if warningDate or endDate is null
*
*
* @return \DateTimeImmutable
*/
public function getWarningDate()
@@ -200,15 +200,15 @@ class SingleTask extends AbstractTask
if ($this->getWarningInterval() === null) {
return null;
}
if ($this->getEndDate() === null) {
return null;
}
return \DateTimeImmutable::createFromMutable($this->getEndDate())
->sub($this->getWarningInterval());
}
function getRecurringTask(): RecurringTask
{
return $this->recurringTask;
@@ -227,7 +227,7 @@ class SingleTask extends AbstractTask
public function setTaskPlaceEvents(Collection $taskPlaceEvents)
{
$this->taskPlaceEvents = $taskPlaceEvents;
return $this;
}
}