Commit 7e8e1746 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

[FIX] priorisation de l'utilisateur pour les notifications au président depuis la page dédiée

parent 53bc5cd1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ Journal des modifications
- Ajout de la modalité de formation mixte
- Ajout d'une garde pour éviter les inscriptions répétées
- Changement des notifications envoyées à propos des listes des formations
- [FIX] priorisation de l'utilisateur pour les notifications au président depuis la page dédiée

5.2.3
-----
+9 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Application\Notification;

use Application\Entity\Db\Utilisateur;
use Individu\Entity\Db\Individu;
use These\Entity\Db\Interfaces\TheseAwareTrait;
use Notification\Notification;
@@ -12,6 +13,8 @@ class ValidationDepotTheseCorrigeeNotification extends Notification

    protected $templatePath = 'application/notification/mail/notif-validation-depot-these-corrigee';

    private ?Utilisateur $destinataire = null;

    /**
     * @return static
     */
@@ -19,7 +22,7 @@ class ValidationDepotTheseCorrigeeNotification extends Notification
    {
        /** @var Individu[] $unknownMails */
        $unknownMails = [];
        $to = $this->these->getPresidentJuryEmail($unknownMails);
        $to = $this->destinataire ? $this->destinataire->getEmail() : $this->these->getPresidentJuryEmail($unknownMails);
        $cc = $this->emailBdd;

        $infoMessage = sprintf(
@@ -71,4 +74,9 @@ class ValidationDepotTheseCorrigeeNotification extends Notification

        return $this;
    }

    public function setDestinataire($utilisateur)
    {
        $this->destinataire = $utilisateur;
    }
}
 No newline at end of file
+4 −1
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ class NotifierService extends \Notification\Service\NotifierService
     *
     * @param These $these
     */
    public function triggerValidationDepotTheseCorrigee(These $these)
    public function triggerValidationDepotTheseCorrigee(These $these, ?Utilisateur $utilisateur)
    {
        $targetedUrl = $this->urlHelper->__invoke( 'these/validation-these-corrigee', ['these' => $these->getId()], ['force_canonical' => true]);
        $president = $this->getRoleService()->getRepository()->findByCodeAndEtablissement(Role::CODE_PRESIDENT_JURY, $these->getEtablissement());
@@ -212,6 +212,9 @@ class NotifierService extends \Notification\Service\NotifierService
                'these' => $these,
                'url'   => $url,
            ]);
        if ($utilisateur !== null) {
            $notif->setDestinataire($utilisateur);
        }

        $this->trigger($notif);

+7 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace These\Controller;

use Application\Entity\Db\Utilisateur;
use These\Entity\Db\Acteur;
use Application\Form\AdresseMail\AdresseMailFormAwareTrait;
use These\Service\Acteur\ActeurServiceAwareTrait;
@@ -35,9 +36,14 @@ class PresidentJuryController extends AbstractActionController {
    public function notifierCorrectionAction()
    {
        $president = $this->getActeurService()->getRequestedActeur($this, 'president');
        $utilisateurId = $this->params()->fromQuery('utilisateur');

        if ($utilisateurId) $utilisateur = $this->getActeurService()->getEntityManager()->getRepository(Utilisateur::class)->find($utilisateurId);


        $these = $president->getThese();

        $message = $this->getTheseService()->notifierCorrectionsApportees($these);
        $message = $this->getTheseService()->notifierCorrectionsApportees($these, $utilisateur);
        if ($message[0] === 'success') $this->flashMessenger()->addSuccessMessage($message[1]);
        if ($message[0] === 'error')   $this->flashMessenger()->addErrorMessage($message[1]);

+5 −4
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace These\Service\These;

use Application\Entity\Db\Utilisateur;
use These\Controller\FichierTheseController;
use These\Entity\Db\Acteur;
use These\Entity\Db\Attestation;
@@ -751,7 +752,7 @@ EOS;
     * @param These $these
     * @return array
     */
    public function notifierCorrectionsApportees(These $these)
    public function notifierCorrectionsApportees(These $these, ?Utilisateur $utilisateur = null)
    {
        $president = $these->getPresidentJury();
        if ($president === null) {
@@ -762,10 +763,10 @@ EOS;
        $individu = $president->getIndividu();
        $utilisateurs = $this->getUtilisateurService()->getRepository()->findByIndividu($individu);

        // Notification direct de l'utilisateur déjà existant
        // Notification directe de l'utilisateur déjà existant
        if (!empty($utilisateurs)) {
            $this->getNotifierService()->triggerValidationDepotTheseCorrigee($these);
            return ['success', "Notification des corrections faite à <strong>".current($utilisateurs)->getEmail()."</strong>"];
            $this->getNotifierService()->triggerValidationDepotTheseCorrigee($these, end($utilisateurs));
            return ['success', "Notification des corrections faite à <strong>".end($utilisateurs)->getEmail()."</strong>"];
        }
        else {
            // Recupération du "meilleur" email
Loading