Commit 5f2283fe authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Utilisation de unicaen-renderer pour les mails liés à l'engagement d'impartialité

parent cfaed70e
Loading
Loading
Loading
Loading
+41 −0
Changes for doc/release-notes/v5.2.9.md: 41 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -20,9 +20,50 @@ git fetch --tags && git checkout --force 5.2.9 && bash ./install.sh
alter table unicaen_renderer_template  add namespace varchar(256);

-- MACROS --------------------------
INSERT INTO unicaen_renderer_macro (code, description, variable_name, methode_name) VALUES ('These#Titre', null, 'these', 'getTitre');
INSERT INTO unicaen_renderer_macro (code, description, variable_name, methode_name) VALUES ('Url#RapporteurDashboard', '<p>Fourni l''url vers le darshboard du rapporteur passé en variable</p>', 'Url', 'getUrlRapporteurDashboard');


-- TEMPLATES -----------------------
INSERT INTO unicaen_renderer_template (code, description, document_type, document_sujet, document_corps, document_css, namespace) VALUES ('DEMANDE_ENGAGEMENT_IMPARTIALITE', '<p>Courrier électronique notifiant un·e futur·e rapporteur·e pour la signature de l''engagement d''impartialité.<br />Envoyé lors de l''appariement membre/acteur</p>', 'mail', 'Demande de signature de l''engagement d''impartialité de la thèse de VAR[Doctorant#Denomination]', '<p>-- Version française ---------------------------------------------------------------</p>
<p>Bonjour,</p>
<p>Afin de pouvoir devenir rapporteur de la thèse de <strong>VAR[Doctorant#Denomination]</strong> intitulée <strong>VAR[These#Titre]</strong>, il est nécessaire de signer électroniquement l\'engagement d\'impartialité dans l\'application <em>ESUP-SyGAL</em> :<strong> VAR[Url#RapporteurDashboard]</strong>.<br /><br />Vous accéderez ainsi à une page "index de la soutenance" listant les membres du jury.<br />Cliquez ensuite sur "accès à l’engagement d’impartialité".<br />Puis après avoir pris connaissance des conditions relatives à cet engagement, vous pourrez signer ou non cet engagement d’impartialité.<br />Si vous signez, vous pourrez alors télécharger le PDF du manuscrit de thèse.</p>
<p>Cordialement<br /><br />-- English version ------------------------------------------------------------------<br /><br />Dear Mrs/Mr,</p>
<p>Before being officially registered as an external referee for the PhD thesis presented by <strong>VAR[Doctorant#Denomination]</strong> entitled <strong>VAR[These#Titre]</strong>, you have to sign the "impartiality commitment" available in your dashborad : <strong>VAR[Url#RapporteurDashboard]</strong>.<br /><br />You will then be connected to a web page entitled "index of the PhD defense" listing the PhD jury members.<br />Click then on "access to the impartiality commitment".<br />Then, after reading the requirements regarding the impartiality commitment of an external referee, you sign it or not.<br />If you sign it, you will be able to download the PDF version of the PhD manuscript.</p>
<p>Best regards,</p>
<p>-- Justification ----------------------------------------------------------------------<br /><br />Vous avez reçu ce mail car :</p>
<ul>
<li>vous avez été désigné rapporteur pour la thèse de VAR[Doctorant#Denomination]</li>
<li>la signature a été annulée<br /><br /></li>
</ul>', null, 'Soutenance\Provider\Template');
INSERT INTO public.unicaen_renderer_template (code, description, document_type, document_sujet, document_corps, document_css, namespace) VALUES ('SIGNATURE_ENGAGEMENT_IMPARTIALITE', '<p>Courrier électronique envoyé vers les maisons du doctorat lors de la signature de l''engagement d''impartialité par un rapporteur</p>', 'mail', 'Signature de l''engagement d''impartialité de la thèse de VAR[Doctorant#Denomination] par VAR[Membre#Denomination]', e'<p>Bonjour,</p>
<p><strong>VAR[Membre#Denomination]</strong> vient de signer l\'engagement d\'impartialité de la thèse de <strong>VAR[Doctorant#Denomination]</strong> intitulée <strong>VAR[These#Titre]</strong>.</p>
<p>-- Justification ----------------------------------------------------------------------<br /><br />Vous avez reçu ce mail car :</p>
<ul>
<li>le rapporteur VAR[Membre#Denomination] vient de signer l\'engagement d\'impartialité; </li>
<li>vous êtes un gestionnaire de la maison du doctorat de l\'établissement d\'inscription du doctorant . <br /><br /></li>
</ul>', null, 'Soutenance\Provider\Template');
INSERT INTO public.unicaen_renderer_template (code, description, document_type, document_sujet, document_corps, document_css, namespace) VALUES ('REFUS_ENGAGEMENT_IMPARTIALITE', '<p>Courrier électronique envoyé lors du refus de l''engagement d''impartialité</p>', 'mail', 'Refus de l''engagement d''impartialité de la thèse de VAR[Doctorant#Denomination] par VAR[Membre#Denomination]', e'<p>Bonjour,</p>
<p><strong>VAR[Membre#Denomination]</strong> vient de refuser l\'engagement d\'impartialité de la thèse de <strong>VAR[Doctorant#Denomination]</strong> intitulée <strong>VAR[These#Titre]</strong>.</p>
<p>-- Justification ----------------------------------------------------------------------</p>
<p>Vous avez reçu ce mail car :</p>
<ul>
<li>le rapporteur VAR[Membre#Denomination] vient de refuser de signer l\'engagement d\'impartialité;</li>
<li>vous êtes :
<ul>
<li>soit un des acteurs directs de la thèse de VAR[Doctorant#Denomination],</li>
<li>soit un gestionnaire de la maison du doctorat de l\'établissement d\'inscription du doctorant.<br />            <br /><br /></li>
</ul>
</li>
</ul>', null, 'Soutenance\Provider\Template');
INSERT INTO public.unicaen_renderer_template (code, description, document_type, document_sujet, document_corps, document_css, namespace) VALUES ('ANNULATION_ENGAGEMENT_IMPARTIALITE', '<p>Courrier électronique envoyé lors de l''annulation d''un engagement d''impartialité</p>', 'mail', 'Annulation de la signature de l''engagement d''impartialité de VAR[Membre#Denomination] pour la thèse de VAR[Doctorant#Denomination]', e'<p>Bonjour,</p>
<p><br />Votre signature de l\'engagement d\'impartialité de la thèse de <strong>VAR[Doctorant#Denomination]</strong> intitulée <strong>VAR[These#Titre]</strong> vient d\'être annulée.</p>
<p>-- Justification ----------------------------------------------------------------------</p>
<p>Vous avez reçu ce mail car :</p>
<ul>
<li>vous avez signé l\'engagement d\'impartialité pour la thèse de VAR[Doctorant#Denomination];  </li>
<li>la signature a été annulée. </li>
</ul>', null, 'Soutenance\Provider\Template');


```
 No newline at end of file
+3 −3
Changes for module/Soutenance/src/Soutenance/Controller/EngagementImpartialiteController.php: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ class EngagementImpartialiteController extends AbstractController
        if ($signature === null) {
            $this->getEngagementImpartialiteService()->create($membre, $these);
            try {
                $notif = $this->soutenanceNotificationFactory->createNotificationSignatureEngagementImpartialite($these, $proposition, $membre);
                $notif = $this->soutenanceNotificationFactory->createNotificationSignatureEngagementImpartialite($these, $membre);
                $this->notifierService->trigger($notif);
            } catch (RuntimeException $e) {
                // aucun destintaire, todo : cas à gérer !
@@ -140,7 +140,7 @@ class EngagementImpartialiteController extends AbstractController
        $this->getEngagementImpartialiteService()->createRefus($membre, $these);
        $this->getPropositionService()->annulerValidationsForProposition($proposition);
        try {
            $notif = $this->soutenanceNotificationFactory->createNotificationRefusEngagementImpartialite($these, $proposition, $membre);
            $notif = $this->soutenanceNotificationFactory->createNotificationRefusEngagementImpartialite($these, $membre);
            $this->notifierService->trigger($notif);
        } catch (RuntimeException $e) {
            // aucun destintaire, todo : cas à gérer !
@@ -159,7 +159,7 @@ class EngagementImpartialiteController extends AbstractController
        /** @var Validation[] $validations */
        $this->getEngagementImpartialiteService()->delete($membre);
        try {
            $notif = $this->soutenanceNotificationFactory->createNotificationAnnulationEngagementImpartialite($these, $proposition, $membre);
            $notif = $this->soutenanceNotificationFactory->createNotificationAnnulationEngagementImpartialite($these, $membre);
            $this->notifierService->trigger($notif);
        } catch (RuntimeException $e) {
            // aucun destintaire, todo : cas à gérer !
+3 −0
Changes for module/Soutenance/src/Soutenance/Provider/Template/MailTemplates.php: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -8,4 +8,7 @@ class MailTemplates

    /** ENGAGEMENT D'IMPARTIALITE *************************************************************************************/
    const DEMANDE_ENGAGEMENT_IMPARTIALITE       = 'DEMANDE_ENGAGEMENT_IMPARTIALITE';
    const SIGNATURE_ENGAGEMENT_IMPARTIALITE     = 'SIGNATURE_ENGAGEMENT_IMPARTIALITE';
    const REFUS_ENGAGEMENT_IMPARTIALITE         = 'REFUS_ENGAGEMENT_IMPARTIALITE';
    const ANNULATION_ENGAGEMENT_IMPARTIALITE    = 'ANNULATION_ENGAGEMENT_IMPARTIALITE';
}
 No newline at end of file
+49 −81
Changes for module/Soutenance/src/Soutenance/Service/Notification/SoutenanceNotificationFactory.php: 49 added lines, 81 removed lines.
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ class SoutenanceNotificationFactory extends NotificationFactory

    /**
     * @param Validation $validation
     * @return \Notification\Notification
     * @return Notification
     * @see Application/view/soutenance/notification/devalidation.phtml
     */
    public function createNotificationDevalidationProposition(Validation $validation): Notification
@@ -89,7 +89,7 @@ class SoutenanceNotificationFactory extends NotificationFactory
    /**
     * @param These $these
     * @param Validation $validation
     * @return \Notification\Notification
     * @return Notification
     * @see Application/view/soutenance/notification/validation-acteur.phtml
     */
    public function createNotificationValidationProposition(These $these, Validation $validation): Notification
@@ -119,7 +119,7 @@ class SoutenanceNotificationFactory extends NotificationFactory

    /**
     * @param These $these
     * @return \Notification\Notification
     * @return Notification
     * @see Application/view/soutenance/notification/validation-structure.phtml
     */
    public function createNotificationUniteRechercheProposition(These $these): Notification
@@ -164,7 +164,7 @@ class SoutenanceNotificationFactory extends NotificationFactory

    /**
     * @param These $these
     * @return \Notification\Notification
     * @return Notification
     * @see Application/view/soutenance/notification/validation-structure.phtml
     */
    public function createNotificationEcoleDoctoraleProposition(These $these): Notification
@@ -209,7 +209,7 @@ class SoutenanceNotificationFactory extends NotificationFactory

    /**
     * @param These $these
     * @return \Notification\Notification
     * @return Notification
     * @see Application/view/soutenance/notification/validation-structure.phtml
     */
    public function createNotificationBureauDesDoctoratsProposition(These $these): Notification
@@ -251,7 +251,7 @@ class SoutenanceNotificationFactory extends NotificationFactory

    /**
     * @param \These\Entity\Db\These $these
     * @return \Notification\Notification
     * @return Notification
     */
    public function createNotificationPropositionValidee(These $these): Notification
    {
@@ -283,7 +283,7 @@ class SoutenanceNotificationFactory extends NotificationFactory

    /**
     * @param $these
     * @return \Notification\Notification
     * @return Notification
     */
    public function createNotificationPresoutenance($these): Notification
    {
@@ -310,7 +310,7 @@ class SoutenanceNotificationFactory extends NotificationFactory
     * @param Individu $currentUser
     * @param RoleInterface $currentRole
     * @param string $motif
     * @return \Notification\Notification
     * @return Notification
     */
    public function createNotificationRefusPropositionSoutenance($these, $currentUser, $currentRole, $motif): Notification
    {
@@ -343,11 +343,6 @@ class SoutenanceNotificationFactory extends NotificationFactory

    /** ENGAGEMENT IMPARTIALITE ***************************************************************************************/

    /**
     * @param These $these
     * @param Membre $membre
     * @return \Notification\Notification
     */
    public function createNotificationDemandeSignatureEngagementImpartialite(These $these, Membre $membre): Notification
    {
        $vars = ['these' => $these, 'doctorant' => $these->getDoctorant(), 'rapporteur' => $membre];
@@ -365,98 +360,71 @@ class SoutenanceNotificationFactory extends NotificationFactory
            ->setSubject($rendu->getSujet())
            ->setTo($mail)
            ->setBody($rendu->getCorps());

        return $notif;
    }

    /**
     * @param These $these
     * @param Proposition $proposition
     * @param Membre $membre
     */
    public function createNotificationSignatureEngagementImpartialite($these, $proposition, $membre): Notification
    public function createNotificationSignatureEngagementImpartialite(These $these, Membre $membre): Notification
    {
        $vars = ['these' => $these, 'doctorant' => $these->getDoctorant(), 'membre' => $membre];
        $url = $this->getUrlService()->setVariables($vars);
        $vars['Url'] = $url;

        $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SIGNATURE_ENGAGEMENT_IMPARTIALITE, $vars);
        $email = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these);
        if (empty($email)) {
            throw new RuntimeException("Aucun mail trouvé pour la maison du doctorat de ". $these->getEtablissement()->getStructure()->getLibelle());
        }

        if ($email !== null) {
        $notif = new Notification();
        $notif
                ->setSubject("Signature de l'engagement d'impartialité de la thèse de " . $these->getDoctorant()->getIndividu())
            ->setSubject($rendu->getSujet())
            ->setTo($email)
                ->setTemplatePath('soutenance/notification/engagement-impartialite-signature')
                ->setTemplateVariables([
                    'these' => $these,
                    'proposition' => $proposition,
                    'membre' => $membre,
                ]);

            ->setBody($rendu->getCorps());
        return $notif;
        } else {
            throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")");
        }

    }

    /**
     * @param These $these
     * @param Proposition $proposition
     * @param Membre $membre
     */
    public function createNotificationRefusEngagementImpartialite($these, $proposition, $membre): Notification
    public function createNotificationRefusEngagementImpartialite(These $these, Membre $membre): Notification
    {
        $vars = ['these' => $these, 'doctorant' => $these->getDoctorant(), 'membre' => $membre];
        $url = $this->getUrlService()->setVariables($vars);
        $vars['Url'] = $url;

        $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::REFUS_ENGAGEMENT_IMPARTIALITE, $vars);

        $emailsAD = $this->emailTheseService->fetchEmailActeursDirects($these);
        $emailsBDD = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these);
        $emails = array_merge($emailsAD, $emailsBDD);
        if (empty($emails)) {
            throw new RuntimeException("Aucun mail trouvé");
        }

        $emails = array_filter($emails, function ($s) {
            return $s !== null;
        });

        if (!empty($emails)) {
        $notif = new Notification();
        $notif
                ->setSubject("Refus de l'engagement d'impartialité de la thèse de " . $these->getDoctorant()->getIndividu())
            ->setSubject($rendu->getSujet())
            ->setTo($emails)
                ->setTemplatePath('soutenance/notification/engagement-impartialite-refus')
                ->setTemplateVariables([
                    'these' => $these,
                    'proposition' => $proposition,
                    'membre' => $membre,
                ]);

            ->setBody($rendu->getCorps());
        return $notif;
        } else {
            throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")");
    }

    }

    /**
     * @param These $these
     * @param Proposition $proposition
     * @param Membre $membre
     */
    public function createNotificationAnnulationEngagementImpartialite($these, $proposition, $membre): Notification
    public function createNotificationAnnulationEngagementImpartialite(These $these, Membre $membre): Notification
    {
        $email = $membre->getEmail();
        $vars = ['these' => $these, 'doctorant' => $these->getDoctorant(), 'membre' => $membre];
        $url = $this->getUrlService()->setVariables($vars);
        $vars['Url'] = $url;

        if ($email) {
            $notif = new Notification();
            $notif
                ->setSubject("Annulation de la signature de l'engagement d'impartialité de la thèse de " . $these->getDoctorant()->getIndividu())
                ->setTo($email)
                ->setTemplatePath('soutenance/notification/engagement-impartialite-annulation')
                ->setTemplateVariables([
                    'these' => $these,
                    'proposition' => $proposition,
                    'membre' => $membre,
                ]);
        $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::ANNULATION_ENGAGEMENT_IMPARTIALITE, $vars);

            return $notif;
        } else {
            throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")");
        $mail = $membre->getEmail();
        if ($mail === null) {
            throw new RuntimeException("Aucun mail trouvé pour le rapporteur");
        }

        $notif = new Notification();
        $notif
            ->setSubject($rendu->getSujet())
            ->setTo($mail)
            ->setBody($rendu->getCorps());
        return $notif;
    }


@@ -565,7 +533,7 @@ class SoutenanceNotificationFactory extends NotificationFactory
     * @param Proposition $proposition
     * @param Membre $rapporteur
     * @param string $url
     * @return \Notification\Notification
     * @return Notification
     */
    public function createNotificationDemandeAvisSoutenance(These $these, Proposition $proposition, Membre $rapporteur, string $url): Notification
    {
@@ -660,7 +628,7 @@ class SoutenanceNotificationFactory extends NotificationFactory
     * @param Proposition $proposition
     * @param Utilisateur $user
     * @param string $url
     * @return \Notification\Notification
     * @return Notification
     */
    public function createNotificationConnexionRapporteur(Proposition $proposition, Utilisateur $user, string $url): Notification
    {
@@ -732,7 +700,7 @@ class SoutenanceNotificationFactory extends NotificationFactory
     * @param string $email
     * @param string $url
     * @param array $avisArray
     * @return \Notification\Notification
     * @return Notification
     */
    public function createNotificationEnvoiConvocationDoctorant(Doctorant $doctorant, Proposition $proposition, DateTime $date, string $email, string $url, array $avisArray): Notification
    {
@@ -766,7 +734,7 @@ class SoutenanceNotificationFactory extends NotificationFactory
     * @param string $email
     * @param string $url
     * @param array $avisArray
     * @return \Notification\Notification
     * @return Notification
     */
    public function createNotificationEnvoiConvocationMembre(Membre $membre, Proposition $proposition, DateTime $date, string $email, string $url, array $avisArray): Notification
    {
+0 −35
Changes for module/Soutenance/view/soutenance/notification/engagement-impartialite-annulation.phtml: 0 added lines, 35 removed lines.
Original line number Diff line number Diff line
<?php

use These\Entity\Db\These;
use Soutenance\Entity\Membre;
use Soutenance\Entity\Proposition;

/**
 * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationAnnulationEngagementImpartialite()
 * @var These $these
 * @var Proposition $proposition
 * @var Membre $membre
 */

$justification = true;

?>

<p>
    Bonjour,
</p>
<p>
    Votre signature de l'engagement d'impartialité de la thèse de
    <strong><?php echo $these->getDoctorant()->getNomComplet(); ?></strong> intitulée
    <strong><?php echo $these->getTitre(); ?></strong> vient d'être annulée.
</p>

<?php if ($justification) : ?>
<p>
    Vous avez reçu ce mail car :
    <ol>
        <li> vous avez signé l'engagement d'impartialité pour la thèse de <?php echo $these->getDoctorant()->getIndividu()->getNomComplet(); ?>;  </li>
        <li> la signature a été annulée. </li>
    </ol>
</p>
<?php endif; ?>
 No newline at end of file
Loading