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

Nouveau template et usage

parent f1557691
Loading
Loading
Loading
Loading
+75 −0
Original line number Diff line number Diff line
# Version 5.2.9

## 1. Sur le serveur d'application

- Placez-vous dans le répertoire de l'application puis lancez la commande suivante
  pour installer la nouvelle version :

```bash
git fetch --tags && git checkout --force 5.2.9 && bash ./install.sh
```

- Selon le moteur PHP que vous avez installé, rechargez le service, exemple :
    - php7.4-fpm         : `service php7.4-fpm reload`
    - apache2-mod-php7.4 : `service apache2 reload`

## 2. Dans la base de données

```sql
-- MACROS --------------------------
INSERT INTO unicaen_renderer_macro (code, description, variable_name, methode_name) VALUES ('Validation#Date', '<p>Retourne la date de la création de la validation au format d/m/Y à H:i</p>', 'validation', 'getDateToString');
INSERT INTO unicaen_renderer_macro (code, description, variable_name, methode_name) VALUES ('Validation#Auteur', '<p>Retour le Displayname de l''auteur de la validation</p>', 'validation', 'getAuteurToString');
INSERT INTO unicaen_renderer_macro (code, description, variable_name, methode_name) VALUES ('Url#SoutenanceProposition', null, 'Url', 'getSoutenanceProposition');
INSERT INTO unicaen_renderer_macro (code, description, variable_name, methode_name) VALUES ('EcoleDoctorale#Libelle', null, 'ecole-doctorale', '__toString');
INSERT INTO unicaen_renderer_macro (code, description, variable_name, methode_name) VALUES ('Etablissement#Libelle', null, 'etablissement', '__toString');
INSERT INTO unicaen_renderer_macro (code, description, variable_name, methode_name) VALUES ('UniteRecherche#Libelle', null, 'unite-recherche', '__toString');

-- TEMPLATES SOUTENANCE --------------------------------------------
INSERT INTO unicaen_renderer_template (code, description, document_type, document_sujet, document_corps, document_css, namespace) 
VALUES (
    'SOUTENANCE_VALIDATION_ANNULEE',
    '<p>Annulation de la validation</p>', 
    'mail',
    'Votre validation de la proposition de soutenance de VAR[Doctorant#Denomination] a été annulée',
    '<p>Bonjour,</p><p>Ceci est un mail envoyé automatiquement par l''application ESUP SyGAL</p><p>Suite à la modification de la proposition de soutenance, votre validation (faite le VAR[Validation#Date]) a été annulée. Si la nouvelle proposition vous convient, veuillez valider la proposition de soutenance à nouveau.<br /><br />Pour consulter, les modifications faites connectez-vous à  ESUP SyGAL et visualisez la proposition de soutenance en utilisant le lien suivant : VAR[Url#SoutenanceProposition].</p><p><span style="text-decoration: underline;">NB :</span> La proposition de soutenance sera envoyée automatiquement à votre unité de recherche puis à votre école doctorale, une fois que tous les intervenants directs auront validé celle-ci (c.-à-d. doctorant, directeur et co-directeur(s)).<br /><br />-- Justification ----------------------------------------------------------------------</p><p>Vous avez reçu ce mail car :</p><ul><li>vous avez validé la proposition de soutenance de VAR[Doctorant#Denomination] ;</li><li>une modification de la proposition a été faite ou demandée.</li></ul>', 
    null, 
    'Soutenance\Provider\Template'
);
INSERT INTO unicaen_renderer_template (code, description, document_type, document_sujet, document_corps, document_css, namespace) 
VALUES (    
    'SOUTENANCE_VALIDATION_ACTEUR_DIRECT',
    '<p>Mail de validation d''une proposition par un des acteurs directs</p>',
    'mail',
    'Une validation de votre proposition de soutenance vient d''être faite',
    '<p>Bonjour,</p><p>Ceci est un mail envoyé automatiquement par l''application ESUP SyGAL.</p><p>VAR[Validation#Auteur] vient de valider la proposition de soutenance de thèse.</p><p><br />Pour consulter cette proposition, connectez-vous à ESUP SyGAL et visualisez la proposition de soutenance en utilisant le lien suivant : VAR[Url#SoutenanceProposition].</p><p><span style="text-decoration: underline;">NB :</span> La proposition de soutenance sera envoyée automatiquement à votre unité de recherche puis à votre école doctorale, une fois que tous les intervenants directs auront validé celle-ci (c.-à-d. doctorant, directeur et co-directeur(s)).</p><p>-- Justification ----------------------------------------------------------------------</p><p>Vous avez reçu ce mail car :</p><ul><li>un des acteurs directs de la thèse de VAR[Doctorant#Denomination] vient de valider la proposition de soutenance  ;</li><li>vous êtes un des acteurs directs de la thèse de VAR[Doctorant#Denomination].</li></ul>',
    null,
    'Soutenance\Provider\Template'
);
INSERT INTO unicaen_renderer_template (code, description, document_type, document_sujet, document_corps, document_css, namespace) VALUES (
     'SOUTENANCE_VALIDATION_DEMANDE_UR',
     null,
     'mail',
     'Demande de validation d''une proposition de la soutenance de VAR[Doctorant#Denomination]',
     '<p>Bonjour,</p><p>Ceci est un mail envoyé automatiquement par l''application ESUP SyGAL.</p><p>Une proposition de soutenance vient d''être faite pour la thèse suivante :</p><table style="width: 473.433px;"><tbody><tr><td style="width: 547px;"><strong>Titre</strong></td><td style="width: 467.433px;">VAR[These#Titre]</td></tr><tr><td style="width: 547px;"><strong>Doctorant·e</strong></td><td style="width: 467.433px;">VAR[Doctorant#Denomination]</td></tr></tbody></table><p>Pour examiner cette proposition et statuer sur celle-ci merci de vous rendre dans l''application ESUP SyGAL : VAR[Url#SoutenanceProposition].<br /><br />-- Justification ----------------------------------------------------------------------</p><p> Vous avez reçu ce mail car :</p><ul><li>tous les acteurs directs de la thèse de VAR[Doctorant#Denomination] ont validé la proposition de soutenance ;</li><li>vous êtes un·e responsable de l''unité de recherche encadrant la thèse.</li></ul>',
     null,
     'Soutenance\Provider\Template'
);
INSERT INTO unicaen_renderer_template (code, description, document_type, document_sujet, document_corps, document_css, namespace) VALUES (
     'SOUTENANCE_VALIDATION_DEMANDE_ED',
     null,
     'mail',
     'Demande de validation d''une proposition de la soutenance de VAR[Doctorant#Denomination]',
     '<p>Bonjour,</p><p>Ceci est un mail envoyé automatiquement par l''application ESUP SyGAL.</p><p>Une proposition de soutenance vient d''être faite pour la thèse suivante :</p><table style="width: 473.433px;"><tbody><tr><td style="width: 547px;"><strong>Titre</strong></td><td style="width: 467.433px;">VAR[These#Titre]</td></tr><tr><td style="width: 547px;"><strong>Doctorant·e</strong></td><td style="width: 467.433px;">VAR[Doctorant#Denomination]</td></tr></tbody></table><p>Pour examiner cette proposition et statuer sur celle-ci merci de vous rendre dans l''application ESUP SyGAL : VAR[Url#SoutenanceProposition].<br /><br />-- Justification ----------------------------------------------------------------------</p><p> Vous avez reçu ce mail car :</p><ul><li>l''unité de recherche de la thèse de VAR[Doctorant#Denomination] ont validé la proposition de soutenance ;</li><li>vous êtes un·e responsable de l''école doctorale encadrant la thèse.</li></ul>',
     null,
     'Soutenance\Provider\Template'
);
INSERT INTO unicaen_renderer_template (code, description, document_type, document_sujet, document_corps, document_css, namespace) VALUES (
   'SOUTENANCE_VALIDATION_DEMANDE_ETAB',
   null,
   'mail',
   'Demande de validation d''une proposition de la soutenance de VAR[Doctorant#Denomination]',
   '<p>Bonjour,</p><p>Ceci est un mail envoyé automatiquement par l''application ESUP SyGAL.</p><p>Une proposition de soutenance vient d''être faite pour la thèse suivante :</p><table style="width: 473.433px;"><tbody><tr><td style="width: 547px;"><strong>Titre</strong></td><td style="width: 467.433px;">VAR[These#Titre]</td></tr><tr><td style="width: 547px;"><strong>Doctorant·e</strong></td><td style="width: 467.433px;">VAR[Doctorant#Denomination]</td></tr></tbody></table><p>Pour examiner cette proposition et statuer sur celle-ci merci de vous rendre dans l''application ESUP SyGAL : VAR[Url#SoutenanceProposition].<br /><br />-- Justification ----------------------------------------------------------------------</p><p> Vous avez reçu ce mail car :</p><ul><li>l''école doctorale de la thèse de VAR[Doctorant#Denomination] ont validé la proposition de soutenance ;</li><li>vous êtes un·e responsable de la maison du doctorat encadrant la thèse.</li></ul>',
   null,
   'Soutenance\Provider\Template'
);
```
 No newline at end of file
+21 −0
Original line number Diff line number Diff line
@@ -162,4 +162,25 @@ class Validation implements HistoriqueAwareInterface, ResourceInterface
    {
        return 'Validation';
    }

    /** Fonction pour les macros du module UnicaenRenderer ************************************************************/

    /**
     * @noinspection
     * @return string
     */
    public function getAuteurToString() : string
    {
        $displayname = $this->getIndividu()->getNomComplet(false, false, false, true);
        return $displayname;
    }
    /**
     * @noinspection
     * @return string
     */
    public function getDateToString() : string
    {
        $date = $this->getHistoCreation()->format('d/m/Y à H:i');
        return $date;
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -6,6 +6,13 @@ class MailTemplates
{
    const TRANSMETTRE_DOCUMENTS_DIRECTION       = "TRANSMETTRE_DOCUMENTS_DIRECTION";

    /** GESTION DES VALIDATIONS ***************************************************************************************/
    const SOUTENANCE_VALIDATION_ANNULEE         = 'SOUTENANCE_VALIDATION_ANNULEE';
    const SOUTENANCE_VALIDATION_ACTEUR_DIRECT   = 'SOUTENANCE_VALIDATION_ACTEUR_DIRECT';
    const SOUTENANCE_VALIDATION_DEMANDE_UR      = 'SOUTENANCE_VALIDATION_DEMANDE_UR';
    const SOUTENANCE_VALIDATION_DEMANDE_ED      = 'SOUTENANCE_VALIDATION_DEMANDE_ED';
    const SOUTENANCE_VALIDATION_DEMANDE_ETAB    = 'SOUTENANCE_VALIDATION_DEMANDE_ETAB';

    /** ENGAGEMENT D'IMPARTIALITE *************************************************************************************/
    const DEMANDE_ENGAGEMENT_IMPARTIALITE       = 'DEMANDE_ENGAGEMENT_IMPARTIALITE';
    const SIGNATURE_ENGAGEMENT_IMPARTIALITE     = 'SIGNATURE_ENGAGEMENT_IMPARTIALITE';
+48 −106
Original line number Diff line number Diff line
@@ -60,29 +60,28 @@ class SoutenanceNotificationFactory extends NotificationFactory
    }

    /**
     * @param These $these
     * @param Validation $validation
     * @return Notification
     * @see Application/view/soutenance/notification/devalidation.phtml
     */
    public function createNotificationDevalidationProposition(Validation $validation): Notification
    public function createNotificationDevalidationProposition(These $these, Validation $validation): Notification
    {
        $mail = $validation->getIndividu()->getEmailPro();
        $these = $validation->getThese();
        $vars = ['these' => $these, 'doctorant' => $these->getDoctorant(), 'validation' => $validation];
        $url = $this->getUrlService()->setVariables($vars);
        $vars['Url'] = $url;

        if (!$mail) {
            throw new RuntimeException("Aucune adresse mail trouvée pour l'individu {$validation->getIndividu()}");
        $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SOUTENANCE_VALIDATION_ANNULEE, $vars);
        $mail = $validation->getIndividu()->getEmailUtilisateur();
        if ($mail === null) {
            throw new RuntimeException("Aucun mail trouvé pour ".$validation->getIndividu()->getNomComplet());
        }

        $notif = new Notification();
        $notif
            ->setSubject("Votre validation de la proposition de soutenance a été annulée")
            ->setSubject($rendu->getSujet())
            ->setTo($mail)
            ->setTemplatePath('soutenance/notification/devalidation')
            ->setTemplateVariables([
                'validation' => $validation,
                'these' => $these,
            ]);

            ->setBody($rendu->getCorps());
        return $notif;
    }

@@ -95,162 +94,105 @@ class SoutenanceNotificationFactory extends NotificationFactory
    public function createNotificationValidationProposition(These $these, Validation $validation): Notification
    {
        $emails = $this->emailTheseService->fetchEmailActeursDirects($these);

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

        if (empty($emails)) {
            throw new RuntimeException("Aucune adresse mail trouvée pour les acteurs directs de la thèse {$these->getId()}");
        }

        $vars = ['these' => $these, 'doctorant' => $these->getDoctorant(), 'validation' => $validation];
        $url = $this->getUrlService()->setVariables($vars);
        $vars['Url'] = $url;

        $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SOUTENANCE_VALIDATION_ACTEUR_DIRECT, $vars);
        $notif = new Notification();
        $notif
            ->setSubject("Une validation de votre proposition de soutenance vient d'être faite")
            ->setSubject($rendu->getSujet())
            ->setTo($emails)
            ->setTemplatePath('soutenance/notification/validation-acteur')
            ->setTemplateVariables([
                'validation' => $validation,
                'these' => $these,
            ]);

            ->setBody($rendu->getCorps());
        return $notif;
    }

    /**
     * @param These $these
     * @return Notification
     * @see Application/view/soutenance/notification/validation-structure.phtml
     */
    public function createNotificationUniteRechercheProposition(These $these): Notification
    {
        $individuRoles = $this->roleService->findIndividuRoleByStructure($these->getUniteRecherche()->getStructure());
        $panic = !($this->emailTheseService->hasEmailsByEtablissement($individuRoles, $these));
        $emails = $this->emailTheseService->fetchEmailsByEtablissement($individuRoles, $these);
        //$emails = $this->emailService->fetchEmailUniteRecherche($these);

        if (!empty($emails)) {
            $notif = new Notification();
            $notif
                ->setSubject("Demande de validation d'une proposition de soutenance")
                ->setTo($emails)
                ->setTemplatePath('soutenance/notification/validation-structure')
                ->setTemplateVariables([
                    'these' => $these,
                    'type' => 'unité de recherche',
                    'panic' => $panic,
                ]);
        if (empty($emails)) {
            throw new RuntimeException("Aucune adresse mail trouvée pour l'unité de recherche de la thèse {$these->getId()}");
        }

            return $notif;
        } else {
            $emailsAdmin = $this->getEmailAdministrateurTechnique();
            $emailsMdd = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these);
            $emails = array_merge($emailsAdmin, $emailsMdd);
        $vars = ['these' => $these, 'doctorant' => $these->getDoctorant(), 'unite-recherche' => $these->getUniteRecherche()];
        $url = $this->getUrlService()->setVariables($vars);
        $vars['Url'] = $url;

        $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SOUTENANCE_VALIDATION_DEMANDE_UR, $vars);
        $notif = new Notification();
        $notif
                ->setSubject("ATTENTION MAIL NON DÉLIVRÉ : Demande de validation d'une proposition de soutenance")
            ->setSubject($rendu->getSujet())
            ->setTo($emails)
                ->setTemplatePath('soutenance/notification/validation-structure')
                ->setTemplateVariables([
                    'these' => $these,
                    'type' => 'unité de recherche',
                    'panic' => true,
                ]);

            ->setBody($rendu->getCorps());
        return $notif;
    }
    }

    /**
     * @param These $these
     * @return Notification
     * @see Application/view/soutenance/notification/validation-structure.phtml
     */
    public function createNotificationEcoleDoctoraleProposition(These $these): Notification
    {
        $individuRoles = $this->roleService->findIndividuRoleByStructure($these->getEcoleDoctorale()->getStructure());
        $panic = !($this->emailTheseService->hasEmailsByEtablissement($individuRoles, $these));
        $emails = $this->emailTheseService->fetchEmailsByEtablissement($individuRoles, $these);
        //$emails = $this->emailService->fetchEmailEcoleDoctorale($these);

        if (!empty($emails)) {
            $notif = new Notification();
            $notif
                ->setSubject("Demande de validation d'une proposition de soutenance")
                ->setTo($emails)
                ->setTemplatePath('soutenance/notification/validation-structure')
                ->setTemplateVariables([
                    'these' => $these,
                    'type' => 'école doctorale',
                    'panic' => $panic,
                ]);
        if (empty($emails)) {
            throw new RuntimeException("Aucune adresse mail trouvée pour l'école doctorale de la thèse {$these->getId()}");
        }

            return $notif;
        } else {
            $emailsAdmin = $this->getEmailAdministrateurTechnique();
            $emailsMdd = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these);
            $emails = array_merge($emailsAdmin, $emailsMdd);
        $vars = ['these' => $these, 'doctorant' => $these->getDoctorant(), 'ecole-doctorale' => $these->getEcoleDoctorale()];
        $url = $this->getUrlService()->setVariables($vars);
        $vars['Url'] = $url;

        $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SOUTENANCE_VALIDATION_DEMANDE_ED, $vars);
        $notif = new Notification();
        $notif
                ->setSubject("ATTENTION MAIL NON DÉLIVRÉ : Demande de validation d'une proposition de soutenance")
            ->setSubject($rendu->getSujet())
            ->setTo($emails)
                ->setTemplatePath('soutenance/notification/validation-structure')
                ->setTemplateVariables([
                    'these' => $these,
                    'type' => 'école doctorale',
                    'panic' => true,
                ]);

            ->setBody($rendu->getCorps());
        return $notif;
    }
    }

    /**
     * @param These $these
     * @return Notification
     * @see Application/view/soutenance/notification/validation-structure.phtml
     */
    public function createNotificationBureauDesDoctoratsProposition(These $these): Notification
    {
        $email = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these);
        $emails = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these);

        if ($email !== null) {
            $notif = new Notification();
            $notif
                ->setSubject("Demande de validation d'une proposition de soutenance")
                ->setTo($email)
                ->setTemplatePath('soutenance/notification/validation-structure')
                ->setTemplateVariables([
                    'these' => $these,
                    'type' => 'maison du doctorat',
                    'panic' => false,
                ]);
        if (empty($emails)) {
            throw new RuntimeException("Aucune adresse mail trouvée pour la maison du doctorat de la thèse {$these->getId()}");
        }

            return $notif;
        } else {
            $emailsAdmin = $this->getEmailAdministrateurTechnique();
            $emailsMdd = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these);
            $emails = array_merge($emailsAdmin, $emailsMdd);
        $vars = ['these' => $these, 'doctorant' => $these->getDoctorant(), 'etablissement' => $these->getEtablissement()];
        $url = $this->getUrlService()->setVariables($vars);
        $vars['Url'] = $url;

        $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SOUTENANCE_VALIDATION_DEMANDE_ETAB, $vars);
        $notif = new Notification();
        $notif
                ->setSubject("ATTENTION MAIL NON DÉLIVRÉ : Demande de validation d'une proposition de soutenance")
                ->setTo($email)
                ->setTemplatePath('soutenance/notification/validation-structure')
                ->setTemplateVariables([
                    'these' => $these,
                    'type' => 'maison du doctorat',
                    'panic' => true,
                ]);

            ->setSubject($rendu->getSujet())
            ->setTo($emails)
            ->setBody($rendu->getCorps());
        return $notif;
    }
    }

    /**
     * @param \These\Entity\Db\These $these
     * @param These $these
     * @return Notification
     */
    public function createNotificationPropositionValidee(These $these): Notification
+4 −4
Original line number Diff line number Diff line
@@ -231,7 +231,7 @@ class PropositionService extends BaseService
        foreach ($validations as $validation) {
            $this->getValidationService()->historise($validation);
            try {
                $notif = $this->soutenanceNotificationFactory->createNotificationDevalidationProposition($validation);
                $notif = $this->soutenanceNotificationFactory->createNotificationDevalidationProposition($these, $validation);
                $this->notifierService->trigger($notif);
            } catch (\Notification\Exception\RuntimeException $e) {
                // aucun destinataire, todo : cas à gérer !
@@ -241,7 +241,7 @@ class PropositionService extends BaseService
        if ($validationED) {
            $this->getValidationService()->historise($validationED);
            try {
                $notif = $this->soutenanceNotificationFactory->createNotificationDevalidationProposition($validationED);
                $notif = $this->soutenanceNotificationFactory->createNotificationDevalidationProposition($these, $validationED);
                $this->notifierService->trigger($notif);
            } catch (\Notification\Exception\RuntimeException $e) {
                // aucun destinataire, todo : cas à gérer !
@@ -251,7 +251,7 @@ class PropositionService extends BaseService
        if ($validationUR) {
            $this->getValidationService()->historise($validationUR);
            try {
                $notif = $this->soutenanceNotificationFactory->createNotificationDevalidationProposition($validationUR);
                $notif = $this->soutenanceNotificationFactory->createNotificationDevalidationProposition($these, $validationUR);
                $this->notifierService->trigger($notif);
            } catch (\Notification\Exception\RuntimeException $e) {
                // aucun destinataire, todo : cas à gérer !
@@ -261,7 +261,7 @@ class PropositionService extends BaseService
        if ($validationBDD) {
            $this->getValidationService()->historise($validationBDD);
            try {
                $notif = $this->soutenanceNotificationFactory->createNotificationDevalidationProposition($validationBDD);
                $notif = $this->soutenanceNotificationFactory->createNotificationDevalidationProposition($these, $validationBDD);
                $this->notifierService->trigger($notif);
            } catch (\Notification\Exception\RuntimeException $e) {
                // aucun destinataire, todo : cas à gérer !
Loading