diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php
index 3a772d878..1e1daead5 100644
--- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php
+++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php
@@ -126,7 +126,7 @@ class ActivityType extends AbstractType
if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) {
$builder->add('socialIssues', HiddenType::class, [
- 'required' => $activityType->getSocialIssuesVisible() === 2
+ 'required' => $activityType->getSocialIssuesVisible() === 2,
]);
$builder->get('socialIssues')
->addModelTransformer(new CallbackTransformer(
@@ -154,7 +154,7 @@ class ActivityType extends AbstractType
if ($activityType->isVisible('socialActions') && $accompanyingPeriod) {
$builder->add('socialActions', HiddenType::class, [
- 'required' => $activityType->getSocialActionsVisible() === 2
+ 'required' => $activityType->getSocialActionsVisible() === 2,
]);
$builder->get('socialActions')
->addModelTransformer(new CallbackTransformer(
@@ -344,8 +344,8 @@ class ActivityType extends AbstractType
if ($activityType->isVisible('location')) {
$builder->add('location', HiddenType::class, [
- 'required' => $activityType->getLocationVisible() === 2
- ])
+ 'required' => $activityType->getLocationVisible() === 2,
+ ])
->get('location')
->addModelTransformer(new CallbackTransformer(
static function (?Location $location): string {
diff --git a/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php
index eca770fe0..3bf1850a4 100644
--- a/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php
+++ b/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php
@@ -41,12 +41,14 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
$period = $parameters['accompanyingCourse'];
if (AccompanyingPeriod::STEP_DRAFT !== $period->getStep()) {
+ /*
$menu->addChild($this->translator->trans('Calendar'), [
'route' => 'chill_calendar_calendar_list',
'routeParameters' => [
'accompanying_period_id' => $period->getId(),
], ])
->setExtras(['order' => 35]);
+ */
}
}
diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php
index 8913951e6..e5324a6cf 100644
--- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php
+++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php
@@ -283,7 +283,7 @@ final class DocGeneratorTemplateController extends AbstractController
}
$datas = $context->getData($template, $entity, $contextGenerationData);
- if ($isTest && $form['show_data']->getData()) {
+ if ($isTest && isset($form) && $form['show_data']->getData()) {
// very ugly hack...
dd($datas);
}
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_notification_include.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_notification_include.html.twig
index 221ddf4b4..558207818 100644
--- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_notification_include.html.twig
+++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_notification_include.html.twig
@@ -1,12 +1,11 @@
+
+ {{ 'workflow_'|trans }}
+
+
-
- {{ 'workflow_'|trans }}
-
- {% include handler.templateTitle(entity_workflow) with handler.templateTitleData(entity_workflow)|merge({
+ {% include handler.template(entity_workflow) with handler.templateData(entity_workflow)|merge({
'description': true,
'breadcrumb': true,
- 'add_classes': 'ms-3 h3'
+ 'add_classes': ''
}) %}
-
-
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php
index 73bd23106..b1022cf4c 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php
@@ -232,7 +232,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
}
if (null !== $this->person && $this->person === $this->personOwner) {
-
$context->buildViolation('You cannot associate a resource with the same person')
->addViolation();
}
diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php
index 929fb2ae0..57be8fecf 100644
--- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php
+++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php
@@ -96,7 +96,19 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
$workflow = $this->registry->get($period, 'accompanying_period_lifecycle');
- if (null !== $period->getClosingDate()) {
+ if ($this->security->isGranted(AccompanyingPeriodVoter::EDIT, $period)) {
+ if ($workflow->can($period, 'close')) {
+ $menu->addChild($this->translator->trans('Close Accompanying Course'), [
+ 'route' => 'chill_person_accompanying_course_close',
+ 'routeParameters' => [
+ 'accompanying_period_id' => $period->getId(),
+ ], ])
+ ->setExtras(['order' => 99999]);
+ }
+ }
+
+ if (null !== $period->getClosingDate()
+ && $this->security->isGranted(AccompanyingPeriodVoter::RE_OPEN_COURSE, $period)) {
$menu->addChild($this->translator->trans('Re-open accompanying course'), [
'route' => 'chill_person_accompanying_course_reopen',
'routeParameters' => [
@@ -104,15 +116,6 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
], ])
->setExtras(['order' => 99998]);
}
-
- if ($workflow->can($period, 'close')) {
- $menu->addChild($this->translator->trans('Close Accompanying Course'), [
- 'route' => 'chill_person_accompanying_course_close',
- 'routeParameters' => [
- 'accompanying_period_id' => $period->getId(),
- ], ])
- ->setExtras(['order' => 99999]);
- }
}
public static function getMenuIds(): array
diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php
index a1166da25..e53d40eee 100644
--- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php
+++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php
@@ -34,12 +34,23 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
self::FULL,
self::TOGGLE_CONFIDENTIAL_ALL,
self::TOGGLE_INTENSITY,
+ self::RE_OPEN_COURSE,
];
public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE';
+ /**
+ * role to DELETE the course.
+ *
+ * Will be true only for the creator, and if the course is still at DRAFT step.
+ */
public const DELETE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_DELETE';
+ /**
+ * role to EDIT the course.
+ *
+ * If the course is closed, it will be always false.
+ */
public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE';
/**
@@ -47,6 +58,14 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
*/
public const FULL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_FULL';
+ /**
+ * Reopen a closed course.
+ *
+ * This forward to the EDIT role, without taking into account that the course
+ * is closed
+ */
+ public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN';
+
public const SEE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE';
/**
@@ -116,6 +135,10 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
if (in_array($attribute, [self::EDIT, self::DELETE], true)) {
return false;
}
+
+ if (self::RE_OPEN_COURSE === $attribute) {
+ return $this->voterHelper->voteOnAttribute(self::EDIT, $subject, $token);
+ }
}
if (AccompanyingPeriod::STEP_DRAFT === $subject->getStep()) {
@@ -131,8 +154,8 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
}
if (in_array($attribute, [
- self::SEE, self::SEE_DETAILS, self::EDIT
- ])) {
+ self::SEE, self::SEE_DETAILS, self::EDIT,
+ ], true)) {
if ($subject->getUser() === $token->getUser()) {
return true;
}
diff --git a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php
index 170f3eb54..47503f052 100644
--- a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php
+++ b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php
@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\TaskBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
+use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Knp\Menu\MenuItem;
use LogicException;
@@ -40,9 +41,11 @@ class MenuBuilder implements LocalMenuBuilderInterface
public function buildAccompanyingCourseMenu($menu, $parameters)
{
+ /** @var AccompanyingPeriod $course */
$course = $parameters['accompanyingCourse'];
- if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) {
+ if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)
+ && AccompanyingPeriod::STEP_DRAFT !== $course->getStep()) {
$menu->addChild(
$this->translator->trans('Tasks'),
[
diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php
index d7efce10c..16260ec97 100644
--- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php
+++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php
@@ -198,7 +198,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
private ?string $email = null;
/**
- * @ORM\Column(name="firstname", type="text", options={"default":""})
+ * @ORM\Column(name="firstname", type="text", options={"default": ""})
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
*/
private string $firstname = '';
diff --git a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php
index e31b950d4..ae91699aa 100644
--- a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php
+++ b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php
@@ -1,5 +1,12 @@
addSql("
+ CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER
+ LANGUAGE plpgsql
+ AS
+ $$
+ BEGIN
+ NEW.canonicalized =
+ UNACCENT(
+ LOWER(
+ NEW.name ||
+ CASE WHEN COALESCE(NEW.name_company, '') <> '' THEN ' ' ELSE '' END ||
+ COALESCE(NEW.name_company, '') ||
+ CASE WHEN COALESCE(NEW.acronym, '') <> '' THEN ' ' ELSE '' END ||
+ COALESCE(NEW.acronym, '')
+ )
+ )
+ ;
+
+ return NEW;
+ END
+ $$
+ ");
+ $this->addSql("
+ UPDATE chill_3party.third_party
+ SET canonicalized =
+ UNACCENT(
+ LOWER(
+ name ||
+ CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END ||
+ COALESCE(name_company, '') ||
+ CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END ||
+ COALESCE(acronym, '')
+ )
+ )
+ ");
+ }
+
public function getDescription(): string
{
return 'indexing of firstname on third parties';
@@ -55,45 +101,5 @@ final class Version20220324175549 extends AbstractMigration
END
$$
");
-
- }
-
- public function down(Schema $schema): void
- {
- $this->addSql("
- CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER
- LANGUAGE plpgsql
- AS
- $$
- BEGIN
- NEW.canonicalized =
- UNACCENT(
- LOWER(
- NEW.name ||
- CASE WHEN COALESCE(NEW.name_company, '') <> '' THEN ' ' ELSE '' END ||
- COALESCE(NEW.name_company, '') ||
- CASE WHEN COALESCE(NEW.acronym, '') <> '' THEN ' ' ELSE '' END ||
- COALESCE(NEW.acronym, '')
- )
- )
- ;
-
- return NEW;
- END
- $$
- ");
- $this->addSql("
- UPDATE chill_3party.third_party
- SET canonicalized =
- UNACCENT(
- LOWER(
- name ||
- CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END ||
- COALESCE(name_company, '') ||
- CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END ||
- COALESCE(acronym, '')
- )
- )
- ");
}
}