mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix activity rights (WIP)
This commit is contained in:
parent
36e35f2e8f
commit
9978e76a87
@ -20,6 +20,7 @@ use Chill\MainBundle\Entity\User;
|
|||||||
use Chill\MainBundle\Form\Type\ChillCollectionType;
|
use Chill\MainBundle\Form\Type\ChillCollectionType;
|
||||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
use Chill\MainBundle\Form\Type\CommentType;
|
use Chill\MainBundle\Form\Type\CommentType;
|
||||||
|
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||||
use Chill\MainBundle\Form\Type\PrivateCommentType;
|
use Chill\MainBundle\Form\Type\PrivateCommentType;
|
||||||
use Chill\MainBundle\Form\Type\ScopePickerType;
|
use Chill\MainBundle\Form\Type\ScopePickerType;
|
||||||
use Chill\MainBundle\Form\Type\UserPickerType;
|
use Chill\MainBundle\Form\Type\UserPickerType;
|
||||||
@ -219,11 +220,9 @@ class ActivityType extends AbstractType
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($activityType->isVisible('user') && $options['center']) {
|
if ($activityType->isVisible('user') && $options['center']) {
|
||||||
$builder->add('user', UserPickerType::class, [
|
$builder->add('user', PickUserDynamicType::class, [
|
||||||
'label' => $activityType->getLabel('user'),
|
'label' => $activityType->getLabel('user'),
|
||||||
'required' => $activityType->isRequired('user'),
|
'required' => $activityType->isRequired('user'),
|
||||||
'center' => $options['center'],
|
|
||||||
'role' => $options['role'],
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,3 +120,11 @@
|
|||||||
|
|
||||||
{{ form_end(edit_form) }}
|
{{ form_end(edit_form) }}
|
||||||
{# {{ form(delete_form) }} #}
|
{# {{ form(delete_form) }} #}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ encore_entry_script_tags('mod_pickentity_type') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ encore_entry_link_tags('mod_pickentity_type') }}
|
||||||
|
{% endblock %}
|
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
{% include 'ChillActivityBundle:Activity:list.html.twig' with {'context': 'person'} %}
|
{% include 'ChillActivityBundle:Activity:list.html.twig' with {'context': 'person'} %}
|
||||||
|
|
||||||
{% if is_granted('CHILL_ACTIVITY_CREATE_PERSON', person) %}
|
{% if is_granted('CHILL_ACTIVITY_CREATE', person) %}
|
||||||
<ul class="record_actions sticky-form-buttons">
|
<ul class="record_actions sticky-form-buttons">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}"
|
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}"
|
||||||
|
@ -119,3 +119,11 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{{ form_end(form) }}
|
{{ form_end(form) }}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ encore_entry_script_tags('mod_pickentity_type') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ encore_entry_link_tags('mod_pickentity_type') }}
|
||||||
|
{% endblock %}
|
@ -133,7 +133,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
|||||||
|
|
||||||
// change attribute CREATE
|
// change attribute CREATE
|
||||||
if (self::CREATE === $attribute) {
|
if (self::CREATE === $attribute) {
|
||||||
$attribute = self::CREATE_PERSON;
|
return $this->voterHelper->voteOnAttribute(self::CREATE_PERSON, null, $token);
|
||||||
}
|
}
|
||||||
} elseif ($subject->getAccompanyingPeriod() instanceof AccompanyingPeriod) {
|
} elseif ($subject->getAccompanyingPeriod() instanceof AccompanyingPeriod) {
|
||||||
if (!$this->security->isGranted(AccompanyingPeriodVoter::SEE, $subject->getAccompanyingPeriod())) {
|
if (!$this->security->isGranted(AccompanyingPeriodVoter::SEE, $subject->getAccompanyingPeriod())) {
|
||||||
@ -144,7 +144,8 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
|||||||
if (AccompanyingPeriod::STEP_CLOSED === $subject->getAccompanyingPeriod()->getStep()) {
|
if (AccompanyingPeriod::STEP_CLOSED === $subject->getAccompanyingPeriod()->getStep()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$attribute = self::CREATE_ACCOMPANYING_COURSE;
|
|
||||||
|
return $this->voterHelper->voteOnAttribute(self::CREATE_ACCOMPANYING_COURSE, $subject->getAccompanyingPeriod(), $token);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException('Could not determine context of activity.');
|
throw new RuntimeException('Could not determine context of activity.');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user