From 1f19366d7f5d2c5cf751488453333aa2fc77ee93 Mon Sep 17 00:00:00 2001 From: Elorfin Date: Wed, 6 Jul 2022 07:35:35 +0200 Subject: [PATCH] [Community] deletes user role on user delete --- .../community/Subscriber/Crud/RoleSubscriber.php | 13 ------------- .../community/Subscriber/Crud/UserSubscriber.php | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/main/community/Subscriber/Crud/RoleSubscriber.php b/src/main/community/Subscriber/Crud/RoleSubscriber.php index 4d18c2517b5..2b5a0b40ca5 100644 --- a/src/main/community/Subscriber/Crud/RoleSubscriber.php +++ b/src/main/community/Subscriber/Crud/RoleSubscriber.php @@ -4,7 +4,6 @@ use Claroline\AppBundle\API\Crud; use Claroline\AppBundle\Event\Crud\CreateEvent; -use Claroline\AppBundle\Event\Crud\DeleteEvent; use Claroline\AppBundle\Event\Crud\PatchEvent; use Claroline\AppBundle\Event\StrictDispatcher; use Claroline\CoreBundle\Entity\AbstractRoleSubject; @@ -45,7 +44,6 @@ public static function getSubscribedEvents(): array Crud::getEventName('create', 'post', Role::class) => 'postCreate', Crud::getEventName('patch', 'pre', Role::class) => 'prePatch', Crud::getEventName('patch', 'post', Role::class) => 'postPatch', - Crud::getEventName('delete', 'pre', Role::class) => 'preDelete', ]; } @@ -111,17 +109,6 @@ public function postCreate(CreateEvent $event) } } - public function preDelete(DeleteEvent $event) - { - /** @var Role $role */ - $role = $event->getObject(); - - if ($role->isReadOnly()) { - // abort delete - $event->block(); - } - } - public function prePatch(PatchEvent $event) { /** @var Role $role */ diff --git a/src/main/community/Subscriber/Crud/UserSubscriber.php b/src/main/community/Subscriber/Crud/UserSubscriber.php index 49728f04e19..271805fe290 100644 --- a/src/main/community/Subscriber/Crud/UserSubscriber.php +++ b/src/main/community/Subscriber/Crud/UserSubscriber.php @@ -250,7 +250,7 @@ public function preDelete(DeleteEvent $event) if ($userRole) { // this would have been better in the postDelete event, but the username has been changed - $this->crud->delete($userRole); + $this->crud->delete($userRole, [Crud::NO_PERMISSIONS]); } }