diff --git a/lib/Alchemy/Phrasea/Controller/Prod/PushController.php b/lib/Alchemy/Phrasea/Controller/Prod/PushController.php index 54b52c86ae..c3223f5478 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/PushController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/PushController.php @@ -302,9 +302,12 @@ class PushController extends Controller // we always add the author of the validation request (current user) to the participants // $found = false; - foreach ($participants as $participant) { - if ($participant['usr_id'] === $this->getAuthenticatedUser()->getId()) { + foreach ($participants as $key => $participant) { + if ($Validation->isInitiator($this->getAuthenticatedUser()) && $participant['usr_id'] == $this->getAuthenticatedUser()->getId()) { + // the initiator always can see others + $participants[$key]['see_others'] = 1; $found = true; + break; } } @@ -353,9 +356,14 @@ class PushController extends Controller } // end of sanity check - // if participant already exists, skip insertion + // if participant already exists, just update right try { - $Validation->getParticipant($participantUser); + $validationParticipant = $Validation->getParticipant($participantUser); + $validationParticipant->setCanAgree($participant['agree']); + $validationParticipant->setCanSeeOthers($participant['see_others']); + $manager->persist($validationParticipant); + $manager->flush(); + continue; } catch (NotFoundHttpException $e) { @@ -460,10 +468,17 @@ class PushController extends Controller $this->app->trans('Unknown user %usr_id%', ['%usr_id%' => $userIdToRemove]) ); } - $validationParticipant = $Validation->getParticipant($participantUser); - $Validation->removeParticipant($validationParticipant); - $manager->remove($validationParticipant); + + // if initiator is removed from the user selection, + // do not remove it to the participant list, just set can_agree to false for it + if ($Validation->isInitiator($participantUser)) { + $validationParticipant->setCanAgree(false); + $manager->persist($validationParticipant); + } else { + $Validation->removeParticipant($validationParticipant); + $manager->remove($validationParticipant); + } } } diff --git a/templates/web/prod/actions/Push.html.twig b/templates/web/prod/actions/Push.html.twig index 71e76f37f6..cc2114e5dc 100644 --- a/templates/web/prod/actions/Push.html.twig +++ b/templates/web/prod/actions/Push.html.twig @@ -273,19 +273,19 @@ - + - + - + - +