diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d6675e3b20347131eca9ed36aa18e7a949f2bb7..6bf2e67c833b44e059c4efdb831c2006ff248cf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,19 @@ Journal des modifications ========================= +5.2.8 +----- +- Second dépôt (correction de thèse) : améliorations et nouvelle notification (MDD, BU, DT). +- Fiche Thèse : bouton usurper pour le rôle Président du jury +- Ajout du bouton de transmission des documents de soutenance à la direction de thèse +- Les co-encadrants sont maintenant des individus et non plus nécessairement des acteurs +- Notifications par mail : utilisation généralisée de factories de notifications +- [FIX] Module formation : récupération du doctorant via l'utilisateur si aucun n'est fourni +- [FIX] Filtres de recherche réutilisables : nouvelle stratégie de prise en compte ou non des filtres. +- [FIX] Changement des fonctions de récupération des emails dans la partie exportation +- [FIX] Correction De la taille des logos dans le serment du docteur +- [FIX] Correction de la fonction getDoctorantsByUser + 5.2.7 ----- - Ajout d'une date de fermeture (indicative) pour les sessions de formation diff --git a/data/assertions/README.md b/data/assertions/README.md deleted file mode 100644 index 4a60d0f62aaaa7f3957b6a5c1a1e7f0710b2fc52..0000000000000000000000000000000000000000 --- a/data/assertions/README.md +++ /dev/null @@ -1,115 +0,0 @@ -# Fonctionnement du fichier CSV - -## Interprétation - -- La ligne 1 désigne la classe d'assertion qui sera générée à partir du fichier CSV. -Par exemple, `class;Depot\Assertion\These\GeneratedTheseEntityAssertion` pour la classe `GeneratedTheseEntityAssertion`. - -- La ligne 2 liste des prédicats qui peuvent être utilisés et qui doivent être définis dans la -classe mère `TheseEntityAssertion`. - -- La colonne A correspond à des références de lignes qui seront inscrites dans le PHP généré sous -la forme `/* line N */`. - -- La colonne B correspond aux témoins indiquant si la ligne concernée doit être prise en compte (valeur `1`) -ou non (valeur `0`). - -- La colonne C correspond aux privilèges concernés (FQDN de la constante PHP). - -- Les colonnes suivantes `isXxxxxx` permettent de lister les prédicats (méthodes `isXxxxxx()` de la classe d'assertion -spécifiée en ligne 1) et de spécifier comment chacun est utilisé en fonction du privilège concerné. - -- La colonne `return` contient la valeur que retournera l'assertion à l'issue des interrogations des prédicats. - -- Chaque ligne faisant référence à un privilège générera un `if` dans l'assertion générée. -Si un même privilège figure 3 fois, 3 `if` seront générés. - -### Exemple d'interprétation - -|line|enabled| privilege | isRoleDoctorantSelected | isTheseEnCours | isTheseSoutenue | isUtilisateurEstAuteurDeLaThese |...| return | -|----|-------|-------------------------------|-------------------------|----------------|-----------------|---------------------------------|---|--------| -|... | | | | | | | | | -|4 |1 |THESE_DEPOT_VERSION_INITIALE | | 1:0 | | |...| 0 | -|5 |1 |THESE_DEPOT_VERSION_INITIALE | | | 1:1 | |...| 0 | -|6 |1 |THESE_DEPOT_VERSION_INITIALE | | | | |...| 1 | -|... | | | | | | | | | -|10 |1 |DOCTORANT_AFFICHER_MAIL_CONTACT| 1:1 | | | 2:1 |...| 0 | -|11 |1 |DOCTORANT_AFFICHER_MAIL_CONTACT| | | | |...| 1 | - -#### Privilège `THESE_DEPOT_VERSION_INITIALE` - -- Line 4 : - - La cellule au croisement du privilège `THESE_DEPOT_VERSION_INITIALE` et du prédicat `isTheseEnCours` vaut `1:0`. - - La cellule dans la colonne `return` mentionne un `0`. - - Cela s'interprète : "Si `isTheseEnCours` est faux (`:0`) alors l'assertion retourne faux (`0`)". - -- Line 5 : - - La cellule au croisement de `THESE_DEPOT_VERSION_INITIALE` et de `isTheseSoutenue` vaut `1:1`. - - La cellule dans la colonne `return` mentionne un `0`. - - Cela s'interprète : "Si `isTheseSoutenue` est vrai (`:1`) alors l'assertion retourne faux (`0`)". - -- Line 6 : - - La ligne ne spécifie aucune valeur en face des prédicats et un `1` dans la colonne `return`. - - La cellule dans la colonne `return` mentionne un `1`. - - Cela s'interprète : "Sinon, l'assertion retourne vrai (`1`)". - -Voici le PHP que ces 3 lignes généreraient dans la classe d'assertion : - -```php -if ($privilege === \Depot\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE) { - //-------------------------------------------------------------------------------------- - /* line 4 */ - $this->linesTrace[] = '/* line 4 */'; - if (! $this->isTheseEnCours()) { - $this->failureMessage = "L’état de la thèse ne permet pas cette opération."; - return false; - } - /* line 5 */ - $this->linesTrace[] = '/* line 5 */'; - if ($this->isTheseSoutenue()) { - $this->failureMessage = "Le dépôt initial n'est plus autorisé car la date de soutenance est passée."; - return false; - } - /* line 6 */ - $this->linesTrace[] = '/* line 6 */'; - return true; - } -``` - -#### Privilège `DOCTORANT_AFFICHER_MAIL_CONTACT` - -Ici, dans les valeurs `1:1` et `2:1`, le chiffre avant `:` spécifie l'ordre d'utilisation du prédicat -concerné : le prédicat `isRoleDoctorantSelected` est testé en 1er, puis `isUtilisateurEstAuteurDeLaThese` en 2e. - -Voici le PHP que ces 2 lignes généreraient dans la classe d'assertion : - - ```php -if ($privilege === \Doctorant\Provider\Privilege\DoctorantPrivileges::DOCTORANT_AFFICHER_EMAIL_CONTACT) { - //-------------------------------------------------------------------------------------- - /* line 10 */ - $this->linesTrace[] = '/* line 10 */'; - if ($this->isRoleDoctorantSelected() && ! $this->isUtilisateurEstAuteurDeLaThese()) { - $this->failureMessage = "Vous ne pouvez pas visualiser l’adresse de contact car vous n’êtes pas l’auteur de la thèse"; - return false; - } - /* line 11 */ - $this->linesTrace[] = '/* line 11 */'; - return true; - } -``` - - -## Ajouter une nouvelle assertion - -***TODO*** - -## Générer le nouveau ficher assertion - -Une fois les modifications effectuées sur le fichier CSV, il faut se positionner dans le repertoire `data/assertions` -et regénérer la classe d'assertion en utilisanr la commande `generate-assertion`. -Exemple : - -```bash -cd data/assertions -./generate-assertion --file ./TheseEntityAssertion.csv -``` \ No newline at end of file diff --git a/data/assertions/generate-assertion b/data/assertions/generate-assertion deleted file mode 100755 index 136eee7e1f0c433da63db3809e2563c552100211..0000000000000000000000000000000000000000 --- a/data/assertions/generate-assertion +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env php -<?php - -use Application\Assertion\Loader\AssertionCsvLoader; -use Application\Assertion\Generator\AssertionGenerator; -use Composer\Autoload\ClassLoader; -use Laminas\Console; - -/** @var ClassLoader $autoloader */ -$autoloader = include __DIR__ . '/../../vendor/autoload.php'; - -$rules = [ - 'help|h' => 'Get usage message', - 'file|f=s' => 'CSV file containing assertion rules to parse; required.', - 'class|c=s' => 'Existing assertion fully qualified class name to regenerate; required.', -]; -try { - $opts = new Console\Getopt($rules); - $opts->parse(); -} catch (Console\Exception\RuntimeException $e) { - echo $e->getUsageMessage(); - exit(2); -} -if ($opts->getOption('h')) { - echo $opts->getUsageMessage(); - exit(); -} - -if (! ($file = $opts->getOption('f'))) { - echo $opts->getUsageMessage(); - exit(); -} - -if (! is_readable($file)) { - throw new \UnicaenApp\Exception\RuntimeException("This file is not readable: " . $file); -} - -// CSV loading -$loader = new AssertionCsvLoader(); -$loader->setRuleFilePath($file); -$result = $loader->loadFile(); -$class = $result->getAssertionClass(); -$classFilePath = $autoloader->findFile($class); - -// Class generating -$generator = new AssertionGenerator(); -$generator->setAssertionCsvLoader($loader); -$code = $generator->generate(); -$content = '<?php' . PHP_EOL . PHP_EOL . $code; -file_put_contents($classFilePath, $content); -echo sprintf("%s ==> %s (%s).", $file, $class, realpath($classFilePath)) . PHP_EOL; diff --git a/bin/assertions/README.md b/doc/assertions.md similarity index 55% rename from bin/assertions/README.md rename to doc/assertions.md index 4a60d0f62aaaa7f3957b6a5c1a1e7f0710b2fc52..f7fea45b621b1774d58249cd0d682bfe12aefe19 100644 --- a/bin/assertions/README.md +++ b/doc/assertions.md @@ -1,28 +1,44 @@ # Fonctionnement du fichier CSV -## Interprétation +Un fichier CSV est utilisé pour spécifier de manière "visuelle" à quelles conditions "métier" un privilège est accordé +ou non. (L'ambition initiale était aussi de permettre de déléguer ces spécifications à des non développeurs, mais cela +n'a pas été mis en place.) + +Si un module utilise un fichier CSV, il est placé dans son répertoire `data`. +Exemple : `module/Depot/data/TheseEntityAssertion.csv`. + +Ce fichier est utilisé pour générer une classe d'assertion abstraite que le développeur devra sous-classer afin +d'implémenter les méthodes abstraites mises en jeu. +Exemple : `module/Depot/src/Depot/Assertion/These/GeneratedTheseEntityAssertion.php` + +C'est le script `bin/assertions/generate-assertion` qui réalise cette opération. + + +## Description du fichier CSV + +Le format d'un fichier CSV de spécifications est précis. - La ligne 1 désigne la classe d'assertion qui sera générée à partir du fichier CSV. -Par exemple, `class;Depot\Assertion\These\GeneratedTheseEntityAssertion` pour la classe `GeneratedTheseEntityAssertion`. + Par exemple, `class;Depot\Assertion\These\GeneratedTheseEntityAssertion` pour la classe `GeneratedTheseEntityAssertion`. + +- La ligne 2 liste des prédicats qui peuvent être utilisés et qui doivent être définis dans la + classe mère `TheseEntityAssertion`. + +- La colonne A correspond à des références de lignes qui seront inscrites dans le PHP généré sous + la forme `/* line N */`. + +- La colonne B correspond aux témoins indiquant si la ligne concernée doit être prise en compte (valeur `1`) + ou non (valeur `0`). -- La ligne 2 liste des prédicats qui peuvent être utilisés et qui doivent être définis dans la -classe mère `TheseEntityAssertion`. - -- La colonne A correspond à des références de lignes qui seront inscrites dans le PHP généré sous -la forme `/* line N */`. - -- La colonne B correspond aux témoins indiquant si la ligne concernée doit être prise en compte (valeur `1`) -ou non (valeur `0`). - - La colonne C correspond aux privilèges concernés (FQDN de la constante PHP). - + - Les colonnes suivantes `isXxxxxx` permettent de lister les prédicats (méthodes `isXxxxxx()` de la classe d'assertion -spécifiée en ligne 1) et de spécifier comment chacun est utilisé en fonction du privilège concerné. + spécifiée en ligne 1) et de spécifier comment chacun est utilisé en fonction du privilège concerné. - La colonne `return` contient la valeur que retournera l'assertion à l'issue des interrogations des prédicats. - + - Chaque ligne faisant référence à un privilège générera un `if` dans l'assertion générée. -Si un même privilège figure 3 fois, 3 `if` seront générés. + Si un même privilège figure 3 fois, 3 `if` seront générés. ### Exemple d'interprétation @@ -38,25 +54,25 @@ Si un même privilège figure 3 fois, 3 `if` seront générés. #### Privilège `THESE_DEPOT_VERSION_INITIALE` -- Line 4 : - - La cellule au croisement du privilège `THESE_DEPOT_VERSION_INITIALE` et du prédicat `isTheseEnCours` vaut `1:0`. - - La cellule dans la colonne `return` mentionne un `0`. - - Cela s'interprète : "Si `isTheseEnCours` est faux (`:0`) alors l'assertion retourne faux (`0`)". +- Line 4 : + - La cellule au croisement du privilège `THESE_DEPOT_VERSION_INITIALE` et du prédicat `isTheseEnCours` vaut `1:0`. + - La cellule dans la colonne `return` mentionne un `0`. + - Cela s'interprète : "Si `isTheseEnCours` est faux (`:0`) alors l'assertion retourne faux (`0`)". -- Line 5 : - - La cellule au croisement de `THESE_DEPOT_VERSION_INITIALE` et de `isTheseSoutenue` vaut `1:1`. - - La cellule dans la colonne `return` mentionne un `0`. - - Cela s'interprète : "Si `isTheseSoutenue` est vrai (`:1`) alors l'assertion retourne faux (`0`)". +- Line 5 : + - La cellule au croisement de `THESE_DEPOT_VERSION_INITIALE` et de `isTheseSoutenue` vaut `1:1`. + - La cellule dans la colonne `return` mentionne un `0`. + - Cela s'interprète : "Si `isTheseSoutenue` est vrai (`:1`) alors l'assertion retourne faux (`0`)". -- Line 6 : - - La ligne ne spécifie aucune valeur en face des prédicats et un `1` dans la colonne `return`. - - La cellule dans la colonne `return` mentionne un `1`. - - Cela s'interprète : "Sinon, l'assertion retourne vrai (`1`)". +- Line 6 : + - La ligne ne spécifie aucune valeur en face des prédicats et un `1` dans la colonne `return`. + - La cellule dans la colonne `return` mentionne un `1`. + - Cela s'interprète : "Sinon, l'assertion retourne vrai (`1`)". Voici le PHP que ces 3 lignes généreraient dans la classe d'assertion : ```php -if ($privilege === \Depot\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE) { +if ($privilege === \Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE) { //-------------------------------------------------------------------------------------- /* line 4 */ $this->linesTrace[] = '/* line 4 */'; @@ -99,17 +115,33 @@ if ($privilege === \Doctorant\Provider\Privilege\DoctorantPrivileges::DOCTORANT_ ``` +## Génération de la classe d'assertion abstraite + +Le fichier CSV est utilisé pour générer une classe d'assertion abstraite. + +Pour cela, une fois les modifications effectuées sur le fichier CSV, il faut (re)générer la classe d'assertion +abstraite en utilisant le script `bin/assertions/generate-assertion`. + +Exemple : +```bash +bin/assertions/generate-assertion --file module/Depot/data/TheseEntityAssertion.csv +``` + + +## Implémentation de la classe d'assertion + +Le fichier CSV est utilisé pour générer une classe d'assertion abstraite que le développeur devra sous-classer afin +d'implémenter les méthodes abstraites mises en jeu. + +Par exemple, la classe `module/Depot/src/Depot/Assertion/These/TheseEntityAssertion.php` hérite de la classe générée +`module/Depot/src/Depot/Assertion/These/GeneratedTheseEntityAssertion.php` et se doit donc d'implémenter toutes les +méthodes abstraites utilisées (`isTheseEnCours()`, `isTheseSoutenue()`, `isUtilisateurEstAuteurDeLaThese()`, +`isExisteValidationRdvBu()`, etc.) + + ## Ajouter une nouvelle assertion ***TODO*** - -## Générer le nouveau ficher assertion -Une fois les modifications effectuées sur le fichier CSV, il faut se positionner dans le repertoire `data/assertions` -et regénérer la classe d'assertion en utilisanr la commande `generate-assertion`. -Exemple : - -```bash -cd data/assertions -./generate-assertion --file ./TheseEntityAssertion.csv -``` \ No newline at end of file + +## Générer la classe d'assertion à partir d'un fichier CSV diff --git a/doc/dev/recherche.md b/doc/dev/recherche.md index 06abda31340e0cfb9e06eee59d429491e1d1341b..5c68dbf6cd68dc74d9c14d532191bb6ed9aaed54 100644 --- a/doc/dev/recherche.md +++ b/doc/dev/recherche.md @@ -204,6 +204,7 @@ class FormationRechercheController extends AbstractController implements SearchC } /** @var LaminasPaginator $paginator */ $paginator = $result; + //$paginator->setItemCountPerPage(-1); // désactive la pagination $model = new ViewModel([ 'title' => $this->title, diff --git a/doc/release-notes/v5.2.8.md b/doc/release-notes/v5.2.8.md new file mode 100644 index 0000000000000000000000000000000000000000..6e0c554f8776d4442d7f376da5d26967f6a537d6 --- /dev/null +++ b/doc/release-notes/v5.2.8.md @@ -0,0 +1,30 @@ +# Version 5.2.8 + +## 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.8 && 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 +-- Nouvelles macros et template +INSERT INTO unicaen_renderer_macro (code, description, variable_name, methode_name) VALUES ('Url#Serment', '<p>Retourne le lien vers le téléchargement du serment du docteur</p>', 'Url', 'getSermentDocteur'); +INSERT INTO unicaen_renderer_macro (code, description, variable_name, methode_name) VALUES ('Url#ProcesVerbal', '<p>Retourne le lien vers le téléchargement du procés verbal</p>', 'Url', 'getProcesVerbal'); +INSERT INTO unicaen_renderer_macro (code, description, variable_name, methode_name) VALUES ('Url#RapportSoutenance', '<p>Retourne le lien vers le téléchargement du rapport de soutenance</p>', 'Url', 'getRapportSoutenance'); +INSERT INTO unicaen_renderer_template (code, description, document_type, document_sujet, document_corps, document_css) VALUES ( + 'TRANSMETTRE_DOCUMENTS_DIRECTION', + '<p>Courrier électronique envoyé à la direction de thèse pour transmission de documents avant soutenance</p>', + 'mail', + 'Transmission des documents pour la soutenance de VAR[Doctorant#Denomination]', + '<p>Bonjour,</p><p>La soutenance de VAR[Doctorant#Denomination] est imminente.<br />Vous retrouverez ci-dessous les liens pour télécharger les documents utiles pour la soutenance.</p><p>Document pour la soutenance :<br />- Serment du docteur : VAR[Url#Serment]<br />- Procès verbal : VAR[Url#ProcesVerbal]<br />- Rapport de soutenance : VAR[Url#RapportSoutenance]<br /><br />Bonne journée,<br />L''équipe SyGAL</p>' + , null); +``` \ No newline at end of file diff --git a/module/Application/config/others/notification.config.php b/module/Application/config/others/notification.config.php index 896085f8197a4dd9c20a3cbc57e610adb9af0f1b..4bdace0f7bde91dde4672d24650d6cb9b3a50205 100755 --- a/module/Application/config/others/notification.config.php +++ b/module/Application/config/others/notification.config.php @@ -2,17 +2,13 @@ namespace Application; -use Application\Service\Notification\NotificationFactory; -use Application\Service\Notification\NotificationFactoryFactory; -use Application\Service\Notification\NotifierService; -use Application\Service\Notification\NotifierServiceFactory; +use Application\Service\Notification\ApplicationNotificationFactory; +use Application\Service\Notification\ApplicationNotificationFactoryFactory; return [ 'service_manager' => [ 'factories' => [ - NotificationFactory::class => NotificationFactoryFactory::class, - NotifierService::class => NotifierServiceFactory::class, - \Notification\Service\NotifierService::class => NotifierServiceFactory::class, // substitution + ApplicationNotificationFactory::class => ApplicationNotificationFactoryFactory::class, ], ], ]; \ No newline at end of file diff --git a/module/Application/src/Application/Controller/AbstractController.php b/module/Application/src/Application/Controller/AbstractController.php index 17c018af650265543ec47922a8986b4dceecf018..7ce7429ff33740bc0d74d2c7a4df32a49933fe11 100755 --- a/module/Application/src/Application/Controller/AbstractController.php +++ b/module/Application/src/Application/Controller/AbstractController.php @@ -2,26 +2,27 @@ namespace Application\Controller; -use Fichier\Controller\Plugin\Uploader\UploaderPlugin; -use Depot\Controller\Plugin\Url\UrlDepotPlugin; -use These\Controller\Plugin\Url\UrlThesePlugin; -use Doctorant\Controller\Plugin\UrlDoctorant; -use Fichier\Controller\Plugin\UrlFichier; -use Depot\Controller\Plugin\UrlFichierThese; -use Depot\Controller\Plugin\UrlWorkflow; -use These\Entity\Db\These; use Application\Entity\Db\Utilisateur; use Application\RouteMatch; use Application\Service\UserContextServiceAwareInterface; use Application\Service\UserContextServiceAwareTrait; use BjyAuthorize\Exception\UnAuthorizedException; +use Depot\Controller\Plugin\Url\UrlDepotPlugin; +use Depot\Controller\Plugin\UrlFichierThese; +use Depot\Controller\Plugin\UrlWorkflow; +use Doctorant\Controller\Plugin\UrlDoctorant; +use Fichier\Controller\Plugin\Uploader\UploaderPlugin; +use Fichier\Controller\Plugin\UrlFichier; +use Laminas\EventManager\EventInterface; +use Laminas\Http\Request as HttpRequest; +use Laminas\Mvc\Controller\AbstractActionController; +use Laminas\Mvc\Plugin\FlashMessenger\FlashMessenger; +use These\Controller\Plugin\Url\UrlThesePlugin; +use These\Entity\Db\These; use UnicaenApp\Controller\Plugin\AppInfos; use UnicaenApp\Controller\Plugin\ConfirmPlugin; use UnicaenApp\Controller\Plugin\Mail; use UnicaenApp\Exception\RuntimeException; -use Laminas\Http\Request as HttpRequest; -use Laminas\Mvc\Controller\AbstractActionController; -use Laminas\Mvc\Plugin\FlashMessenger\FlashMessenger; use ZfcUser\Controller\Plugin\ZfcUserAuthentication; /** @@ -99,4 +100,19 @@ class AbstractController extends AbstractActionController return $this; } + + /** + * Alimente le flashMessenger avec les éventuels messages/logs présents dans les paramètres de l'événement. + * + * @param \Laminas\EventManager\EventInterface $event Evénement en question + * @param string $paramName Nom du paramètre contenant potentiellement les messages/logs + */ + protected function flashMessengerAddMessagesFromEvent(EventInterface $event, string $paramName = 'logs') + { + if ($messages = $event->getParam($paramName, [])) { + foreach ($messages as $namespace => $message) { + $this->flashMessenger()->addMessage($message, $namespace); + } + } + } } \ No newline at end of file diff --git a/module/Application/src/Application/Controller/ExportController.php b/module/Application/src/Application/Controller/ExportController.php index af9ce33bdef51eb2655eb94547de9504428f7c63..c64e7510f9dad9e0c73668afbfdad356ebe31375 100644 --- a/module/Application/src/Application/Controller/ExportController.php +++ b/module/Application/src/Application/Controller/ExportController.php @@ -31,8 +31,8 @@ class ExportController extends AbstractController 'Nom patronymique' => function ($variables) { return $variables['doctorant']->getIndividu()->getNomPatronymique(); }, 'Date de naissance' => function ($variables) { return $variables['doctorant']->getIndividu()->getDateNaissance(); }, 'Nationalité' => function ($variables) { return $variables['doctorant']->getIndividu()->getNationalite(); }, - 'Adresse électronique' => function ($variables) { return $variables['doctorant']->getIndividu()->getEmail(); }, - 'Adresse électronique personnelle' => function ($variables) { return $variables['doctorant']->getEmail(); }, + 'Adresse électronique' => function ($variables) { return $variables['doctorant']->getIndividu()->getEmailPro(); }, + 'Adresse électronique personnelle' => function ($variables) { return $variables['doctorant']->getIndividu()->getEmailContact(); }, 'Numéro étudiant' => function ($variables) { return $this->sourceCodeStringHelper->removePrefixFrom($variables['doctorant']->getSourceCode()); }, 'I.N.E.' => function ($variables) { return $variables['doctorant']->getIne(); }, //These diff --git a/module/Application/src/Application/Controller/Factory/ListeDiffusionControllerFactory.php b/module/Application/src/Application/Controller/Factory/ListeDiffusionControllerFactory.php index d182ce93bacd0b9407c75be07b69f9d4b30672d0..7f5290e86bf7e5f8946fc488ce1010788883d8d2 100644 --- a/module/Application/src/Application/Controller/Factory/ListeDiffusionControllerFactory.php +++ b/module/Application/src/Application/Controller/Factory/ListeDiffusionControllerFactory.php @@ -8,7 +8,7 @@ use Structure\Service\Etablissement\EtablissementService; use Fichier\Service\Fichier\FichierStorageService; use Individu\Service\IndividuService; use Application\Service\ListeDiffusion\ListeDiffusionService; -use Application\Service\Notification\NotifierService; +use Notification\Service\NotifierService; use Application\Service\Role\RoleService; use Structure\Service\Structure\StructureService; use Interop\Container\ContainerInterface; diff --git a/module/Application/src/Application/Controller/Factory/MailConfirmationControllerFactory.php b/module/Application/src/Application/Controller/Factory/MailConfirmationControllerFactory.php index 22695956369f357dc649c5aa2884d686ebdac3d2..1d29582e8ee62949b463eddcd7c3b07704a75723 100644 --- a/module/Application/src/Application/Controller/Factory/MailConfirmationControllerFactory.php +++ b/module/Application/src/Application/Controller/Factory/MailConfirmationControllerFactory.php @@ -4,20 +4,19 @@ namespace Application\Controller\Factory; use Application\Controller\MailConfirmationController; use Application\Form\MailConfirmationForm; +use Application\Service\Notification\ApplicationNotificationFactory; use Individu\Service\IndividuService; use Application\Service\MailConfirmationService; -use Application\Service\Notification\NotifierService; +use Notification\Service\NotifierService; use Interop\Container\ContainerInterface; class MailConfirmationControllerFactory { /** - * Create service - * - * @param ContainerInterface $container - * @return MailConfirmationController + * @throws \Psr\Container\NotFoundExceptionInterface + * @throws \Psr\Container\ContainerExceptionInterface */ - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container): MailConfirmationController { /** * @var MailConfirmationService $mailConfirmationService @@ -37,6 +36,10 @@ class MailConfirmationControllerFactory $controller->setNotifierService($notifierService); $controller->setMailConfirmationForm($mailConfirmationForm); + /** @var \Application\Service\Notification\ApplicationNotificationFactory $applicationNotificationFactory */ + $applicationNotificationFactory = $container->get(ApplicationNotificationFactory::class); + $controller->setApplicationNotificationFactory($applicationNotificationFactory); + return $controller; } } \ No newline at end of file diff --git a/module/Application/src/Application/Controller/Factory/Rapport/RapportCsiControllerFactory.php b/module/Application/src/Application/Controller/Factory/Rapport/RapportCsiControllerFactory.php index 327bf3c8e5b28e2559dacf3f37c8ac2e29f5e53c..f30acb861ceb3c21e1166a6d58cb1eb6b5f3a527 100644 --- a/module/Application/src/Application/Controller/Factory/Rapport/RapportCsiControllerFactory.php +++ b/module/Application/src/Application/Controller/Factory/Rapport/RapportCsiControllerFactory.php @@ -10,7 +10,6 @@ use Application\Form\RapportCsiForm; use ComiteSuiviIndividuel\Service\Membre\MembreService; use Fichier\Service\Fichier\FichierService; use Individu\Service\IndividuService; -use Application\Service\Notification\NotifierService; use Application\Service\Rapport\RapportService; use These\Service\These\TheseService; use These\Service\TheseAnneeUniv\TheseAnneeUnivService; @@ -33,7 +32,6 @@ class RapportCsiControllerFactory * @var FichierService $fichierService * @var RapportService $rapportService * @var VersionFichierService $versionFichierService - * @var NotifierService $notificationService * @var IndividuService $individuService * @var ValidationService $validationService * @var RapportForm $rapportForm @@ -44,7 +42,6 @@ class RapportCsiControllerFactory $fichierService = $container->get(FichierService::class); $rapportService = $container->get(RapportService::class); $versionFichierService = $container->get('VersionFichierService'); - $notificationService = $container->get(NotifierService::class); $individuService = $container->get(IndividuService::class); $rapportForm = $container->get('FormElementManager')->get(RapportCsiForm::class); $validationService = $container->get(ValidationService::class); @@ -59,7 +56,6 @@ class RapportCsiControllerFactory $controller->setRapportService($rapportService); $controller->setFichierService($fichierService); $controller->setVersionFichierService($versionFichierService); - $controller->setNotifierService($notificationService); $controller->setIndividuService($individuService); $controller->setForm($rapportForm); $controller->setValidationService($validationService); diff --git a/module/Application/src/Application/Controller/Factory/Rapport/RapportMiparcoursControllerFactory.php b/module/Application/src/Application/Controller/Factory/Rapport/RapportMiparcoursControllerFactory.php index 5051abbfc7bf32f4828273288540452302c3ee41..724c2b29c9e5e30870c162121f0f93c6c2a1256c 100644 --- a/module/Application/src/Application/Controller/Factory/Rapport/RapportMiparcoursControllerFactory.php +++ b/module/Application/src/Application/Controller/Factory/Rapport/RapportMiparcoursControllerFactory.php @@ -9,7 +9,6 @@ use Application\Form\Rapport\RapportForm; use Application\Form\RapportMiparcoursForm; use Fichier\Service\Fichier\FichierService; use Individu\Service\IndividuService; -use Application\Service\Notification\NotifierService; use Application\Service\Rapport\RapportService; use These\Service\These\TheseService; use These\Service\TheseAnneeUniv\TheseAnneeUnivService; @@ -32,7 +31,6 @@ class RapportMiparcoursControllerFactory * @var FichierService $fichierService * @var RapportService $rapportService * @var VersionFichierService $versionFichierService - * @var NotifierService $notificationService * @var IndividuService $individuService * @var ValidationService $validationService * @var RapportForm $rapportForm @@ -41,7 +39,6 @@ class RapportMiparcoursControllerFactory $fichierService = $container->get(FichierService::class); $rapportService = $container->get(RapportService::class); $versionFichierService = $container->get('VersionFichierService'); - $notificationService = $container->get(NotifierService::class); $individuService = $container->get(IndividuService::class); $rapportForm = $container->get('FormElementManager')->get(RapportMiparcoursForm::class); $validationService = $container->get(ValidationService::class); @@ -54,7 +51,6 @@ class RapportMiparcoursControllerFactory $controller->setRapportService($rapportService); $controller->setFichierService($fichierService); $controller->setVersionFichierService($versionFichierService); - $controller->setNotifierService($notificationService); $controller->setIndividuService($individuService); $controller->setForm($rapportForm); $controller->setValidationService($validationService); diff --git a/module/Application/src/Application/Controller/Factory/UtilisateurControllerFactory.php b/module/Application/src/Application/Controller/Factory/UtilisateurControllerFactory.php index a23d010ee4fbdc31d2364a90dc485d4e0ad02cc2..18d66840fb74f8f8cf28413154003880780aab0a 100644 --- a/module/Application/src/Application/Controller/Factory/UtilisateurControllerFactory.php +++ b/module/Application/src/Application/Controller/Factory/UtilisateurControllerFactory.php @@ -5,8 +5,9 @@ namespace Application\Controller\Factory; use Application\Controller\UtilisateurController; use Application\Form\CreationUtilisateurForm; use Application\Form\InitCompteForm; +use Application\Service\Notification\ApplicationNotificationFactory; use These\Service\Acteur\ActeurService; -use Application\Service\Notification\NotifierService; +use Notification\Service\NotifierService; use Application\Service\Role\RoleService; use Application\Service\UserContextService; use Application\Service\Utilisateur\UtilisateurSearchService; @@ -33,6 +34,10 @@ class UtilisateurControllerFactory { use IndividuServiceLocateTrait; + /** + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface + */ public function __invoke(ContainerInterface $container): UtilisateurController { /** @@ -110,6 +115,10 @@ class UtilisateurControllerFactory $controller->setUserMapper($userMapper); $controller->setSessionService($sessionService); + /** @var \Application\Service\Notification\ApplicationNotificationFactory $applicationNotificationFactory */ + $applicationNotificationFactory = $container->get(ApplicationNotificationFactory::class); + $controller->setApplicationNotificationFactory($applicationNotificationFactory); + /** * @var SourceCodeStringHelper $sourceCodeHelper */ diff --git a/module/Application/src/Application/Controller/ListeDiffusionController.php b/module/Application/src/Application/Controller/ListeDiffusionController.php index a9e439906ad59b341660dd25e9b6b51321b0ce34..17a263865b74e3b3cabf901605dc8780d81a5dfa 100644 --- a/module/Application/src/Application/Controller/ListeDiffusionController.php +++ b/module/Application/src/Application/Controller/ListeDiffusionController.php @@ -2,6 +2,7 @@ namespace Application\Controller; +use Application\Service\Notification\ApplicationNotificationFactoryAwareTrait; use Structure\Entity\Db\EcoleDoctorale; use Structure\Entity\Db\Etablissement; use Individu\Entity\Db\Individu; @@ -15,7 +16,7 @@ use Fichier\Service\Fichier\FichierStorageServiceAwareTrait; use Individu\Service\IndividuServiceAwareTrait; use Application\Service\ListeDiffusion\Address\ListeDiffusionAddressGenerator; use Application\Service\ListeDiffusion\ListeDiffusionServiceAwareTrait; -use Application\Service\Notification\NotifierServiceAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; use Application\Service\Role\RoleServiceAwareTrait; use Structure\Service\Structure\StructureServiceAwareTrait; use Doctrine\ORM\ORMException; @@ -32,6 +33,7 @@ class ListeDiffusionController extends AbstractController use IndividuServiceAwareTrait; use FichierStorageServiceAwareTrait; use NotifierServiceAwareTrait; + use ApplicationNotificationFactoryAwareTrait; use StructureServiceAwareTrait; use EtablissementServiceAwareTrait; use EcoleDoctoraleServiceAwareTrait; @@ -395,11 +397,12 @@ class ListeDiffusionController extends AbstractController // Envoi d'une notif aux admin tech $to = $this->fetchAdminTechEmails(); - $this->notifierService->triggerAbonnesListeDiffusionSansAdresse( + $notif = $this->applicationNotificationFactory->createNotificationAbonnesListeDiffusionSansAdresse( $to, $this->liste, $individusAvecAdresse, $individusSansAdresse); + $this->notifierService->trigger($notif); } /** diff --git a/module/Application/src/Application/Controller/MailConfirmationController.php b/module/Application/src/Application/Controller/MailConfirmationController.php index 5cb0c33da14400025f151f84da8e6b15af086c56..53d471cbddf1c7f5ba0d91c11655ee3bee629ea7 100644 --- a/module/Application/src/Application/Controller/MailConfirmationController.php +++ b/module/Application/src/Application/Controller/MailConfirmationController.php @@ -5,17 +5,18 @@ namespace Application\Controller; use Application\Entity\Db\MailConfirmation; use Application\Form\MailConfirmationForm; use Application\Service\MailConfirmationService; -use Application\Service\Notification\NotifierServiceAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; +use Application\Service\Notification\ApplicationNotificationFactoryAwareTrait; use Individu\Entity\Db\Individu; use Individu\Service\IndividuServiceAwareTrait; use Laminas\Http\Response; use Laminas\View\Model\ViewModel; -use Notification\Exception\NotificationException; use UnicaenApp\Exception\RuntimeException; class MailConfirmationController extends AbstractController { use NotifierServiceAwareTrait; + use ApplicationNotificationFactoryAwareTrait; use IndividuServiceAwareTrait; private MailConfirmationService $mailConfirmationService; @@ -110,11 +111,8 @@ class MailConfirmationController extends AbstractController ['force_canonical' => true] , true ); - try { - $this->notifierService->triggerMailConfirmation($mailConfirmation, $confirmUrl); - } catch (NotificationException $e) { - throw new RuntimeException("Erreur lors de l'envoi de la notification", null, $e); - } + $notif = $this->applicationNotificationFactory->createNotificationMailConfirmation($mailConfirmation, $confirmUrl); + $this->notifierService->trigger($notif); return $this->redirect()->toRoute('mail-confirmation/envoye', [], [], true); } diff --git a/module/Application/src/Application/Controller/Rapport/RapportAvisController.php b/module/Application/src/Application/Controller/Rapport/RapportAvisController.php index 08508fcbb041a4a6b3815b10c74ef8664b91b37c..c27d5e0a1a9ad9b5c551f17e6515d5dd0cd7baab 100644 --- a/module/Application/src/Application/Controller/Rapport/RapportAvisController.php +++ b/module/Application/src/Application/Controller/Rapport/RapportAvisController.php @@ -10,7 +10,6 @@ use Application\Filter\IdifyFilter; use Application\Filter\IdifyFilterAwareTrait; use Application\Form\Rapport\RapportAvisForm; use Individu\Service\IndividuServiceAwareTrait; -use Application\Service\Notification\NotifierServiceAwareTrait; use Application\Service\Rapport\Avis\RapportAvisServiceAwareTrait; use Application\Service\Rapport\RapportServiceAwareTrait; use Doctrine\ORM\NoResultException; @@ -22,7 +21,6 @@ class RapportAvisController extends AbstractController use RapportServiceAwareTrait; use RapportAvisServiceAwareTrait; use IdifyFilterAwareTrait; - use NotifierServiceAwareTrait; use IndividuServiceAwareTrait; use EventRouterReplacerAwareTrait; diff --git a/module/Application/src/Application/Controller/Rapport/RapportController.php b/module/Application/src/Application/Controller/Rapport/RapportController.php index d87761ef2621ceb69f9875f5371f3cd4b7fa4118..52d5c4bb35365b231f266202bc8567a2a49a424c 100644 --- a/module/Application/src/Application/Controller/Rapport/RapportController.php +++ b/module/Application/src/Application/Controller/Rapport/RapportController.php @@ -16,7 +16,6 @@ use ComiteSuiviIndividuel\Service\Membre\MembreServiceAwareTrait; use Fichier\Service\Fichier\FichierServiceAwareTrait; use Fichier\Service\Fichier\FichierStorageServiceAwareTrait; use Individu\Service\IndividuServiceAwareTrait; -use Application\Service\Notification\NotifierServiceAwareTrait; use Application\Service\Rapport\RapportServiceAwareTrait; use These\Service\These\TheseServiceAwareTrait; use These\Service\TheseAnneeUniv\TheseAnneeUnivService; @@ -36,7 +35,6 @@ abstract class RapportController extends AbstractController use RapportServiceAwareTrait; use VersionFichierServiceAwareTrait; use IdifyFilterAwareTrait; - use NotifierServiceAwareTrait; use IndividuServiceAwareTrait; use ValidationServiceAwareTrait; use EventRouterReplacerAwareTrait; diff --git a/module/Application/src/Application/Controller/UtilisateurController.php b/module/Application/src/Application/Controller/UtilisateurController.php index 588d3ce8d5d0fc7fa34846cc70729b1f2bd50f42..0c3d9a2bdb94e8891030e3b768b328a157a5d75a 100644 --- a/module/Application/src/Application/Controller/UtilisateurController.php +++ b/module/Application/src/Application/Controller/UtilisateurController.php @@ -9,11 +9,12 @@ use Application\Form\InitCompteFormAwareTrait; use Application\Search\Controller\SearchControllerInterface; use Application\Search\Controller\SearchControllerTrait; use Application\Search\SearchServiceAwareTrait; +use Application\Service\Notification\ApplicationNotificationFactoryAwareTrait; use These\Service\Acteur\ActeurServiceAwareTrait; use Doctorant\Service\DoctorantServiceAwareTrait; use Structure\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait; use Structure\Service\Etablissement\EtablissementServiceAwareTrait; -use Application\Service\Notification\NotifierServiceAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; use Application\Service\Role\RoleServiceAwareTrait; use Structure\Service\Structure\StructureServiceAwareTrait; use Structure\Service\UniteRecherche\UniteRechercheServiceAwareTrait; @@ -63,6 +64,7 @@ class UtilisateurController extends \UnicaenAuth\Controller\UtilisateurControlle use UniteRechercheServiceAwareTrait; use EtablissementServiceAwareTrait; use NotifierServiceAwareTrait; + use ApplicationNotificationFactoryAwareTrait; use StructureServiceAwareTrait; use SourceCodeStringHelperAwareTrait; use UserServiceAwareTrait; @@ -218,7 +220,7 @@ class UtilisateurController extends \UnicaenAuth\Controller\UtilisateurControlle * @param string|null $type => permet de spécifier un type d'acteur ... * @return JsonModel */ - public function rechercherIndividuAction(?string $type = null) + public function rechercherIndividuAction(?string $type = null) : JsonModel { $type = $this->params()->fromQuery('type'); if (($term = $this->params()->fromQuery('term'))) { @@ -267,7 +269,14 @@ class UtilisateurController extends \UnicaenAuth\Controller\UtilisateurControlle $utilisateur = $this->utilisateurService->createFromFormData($data->toArray()); } $this->userService->updateUserPasswordResetToken($utilisateur); - $this->notifierService->triggerInitialisationCompte($utilisateur, $utilisateur->getPasswordResetToken()); + + try { + $notif = $this->applicationNotificationFactory->createNotificationInitialisationCompte($utilisateur, $utilisateur->getPasswordResetToken()); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : gerer le cas ! + } + $this->flashMessenger()->addSuccessMessage("Utilisateur <strong>{$utilisateur->getUsername()}</strong> créé avec succès."); return $this->redirect()->toRoute('utilisateur'); @@ -366,7 +375,13 @@ class UtilisateurController extends \UnicaenAuth\Controller\UtilisateurControlle $role = $this->getRoleService()->getRepository()->find($roleId); $this->roleService->removeRole($individuId, $roleId); - $this->notifierService->triggerChangementRole("retrait", $role, $individu); + + try { + $notif = $this->applicationNotificationFactory->createNotificationChangementRole("retrait", $role, $individu); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : gerer le cas ! + } } return new ViewModel([]); @@ -386,7 +401,13 @@ class UtilisateurController extends \UnicaenAuth\Controller\UtilisateurControlle $role = $this->getRoleService()->getRepository()->find($roleId); $this->roleService->addRole($individuId, $roleId); - $this->notifierService->triggerChangementRole("ajout", $role, $individu); + + try { + $notif = $this->applicationNotificationFactory->createNotificationChangementRole("ajout", $role, $individu); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : gerer le cas ! + } } return false; } @@ -417,8 +438,14 @@ class UtilisateurController extends \UnicaenAuth\Controller\UtilisateurControlle if (empty($utilisateurs)) { $user = $this->utilisateurService->createFromIndividu($individu, $individu->getEmailPro(), 'none'); $this->userService->updateUserPasswordResetToken($user); + $url = $this->url()->fromRoute('utilisateur/init-compte', ['token' => $user->getPasswordResetToken()], ['force_canonical' => true], true); - $this->notifierService->triggerInitialisationCompte($user, $url); + try { + $notif = $this->applicationNotificationFactory->createNotificationInitialisationCompte($user, $url); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : gerer le cas ! + } } else { $this->flashMessenger()->addErrorMessage('Impossible de créer le compte local car un utilisateur est déjà lié à cet individu.'); } @@ -436,7 +463,13 @@ class UtilisateurController extends \UnicaenAuth\Controller\UtilisateurControlle if ($utilisateur !== null) { $this->userService->updateUserPasswordResetToken($utilisateur); $url = $this->url()->fromRoute('utilisateur/init-compte', ['token' => $utilisateur->getPasswordResetToken()], ['force_canonical' => true], true); - $this->notifierService->triggerResetCompte($utilisateur, $url); + + try { + $notif = $this->applicationNotificationFactory->createNotificationResetCompte($utilisateur, $url); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : gerer le cas ! + } } else { $this->flashMessenger()->addErrorMessage('Impossible de réinitiliser la mot de passe car aucun utilisateur est lié'); } diff --git a/module/Application/src/Application/Entity/Db/Role.php b/module/Application/src/Application/Entity/Db/Role.php index 78e11f8b664151868b1bbb29261f65253feae2da..fc1467267ca1d082856049875b94d21b74ca0e74 100644 --- a/module/Application/src/Application/Entity/Db/Role.php +++ b/module/Application/src/Application/Entity/Db/Role.php @@ -386,4 +386,14 @@ class Role extends AbstractRole implements SourceAwareInterface, HistoriqueAware return $this->profils->contains($profil); } + public function estUsurpable(): bool + { + return in_array($this->getCode(), [ + Role::CODE_DIRECTEUR_THESE, + Role::CODE_CODIRECTEUR_THESE, + Role::CODE_PRESIDENT_JURY, + Role::CODE_RAPPORTEUR_JURY, + Role::CODE_RAPPORTEUR_ABSENT, + ]); + } } \ No newline at end of file diff --git a/module/Application/src/Application/Entity/Db/Variable.php b/module/Application/src/Application/Entity/Db/Variable.php index 01616a093c9a1167eeb985cb6e4f2daab4644236..9e4553d016734b8b1284363ba6c36b4f83037447 100644 --- a/module/Application/src/Application/Entity/Db/Variable.php +++ b/module/Application/src/Application/Entity/Db/Variable.php @@ -15,8 +15,6 @@ class Variable implements HistoriqueAwareInterface use HistoriqueAwareTrait; use SourceAwareTrait; - const CODE_EMAIL_BDD = 'EMAIL_BDD'; - const CODE_EMAIL_BU = 'EMAIL_BU'; const CODE_EMAIL_ASSISTANCE = 'EMAIL_ASSISTANCE'; const CODE_ETB_ART_ETB_LIB = 'ETB_ART_ETB_LIB'; // Ex: "L'" const CODE_ETB_LIB = 'ETB_LIB'; // Ex: "Université de Caen Normandie" diff --git a/module/Application/src/Application/Search/Filter/SearchFilter.php b/module/Application/src/Application/Search/Filter/SearchFilter.php index 1ed74cea3bd72ce19ae39238dc64c8e71b396b47..b1b64654cf23431106fef021325422fb63c754b7 100644 --- a/module/Application/src/Application/Search/Filter/SearchFilter.php +++ b/module/Application/src/Application/Search/Filter/SearchFilter.php @@ -125,10 +125,6 @@ abstract class SearchFilter implements SearchFilterInterface */ public function applyToQueryBuilder(QueryBuilder $qb) { - if (!$this->canApplyToQueryBuilder()) { - return; - } - if ($this->applyToQueryBuilderCallable !== null) { $this->applyToQueryBuilderUsingCallable($qb); return; @@ -182,9 +178,9 @@ abstract class SearchFilter implements SearchFilterInterface /** * @return bool */ - protected function canApplyToQueryBuilder(): bool + public function canApplyToQueryBuilder(): bool { - return true; + return (bool) $this->getValue(); } /** diff --git a/module/Application/src/Application/Search/Filter/SelectSearchFilter.php b/module/Application/src/Application/Search/Filter/SelectSearchFilter.php index b01f8491fd7342a1349fe02f19ae56879e76adc5..9a16386fba5f280312748b4cf269d829434b7f68 100644 --- a/module/Application/src/Application/Search/Filter/SelectSearchFilter.php +++ b/module/Application/src/Application/Search/Filter/SelectSearchFilter.php @@ -91,6 +91,11 @@ class SelectSearchFilter extends SearchFilter return $this->dataProvider; } + public function canApplyToQueryBuilder(): bool + { + return $this->getValue() !== null; // '0' est une valeur valide + } + /** * Application de ce filtre au query builder spécifié, en utilisant le champ de condition. * diff --git a/module/Application/src/Application/Search/Filter/TextSearchFilter.php b/module/Application/src/Application/Search/Filter/TextSearchFilter.php index b6c2418a9f910a8175f3984abfeddaf6073c8729..7d5379a3f824b42ae8424042cddbe44e5843441a 100644 --- a/module/Application/src/Application/Search/Filter/TextSearchFilter.php +++ b/module/Application/src/Application/Search/Filter/TextSearchFilter.php @@ -34,7 +34,7 @@ class TextSearchFilter extends SearchFilter return $this; } - protected function canApplyToQueryBuilder(): bool + public function canApplyToQueryBuilder(): bool { $filterValue = trim($this->getValue()); diff --git a/module/Application/src/Application/Search/SearchService.php b/module/Application/src/Application/Search/SearchService.php index c67578e45e2982296797262e243f38ce3b7bd2e3..20221794a9bde0b822b1cac8b0691d86fb499976 100644 --- a/module/Application/src/Application/Search/SearchService.php +++ b/module/Application/src/Application/Search/SearchService.php @@ -335,7 +335,7 @@ abstract class SearchService implements SearchServiceInterface $qb = $this->createQueryBuilder(); foreach ($this->filters as $filter) { - if ($filter->getValue() !== null) { + if ($filter->canApplyToQueryBuilder()) { $filter->applyToQueryBuilder($qb); } } diff --git a/module/Application/src/Application/Service/Email/EmailTheseService.php b/module/Application/src/Application/Service/Email/EmailTheseService.php index 8bb011812a605458f4739831fb27c3ce1c373950..7e3b1bfedf8f6d8abd3694680c3c6fac06610250 100644 --- a/module/Application/src/Application/Service/Email/EmailTheseService.php +++ b/module/Application/src/Application/Service/Email/EmailTheseService.php @@ -2,30 +2,26 @@ namespace Application\Service\Email; -use Individu\Entity\Db\IndividuRole; use Application\Entity\Db\Role; -use These\Entity\Db\These; use Application\Entity\Db\Variable; use Application\Service\Role\RoleServiceAwareTrait; use Application\Service\Utilisateur\UtilisateurServiceAwareTrait; use Application\Service\Variable\VariableServiceAwareTrait; +use Individu\Entity\Db\IndividuRole; +use Individu\Service\IndividuServiceAwareTrait; +use InvalidArgumentException; +use Soutenance\Service\Membre\MembreServiceAwareTrait; +use These\Entity\Db\These; +use These\Service\Acteur\ActeurServiceAwareTrait; class EmailTheseService { use RoleServiceAwareTrait; use VariableServiceAwareTrait; use UtilisateurServiceAwareTrait; - - /** - * @param These $these - * @return string - */ - public function fetchEmailBdd(These $these) : string - { - $variable = $this->variableService->getRepository()->findOneByCodeAndThese(Variable::CODE_EMAIL_BDD, $these); - return $variable->getValeur(); - - } + use ActeurServiceAwareTrait; + use IndividuServiceAwareTrait; + use MembreServiceAwareTrait; /** * @param IndividuRole[] $individuRoles @@ -110,4 +106,65 @@ class EmailTheseService $individuRoles = array_filter($individuRoles, function (IndividuRole $ir) { return $ir->getRole()->getCode() === Role::CODE_BDD;}); return $this->fetchEmailsByEtablissement($individuRoles, $these); } + + /** + * @param These $these + * @return string[] + */ + public function fetchEmailBibliothequeUniv(These $these) : array + { + /** @var IndividuRole[] $individuRoles */ + $individuRoles = $this->roleService->findIndividuRoleByStructure($these->getEtablissement()->getStructure()); + $individuRoles = array_filter($individuRoles, function (IndividuRole $ir) { return $ir->getRole()->getCode() === Role::CODE_BU;}); + return $this->fetchEmailsByEtablissement($individuRoles, $these); + } + + /** + * @param These $these + * @return string[] + */ + public function fetchEmailEncadrants(These $these) : array + { + $emails = []; + $encadrants = $this->acteurService->getRepository()->findEncadrementThese($these); + foreach ($encadrants as $encadrant) { + //tentative dans individu + $email = $encadrant->getIndividu()->getEmailPro(); + //tentative dans membre + if ($email === null) { + $membre = $this->membreService->getMembreByActeur($encadrant); + if ($membre) $email = $membre->getEmail(); + } + //tentative dans utilisateur + if ($email === null) { + $utilisateurs = $this->utilisateurService->getRepository()->findByIndividu($encadrant->getIndividu()); + foreach ($utilisateurs as $utilisateur) { + $email = $utilisateur->getEmail(); + if ($email !== null) break; + } + } + // echec ... + if ($email === null) { + throw new InvalidArgumentException("Pas de mail pour l'encadrant de thèse [".$encadrant->getIndividu()->getNomComplet()."]"); + } + $emails[] = $email; + } + return $emails; + } + + /** + * @param These $these + * @return array + */ + public function fetchEmailActeursDirects(These $these) : array + { + $emails = []; + $emails[] = $these->getDoctorant()->getIndividu()->getEmailPro(); + + $encadrants = $this->fetchEmailEncadrants($these); + foreach ($encadrants as $encadrant) { + $emails[] = $encadrant; + } + return $emails; + } } \ No newline at end of file diff --git a/module/Application/src/Application/Service/Email/EmailTheseServiceFactory.php b/module/Application/src/Application/Service/Email/EmailTheseServiceFactory.php index 9b9f3b198b88070b8a6947ff187b2f25501d51ca..529f6514c58646072bf359b708a9b22143ac42a4 100644 --- a/module/Application/src/Application/Service/Email/EmailTheseServiceFactory.php +++ b/module/Application/src/Application/Service/Email/EmailTheseServiceFactory.php @@ -4,7 +4,10 @@ namespace Application\Service\Email; use Application\Service\Utilisateur\UtilisateurService; use Application\Service\Variable\VariableService; +use Individu\Service\IndividuService; use Psr\Container\ContainerInterface; +use Soutenance\Service\Membre\MembreService; +use These\Service\Acteur\ActeurService; class EmailTheseServiceFactory { @@ -18,15 +21,32 @@ class EmailTheseServiceFactory */ public function __invoke(ContainerInterface $container): EmailTheseService { - $roleService = $container->get('RoleService'); - $utilisateurService = $container->get(UtilisateurService::class); - $variableService = $container->get(VariableService::class); - $service = new EmailTheseService(); + + /** @var $roleService \Application\Service\Role\RoleService */ + $roleService = $container->get('RoleService'); $service->setRoleService($roleService); + + /** @var $utilisateurService \Application\Service\Utilisateur\UtilisateurService */ + $utilisateurService = $container->get(UtilisateurService::class); $service->setUtilisateurService($utilisateurService); + + /** @var $variableService \Application\Service\Variable\VariableService */ + $variableService = $container->get(VariableService::class); $service->setVariableService($variableService); + /** @var $acteurService \These\Service\Acteur\ActeurService */ + $acteurService = $container->get(ActeurService::class); + $service->setActeurService($acteurService); + + /** @var $membreService \Soutenance\Service\Membre\MembreService */ + $membreService = $container->get(MembreService::class); + $service->setMembreService($membreService); + + /** @var $individuService \Individu\Service\IndividuService */ + $individuService = $container->get(IndividuService::class); + $service->setIndividuService($individuService); + return $service; } } diff --git a/module/Application/src/Application/Service/Notification/ApplicationNotificationFactory.php b/module/Application/src/Application/Service/Notification/ApplicationNotificationFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..76b1be4b2392e02f316158637550a5112a0d3fe1 --- /dev/null +++ b/module/Application/src/Application/Service/Notification/ApplicationNotificationFactory.php @@ -0,0 +1,171 @@ +<?php + +namespace Application\Service\Notification; + +use Application\Entity\Db\MailConfirmation; +use Application\Entity\Db\Role; +use Application\Entity\Db\Utilisateur; +use Individu\Entity\Db\Individu; +use Laminas\View\Helper\Url as UrlHelper; +use Notification\Exception\RuntimeException; +use Notification\Factory\NotificationFactory; +use Notification\Notification; +use UnicaenApp\Exception\LogicException; + +/** + * Classe de construction de notifications par mail. + * + * @author Unicaen + */ +class ApplicationNotificationFactory extends NotificationFactory +{ + /** + * @var UrlHelper + */ + protected UrlHelper $urlHelper; + + public function setUrlHelper(UrlHelper $urlHelper) + { + $this->urlHelper = $urlHelper; + } + + /** + * Notification pour confirmation d'une adresse mail. + * + * @param MailConfirmation $mailConfirmation + * @param string $confirmUrl + * @return \Notification\Notification + */ + public function createNotificationMailConfirmation(MailConfirmation $mailConfirmation, string $confirmUrl): Notification + { + $notif = new Notification(); + $notif + ->setSubject("Confirmation de votre adresse électronique") + ->setTo($mailConfirmation->getEmail()) + ->setTemplatePath('doctorant/mail/demande-confirmation-mail') + ->setTemplateVariables([ + 'destinataire' => $mailConfirmation->getIndividu()->getNomUsuel(), + 'confirmUrl' => $confirmUrl, + ]); + + return $notif; + } + + /** + * Notification à propos d'un rôle attribué/retiré à un utilisateur. + * + * @var string $type + * @var Role $role + * @var Individu $individu + */ + public function createNotificationChangementRole($type, $role, $individu): Notification + { + $mail = $individu->getEmailContact() ?: $individu->getEmailPro() ?: $individu->getEmailUtilisateur(); + if ($mail === null) { + throw new RuntimeException("Aucun email dispo pour l'individu {$individu}"); + } + + $notif = new Notification(); + $notif + ->setSubject("Modification de vos rôles dans l'application") + ->setTo($mail) + ->setTemplatePath('application/utilisateur/changement-role') + ->setTemplateVariables([ + 'type' => $type, + 'role' => $role, + 'individu' => $individu, + ]); + + return $notif; + } + + /** + * Notification à propos de la création d'un compte local. + * + * @param Utilisateur $utilisateur + * @param string $token + * @return \Notification\Notification + */ + public function createNotificationInitialisationCompte(Utilisateur $utilisateur, string $token): Notification + { + $email = $utilisateur->getEmail(); + if ($email === null) { + throw new RuntimeException("Aucun email dispo pour l'utilisateur {$utilisateur->getUsername()} !"); + } + + $token = $utilisateur->getPasswordResetToken(); + if ($token === null) throw new LogicException("Aucun token de fourni !"); + + $notif = new Notification(); + $notif + ->setSubject("Initialisation de votre compte") + ->setTo($email) + ->setTemplatePath('application/utilisateur/mail/init-compte') + ->setTemplateVariables([ + 'username' => $utilisateur->getUsername(), + 'url' => $this->urlHelper->__invoke('utilisateur/init-compte', ['token' => $token], ['force_canonical' => true], true), + ]); + + return $notif; + } + + /** + * Notification à propos de la réinitialisation d'un compte local. + * + * @param Utilisateur $utilisateur + * @param string $url + */ + public function createNotificationResetCompte($utilisateur, $url): Notification + { + $email = $utilisateur->getEmail(); + if ($email === null) { + throw new RuntimeException("Aucun email dispo pour l'utilisateur {$utilisateur->getUsername()}"); + } + + $token = $utilisateur->getPasswordResetToken(); + if ($token === null) throw new LogicException("Aucun token de fourni !"); + + $notif = new Notification(); + $notif + ->setSubject("Réinitialisation de votre mot de passe de votre compte") + ->setTo($email) + ->setTemplatePath('application/utilisateur/mail/reinit-compte') + ->setTemplateVariables([ + 'username' => $utilisateur->getUsername(), + 'url' => $url, + ]); + + return $notif; + } + + /** + * Notification à propos d'abonnés de liste de diffusion sans adresse connue. + * + * @param string[] $to + * @param string $liste + * @param string[] $individusAvecAdresse + * @param string[] $individusSansAdresse + * @return \Notification\Notification + */ + public function createNotificationAbonnesListeDiffusionSansAdresse( + array $to, + string $liste, + array $individusAvecAdresse, + array $individusSansAdresse): Notification + { + $to = array_unique(array_filter($to)); + + $notif = new Notification(); + $notif + ->setSubject("Abonnés de liste de diffusion sans adresse mail") + ->setTo($to) + ->setTemplatePath('application/liste-diffusion/mail/notif-abonnes-sans-adresse') + ->setTemplateVariables([ + 'liste' => $liste, + 'individusAvecAdresse' => $individusAvecAdresse, + 'individusSansAdresse' => $individusSansAdresse, + ]); + + return $notif; + } +} \ No newline at end of file diff --git a/module/Application/src/Application/Service/Notification/ApplicationNotificationFactoryAwareTrait.php b/module/Application/src/Application/Service/Notification/ApplicationNotificationFactoryAwareTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..d676472d416046ac62815798af2112f93dd0c769 --- /dev/null +++ b/module/Application/src/Application/Service/Notification/ApplicationNotificationFactoryAwareTrait.php @@ -0,0 +1,13 @@ +<?php + +namespace Application\Service\Notification; + +trait ApplicationNotificationFactoryAwareTrait +{ + protected ApplicationNotificationFactory $applicationNotificationFactory; + + public function setApplicationNotificationFactory(ApplicationNotificationFactory $applicationNotificationFactory): void + { + $this->applicationNotificationFactory = $applicationNotificationFactory; + } +} \ No newline at end of file diff --git a/module/Application/src/Application/Service/Notification/ApplicationNotificationFactoryFactory.php b/module/Application/src/Application/Service/Notification/ApplicationNotificationFactoryFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..37b0faaaf33bd3691fa97e2275fed22fbf005f99 --- /dev/null +++ b/module/Application/src/Application/Service/Notification/ApplicationNotificationFactoryFactory.php @@ -0,0 +1,34 @@ +<?php + +namespace Application\Service\Notification; + +use Interop\Container\ContainerInterface; +use Laminas\View\Helper\Url as UrlHelper; +use Notification\Factory\NotificationFactoryFactory; + +/** + * @author Unicaen + */ +class ApplicationNotificationFactoryFactory extends NotificationFactoryFactory +{ + /** + * @var string + */ + protected string $class = ApplicationNotificationFactory::class; + + /** + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface + */ + public function __invoke(ContainerInterface $container): ApplicationNotificationFactory + { + /** @var ApplicationNotificationFactory $factory */ + $factory = parent::__invoke($container); + + /** @var UrlHelper $urlHelper */ + $urlHelper = $container->get('ViewHelperManager')->get('Url'); + $factory->setUrlHelper($urlHelper); + + return $factory; + } +} diff --git a/module/Application/src/Application/Service/Notification/NotificationFactory.php b/module/Application/src/Application/Service/Notification/NotificationFactory.php deleted file mode 100644 index 2f29f1997bf20befa36bc5d8739d6688074746cf..0000000000000000000000000000000000000000 --- a/module/Application/src/Application/Service/Notification/NotificationFactory.php +++ /dev/null @@ -1,215 +0,0 @@ -<?php - -namespace Application\Service\Notification; - -use Depot\Entity\Db\FichierThese; -use These\Entity\Db\These; -use Application\Entity\Db\ValiditeFichier; -use Application\Entity\Db\Variable; -use Fichier\Entity\Db\VersionFichier; -use Structure\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait; -use Structure\Service\UniteRecherche\UniteRechercheServiceAwareTrait; -use Application\Service\Variable\VariableServiceAwareTrait; -use Notification\Notification; -use UnicaenApp\Options\ModuleOptions; -use Laminas\View\Helper\Url as UrlHelper; - -/** - * Classe de construction de notifications par mail. - * - * @author Unicaen - */ -class NotificationFactory extends \Notification\Service\NotificationFactory -{ - use VariableServiceAwareTrait; - use EcoleDoctoraleServiceAwareTrait; - use UniteRechercheServiceAwareTrait; - - /** - * @var UrlHelper - */ - protected $urlHelper; - - /** - * @var ModuleOptions - */ - private $appModuleOptions; - - /** - * {@inheritdoc} - */ - public function initNotification(Notification $notification) - { - parent::initNotification($notification); - - // injecte le nom de l'appli dans la variable 'appName' utilisée par tous les templates - $appInfos = $this->appModuleOptions->getAppInfos(); - $appName = $appInfos['nom']; - $notification->setTemplateVariables([ - 'appName' => $appName, - ]); - } - - /** - * Notifie que le retraitement automatique du fichier PDF est terminé. - * - * @param string $destinataires Emails séparés par une virgule - * @param FichierThese $fichierTheseRetraite Fichier retraité concerné - * @param ValiditeFichier|null $validite Résultat du test d'archivabilité éventuel - * @return Notification - * @return Notification - */ - public function createNotificationForRetraitementFini($destinataires, FichierThese $fichierTheseRetraite, ValiditeFichier $validite = null) - { - $to = array_map('trim', explode(',', $destinataires)); - - $notif = $this->createNotification(); - $notif - ->setSubject("Retraitement terminé") - ->setTo($to) - ->setTemplatePath('depot/depot/mail/notif-retraitement-fini') - ->setTemplateVariables([ - 'fichierRetraite' => $fichierTheseRetraite, - 'validite' => $validite, - 'url' => '', - ]); - - return $notif; - } - - /** - * Notification à l'issu du remplissage du formulaire RDV BU par le doctorant. - * - * @param These $these - * @param bool $estLaPremiereSaisie - * @return Notification - */ - public function createNotificationForRdvBuSaisiParDoctorant(These $these, $estLaPremiereSaisie) - { - $subject = sprintf("%s Saisie des informations pour la prise de rendez-vous avec la bibliothèque universitaire", $these->getLibelleDiscipline()); - $to = $this->fetchEmailBu($these); - - $notif = $this->createNotification(); - $notif - ->setTo($to) - ->setSubject($subject) - ->setTemplatePath('depot/depot/mail/notif-modif-rdv-bu-doctorant') - ->setTemplateVariables([ - 'these' => $these, - 'updating' => !$estLaPremiereSaisie, - ]); - - $infoMessage = sprintf("Un mail de notification vient d'être envoyé à la bibliothèque universitaire (%s).", $to); - $notif->setInfoMessages($infoMessage); - - return $notif; - } - - /** - * Notification à l'issue du dépôt d'un fichier de thèse. - * - * @param These $these - * @param VersionFichier $version - * @return Notification - */ - public function createNotificationForTheseTeleversee(These $these, VersionFichier $version) - { - $to = $this->fetchEmailBdd($these); - - $notif = $this->createNotification('notif-depot-these'); - $notif - ->setTo($to) - ->setSubject("Dépôt d'une thèse") -// ->setTemplatePath('depot/depot/mail/notif-depot-these') // le template est dans la NotifEntity - ->setTemplateVariables([ - 'these' => $these, - 'version' => $version, - ]); - - return $notif; - } - - /** - * Notification à l'issue du dépôt d'un fichier. - * - * @param These $these - * @return Notification - */ - public function createNotificationForFichierTeleverse(These $these) - { - $to = $this->fetchEmailBdd($these); - - $notif = $this->createNotification(); - $notif - ->setTo($to) - ->setTemplateVariables([ - 'these' => $these, - ]); - - return $notif; - } - - /** - * @param These $these - * @return string - */ - private function fetchEmailBdd(These $these) - { - $variable = $this->variableService->getRepository()->findOneByCodeAndThese(Variable::CODE_EMAIL_BDD, $these); - - return $variable->getValeur(); - } - - /** - * @param These $these - * @return string - */ - private function fetchEmailBu(These $these) - { - $variable = $this->variableService->getRepository()->findOneByCodeAndThese(Variable::CODE_EMAIL_BU, $these); - - return $variable->getValeur(); - } - - /** - * @param UrlHelper $urlHelper - */ - public function setUrlHelper(UrlHelper $urlHelper) - { - $this->urlHelper = $urlHelper; - } - - /** - * @param ModuleOptions $options - */ - public function setAppModuleOptions(ModuleOptions $options) - { - $this->appModuleOptions = $options; - } - - /** - * Notifie que la fusion de la page de couverture avec la thèse PDF est terminée. - * - * @param string $destinataires Emails séparés par une virgule - * @param These $these - * @param string $outputFilePath Chemin vers le fichier stocké en local - * @return Notification - */ - public function createNotificationFusionFini(string $destinataires, These $these, string $outputFilePath): Notification - { - $to = array_map('trim', explode(',', $destinataires)); - - $notif = $this->createNotification(); - $notif - ->setSubject("Ajout de la page de couverture terminé") - ->setTo($to) - ->setTemplatePath('depot/depot/mail/notif-fusion-fini') - ->setTemplateVariables([ - 'these' => $these, - 'outputFilePath' => $outputFilePath, - 'url' => '', - ]); - - return $notif; - } -} \ No newline at end of file diff --git a/module/Application/src/Application/Service/Notification/NotificationFactoryAwareTrait.php b/module/Application/src/Application/Service/Notification/NotificationFactoryAwareTrait.php deleted file mode 100644 index 72176e19c3b89c266bc3eed63df96edfa35eb70a..0000000000000000000000000000000000000000 --- a/module/Application/src/Application/Service/Notification/NotificationFactoryAwareTrait.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php - -namespace Application\Service\Notification; - -trait NotificationFactoryAwareTrait -{ - /** - * @var NotificationFactory - */ - protected $notificationFactory; - - /** - * @param NotificationFactory $notificationFactory - */ - public function setNotificationFactory(NotificationFactory $notificationFactory) - { - $this->notificationFactory = $notificationFactory; - } -} \ No newline at end of file diff --git a/module/Application/src/Application/Service/Notification/NotifierService.php b/module/Application/src/Application/Service/Notification/NotifierService.php deleted file mode 100644 index 696a5fd220b6cbf82ebb764b70a911c7c010b8fc..0000000000000000000000000000000000000000 --- a/module/Application/src/Application/Service/Notification/NotifierService.php +++ /dev/null @@ -1,512 +0,0 @@ -<?php - -namespace Application\Service\Notification; - -use These\Entity\Db\Acteur; -use Individu\Entity\Db\Individu; -use Application\Entity\Db\MailConfirmation; -use Application\Entity\Db\Role; -use These\Entity\Db\These; -use Application\Entity\Db\Utilisateur; -use Application\Entity\Db\Variable; -use Depot\Notification\ChangementCorrectionAttendueNotification; -use These\Notification\ChangementsResultatsThesesNotification; -use Depot\Notification\PasDeMailPresidentJury; -use These\Notification\ResultatTheseAdmisNotification; -use Depot\Notification\ValidationDepotTheseCorrigeeNotification; -use Depot\Notification\ValidationPageDeCouvertureNotification; -use Depot\Notification\ValidationRdvBuNotification; -use Depot\Rule\NotificationDepotVersionCorrigeeAttenduRule; -use Structure\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait; -use Individu\Service\IndividuServiceAwareTrait; -use Application\Service\Role\RoleServiceAwareTrait; -use Structure\Service\UniteRecherche\UniteRechercheServiceAwareTrait; -use Application\Service\Variable\VariableServiceAwareTrait; -use Import\Model\ImportObservResult; -use Notification\Notification; -use UnicaenApp\Exception\LogicException; -use Laminas\Mvc\Plugin\FlashMessenger\FlashMessenger; -use Laminas\View\Helper\Url as UrlHelper; - -/** - * Service d'envoi de notifications par mail. - * - * @method NotificationFactory getNotificationFactory() - * - * @author Unicaen - */ -class NotifierService extends \Notification\Service\NotifierService -{ - use VariableServiceAwareTrait; - use EcoleDoctoraleServiceAwareTrait; - use UniteRechercheServiceAwareTrait; - use RoleServiceAwareTrait; - use IndividuServiceAwareTrait; - - /** - * @var UrlHelper - */ - protected $urlHelper; - - /** - * Notification à l'issue de la validation de la page de couverture. - * - * @param \These\Entity\Db\These $these - * @param string $action - * @throws \Notification\Exception\NotificationException - */ - public function triggerValidationPageDeCouvertureNotification(These $these, string $action) - { - $notification = new ValidationPageDeCouvertureNotification(); - $notification->setThese($these); - $notification->setAction($action); - $notification->setEmailBu($this->fetchEmailBu($these)); - - $this->trigger($notification); - } - - /** - * Notification concernant la validation à l'issue du RDV BU. - * - * @param \Depot\Notification\ValidationRdvBuNotification $notification - */ - public function triggerValidationRdvBu(ValidationRdvBuNotification $notification) - { - $these = $notification->getThese(); - - $notification->setEmailBdd($this->fetchEmailBdd($these)); - $notification->setEmailBu($this->fetchEmailBu($these)); - - $this->trigger($notification); - } - - /** - * Notification concernant des changements quelconques de résultats de thèses. - * - * @param array $data Données concernant les thèses dont le résultat a changé - * @return ChangementsResultatsThesesNotification - */ - public function triggerChangementResultatTheses(array $data): ChangementsResultatsThesesNotification - { - $these = current($data)['these']; - - $emailBdd = $this->fetchEmailBdd($these); - $emailBu = $this->fetchEmailBu($these); - - $notif = new ChangementsResultatsThesesNotification(); - $notif->setData($data); - $notif->setTo([$emailBdd, $emailBu]); - - $this->trigger($notif); - - return $notif; - } - - /** - * Notification à propos de résultats de thèses passés à 'Admis'. - * - * @param array $data - * @return ResultatTheseAdmisNotification[] - */ - public function triggerChangementResultatThesesAdmis(array $data): array - { - $notifs = []; - - foreach ($data as $array) { - $these = $array['these']; - /* @var These $these */ - - $emailBdd = $this->fetchEmailBdd($these); - - $notif = new ResultatTheseAdmisNotification(); - $notif->setThese($these); - $notif->setEmailBdd($emailBdd); - - $this->trigger($notif); - - $notifs[] = $notif; - } - - return $notifs; - } - - /** - * Notification à propos de corrections attendues. - * - * @param ImportObservResult $record - * @param These $these - * @param string $message - * @return ChangementCorrectionAttendueNotification|null - */ - public function triggerCorrectionAttendue(ImportObservResult $record, These $these, &$message = null): ?ChangementCorrectionAttendueNotification - { - // interrogation de la règle métier pour savoir comment agir... - $rule = new NotificationDepotVersionCorrigeeAttenduRule(); - $rule - ->setThese($these) - ->setDateDerniereNotif($record->getDateNotif()) - ->execute(); - $message = $rule->getMessage(' '); - $estPremiereNotif = $rule->estPremiereNotif(); - $dateProchaineNotif = $rule->getDateProchaineNotif(); - - if ($dateProchaineNotif === null) { - return null; - } - - $dateProchaineNotif->setTime(0, 0, 0); - $now = (new \DateTime())->setTime(0, 0, 0); - - if ($now != $dateProchaineNotif) { - return null; - } - - $notif = new ChangementCorrectionAttendueNotification(); - $notif - ->setThese($these) - ->setEstPremiereNotif($estPremiereNotif); - - $this->trigger($notif); - - return $notif; - } - - /** - * Notification à propos du dépassement de la date butoir de dépôt de la version corrigée de la thèse. - * - * @param These $these - */ - public function triggerDateButoirCorrectionDepassee(These $these) - { - $to = $this->fetchEmailBdd($these); - - $notif = new Notification(); - $notif - ->setSubject("Corrections " . lcfirst($these->getCorrectionAutoriseeToString(true)) . " non faites") - ->setTo($to) - ->setTemplatePath('depot/depot/mail/notif-date-butoir-correction-depassee') - ->setTemplateVariables([ - 'these' => $these, - ]); - - $this->trigger($notif); - } - - /** - * Notification pour inviter à valider les corrections. - * - * @param 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()->findOneByCodeAndStructureConcrete(Role::CODE_PRESIDENT_JURY, $these->getEtablissement()); - $url = $this->urlHelper->__invoke('zfcuser/login', ['type' => 'local'], ['query' => ['redirect' => $targetedUrl, 'role' => $president->getRoleId()], 'force_canonical' => true], true); - - // envoi de mail aux directeurs de thèse - $notif = new ValidationDepotTheseCorrigeeNotification(); - $notif - ->setThese($these) - ->setEmailBdd($this->fetchEmailBdd($these)) - ->setTemplateVariables([ - 'these' => $these, - 'url' => $url, - ]); - if ($utilisateur !== null) { - $notif->setDestinataire($utilisateur); - } - - $this->trigger($notif); - - $infoMessages = $notif->getInfoMessages(); - $this->messageContainer->setMessages([ - 'info' => $infoMessages[0], - ]); - if ($errorMessages = $notif->getWarningMessages()) { - $this->messageContainer->addMessages([ - 'danger' => $errorMessages[0], - ]); - } - } - - /** - * Notification à propos de l'absence de mail connu pour le président du jury. - * - * @param These $these - * @param Acteur|null $president - */ - public function triggerPasDeMailPresidentJury(These $these, ?Acteur $president) - { - $notif = new PasDeMailPresidentJury(); - $notif - ->setThese($these) - ->setEmailBdd($this->fetchEmailBdd($these)) - ->setPresident($president) - ->setTemplateVariables([ - 'these' => $these, - 'president' => $president, - ]); - - $this->trigger($notif); - - $infoMessages = $notif->getInfoMessages(); - $this->messageContainer->setMessages([ - 'info' => $infoMessages[0], - ]); - if ($errorMessages = $notif->getWarningMessages()) { - $this->messageContainer->addMessages([ - 'danger' => $errorMessages[0], - ]); - } - } - - /** - * Notification à propos de la validation des corrections attendues. - * - * @param Notification $notif - * @param These $these - */ - public function triggerValidationCorrectionThese(Notification $notif, These $these) - { - $to = $this->fetchEmailBdd($these); - $notif - ->setTo($to) - ->setTemplateVariables([ - 'these' => $these, - ]); - - $this->trigger($notif); - - $infoMessage = sprintf("Un mail de notification vient d'être envoyé à la Maison du doctorat (%s)", $to); - $this->messageContainer->setMessage($infoMessage, 'info'); - } - - /** - * @param Notification $notif - * @param These $these - */ - public function triggerValidationCorrectionTheseEtudiant(Notification $notif, These $these) - { - $individu = $these->getDoctorant()->getIndividu(); - $to = $individu->getEmailContact() ?: $individu->getEmailPro() ?: $individu->getEmailUtilisateur(); - if (!$to) { - $this->messageContainer->setMessage("Impossible d'envoyer un mail à {$these->getDoctorant()} car son adresse est inconnue", 'danger'); - - return; - } - $notif->setTo($to); - - $this->trigger($notif); - - $infoMessage = sprintf("Un mail de notification vient d'être envoyé au doctorant (%s)", $to); - if ($this->messageContainer->getMessage()) { - $new_message = "<ul><li>" . $this->messageContainer->getMessage() . "</li><li>" . $infoMessage . "</li></ul>"; - $this->messageContainer->setMessage($new_message, 'info'); - } else { - $this->messageContainer->setMessage($infoMessage, 'info'); - } - } - - /** - * Notification pour confirmation d'une adresse mail. - * - * @param MailConfirmation $mailConfirmation - * @param string $confirmUrl - * @throws \Notification\Exception\NotificationException - */ - public function triggerMailConfirmation(MailConfirmation $mailConfirmation, string $confirmUrl) - { - $notif = new Notification(); - $notif - ->setSubject("Confirmation de votre adresse électronique") - ->setTo($mailConfirmation->getEmail()) - ->setTemplatePath('doctorant/mail/demande-confirmation-mail') - ->setTemplateVariables([ - 'destinataire' => $mailConfirmation->getIndividu()->getNomUsuel(), - 'confirmUrl' => $confirmUrl, - ]); - - $this->trigger($notif); - } - - /** - * @param These $these - * @return string - */ - protected function fetchEmailBdd(These $these) - { - $variable = $this->variableService->getRepository()->findOneByCodeAndThese(Variable::CODE_EMAIL_BDD, $these); - - return $variable->getValeur(); - } - - /** - * @param These $these - * @return string - */ - protected function fetchEmailBu(These $these) - { - $variable = $this->variableService->getRepository()->findOneByCodeAndThese(Variable::CODE_EMAIL_BU, $these); - - return $variable->getValeur(); - } - - /** - * @param UrlHelper $urlHelper - */ - public function setUrlHelper(UrlHelper $urlHelper) - { - $this->urlHelper = $urlHelper; - } - - /** - * @param FlashMessenger $flashMessenger - * @param string $namespacePrefix - */ - public function feedFlashMessenger(FlashMessenger $flashMessenger, $namespacePrefix = '') - { - $notificationLogs = $this->getLogs(); - - if (! empty($notificationLogs['info'])) { - $flashMessenger->addMessage($notificationLogs['info'], $namespacePrefix . 'info'); - } - if (! empty($notificationLogs['danger'])) { - $flashMessenger->addMessage($notificationLogs['danger'], $namespacePrefix . 'danger'); - } - } - - /** - * Notification à propos d'un rôle attribué/retiré à un utilisateur. - * - * @var string $type - * @var Role $role - * @var Individu $individu - * @throws \Notification\Exception\NotificationException - */ - public function triggerChangementRole($type, $role, $individu) - { - $mail = $individu->getEmailContact() ?: $individu->getEmailPro() ?: $individu->getEmailUtilisateur(); - - $notif = new Notification(); - $notif - ->setSubject("Modification de vos rôles dans l'application") - ->setTo($mail) - ->setTemplatePath('application/utilisateur/changement-role') - ->setTemplateVariables([ - 'type' => $type, - 'role' => $role, - 'individu' => $individu, - ]); - - $this->trigger($notif); - } - - /** - * Notification à propos de la création d'un compte local. - * - * @param Utilisateur $utilisateur - * @param string $token - */ - public function triggerInitialisationCompte(Utilisateur $utilisateur, string $token) { - - $email = $utilisateur->getEmail(); - if ($email === null) throw new LogicException("Aucun email de fourni !"); - - $token = $utilisateur->getPasswordResetToken(); - if ($token === null) throw new LogicException("Aucun token de fourni !"); - - if (!empty($email)) { - $notif = new Notification(); - $notif - ->setSubject("Initialisation de votre compte") - ->setTo($email) - ->setTemplatePath('application/utilisateur/mail/init-compte') - ->setTemplateVariables([ - 'username' => $utilisateur->getUsername(), - 'url' => $this->urlHelper->__invoke('utilisateur/init-compte', ['token' => $token], ['force_canonical' => true], true), - ]); - $this->trigger($notif); - } - } - - /** - * Notification à propos de la réinitialisation d'un compte local. - * - * @param Utilisateur $utilisateur - * @param string $url - */ - public function triggerResetCompte($utilisateur, $url) { - - $email = $utilisateur->getEmail(); - if ($email === null) throw new LogicException("Aucun email de fourni !"); - - $token = $utilisateur->getPasswordResetToken(); - if ($token === null) throw new LogicException("Aucun token de fourni !"); - - if (!empty($email)) { - $notif = new Notification(); - $notif - ->setSubject("Réinitialisation de votre mot de passe de votre compte") - ->setTo($email) - ->setTemplatePath('application/utilisateur/mail/reinit-compte') - ->setTemplateVariables([ - 'username' => $utilisateur->getUsername(), - 'url' => $url, - ]); - $this->trigger($notif); - } - } - - /** - * Notification à propos d'abonnés de liste de diffusion sans adresse connue. - * - * @param string[] $to - * @param string $liste - * @param string[] $individusAvecAdresse - * @param string[] $individusSansAdresse - */ - public function triggerAbonnesListeDiffusionSansAdresse( - array $to, - $liste, - array $individusAvecAdresse, - array $individusSansAdresse) - { - $to = array_unique(array_filter($to)); - - $notif = $this->createNotificationForAbonnesListeDiffusionSansAdresse( - $to, - $liste, - $individusAvecAdresse, - $individusSansAdresse); - $this->trigger($notif); - } - - /** - * Notification à propos d'abonnés de liste de diffusion sans adresse connue. - * - * @param string[] $to - * @param string $liste - * @param string[] $individusAvecAdresse - * @param string[] $individusSansAdresse - * @return Notification - */ - private function createNotificationForAbonnesListeDiffusionSansAdresse( - array $to, - $liste, - array $individusAvecAdresse, - array $individusSansAdresse): Notification - { - $notif = new Notification(); - $notif - ->setSubject("Abonnés de liste de diffusion sans adresse mail") - ->setTo($to) - ->setTemplatePath('application/liste-diffusion/mail/notif-abonnes-sans-adresse') - ->setTemplateVariables([ - 'liste' => $liste, - 'individusAvecAdresse' => $individusAvecAdresse, - 'individusSansAdresse' => $individusSansAdresse, - ]); - - return $notif; - } -} \ No newline at end of file diff --git a/module/Application/src/Application/Service/Notification/NotifierServiceAwareInterface.php b/module/Application/src/Application/Service/Notification/NotifierServiceAwareInterface.php deleted file mode 100644 index d20db1909005ff19e6047692cd0602dcae52da54..0000000000000000000000000000000000000000 --- a/module/Application/src/Application/Service/Notification/NotifierServiceAwareInterface.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php - -namespace Application\Service\Notification; - -interface NotifierServiceAwareInterface -{ - public function setNotifierService(NotifierService $notifierService); -} \ No newline at end of file diff --git a/module/Application/src/Application/Service/Notification/NotifierServiceAwareTrait.php b/module/Application/src/Application/Service/Notification/NotifierServiceAwareTrait.php deleted file mode 100644 index 1d90bcb436c57437ee79c9e04c0613ab49e88489..0000000000000000000000000000000000000000 --- a/module/Application/src/Application/Service/Notification/NotifierServiceAwareTrait.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -namespace Application\Service\Notification; - -trait NotifierServiceAwareTrait -{ - /** - * @var NotifierService - */ - protected $notifierService; - - /** - * @param NotifierService $notifierService - */ - public function setNotifierService(NotifierService $notifierService) - { - $this->notifierService = $notifierService; - } - - /** - * @return NotifierService - */ - public function getNotifierService() - { - return $this->notifierService; - } - - -} \ No newline at end of file diff --git a/module/Application/src/Application/Service/Notification/NotifierServiceFactory.php b/module/Application/src/Application/Service/Notification/NotifierServiceFactory.php deleted file mode 100644 index dac84f863980c876f13ce964f499cedd85a8a97c..0000000000000000000000000000000000000000 --- a/module/Application/src/Application/Service/Notification/NotifierServiceFactory.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -namespace Application\Service\Notification; - -use Structure\Service\EcoleDoctorale\EcoleDoctoraleService; -use Individu\Service\IndividuService; -use Application\Service\Role\RoleService; -use Structure\Service\UniteRecherche\UniteRechercheService; -use Application\Service\Variable\VariableService; -use Interop\Container\ContainerInterface; -use Laminas\Mvc\Console\View\ViewManager as ConsoleViewManager; -use Laminas\Mvc\View\Http\ViewManager as HttpViewManager; -use Laminas\View\Helper\Url as UrlHelper; - -/** - * @author Unicaen - */ -class NotifierServiceFactory extends \Notification\Service\NotifierServiceFactory -{ - protected $notifierServiceClass = NotifierService::class; - - /** - * Create service. - * - * @param ContainerInterface $container - * @return NotifierService - */ - public function __invoke(ContainerInterface $container) - { - /** @var NotifierService $service */ - $service = parent::__invoke($container); - - /** - * @var VariableService $variableService - * @var EcoleDoctoraleService $ecoleDoctoraleService - * @var UniteRechercheService $uniteRechercheService - * @var IndividuService $individuService - * @var RoleService $roleService - */ - $variableService = $container->get('VariableService'); - $ecoleDoctoraleService = $container->get('EcoleDoctoraleService'); - $uniteRechercheService = $container->get('UniteRechercheService'); - $individuService = $container->get(IndividuService::class); - $roleService = $container->get('RoleService'); - - /** @var HttpViewManager|ConsoleViewManager $vm */ - $vm = $container->get('ViewManager'); - /** @var UrlHelper $urlHelper */ -// $urlHelper = $vm->getHelperManager()->get('Url'); - $urlHelper = $container->get('ViewHelperManager')->get('Url'); - - /** @var NotificationFactory $notificationFactory */ - $notificationFactory = $container->get(NotificationFactory::class); - - $service->setNotificationFactory($notificationFactory); - $service->setVariableService($variableService); - $service->setEcoleDoctoraleService($ecoleDoctoraleService); - $service->setUniteRechercheService($uniteRechercheService); - $service->setUrlHelper($urlHelper); - $service->setIndividuService($individuService); - $service->setRoleService($roleService); - - return $service; - } -} diff --git a/module/Application/src/Application/Service/Rapport/Avis/RapportAvisService.php b/module/Application/src/Application/Service/Rapport/Avis/RapportAvisService.php index 0cd1b3faae7f6eae30647e59924aa943d519dfd6..23b2e045dda08164306622e0d3130cdab556377b 100644 --- a/module/Application/src/Application/Service/Rapport/Avis/RapportAvisService.php +++ b/module/Application/src/Application/Service/Rapport/Avis/RapportAvisService.php @@ -6,7 +6,6 @@ use Application\Entity\Db\RapportAvis; use Application\Service\BaseService; use Structure\Service\Etablissement\EtablissementServiceAwareTrait; use Fichier\Service\NatureFichier\NatureFichierServiceAwareTrait; -use Application\Service\Notification\NotifierServiceAwareTrait; use Doctrine\ORM\NonUniqueResultException; use Exception; use UnicaenApp\Exception\RuntimeException; @@ -14,7 +13,6 @@ use UnicaenApp\Exception\RuntimeException; class RapportAvisService extends BaseService { use EtablissementServiceAwareTrait; - use NotifierServiceAwareTrait; use NatureFichierServiceAwareTrait; /** diff --git a/module/Application/src/Application/Service/Rapport/Avis/RapportAvisServiceFactory.php b/module/Application/src/Application/Service/Rapport/Avis/RapportAvisServiceFactory.php index e3fa83503c065baec6185b7b757db89f7126f6d6..1e9bc3862529f5bbee835dea2e5360a00eb7f0cb 100644 --- a/module/Application/src/Application/Service/Rapport/Avis/RapportAvisServiceFactory.php +++ b/module/Application/src/Application/Service/Rapport/Avis/RapportAvisServiceFactory.php @@ -3,7 +3,6 @@ namespace Application\Service\Rapport\Avis; use Structure\Service\Etablissement\EtablissementService; -use Application\Service\Notification\NotifierService; use Interop\Container\ContainerInterface; class RapportAvisServiceFactory @@ -12,15 +11,12 @@ class RapportAvisServiceFactory { /** * @var EtablissementService $etablissementService - * @var NotifierService $notifierService */ $etablissementService = $container->get('EtablissementService'); - $notifierService = $container->get(NotifierService::class); $service = new RapportAvisService(); $service->setEtablissementService($etablissementService); - $service->setNotifierService($notifierService); return $service; } diff --git a/module/Application/src/Application/Service/Rapport/RapportService.php b/module/Application/src/Application/Service/Rapport/RapportService.php index a6ab2d473052c8feb2c385dd7a19ebb7fbb97df2..622f88fb6bcd19f0849e4eb9915ecee07e9db623 100644 --- a/module/Application/src/Application/Service/Rapport/RapportService.php +++ b/module/Application/src/Application/Service/Rapport/RapportService.php @@ -18,7 +18,6 @@ use Fichier\Service\Fichier\FichierServiceAwareTrait; use These\Service\FichierThese\PdcData; use Fichier\Service\Fichier\FichierStorageServiceAwareTrait; use Fichier\Service\NatureFichier\NatureFichierServiceAwareTrait; -use Application\Service\Notification\NotifierServiceAwareTrait; use Depot\Service\PageDeCouverture\PageDeCouverturePdfExporterAwareTrait; use Application\Service\RapportValidation\RapportValidationServiceAwareTrait; use Fichier\Service\Storage\Adapter\Exception\StorageAdapterException; @@ -37,7 +36,6 @@ class RapportService extends BaseService use FichierStorageServiceAwareTrait; use VersionFichierServiceAwareTrait; use EtablissementServiceAwareTrait; - use NotifierServiceAwareTrait; use NatureFichierServiceAwareTrait; use RapportValidationServiceAwareTrait; use PageDeCouverturePdfExporterAwareTrait; diff --git a/module/Application/src/Application/Service/Rapport/RapportServiceFactory.php b/module/Application/src/Application/Service/Rapport/RapportServiceFactory.php index b940413cdf36b89fdf09208f430f0a8fb5c4f2ce..4833b3db0e5d0a53d7847bda9ed5fc1668e61575 100644 --- a/module/Application/src/Application/Service/Rapport/RapportServiceFactory.php +++ b/module/Application/src/Application/Service/Rapport/RapportServiceFactory.php @@ -6,7 +6,6 @@ use Structure\Service\Etablissement\EtablissementService; use Fichier\Service\Fichier\FichierService; use Fichier\Service\Fichier\FichierStorageService; use Fichier\Service\NatureFichier\NatureFichierService; -use Application\Service\Notification\NotifierService; use Depot\Service\PageDeCouverture\PageDeCouverturePdfExporter; use Application\Service\RapportValidation\RapportValidationService; use Fichier\Service\ValiditeFichier\ValiditeFichierService; @@ -34,7 +33,6 @@ class RapportServiceFactory implements FactoryInterface * @var \Fichier\Service\ValiditeFichier\ValiditeFichierService $validiteFichierService * @var RetraitementService $retraitementService * @var EtablissementService $etablissementService - * @var NotifierService $notifierService * @var NatureFichierService $natureFichierService * @var RapportValidationService $rapportValidationService */ @@ -42,7 +40,6 @@ class RapportServiceFactory implements FactoryInterface $fileService = $container->get(FichierStorageService::class); $versionFichierService = $container->get('VersionFichierService'); $etablissementService = $container->get('EtablissementService'); - $notifierService = $container->get(NotifierService::class); $natureFichierService = $container->get('NatureFichierService'); $rapportValidationService = $container->get(RapportValidationService::class); $pdcPdfExporter = $this->createPageDeCouverturePdfExporter($container); @@ -53,7 +50,6 @@ class RapportServiceFactory implements FactoryInterface $service->setFichierStorageService($fileService); $service->setVersionFichierService($versionFichierService); $service->setEtablissementService($etablissementService); - $service->setNotifierService($notifierService); $service->setNatureFichierService($natureFichierService); $service->setRapportValidationService($rapportValidationService); $service->setPageDeCouverturePdfExporter($pdcPdfExporter); diff --git a/module/Application/tests/ApplicationFunctionalTest/Service/Workflow/VersionCorrigee/WorkflowServiceTest.php b/module/Application/tests/ApplicationFunctionalTest/Service/Workflow/VersionCorrigee/WorkflowServiceTest.php index f11c5046ff1b2c48fc579368abc1eb4ede516fcd..ab35af86933f778ae0c2f602545390350dd65368 100644 --- a/module/Application/tests/ApplicationFunctionalTest/Service/Workflow/VersionCorrigee/WorkflowServiceTest.php +++ b/module/Application/tests/ApplicationFunctionalTest/Service/Workflow/VersionCorrigee/WorkflowServiceTest.php @@ -38,13 +38,13 @@ class WorkflowServiceTest extends WorkflowServiceAbstractTest $this->assertEtapeEstCourante(WfEtape::CODE_DEPOT_VERSION_ORIGINALE); // correction autorisee = mineure - $this->these->setCorrectionAutorisee(These::CORRECTION_AUTORISEE_FACULTATIVE); + $this->these->setCorrectionAutorisee(These::$CORRECTION_AUTORISEE_FACULTATIVE); $this->em()->flush($this->these); $this->wfs->reloadWorkflow($this->these); $this->assertEtapeEstCourante(WfEtape::CODE_DEPOT_VERSION_ORIGINALE); // correction autorisee = majeure - $this->these->setCorrectionAutorisee(These::CORRECTION_AUTORISEE_OBLIGATOIRE); + $this->these->setCorrectionAutorisee(These::$CORRECTION_AUTORISEE_OBLIGATOIRE); $this->em()->flush($this->these); $this->wfs->reloadWorkflow($this->these); $this->assertEtapeEstCourante(WfEtape::CODE_DEPOT_VERSION_ORIGINALE_CORRIGEE); @@ -52,13 +52,13 @@ class WorkflowServiceTest extends WorkflowServiceAbstractTest $this->_franchir_etape_rdv_bu_validation_bu(); // correction autorisee = mineure - $this->these->setCorrectionAutorisee(These::CORRECTION_AUTORISEE_FACULTATIVE); + $this->these->setCorrectionAutorisee(These::$CORRECTION_AUTORISEE_FACULTATIVE); $this->em()->flush($this->these); $this->wfs->reloadWorkflow($this->these); $this->assertEtapeEstCourante(WfEtape::CODE_DEPOT_VERSION_ORIGINALE_CORRIGEE); // correction autorisee = majeure - $this->these->setCorrectionAutorisee(These::CORRECTION_AUTORISEE_OBLIGATOIRE); + $this->these->setCorrectionAutorisee(These::$CORRECTION_AUTORISEE_OBLIGATOIRE); $this->em()->flush($this->these); $this->wfs->reloadWorkflow($this->these); $this->assertEtapeEstCourante(WfEtape::CODE_DEPOT_VERSION_ORIGINALE_CORRIGEE); @@ -67,7 +67,7 @@ class WorkflowServiceTest extends WorkflowServiceAbstractTest public function test_etape_validation_correction_directeurs_necessite_toutes_les_validations() { // pré-requis: correction autorisee != null - $this->these->setCorrectionAutorisee(These::CORRECTION_AUTORISEE_FACULTATIVE); + $this->these->setCorrectionAutorisee(These::$CORRECTION_AUTORISEE_FACULTATIVE); $this->em()->flush($this->these); $this->wfs->reloadWorkflow($this->these); $this->assertEtapeEstCourante(WfEtape::CODE_DEPOT_VERSION_ORIGINALE_CORRIGEE); @@ -108,7 +108,7 @@ class WorkflowServiceTest extends WorkflowServiceAbstractTest public function test_cas_version_originale_valide() { // pré-requis: correction autorisee != null - $this->these->setCorrectionAutorisee(These::CORRECTION_AUTORISEE_FACULTATIVE); + $this->these->setCorrectionAutorisee(These::$CORRECTION_AUTORISEE_FACULTATIVE); $this->em()->flush($this->these); $this->wfs->reloadWorkflow($this->these); $this->_assertSeuleEtapeCourante(WfEtape::CODE_DEPOT_VERSION_ORIGINALE_CORRIGEE); @@ -154,7 +154,7 @@ class WorkflowServiceTest extends WorkflowServiceAbstractTest public function test_cas_vo_nonvalide_va_valide_conforme() { // pré-requis: correction autorisee != null - $this->these->setCorrectionAutorisee(These::CORRECTION_AUTORISEE_FACULTATIVE); + $this->these->setCorrectionAutorisee(These::$CORRECTION_AUTORISEE_FACULTATIVE); $this->em()->flush($this->these); $this->wfs->reloadWorkflow($this->these); @@ -200,7 +200,7 @@ class WorkflowServiceTest extends WorkflowServiceAbstractTest public function test_cas_vo_nonvalide_va_valide_nonconforme() { // pré-requis: correction autorisee != null - $this->these->setCorrectionAutorisee(These::CORRECTION_AUTORISEE_FACULTATIVE); + $this->these->setCorrectionAutorisee(These::$CORRECTION_AUTORISEE_FACULTATIVE); $this->em()->flush($this->these); $this->wfs->reloadWorkflow($this->these); @@ -225,7 +225,7 @@ class WorkflowServiceTest extends WorkflowServiceAbstractTest public function test_cas_vo_nonvalide_va_nonvalide() { // pré-requis: correction autorisee != null - $this->these->setCorrectionAutorisee(These::CORRECTION_AUTORISEE_FACULTATIVE); + $this->these->setCorrectionAutorisee(These::$CORRECTION_AUTORISEE_FACULTATIVE); $this->em()->flush($this->these); $this->wfs->reloadWorkflow($this->these); diff --git a/module/Application/tests/ApplicationUnitTest/Rule/NotificationDepotVersionCorrigeeAttenduRuleTest.php b/module/Application/tests/ApplicationUnitTest/Rule/NotificationDepotVersionCorrigeeAttenduRuleTest.php index 8ab9f54eaec2703449dc59df36c8ca51021bb5e8..a321fe944812a68837b4dc8c2c357040926cfc79 100644 --- a/module/Application/tests/ApplicationUnitTest/Rule/NotificationDepotVersionCorrigeeAttenduRuleTest.php +++ b/module/Application/tests/ApplicationUnitTest/Rule/NotificationDepotVersionCorrigeeAttenduRuleTest.php @@ -12,7 +12,7 @@ class NotificationDepotVersionCorrigeeAttenduRuleTest extends \PHPUnit_Framework { public function test_retourne_date_null_si_date_butoire_null() { - $correctionAutorisee = These::CORRECTION_AUTORISEE_FACULTATIVE; + $correctionAutorisee = These::$CORRECTION_AUTORISEE_FACULTATIVE; $these = $this->theseMock($correctionAutorisee, $dateButoir = null); @@ -88,7 +88,7 @@ class NotificationDepotVersionCorrigeeAttenduRuleTest extends \PHPUnit_Framework */ public function test_correction_mineure($aujourdhui, $dateDerniereNotif, $dateButoir, $expectedDateProchaineNotif, $expectedEstPremiereNotif) { - $correctionAutorisee = These::CORRECTION_AUTORISEE_FACULTATIVE; + $correctionAutorisee = These::$CORRECTION_AUTORISEE_FACULTATIVE; $these = $this->theseMock($correctionAutorisee, $dateButoir); @@ -216,7 +216,7 @@ class NotificationDepotVersionCorrigeeAttenduRuleTest extends \PHPUnit_Framework */ public function test_correction_majeure($aujourdhui, $dateDerniereNotif, $dateButoir, $expectedDateProchaineNotif, $expectedEstPremiereNotif) { - $correctionAutorisee = These::CORRECTION_AUTORISEE_OBLIGATOIRE; + $correctionAutorisee = These::$CORRECTION_AUTORISEE_OBLIGATOIRE; $these = $this->theseMock($correctionAutorisee, $dateButoir); diff --git a/module/Application/tests/ApplicationUnitTest/Service/ImportObservResultService/NotifCorrectionAttendueTest.php b/module/Application/tests/ApplicationUnitTest/Service/ImportObservResultService/NotifCorrectionAttendueTest.php index d2c6b65b787fc51ab4b7e898f6750981de13df6c..a73bc473c0b5766f50df6d9d4f3cf55afa8f23dd 100644 --- a/module/Application/tests/ApplicationUnitTest/Service/ImportObservResultService/NotifCorrectionAttendueTest.php +++ b/module/Application/tests/ApplicationUnitTest/Service/ImportObservResultService/NotifCorrectionAttendueTest.php @@ -7,7 +7,7 @@ use Import\Model\Repository\ImportObservResultRepository; use These\Entity\Db\These; use Depot\Rule\NotificationDepotVersionCorrigeeAttenduRule; use Import\Model\Service\ImportObservResultService; -use Application\Service\Notification\NotifierService; +use Notification\Service\NotifierService; use These\Service\These\TheseService; use ApplicationUnitTest\Test\Asset\EntityAsset; use ApplicationUnitTest\Test\Provider\MockProviderAwareTrait; @@ -37,8 +37,8 @@ class NotifCorrectionAttendueTest extends \PHPUnit_Framework_TestCase public function getTypeCorrectionAttendue() { return [ - [These::CORRECTION_AUTORISEE_FACULTATIVE], - [These::CORRECTION_AUTORISEE_OBLIGATOIRE], + [These::$CORRECTION_AUTORISEE_FACULTATIVE], + [These::$CORRECTION_AUTORISEE_OBLIGATOIRE], ]; } @@ -59,7 +59,7 @@ class NotifCorrectionAttendueTest extends \PHPUnit_Framework_TestCase ->expects($this->exactly(1)) // 1 fois par record ->method('triggerCorrectionAttendue'); - if ($typeCorrectionAttendue === These::CORRECTION_AUTORISEE_FACULTATIVE) { + if ($typeCorrectionAttendue === These::$CORRECTION_AUTORISEE_FACULTATIVE) { $this->service->handleImportObservResultsForCorrectionMineure(); } else { @@ -87,7 +87,7 @@ class NotifCorrectionAttendueTest extends \PHPUnit_Framework_TestCase ->expects($this->never()) ->method('triggerCorrectionAttendue'); - if ($typeCorrectionAttendue === These::CORRECTION_AUTORISEE_FACULTATIVE) { + if ($typeCorrectionAttendue === These::$CORRECTION_AUTORISEE_FACULTATIVE) { $this->service->handleImportObservResultsForCorrectionMineure(); } else { @@ -114,7 +114,7 @@ class NotifCorrectionAttendueTest extends \PHPUnit_Framework_TestCase ->expects($this->never()) ->method('triggerCorrectionAttendue'); - if ($typeCorrectionAttendue === These::CORRECTION_AUTORISEE_FACULTATIVE) { + if ($typeCorrectionAttendue === These::$CORRECTION_AUTORISEE_FACULTATIVE) { $this->service->handleImportObservResultsForCorrectionMineure(); } else { @@ -126,7 +126,7 @@ class NotifCorrectionAttendueTest extends \PHPUnit_Framework_TestCase public function test_directeurs_de_these_ne_sont_pas_en_copie_de_la_notif_correction_mineure_attendue() { - $typeCorrectionAttendue = These::CORRECTION_AUTORISEE_FACULTATIVE; + $typeCorrectionAttendue = These::$CORRECTION_AUTORISEE_FACULTATIVE; $record = $this->createImportObservResult($typeCorrectionAttendue); $aujourdhui = new DateTime('today'); // set time to 0 @@ -144,7 +144,7 @@ class NotifCorrectionAttendueTest extends \PHPUnit_Framework_TestCase public function test_directeurs_de_these_ne_sont_pas_en_copie_de_la_1ere_notif_correction_majeure_attendue() { - $typeCorrectionAttendue = These::CORRECTION_AUTORISEE_OBLIGATOIRE; + $typeCorrectionAttendue = These::$CORRECTION_AUTORISEE_OBLIGATOIRE; $record = $this->createImportObservResult($typeCorrectionAttendue); $aujourdhui = new DateTime('today'); // set time to 0 @@ -165,7 +165,7 @@ class NotifCorrectionAttendueTest extends \PHPUnit_Framework_TestCase public function test_directeurs_de_these_sont_en_copie_de_la_2eme_notif_correction_majeure_attendue() { - $typeCorrectionAttendue = These::CORRECTION_AUTORISEE_OBLIGATOIRE; + $typeCorrectionAttendue = These::$CORRECTION_AUTORISEE_OBLIGATOIRE; $record = $this->createImportObservResult($typeCorrectionAttendue); $aujourdhui = new DateTime('today'); // set time to 0 @@ -223,7 +223,7 @@ class NotifCorrectionAttendueTest extends \PHPUnit_Framework_TestCase $this->service = new ImportObservResultService(); $this->service->setEntityManager($em); $this->service->setTheseService($theseService); - $this->service->setNotifierService($this->notificationServiceMock); + $this->service->setApplicationNotifierService($this->notificationServiceMock); $this->service->setRepository($repository); $this->service->setNotificationDepotVersionCorrigeeAttenduRule($this->ruleMock); } diff --git a/module/Application/tests/ApplicationUnitTest/Test/Provider/MockProvider.php b/module/Application/tests/ApplicationUnitTest/Test/Provider/MockProvider.php index 68b1dcb95c5555ef979dd43e53d80dc078aa2301..dce198fa58a0c018a9d266bdb5df4ab77251f461 100644 --- a/module/Application/tests/ApplicationUnitTest/Test/Provider/MockProvider.php +++ b/module/Application/tests/ApplicationUnitTest/Test/Provider/MockProvider.php @@ -2,7 +2,7 @@ namespace ApplicationUnitTest\Test\Provider; -use Application\Service\Notification\NotifierService; +use Notification\Service\NotifierService; use These\Service\These\TheseService; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityRepository; diff --git a/module/Application/view/application/notification/mail/notif-validation-depot-these-corrigee.phtml b/module/Application/view/application/notification/mail/notif-validation-depot-these-corrigee.phtml index fed512cabd6168594b29553e7afbb0bf7993d6aa..c606bc1a23444088f4dd44cbdf6ad0dffc9b1b2f 100644 --- a/module/Application/view/application/notification/mail/notif-validation-depot-these-corrigee.phtml +++ b/module/Application/view/application/notification/mail/notif-validation-depot-these-corrigee.phtml @@ -3,9 +3,8 @@ use These\Entity\Db\These; /** - * @see \Application\Service\Notification\NotifierService::triggerValidationDepotTheseCorrigee() + * @see \Depot\Service\Notification\DepotNotificationFactory::createNotificationValidationDepotTheseCorrigee() * @var These $these - * @var string $message * @var string $url */ ?> diff --git a/module/Depot/config/others/depot.config.php b/module/Depot/config/others/depot.config.php index 72c47e36d915c98e0dc57ca9735a06188f013a82..46f3fdc17c07917b524d601fb438e07df02ec349 100755 --- a/module/Depot/config/others/depot.config.php +++ b/module/Depot/config/others/depot.config.php @@ -32,6 +32,8 @@ use Depot\Service\PageDeCouverture\PageDeCouverturePdfExporter; use Depot\Service\PageDeCouverture\PageDeCouverturePdfExporterFactory; use Depot\Service\These\DepotService; use Depot\Service\These\Factory\DepotServiceFactory; +use Depot\Service\These\Factory\TheseObserverServiceFactory; +use Depot\Service\These\TheseObserverService; use Depot\Service\Url\UrlDepotService; use Depot\Service\Url\UrlDepotServiceFactory; use Depot\View\Helper\Url\UrlDepotHelperFactory; @@ -262,13 +264,6 @@ return [ ], 'roles' => 'user', ], - [ - 'controller' => ObserverController::class, - 'action' => [ - 'notify-date-butoir-correction-depassee', - ], - 'roles' => [], - ], [ 'controller' => DepotController::class, 'action' => [ @@ -708,15 +703,6 @@ return [ 'console' => [ 'router' => [ 'routes' => [ - 'notify-date-butoir-correction-depassee' => [ - 'options' => [ - 'route' => 'notify-date-butoir-correction-depassee', - 'defaults' => [ - 'controller' => ObserverController::class, - 'action' => 'notify-date-butoir-correction-depassee', - ], - ], - ], 'transfer-these-data' => [ 'options' => [ 'route' => 'transfer-these-data --source-id= --destination-id=', @@ -1022,6 +1008,8 @@ return [ DepotController::class => DepotControllerFactory::class, ConsoleController::class => ConsoleControllerFactory::class, ObserverController::class => ObserverControllerFactory::class, + TheseObserverService::class => TheseObserverServiceFactory::class, + 'TheseObserverService' => TheseObserverServiceFactory::class, ], ], 'controller_plugins' => [ diff --git a/module/Depot/config/others/notification.config.php b/module/Depot/config/others/notification.config.php new file mode 100644 index 0000000000000000000000000000000000000000..98949d3491edd1c4db50dda19b0e02b4f155a535 --- /dev/null +++ b/module/Depot/config/others/notification.config.php @@ -0,0 +1,44 @@ +<?php + +namespace Depot; + +use UnicaenAuth\Guard\PrivilegeController; +use Depot\Controller\ObserverController; +use Depot\Service\Notification\DepotNotificationFactory; +use Depot\Service\Notification\DepotNotificationFactoryFactory; + +return [ + 'bjyauthorize' => [ + 'guards' => [ + PrivilegeController::class => [ + [ + 'controller' => ObserverController::class, + 'action' => [ + 'notify-date-butoir-correction-depassee', + ], + 'roles' => [], + ], + ], + ], + ], + 'console' => [ + 'router' => [ + 'routes' => [ + 'notify-date-butoir-correction-depassee' => [ + 'options' => [ + 'route' => 'notify-date-butoir-correction-depassee', + 'defaults' => [ + 'controller' => ObserverController::class, + 'action' => 'notify-date-butoir-correction-depassee', + ], + ], + ], + ], + ], + ], + 'service_manager' => [ + 'factories' => [ + DepotNotificationFactory::class => DepotNotificationFactoryFactory::class, + ], + ], +]; diff --git a/module/Depot/data/TheseEntityAssertion.csv b/module/Depot/data/TheseEntityAssertion.csv index 8e01f39576f5d68489843d204c35702c2d69f163..be45e13995974af3e588b848fb3725b70ef11dc5 100755 --- a/module/Depot/data/TheseEntityAssertion.csv +++ b/module/Depot/data/TheseEntityAssertion.csv @@ -1,28 +1,28 @@ class;Depot\Assertion\These\GeneratedTheseEntityAssertion;;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;;; line;enabled;privilege;isTheseEnCours;isTheseSoutenue;isCorrectionAttendue;isDateButoirDepotVersionCorrigeeDepassee;isInfosBuSaisies;;isExisteFichierTheseVersionCorrigee;isExisteFichierTheseVersionOriginale;;isDepotVersionCorrigeeValide;isExisteValidationBU;isExisteValidationCorrectionsThese;isExisteValidationDepotVersionCorrigee;isExisteValidationRdvBu;isExisteValidationVersionPapierCorrigee;isExisteValidationPageDeCouverture;;isUtilisateurEstAuteurDeLaThese;isUtilisateurExisteParmiValidateursAttendus;isUtilisateurExisteParmiValidateursAyantValide;;isPageDeCouvertureGenerable;;return;message -4;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -5;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;1:1;;;;;;;;;;;;;;;;;;;;;;0;Le dépôt initial n'est plus autorisé car la date de soutenance est passée. -6;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;;;;;;1:0;;;;;;;;0;La page de couverture n’a pas été validée. -7;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Le dépôt d'une version initiale n'est plus possible dès lors qu'une version corrigée est attendue. -8;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. -9;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; -10;1;\These\Provider\Privilege\ThesePrivileges::THESE_FICHIER_DIVERS_TELEVERSER;;;;;;;;;;;;;;;;;;;;;;;;1; -11;1;\These\Provider\Privilege\ThesePrivileges::THESE_FICHIER_DIVERS_CONSULTER;;;;;;;;;;;;;;;;;;;;;;;;1; -12;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -13;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. -14;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. -15;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; -16;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse -17;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;;1:1;;;;;;;;;;;;;;;;;;;;0;La date butoir pour le dépôt de la version corrigée est dépassée (%s). -18;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;;;;;;;;;;1:1;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé par au moins un directeur. -19;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; -20;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;1:0;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -21;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse -22;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. -23;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; -24;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_RDV_BU;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -25;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_RDV_BU;;;;;;;;;;;1:1;;;;;;;;;;;;;0;La validation par la bibliothèque universitaire a été faite. -26;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_RDV_BU;;;;;;;;;;;;;;;;;;;;;;;;1; +4;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +5;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE;;1:1;;;;;;;;;;;;;;;;;;;;;;0;Le dépôt initial n'est plus autorisé car la date de soutenance est passée. +6;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;;;;;;1:0;;;;;;;;0;La page de couverture n’a pas été validée. +7;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Le dépôt d'une version initiale n'est plus possible dès lors qu'une version corrigée est attendue. +8;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. +9;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; +10;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_FICHIER_DIVERS_TELEVERSER;;;;;;;;;;;;;;;;;;;;;;;;1; +11;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_FICHIER_DIVERS_CONSULTER;;;;;;;;;;;;;;;;;;;;;;;;1; +12;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +13;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. +14;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. +15;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; +16;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse +17;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;;1:1;;;;;;;;;;;;;;;;;;;;0;La date butoir pour le dépôt de la version corrigée est dépassée (%s). +18;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;;;;;;;;;;1:1;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé par au moins un directeur. +19;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; +20;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;1:0;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +21;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse +22;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. +23;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; +24;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_RDV_BU;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +25;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_RDV_BU;;;;;;;;;;;1:1;;;;;;;;;;;;;0;La validation par la bibliothèque universitaire a été faite. +26;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_RDV_BU;;;;;;;;;;;;;;;;;;;;;;;;1; 27;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. 28;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE;;;;;;;;;;;;;;;;;;;;;;1:0;;0;Des informations sont manquantes pour pouvoir générer la page de couverture. 29;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE;;;;;;;;;;;;;;;;;;;;;;;;1; @@ -49,31 +49,30 @@ line;enabled;privilege;isTheseEnCours;isTheseSoutenue;isCorrectionAttendue;isDat 50;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_CORRECTION_THESE_SUPPR;;;;;;;;;;;;;;;;;;;;;;;;1; 51;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_VERSION_PAPIER_CORRIGEE;;;;;;;;;;;;;;;1:1;;;;;;;;;0; 52;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_VERSION_PAPIER_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; -53;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -54;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. -55;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. -56;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; -57;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse -58;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. -59;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; -60;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse -61;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;;;;;;1:0;;;;;;;;;;;;;;;;0;Le dépôt d'une version initiale doit être fait au préalable. -62;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. -63;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; -64;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -65;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. -66;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. -67;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; -68;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse -69;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_CORRIGEE;;;;;;;;;;2:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. -70;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; -71;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -72;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. -73;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. -74;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; -75;1;\These\Provider\Privilege\ThesePrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse -76;1;\These\Provider\Privilege\ThesePrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;;1:0;;;;;;;;;;;;;;;;;;;;0;La date butoir pour le dépôt de la version corrigée n’est pas dépassée (%s). -77;1;\These\Provider\Privilege\ThesePrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;;;;;;;;;;;1:1;;;;;;;;;;;0;Le dépôt de la version corrigée a été validé par le doctorant. -78;1;\These\Provider\Privilege\ThesePrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;;;;;;;;;;;;;;;;;;;;;;1; -79;1;\These\Provider\Privilege\ThesePrivileges::THESE_TELECHARGEMENT_FICHIER /* évite UnexpectedPrivilegeException */;;;;;;;;;;;;;;;;;;;;;;;;1; -80;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CORREC_AUTORISEE_FORCEE /* évite UnexpectedPrivilegeException */;;;;;;;;;;;;;;;;;;;;;;;;1; +53;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +54;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. +55;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. +56;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; +57;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse +58;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. +59;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; +60;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse +61;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;;;;;;1:0;;;;;;;;;;;;;;;;0;Le dépôt d'une version initiale doit être fait au préalable. +62;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. +63;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; +64;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +65;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. +66;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. +67;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; +68;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse +69;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_CORRIGEE;;;;;;;;;;2:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. +70;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; +71;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +72;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. +73;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. +74;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; +75;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse +76;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;;1:0;;;;;;;;;;;;;;;;;;;;0;La date butoir pour le dépôt de la version corrigée n’est pas dépassée (%s). +78;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;;;;;;;;;;;;;;;;;;;;;;1; +79;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_TELECHARGEMENT_FICHIER /* évite UnexpectedPrivilegeException */;;;;;;;;;;;;;;;;;;;;;;;;1; +80;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CORREC_AUTORISEE_FORCEE /* évite UnexpectedPrivilegeException */;;;;;;;;;;;;;;;;;;;;;;;;1; diff --git a/module/Depot/src/Depot/Assertion/These/GeneratedTheseEntityAssertion.php b/module/Depot/src/Depot/Assertion/These/GeneratedTheseEntityAssertion.php index 80db34bf2051dd65daef40f5e8ff24ab817fe1e5..0caf9ed4043bf1385c6923f5b89dc26abf2bc893 100644 --- a/module/Depot/src/Depot/Assertion/These/GeneratedTheseEntityAssertion.php +++ b/module/Depot/src/Depot/Assertion/These/GeneratedTheseEntityAssertion.php @@ -5,10 +5,11 @@ namespace Depot\Assertion\These; /** * Classe mère d'Assertion. * - * Générée à partir du fichier /app/module/Depot/data/TheseEntityAssertion.csv. + * Générée à partir du fichier + * /home/gauthierb/workspace/sygal/module/Depot/data/TheseEntityAssertion.csv. * * @author Application\Assertion\Generator\AssertionGenerator - * @date 21/11/2022 10:33:54 + * @date 11/01/2023 11:25:55 */ abstract class GeneratedTheseEntityAssertion { @@ -493,12 +494,6 @@ abstract class GeneratedTheseEntityAssertion $this->failureMessage = "La date butoir pour le dépôt de la version corrigée n’est pas dépassée (%s)."; return false; } - /* line 77 */ - $this->linesTrace[] = '/* line 77 */'; - if ($this->isExisteValidationDepotVersionCorrigee() /* test 17 */) { - $this->failureMessage = "Le dépôt de la version corrigée a été validé par le doctorant."; - return false; - } /* line 78 */ $this->linesTrace[] = '/* line 78 */'; return true; @@ -605,83 +600,82 @@ abstract class GeneratedTheseEntityAssertion return <<<'EOT' class;Depot\Assertion\These\GeneratedTheseEntityAssertion;;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;;; line;enabled;privilege;isTheseEnCours;isTheseSoutenue;isCorrectionAttendue;isDateButoirDepotVersionCorrigeeDepassee;isInfosBuSaisies;;isExisteFichierTheseVersionCorrigee;isExisteFichierTheseVersionOriginale;;isDepotVersionCorrigeeValide;isExisteValidationBU;isExisteValidationCorrectionsThese;isExisteValidationDepotVersionCorrigee;isExisteValidationRdvBu;isExisteValidationVersionPapierCorrigee;isExisteValidationPageDeCouverture;;isUtilisateurEstAuteurDeLaThese;isUtilisateurExisteParmiValidateursAttendus;isUtilisateurExisteParmiValidateursAyantValide;;isPageDeCouvertureGenerable;;return;message -4;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -5;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;1:1;;;;;;;;;;;;;;;;;;;;;;0;Le dépôt initial n'est plus autorisé car la date de soutenance est passée. -6;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;;;;;;1:0;;;;;;;;0;La page de couverture n’a pas été validée. -7;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Le dépôt d'une version initiale n'est plus possible dès lors qu'une version corrigée est attendue. -8;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. -9;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; -10;1;\These\Provider\Privilege\ThesePrivileges::THESE_FICHIER_DIVERS_TELEVERSER;;;;;;;;;;;;;;;;;;;;;;;;1; -11;1;\These\Provider\Privilege\ThesePrivileges::THESE_FICHIER_DIVERS_CONSULTER;;;;;;;;;;;;;;;;;;;;;;;;1; -12;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -13;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. -14;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. -15;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; -16;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse -17;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;;1:1;;;;;;;;;;;;;;;;;;;;0;La date butoir pour le dépôt de la version corrigée est dépassée (%s). -18;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;;;;;;;;;;1:1;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé par au moins un directeur. -19;1;\These\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; -20;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;1:0;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -21;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse -22;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. -23;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; -24;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_RDV_BU;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -25;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_RDV_BU;;;;;;;;;;;1:1;;;;;;;;;;;;;0;La validation par la bibliothèque universitaire a été faite. -26;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_RDV_BU;;;;;;;;;;;;;;;;;;;;;;;;1; -27;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -28;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE;;;;;;;;;;;;;;;;;;;;;;1:0;;0;Des informations sont manquantes pour pouvoir générer la page de couverture. -29;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE;;;;;;;;;;;;;;;;;;;;;;;;1; -30;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE_SUPPR;;;;;;;;;;;;;;;;1:0;;;;;;;;0;La page de couverture n’a pas été validée. -31;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE_SUPPR;;;;;;;;;;;;;;;;;;;;;;;;1; -32;1;\Application\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -33;1;\Application\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU;;;;;;;;;;;1:1;;;;;;;;;;;;;0;La validation par la bibliothèque universitaire a été faite. -34;1;\Application\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU;;;;;1:0;;;;;;;;;;;;;;;;;;;0;La bibliothèque universitaire n'a pas renseigné toutes informations requises. -35;1;\Application\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU;;;;;;;;;;;;;;;;;;;;;;;;1; -36;1;\Application\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU_SUPPR;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -37;1;\Application\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU_SUPPR;;;;;;;;;;;;;;1:0;;;;;;;;;;0; -38;1;\Application\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU_SUPPR;;;;;;;1:1;;;;;;;2:1;;;;;;;;;;0; -39;1;\Application\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU_SUPPR;;;;;;;1:0;;;;;;;2:1;;;;;;;;;;1; -40;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_DEPOT_THESE_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse. -41;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_DEPOT_THESE_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. -42;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_DEPOT_THESE_CORRIGEE;;;;1:1;;;;;;;;;;;;;;;;;;;;0;La date butoir pour le dépôt de la version corrigée est dépassée (%s). -43;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_DEPOT_THESE_CORRIGEE;;;1:1;3:0;;;;;;2:0;;;;;;;;;;;;;;1; -44;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_DEPOT_THESE_CORRIGEE_SUPPR;;;;;;;;;;;;1:1;;;;;;;;;;;;0; -45;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_DEPOT_THESE_CORRIGEE_SUPPR;;;;;;;;;;;;;;;;;;;;;;;;1; -46;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_CORRECTION_THESE;;;;;;;;;;;;;1:0;;;;;;;;;;;0;Le dépôt de la version corrigée n'a pas encore été validé par le doctorant. -47;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_CORRECTION_THESE;;;;;;;;;;;;;;;;;;;1:0;;;;;0; -48;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_CORRECTION_THESE;;;;;;;;;;;;;;;;;;;;;;;;1; -49;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_CORRECTION_THESE_SUPPR;;;;;;;;;;;;;;;;;;;;1:0;;;;0; -50;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_CORRECTION_THESE_SUPPR;;;;;;;;;;;;;;;;;;;;;;;;1; -51;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_VERSION_PAPIER_CORRIGEE;;;;;;;;;;;;;;;1:1;;;;;;;;;0; -52;1;\Application\Provider\Privilege\ValidationPrivileges::VALIDATION_VERSION_PAPIER_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; -53;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -54;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. -55;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. -56;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; -57;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse -58;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. -59;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_DESCRIPTION_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; -60;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse -61;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;;;;;;1:0;;;;;;;;;;;;;;;;0;Le dépôt d'une version initiale doit être fait au préalable. -62;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. -63;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; -64;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -65;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. -66;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. -67;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; -68;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse -69;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_CORRIGEE;;;;;;;;;;2:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. -70;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; -71;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. -72;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. -73;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. -74;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; -75;1;\These\Provider\Privilege\ThesePrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse -76;1;\These\Provider\Privilege\ThesePrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;;1:0;;;;;;;;;;;;;;;;;;;;0;La date butoir pour le dépôt de la version corrigée n’est pas dépassée (%s). -77;1;\These\Provider\Privilege\ThesePrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;;;;;;;;;;;1:1;;;;;;;;;;;0;Le dépôt de la version corrigée a été validé par le doctorant. -78;1;\These\Provider\Privilege\ThesePrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;;;;;;;;;;;;;;;;;;;;;;1; -79;1;\These\Provider\Privilege\ThesePrivileges::THESE_TELECHARGEMENT_FICHIER /* évite UnexpectedPrivilegeException */;;;;;;;;;;;;;;;;;;;;;;;;1; -80;1;\These\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CORREC_AUTORISEE_FORCEE /* évite UnexpectedPrivilegeException */;;;;;;;;;;;;;;;;;;;;;;;;1; +4;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +5;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE;;1:1;;;;;;;;;;;;;;;;;;;;;;0;Le dépôt initial n'est plus autorisé car la date de soutenance est passée. +6;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;;;;;;1:0;;;;;;;;0;La page de couverture n’a pas été validée. +7;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Le dépôt d'une version initiale n'est plus possible dès lors qu'une version corrigée est attendue. +8;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. +9;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; +10;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_FICHIER_DIVERS_TELEVERSER;;;;;;;;;;;;;;;;;;;;;;;;1; +11;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_FICHIER_DIVERS_CONSULTER;;;;;;;;;;;;;;;;;;;;;;;;1; +12;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +13;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. +14;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. +15;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; +16;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse +17;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;;1:1;;;;;;;;;;;;;;;;;;;;0;La date butoir pour le dépôt de la version corrigée est dépassée (%s). +18;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;;;;;;;;;;1:1;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé par au moins un directeur. +19;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_DEPOT_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; +20;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;1:0;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +21;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse +22;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. +23;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; +24;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_RDV_BU;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +25;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_RDV_BU;;;;;;;;;;;1:1;;;;;;;;;;;;;0;La validation par la bibliothèque universitaire a été faite. +26;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_RDV_BU;;;;;;;;;;;;;;;;;;;;;;;;1; +27;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +28;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE;;;;;;;;;;;;;;;;;;;;;;1:0;;0;Des informations sont manquantes pour pouvoir générer la page de couverture. +29;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE;;;;;;;;;;;;;;;;;;;;;;;;1; +30;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE_SUPPR;;;;;;;;;;;;;;;;1:0;;;;;;;;0;La page de couverture n’a pas été validée. +31;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_PAGE_DE_COUVERTURE_SUPPR;;;;;;;;;;;;;;;;;;;;;;;;1; +32;1;\Depot\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +33;1;\Depot\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU;;;;;;;;;;;1:1;;;;;;;;;;;;;0;La validation par la bibliothèque universitaire a été faite. +34;1;\Depot\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU;;;;;1:0;;;;;;;;;;;;;;;;;;;0;La bibliothèque universitaire n'a pas renseigné toutes informations requises. +35;1;\Depot\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU;;;;;;;;;;;;;;;;;;;;;;;;1; +36;1;\Depot\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU_SUPPR;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +37;1;\Depot\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU_SUPPR;;;;;;;;;;;;;;1:0;;;;;;;;;;0; +38;1;\Depot\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU_SUPPR;;;;;;;1:1;;;;;;;2:1;;;;;;;;;;0; +39;1;\Depot\Provider\Privilege\ValidationPrivileges::THESE_VALIDATION_RDV_BU_SUPPR;;;;;;;1:0;;;;;;;2:1;;;;;;;;;;1; +40;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_DEPOT_THESE_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse. +41;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_DEPOT_THESE_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. +42;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_DEPOT_THESE_CORRIGEE;;;;1:1;;;;;;;;;;;;;;;;;;;;0;La date butoir pour le dépôt de la version corrigée est dépassée (%s). +43;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_DEPOT_THESE_CORRIGEE;;;1:1;3:0;;;;;;2:0;;;;;;;;;;;;;;1; +44;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_DEPOT_THESE_CORRIGEE_SUPPR;;;;;;;;;;;;1:1;;;;;;;;;;;;0; +45;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_DEPOT_THESE_CORRIGEE_SUPPR;;;;;;;;;;;;;;;;;;;;;;;;1; +46;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_CORRECTION_THESE;;;;;;;;;;;;;1:0;;;;;;;;;;;0;Le dépôt de la version corrigée n'a pas encore été validé par le doctorant. +47;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_CORRECTION_THESE;;;;;;;;;;;;;;;;;;;1:0;;;;;0; +48;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_CORRECTION_THESE;;;;;;;;;;;;;;;;;;;;;;;;1; +49;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_CORRECTION_THESE_SUPPR;;;;;;;;;;;;;;;;;;;;1:0;;;;0; +50;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_CORRECTION_THESE_SUPPR;;;;;;;;;;;;;;;;;;;;;;;;1; +51;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_VERSION_PAPIER_CORRIGEE;;;;;;;;;;;;;;;1:1;;;;;;;;;0; +52;1;\Depot\Provider\Privilege\ValidationPrivileges::VALIDATION_VERSION_PAPIER_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; +53;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +54;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. +55;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. +56;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; +57;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse +58;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. +59;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_DESCRIPTION_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; +60;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse +61;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;;;;;;1:0;;;;;;;;;;;;;;;;0;Le dépôt d'une version initiale doit être fait au préalable. +62;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;;;;;;;;1:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. +63;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; +64;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +65;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. +66;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. +67;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_ATTESTATIONS_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; +68;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_CORRIGEE;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse +69;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_CORRIGEE;;;;;;;;;;2:1;;;;;;;;;;;;;;0;Opération impossible dès lors que le dépôt de la version corrigée a été validé. +70;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_CORRIGEE;;;;;;;;;;;;;;;;;;;;;;;;1; +71;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération. +72;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue. +73;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la bibliothèque universitaire a validé. +74;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_AUTORISATION_DIFFUSION_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;1; +75;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;1:0;;;;;;;;;;;;;;;;;;;;;0;Aucune correction n'est attendue pour cette thèse +76;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;;1:0;;;;;;;;;;;;;;;;;;;;0;La date butoir pour le dépôt de la version corrigée n’est pas dépassée (%s). +78;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_CORREC_AUTORISEE_ACCORDER_SURSIS;;;;;;;;;;;;;;;;;;;;;;;;1; +79;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_TELECHARGEMENT_FICHIER /* évite UnexpectedPrivilegeException */;;;;;;;;;;;;;;;;;;;;;;;;1; +80;1;\Depot\Provider\Privilege\DepotPrivileges::THESE_SAISIE_CORREC_AUTORISEE_FORCEE /* évite UnexpectedPrivilegeException */;;;;;;;;;;;;;;;;;;;;;;;;1; EOT; } diff --git a/module/Depot/src/Depot/Assertion/These/TheseEntityAssertion.php b/module/Depot/src/Depot/Assertion/These/TheseEntityAssertion.php index 019ff1d00e1f4b0637d65985133e20f3c39a2d3f..b19aa72e8f6d6e646bd33349dd8421f6762d2944 100644 --- a/module/Depot/src/Depot/Assertion/These/TheseEntityAssertion.php +++ b/module/Depot/src/Depot/Assertion/These/TheseEntityAssertion.php @@ -154,7 +154,7 @@ class TheseEntityAssertion extends GeneratedTheseEntityAssertion protected function isDateButoirDepotVersionCorrigeeDepassee(): bool { - return $this->these->isDateButoirDepotVersionCorrigeeDepassee(); + return $this->these->isDateButoirDepotVersionCorrigeeDepassee($this->these->getDateSoutenance()); } protected function isUtilisateurEstAuteurDeLaThese(): bool diff --git a/module/Depot/src/Depot/Controller/DepotController.php b/module/Depot/src/Depot/Controller/DepotController.php index 2a3b17e53c598313448c224c7023da3e5fea3906..0f8ad1b31fcf539fa45c2d1e2528bcc9909e2a85 100755 --- a/module/Depot/src/Depot/Controller/DepotController.php +++ b/module/Depot/src/Depot/Controller/DepotController.php @@ -9,7 +9,6 @@ use Application\Entity\Db\TypeValidation; use Application\Entity\Db\Variable; use Application\Filter\IdifyFilterAwareTrait; use Application\Service\MailConfirmationServiceAwareTrait; -use Application\Service\Notification\NotifierServiceAwareTrait; use Application\Service\Role\RoleServiceAwareTrait; use Application\Service\UserContextServiceAwareTrait; use Application\Service\Utilisateur\UtilisateurServiceAwareTrait; @@ -21,6 +20,7 @@ use Depot\Entity\Db\FichierThese; use Depot\Entity\Db\MetadonneeThese; use Depot\Entity\Db\RdvBu; use Depot\Entity\Db\WfEtape; +use Depot\Event\EventsInterface; use Depot\Form\Attestation\AttestationTheseForm; use Depot\Form\ConformiteFichierForm; use Depot\Form\Diffusion\DiffusionTheseForm; @@ -30,6 +30,7 @@ use Depot\Form\RdvBuTheseDoctorantForm; use Depot\Form\RdvBuTheseForm; use Depot\Service\FichierThese\Exception\ValidationImpossibleException; use Depot\Service\FichierThese\FichierTheseServiceAwareTrait; +use Depot\Service\Notification\DepotNotificationFactoryAwareTrait; use Depot\Service\These\Convention\ConventionPdfExporter; use Depot\Service\These\DepotServiceAwareTrait; use Depot\Service\Validation\DepotValidationServiceAwareTrait; @@ -40,6 +41,7 @@ use Fichier\Entity\Db\VersionFichier; use Fichier\Service\Fichier\FichierStorageServiceAwareTrait; use Fichier\Service\Storage\Adapter\Exception\StorageAdapterException; use Fichier\Service\VersionFichier\VersionFichierServiceAwareTrait; +use Laminas\EventManager\Event; use Laminas\Form\Element\Hidden; use Laminas\Form\Element\Radio; use Laminas\Form\Element\Submit; @@ -49,6 +51,7 @@ use Laminas\InputFilter\InputFilter; use Laminas\Stdlib\ParametersInterface; use Laminas\View\Model\ViewModel; use Laminas\View\Renderer\PhpRenderer; +use Notification\Service\NotifierServiceAwareTrait; use Structure\Service\Etablissement\EtablissementServiceAwareTrait; use Structure\Service\UniteRecherche\UniteRechercheServiceAwareTrait; use These\Entity\Db\These; @@ -64,6 +67,7 @@ class DepotController extends AbstractController use FichierTheseServiceAwareTrait; use FichierStorageServiceAwareTrait; use MessageCollectorAwareTrait; + use DepotNotificationFactoryAwareTrait; use NotifierServiceAwareTrait; use RoleServiceAwareTrait; use TheseServiceAwareTrait; @@ -496,9 +500,9 @@ class DepotController extends AbstractController $valeurCorrectionAutoriseeFromImport = $these->getCorrectionAutorisee(false); $radioOptions = [ - These::CORRECTION_AUTORISEE_FORCAGE_AUCUNE => "Forcer à « <strong>Aucune correction attendue</strong> ».", - These::CORRECTION_AUTORISEE_FORCAGE_FACULTATIVE => "Forcer à « <strong>Corrections facultatives attendues</strong> ».", - These::CORRECTION_AUTORISEE_FORCAGE_OBLIGATOIRE => "Forcer à « <strong>Corrections obligatoires attendues</strong> ».", + These::$CORRECTION_AUTORISEE_FORCAGE_AUCUNE => "Forcer à « <strong>Aucune correction attendue</strong> ».", + These::$CORRECTION_AUTORISEE_FORCAGE_FACULTATIVE => "Forcer à « <strong>Corrections facultatives attendues</strong> ».", + These::$CORRECTION_AUTORISEE_FORCAGE_OBLIGATOIRE => "Forcer à « <strong>Corrections obligatoires attendues</strong> ».", ]; if ($isCorrectionAutoriseeFromImport) { @@ -506,7 +510,7 @@ class DepotController extends AbstractController unset($radioOptions[$valeurCorrectionAutoriseeFromImport]); } else { $correctionAttendueImportee = "Aucune correction attendue"; - unset($radioOptions[These::CORRECTION_AUTORISEE_FORCAGE_AUCUNE]); + unset($radioOptions[These::$CORRECTION_AUTORISEE_FORCAGE_AUCUNE]); } $radioOptions = array_merge( @@ -549,11 +553,16 @@ class DepotController extends AbstractController $result = $this->confirm()->execute(); $these = $this->requestedThese(); - $dateButoirDepotVersionCorrigeeAvecSursis = $these->computeDateButoirDepotVersionCorrigeeAvecSursis(); + $dateButoirDepotVersionCorrigeeAvecSursis = $these->computeDateButoirDepotVersionCorrigeeAvecSursis($these->getDateSoutenance()); // si un tableau est retourné par le plugin Confirm, l'opération a été confirmée if (is_array($result)) { $this->depotService->updateSursisDateButoirDepotVersionCorrigee($these, $dateButoirDepotVersionCorrigeeAvecSursis); + + // déclenchement d'un événement + $event = new Event(EventsInterface::EVENT__SURSIS_CORRECTION_ACCORDE, $these); + $this->events->triggerEvent($event); + $this->flashMessengerAddMessagesFromEvent($event); } $viewModel = $this->confirm()->getViewModel(); @@ -604,9 +613,9 @@ class DepotController extends AbstractController // notification par mail à la BU quand le doctorant saisit les infos pour la 1ere fois if ($estDoctorant && $inserting) { - $notif = $this->notifierService->getNotificationFactory()->createNotificationForRdvBuSaisiParDoctorant($these, $inserting); - $this->notifierService->trigger($notif); - $this->notifierService->feedFlashMessenger($this->flashMessenger(), 'rdv_bu/'); + $notif = $this->depotNotificationFactory->createNotificationForRdvBuSaisiParDoctorant($these, true); + $result = $this->notifierService->trigger($notif); + $result->feedFlashMessenger($this->flashMessenger(), 'rdv_bu/'); } if (! $this->getRequest()->isXmlHttpRequest()) { @@ -1005,7 +1014,6 @@ class DepotController extends AbstractController /** * @throws \Doctrine\ORM\OptimisticLockException - * @throws \Notification\Exception\NotificationImpossibleException */ public function testArchivabiliteAction() { @@ -1430,9 +1438,6 @@ class DepotController extends AbstractController return $form; } - /** - * @throws \Notification\Exception\NotificationImpossibleException - */ public function modifierCertifConformiteAction() { $these = $this->requestedThese(); diff --git a/module/Depot/src/Depot/Controller/Factory/DepotControllerFactory.php b/module/Depot/src/Depot/Controller/Factory/DepotControllerFactory.php index 3f3262002fc930f48a9d995b072b93f89faa6d8b..1a2299eb9e3f2e7c5a15f322aa65e9c0a2720b60 100644 --- a/module/Depot/src/Depot/Controller/Factory/DepotControllerFactory.php +++ b/module/Depot/src/Depot/Controller/Factory/DepotControllerFactory.php @@ -3,13 +3,13 @@ namespace Depot\Controller\Factory; use Application\Service\MailConfirmationService; -use Application\Service\Notification\NotifierService; use Application\Service\Role\RoleService; use Application\Service\Utilisateur\UtilisateurService; use Application\Service\Validation\ValidationService; use Application\Service\Variable\VariableService; use Depot\Controller\DepotController; use Depot\Service\FichierThese\FichierTheseService; +use Depot\Service\Notification\DepotNotificationFactory; use Depot\Service\These\DepotService; use Depot\Service\Validation\DepotValidationService; use Doctrine\ORM\EntityManager; @@ -17,7 +17,9 @@ use Fichier\Service\Fichier\FichierStorageService; use Fichier\Service\VersionFichier\VersionFichierService; use Individu\Service\IndividuService; use Interop\Container\ContainerInterface; +use Laminas\EventManager\EventManager; use Laminas\View\Renderer\PhpRenderer; +use Notification\Service\NotifierService; use Structure\Service\Etablissement\EtablissementService; use Structure\Service\UniteRecherche\UniteRechercheService; use These\Service\Acteur\ActeurService; @@ -26,10 +28,8 @@ use These\Service\These\TheseService; class DepotControllerFactory { /** - * Create service - * - * @param ContainerInterface $container - * @return DepotController + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface */ public function __invoke(ContainerInterface $container): DepotController { @@ -53,6 +53,7 @@ class DepotControllerFactory * @var UtilisateurService $utilisateurService * @var ActeurService $acteurService * @var IndividuService $indivdiService + * @var EventManager $eventManager */ $variableService = $container->get('VariableService'); $validationService = $container->get('ValidationService'); @@ -69,6 +70,7 @@ class DepotControllerFactory $entityManager = $container->get('doctrine.entitymanager.orm_default'); $notifierService = $container->get(NotifierService::class); $utilisateurService = $container->get('UtilisateurService'); + $eventManager = $container->get('EventManager'); /** * @var \Depot\Form\RdvBuTheseDoctorantForm $rdvBuTheseDoctorantForm @@ -120,6 +122,14 @@ class DepotControllerFactory $depotService = $container->get(DepotService::class); $controller->setDepotService($depotService); + /** @var \Depot\Service\Notification\DepotNotificationFactory $depotNotificationFactory */ + $depotNotificationFactory = $container->get(DepotNotificationFactory::class); + $controller->setDepotNotificationFactory($depotNotificationFactory); + + // gestion d'événements : DepotService écoute certains événement de FichierTheseController + $controller->setEventManager($eventManager); + $depotService->attach($eventManager); + return $controller; } diff --git a/module/Depot/src/Depot/Controller/Factory/FichierTheseControllerFactory.php b/module/Depot/src/Depot/Controller/Factory/FichierTheseControllerFactory.php index 6531f639064bbc4e85e8b25adfaf2bcceea5c2e4..8a7d32f191e3a80233295f5f49b30b56e90a4c78 100644 --- a/module/Depot/src/Depot/Controller/Factory/FichierTheseControllerFactory.php +++ b/module/Depot/src/Depot/Controller/Factory/FichierTheseControllerFactory.php @@ -3,10 +3,11 @@ namespace Depot\Controller\Factory; use Application\EventRouterReplacer; -use Application\Service\Notification\NotifierService; use Application\Service\Validation\ValidationService; use Depot\Controller\FichierTheseController; use Depot\Service\FichierThese\FichierTheseService; +use Depot\Service\Notification\DepotNotificationFactory; +use Notification\Service\NotifierService; use Depot\Service\These\DepotService; use Depot\Service\Validation\DepotValidationService; use Fichier\Service\Fichier\FichierService; @@ -20,6 +21,10 @@ use These\Service\These\TheseService; class FichierTheseControllerFactory { + /** + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface + */ public function __invoke(ContainerInterface $container): FichierTheseController { /** @var TreeRouteStack $httpRouter */ @@ -58,17 +63,23 @@ class FichierTheseControllerFactory $controller->setIndividuService($individuService); $controller->setValidationService($validationService); $controller->setEventRouterReplacer($eventRouterReplacer); - $controller->setEventManager($eventManager); /** @var DepotService $depotService */ $depotService = $container->get(DepotService::class); - $depotService->attach($eventManager); $controller->setDepotService($depotService); /** @var \Depot\Service\Validation\DepotValidationService $depotValidationService */ $depotValidationService = $container->get(DepotValidationService::class); $controller->setDepotValidationService($depotValidationService); + /** @var \Depot\Service\Notification\DepotNotificationFactory $depotNotificationFactory */ + $depotNotificationFactory = $container->get(DepotNotificationFactory::class); + $controller->setDepotNotificationFactory($depotNotificationFactory); + + // gestion d'événements : DepotService écoute certains événement de FichierTheseController + $controller->setEventManager($eventManager); + $depotService->attach($eventManager); + return $controller; } diff --git a/module/Depot/src/Depot/Controller/Factory/ObserverControllerFactory.php b/module/Depot/src/Depot/Controller/Factory/ObserverControllerFactory.php index b0d2533c17fe00c06d93b75b45b93d64e882e734..95b268f5c8d0415ca6f3f4fbc1fe8d785e3b118d 100644 --- a/module/Depot/src/Depot/Controller/Factory/ObserverControllerFactory.php +++ b/module/Depot/src/Depot/Controller/Factory/ObserverControllerFactory.php @@ -5,11 +5,15 @@ namespace Depot\Controller\Factory; use Application\EventRouterReplacer; use Depot\Controller\ObserverController; use Depot\Service\These\TheseObserverService; -use Interop\Container\ContainerInterface; +use Psr\Container\ContainerInterface; use Laminas\Router\Http\TreeRouteStack; class ObserverControllerFactory { + /** + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface + */ public function __invoke(ContainerInterface $container): ObserverController { /** @var TreeRouteStack $httpRouter */ @@ -18,7 +22,7 @@ class ObserverControllerFactory $routerReplacer = new EventRouterReplacer($httpRouter, $cliConfig); /** @var TheseObserverService $theseObserverService */ - $theseObserverService = $container->get('TheseObserverService'); + $theseObserverService = $container->get(TheseObserverService::class); $controller = new ObserverController(); $controller->setEventRouterReplacer($routerReplacer); diff --git a/module/Depot/src/Depot/Controller/Factory/ValidationControllerFactory.php b/module/Depot/src/Depot/Controller/Factory/ValidationControllerFactory.php index 30ee36bd64d2157edaf2e5f16ca243cd726d740c..35598dacc10929ca5f7564d16472e5df7789c66d 100644 --- a/module/Depot/src/Depot/Controller/Factory/ValidationControllerFactory.php +++ b/module/Depot/src/Depot/Controller/Factory/ValidationControllerFactory.php @@ -2,15 +2,16 @@ namespace Depot\Controller\Factory; -use Application\Service\Notification\NotifierService; use Application\Service\Role\RoleService; use Application\Service\Utilisateur\UtilisateurService; use Application\Service\Validation\ValidationService; use Depot\Controller\ValidationController; +use Depot\Service\Notification\DepotNotificationFactory; use Depot\Service\These\DepotService; use Depot\Service\Validation\DepotValidationService; use Interop\Container\ContainerInterface; use Laminas\ServiceManager\Factory\FactoryInterface; +use Notification\Service\NotifierService; class ValidationControllerFactory implements FactoryInterface { @@ -41,6 +42,10 @@ class ValidationControllerFactory implements FactoryInterface $depotValidationService = $container->get(DepotValidationService::class); $controller->setDepotValidationService($depotValidationService); + /** @var \Depot\Service\Notification\DepotNotificationFactory $depotNotificationFactory */ + $depotNotificationFactory = $container->get(DepotNotificationFactory::class); + $controller->setDepotNotificationFactory($depotNotificationFactory); + return $controller; } } \ No newline at end of file diff --git a/module/Depot/src/Depot/Controller/FichierTheseController.php b/module/Depot/src/Depot/Controller/FichierTheseController.php index cdc8976d2e54dabfeff706ac3c3dcccc89bdd658..6877c34768f2ff9b604ed7565071a89e529b8ab5 100644 --- a/module/Depot/src/Depot/Controller/FichierTheseController.php +++ b/module/Depot/src/Depot/Controller/FichierTheseController.php @@ -7,13 +7,14 @@ use Application\Controller\AbstractController; use Application\EventRouterReplacerAwareTrait; use Application\Filter\IdifyFilterAwareTrait; use Application\RouteMatch; -use Application\Service\Notification\NotifierServiceAwareTrait; use Application\Service\Validation\ValidationServiceAwareTrait; use Application\View\Helper\Sortable; use Depot\Entity\Db\FichierThese; +use Depot\Event\EventsInterface; use Depot\Service\FichierThese\Exception\DepotImpossibleException; use Depot\Service\FichierThese\Exception\ValidationImpossibleException; use Depot\Service\FichierThese\FichierTheseServiceAwareTrait; +use Depot\Service\Notification\DepotNotificationFactoryAwareTrait; use Depot\Service\These\DepotServiceAwareTrait; use Depot\Service\Validation\DepotValidationServiceAwareTrait; use Doctrine\ORM\NonUniqueResultException; @@ -32,7 +33,7 @@ use Laminas\Form\Element\Hidden; use Laminas\Http\Response; use Laminas\View\Model\JsonModel; use Laminas\View\Model\ViewModel; -use Notification\Exception\NotificationException; +use Notification\Service\NotifierServiceAwareTrait; use These\Entity\Db\These; use These\Service\These\TheseServiceAwareTrait; use UnicaenApp\Exception\RuntimeException; @@ -47,13 +48,12 @@ class FichierTheseController extends AbstractController use VersionFichierServiceAwareTrait; use IdifyFilterAwareTrait; use NotifierServiceAwareTrait; + use DepotNotificationFactoryAwareTrait; use IndividuServiceAwareTrait; use ValidationServiceAwareTrait; use DepotValidationServiceAwareTrait; use EventRouterReplacerAwareTrait; - const FICHIER_THESE_TELEVERSE = 'FICHIER_THESE_DEPOSE'; - public function deposesAction() { /** @@ -270,7 +270,7 @@ class FichierTheseController extends AbstractController // déclenchement d'un événement "fichier de thèse téléversé" $this->events->trigger( - self::FICHIER_THESE_TELEVERSE, + EventsInterface::EVENT__FICHIER_THESE_TELEVERSE, $these, [ 'nature' => $nature, 'version' => $version, @@ -280,10 +280,10 @@ class FichierTheseController extends AbstractController // si une thèse est déposée, on notifie de BdD // todo: déplacer ceci dans un service écoutant l'événement "fichier de thèse téléversé" déclenché ci-dessus if ($nature->estThesePdf()) { - $notif = $this->notifierService->getNotificationFactory()->createNotificationForTheseTeleversee($these, $version); + $notif = $this->depotNotificationFactory->createNotificationForTheseTeleversee($these, $version); try { $this->notifierService->trigger($notif); - } catch (NotificationException $e) { + } catch (Exception $e) { return new JsonModel([ 'errors' => array_filter([ $e->getMessage(), @@ -296,13 +296,13 @@ class FichierTheseController extends AbstractController // si un rapport de soutenance est déposé, on notifie de BdD // todo: déplacer ceci dans un service écoutant l'événement "fichier de thèse téléversé" déclenché ci-dessus if ($nature->estRapportSoutenance()) { - $notif = $this->notifierService->getNotificationFactory()->createNotificationForFichierTeleverse($these); + $notif = $this->depotNotificationFactory->createNotificationForFichierTeleverse($these); $notif ->setSubject("Dépôt du rapport de soutenance") ->setTemplatePath('depot/depot/mail/notif-depot-rapport-soutenance'); try { $this->notifierService->trigger($notif); - } catch (NotificationException $e) { + } catch (Exception $e) { return new JsonModel([ 'errors' => array_filter([ $e->getMessage(), @@ -521,7 +521,7 @@ class FichierTheseController extends AbstractController if ($notifier) { $destinataires = $notifier; - $notif = $this->notifierService->getNotificationFactory()->createNotificationFusionFini($destinataires, $these, $outputFilePath); + $notif = $this->depotNotificationFactory->createNotificationFusionFini($destinataires, $these, $outputFilePath); $this->notifierService->trigger($notif); echo "Destinataires du courriel envoyé: " . implode(",",$notif->getTo()); echo PHP_EOL; diff --git a/module/Depot/src/Depot/Controller/ValidationController.php b/module/Depot/src/Depot/Controller/ValidationController.php index 3ee5781c76dd8d41e7becce5fd4de7d507acd8c5..1c49e578be279482c3645247646c71fb8063b926 100755 --- a/module/Depot/src/Depot/Controller/ValidationController.php +++ b/module/Depot/src/Depot/Controller/ValidationController.php @@ -3,18 +3,16 @@ namespace Depot\Controller; use Application\Controller\AbstractController; -use Application\Entity\Db\Role; use Application\Entity\Db\TypeValidation; -use Application\Service\Notification\NotifierServiceAwareTrait; use Application\Service\Role\RoleServiceAwareTrait; use Application\Service\Utilisateur\UtilisateurServiceAwareTrait; use Application\Service\Validation\ValidationServiceAwareTrait; -use Depot\Notification\ValidationRdvBuNotification; use Depot\Provider\Privilege\ValidationPrivileges; +use Depot\Service\Notification\DepotNotificationFactoryAwareTrait; use Depot\Service\These\DepotServiceAwareTrait; use Depot\Service\Validation\DepotValidationServiceAwareTrait; use Laminas\View\Model\ViewModel; -use Notification\Notification; +use Notification\Service\NotifierServiceAwareTrait; use These\Entity\Db\Acteur; use These\Service\These\TheseServiceAwareTrait; use UnicaenApp\Exception\RuntimeException; @@ -24,6 +22,7 @@ class ValidationController extends AbstractController use TheseServiceAwareTrait; use DepotValidationServiceAwareTrait; use NotifierServiceAwareTrait; + use DepotNotificationFactoryAwareTrait; use RoleServiceAwareTrait; use UtilisateurServiceAwareTrait; use DepotServiceAwareTrait; @@ -42,7 +41,8 @@ class ValidationController extends AbstractController $successMessage = "Validation de la page de couverture enregistrée avec succès."; // notification - $this->notifierService->triggerValidationPageDeCouvertureNotification($these, $action); + $notification = $this->depotNotificationFactory->createNotificationValidationPageDeCouverture($these, $action); + $this->notifierService->trigger($notification); } elseif ($action === 'devalider') { $this->depotValidationService->unvalidatePageDeCouverture($these); @@ -88,8 +88,7 @@ class ValidationController extends AbstractController // si un tableau est retourné par le plugin, l'opération a été confirmée if (is_array($result)) { - $notification = new ValidationRdvBuNotification(); - $notification->setThese($these); + $notification = $this->depotNotificationFactory->createNotificationValidationRdvBu($these); if ($action === 'valider') { $this->depotValidationService->validateRdvBu($these, $this->userContextService->getIdentityIndividu()); @@ -98,7 +97,6 @@ class ValidationController extends AbstractController // notification (doctorant: à la 1ere validation seulement) $notifierDoctorant = ! $this->depotValidationService->existsValidationRdvBuHistorisee($these); $notification->setNotifierDoctorant($notifierDoctorant); - $this->notifierService->triggerValidationRdvBu($notification); } elseif ($action === 'devalider') { $this->depotValidationService->unvalidateRdvBu($these); @@ -107,16 +105,14 @@ class ValidationController extends AbstractController // notification $notification->setEstDevalidation(true); $notification->setNotifierDoctorant(false); - $this->notifierService->triggerValidationRdvBu($notification); } else { throw new RuntimeException("Action inattendue!"); } -// $notificationLog = $this->notifierService->getMessage('<br>', 'info'); + $this->notifierService->trigger($notification); $this->flashMessenger()->addSuccessMessage($successMessage); -// $this->flashMessenger()->addInfoMessage($notificationLog); } // récupération du modèle de vue auprès du plugin et passage de variables classique @@ -174,9 +170,6 @@ class ValidationController extends AbstractController return $view; } - /** - * @throws \Notification\Exception\NotificationImpossibleException - */ public function modifierValidationDepotTheseCorrigeeAction(): ViewModel { $these = $this->requestedThese(); @@ -190,27 +183,28 @@ class ValidationController extends AbstractController $successMessage = "Validation enregistrée avec succès."; // notification des directeurs de thèse - $this->depotService->notifierCorrectionsApportees($these); + $resultArray = $this->depotService->notifierCorrectionsApportees($these); } elseif ($action === 'devalider') { $validation = $this->depotValidationService->unvalidateDepotTheseCorrigee($these); $successMessage ="Validation annulée avec succès."; // pas de notification par mail + $resultArray = null; } else { throw new RuntimeException("Action inattendue!"); } - $notificationLogs = $this->notifierService->getLogs(); - $tvCode = $validation->getTypeValidation()->getCode(); $this->flashMessenger()->addMessage($successMessage, "$tvCode/success"); - if (isset($notificationLogs['info'])) { - $this->flashMessenger()->addMessage($notificationLogs['info'], "$tvCode/info"); - } - if (isset($notificationLogs['danger'])) { - $this->flashMessenger()->addMessage($notificationLogs['danger'], "$tvCode/danger"); + if ($resultArray) { + if ($resultArray[0] === 'success') { + $this->flashMessenger()->addMessage($resultArray[1], "$tvCode/info"); + } + if ($resultArray[0] === 'error') { + $this->flashMessenger()->addMessage($resultArray[1], "$tvCode/danger"); + } } } @@ -234,6 +228,8 @@ class ValidationController extends AbstractController $result = $this->confirm()->execute(); $action = $this->params()->fromQuery('action'); + $notificationLogs = []; + // si un tableau est retourné par le plugin, l'opération a été confirmée if (is_array($result)) { if ($action === 'valider') { @@ -245,21 +241,27 @@ class ValidationController extends AbstractController // notification par mail si plus aucune validation attendue $results = $this->depotValidationService->getValidationsAttenduesPourCorrectionThese($these); if (count($results) === 0) { - $notif = new Notification(); - $notif - ->setSubject("Validation des corrections de la thèse") - ->setTemplatePath('application/notification/mail/notif-validation-correction-these') - ->setTemplateVariables([ - 'these' => $these, - 'role' => $this->roleService->getRepository()->findOneBy(['code' => Role::CODE_PRESIDENT_JURY]), - 'url' => $this->url()->fromRoute('these/depot', ['these' => $these->getId()], ['force_canonical' => true]), - ]); - // notification du BDD - $this->notifierService->triggerValidationCorrectionThese($notif, $these); - // notification du doctorant - $this->notifierService->triggerValidationCorrectionTheseEtudiant($notif, $these); + // notification de la MDD + $notification = $this->depotNotificationFactory->createNotificationValidationCorrectionThese($these); + $notificationResult = $this->notifierService->trigger($notification); + $notificationLogs = array_merge_recursive($notificationLogs, array_filter([ + 'success' => $notificationResult->getSuccessMessages(), + 'danger' => $notificationResult->getErrorMessages(), + ])); - //todo mail pour etudiant + // notification du doctorant + try { + $notification = $this->depotNotificationFactory->createNotificationValidationCorrectionTheseEtudiant($these); + $notificationResult = $this->notifierService->trigger($notification); + $notificationLogs = array_merge_recursive($notificationLogs, array_filter([ + 'success' => $notificationResult->getSuccessMessages(), + 'danger' => $notificationResult->getErrorMessages(), + ])); + } catch (\Notification\Exception\RuntimeException $e) { + $notificationLogs = array_merge_recursive($notificationLogs, [ + 'danger' => $e->getMessage(), + ]); + } } } elseif ($action === 'devalider') { @@ -274,12 +276,10 @@ class ValidationController extends AbstractController throw new RuntimeException("Action inattendue!"); } - $notificationLogs = $this->notifierService->getLogs(); - $tvCode = $validation->getTypeValidation()->getCode(); $this->flashMessenger()->addMessage($successMessage, "$tvCode/success"); if (isset($notificationLogs['info'])) { - $this->flashMessenger()->addMessage($notificationLogs['info'], "$tvCode/info"); + $this->flashMessenger()->addMessage($notificationLogs['success'], "$tvCode/info"); } if (isset($notificationLogs['danger'])) { $this->flashMessenger()->addMessage($notificationLogs['danger'], "$tvCode/danger"); diff --git a/module/Depot/src/Depot/Event/EventsInterface.php b/module/Depot/src/Depot/Event/EventsInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..e051fab9ace736c50f1623d8cdb484e72050e22a --- /dev/null +++ b/module/Depot/src/Depot/Event/EventsInterface.php @@ -0,0 +1,9 @@ +<?php + +namespace Depot\Event; + +interface EventsInterface +{ + const EVENT__FICHIER_THESE_TELEVERSE = 'FICHIER_THESE_DEPOSE'; + const EVENT__SURSIS_CORRECTION_ACCORDE = 'SURSIS_CORRECTION_ACCORDE'; +} \ No newline at end of file diff --git a/module/Depot/src/Depot/Notification/ChangementCorrectionAttendueNotification.php b/module/Depot/src/Depot/Notification/ChangementCorrectionAttendueNotification.php index 8c67d1ce7a2401a90291069bf2128f42bbdfabe8..273f7d46f89d4da7b161ca8a373a22735e9f2a85 100644 --- a/module/Depot/src/Depot/Notification/ChangementCorrectionAttendueNotification.php +++ b/module/Depot/src/Depot/Notification/ChangementCorrectionAttendueNotification.php @@ -2,6 +2,7 @@ namespace Depot\Notification; +use Notification\Exception\RuntimeException; use Notification\Notification; use These\Entity\Db\Interfaces\TheseAwareTrait; use UnicaenApp\Exception\LogicException; @@ -10,7 +11,7 @@ class ChangementCorrectionAttendueNotification extends Notification { use TheseAwareTrait; - protected $templatePath = 'depot/depot/mail/notif-depot-version-corrigee-attendu'; + protected ?string $templatePath = 'depot/depot/mail/notif-depot-version-corrigee-attendu'; /** * Initialisation, préparation, etc. nécessaires avant de pouvoir envoyer la notification. @@ -31,6 +32,10 @@ class ChangementCorrectionAttendueNotification extends Notification $individu = $this->these->getDoctorant()->getIndividu(); $to = $individu->getEmailContact() ?: $individu->getEmailPro() ?: $individu->getEmailUtilisateur(); + if (!$to) { + throw new RuntimeException("Aucune adresse mail trouvée pour le doctorant {$this->these->getDoctorant()}"); + } + $cc = null; if ($directeursTheseEnCopie) { $cc = $this->these->getDirecteursTheseEmails(); diff --git a/module/Depot/src/Depot/Notification/PasDeMailPresidentJury.php b/module/Depot/src/Depot/Notification/PasDeMailPresidentJury.php index e83e8190fbc4444d13737154d2ee078b5716dec7..8d7bdac0de4403fac2b6fd43ad790f542199b1e1 100644 --- a/module/Depot/src/Depot/Notification/PasDeMailPresidentJury.php +++ b/module/Depot/src/Depot/Notification/PasDeMailPresidentJury.php @@ -2,7 +2,6 @@ namespace Depot\Notification; -use Individu\Entity\Db\Individu; use Notification\Notification; use These\Entity\Db\Acteur; use These\Entity\Db\Interfaces\TheseAwareTrait; @@ -11,65 +10,40 @@ class PasDeMailPresidentJury extends Notification { use TheseAwareTrait; - protected $templatePath = 'application/notification/mail/notif-pas-de-mail-president-jury'; + protected ?string $templatePath = 'application/notification/mail/notif-pas-de-mail-president-jury'; /** * @return static */ public function prepare() { - /** @var Individu[] $unknownMails */ - $unknownMails = []; - $to = $this->emailBdd; + $to = $this->emailsBdd; $cc = null; - $infoMessage = sprintf( + $successMessage = sprintf( "Un mail de notification vient d'être envoyé à la Maison du doctorat (%s)", $to, ); - $errorMessage = null; - if (count($unknownMails)) { - $temp = current($unknownMails); - $source = $temp->getSource(); - $errorMessage = sprintf( - "<strong>NB:</strong> Les directeurs de thèses suivants n'ont pas pu être notifiés " . - "car leur adresse électronique n'est pas connue dans %s : <br> %s", - $source, - implode(',', $unknownMails) - ); - } - $this ->setSubject("Pas de mail pour le président du jury de la thèse " . $this->these->getId()) ->setTo($to) ->setCc($cc) ->setTemplateVariables([ - 'message' => $errorMessage, 'these' => $this->these, 'president' => $this->president, ]); - $this->setInfoMessages($infoMessage); - if ($errorMessage) { - $this->setWarningMessages($errorMessage); - } + $this->addSuccessMessage($successMessage); return $this; } - /** - * @var string - */ - protected $emailBdd; + protected array $emailsBdd = []; - /** - * @param mixed $emailBdd - * @return self - */ - public function setEmailBdd($emailBdd) + public function setEmailsBdd(array $emailsBdd): self { - $this->emailBdd = $emailBdd; + $this->emailsBdd = $emailsBdd; return $this; } diff --git a/module/Depot/src/Depot/Notification/ValidationDepotTheseCorrigeeNotification.php b/module/Depot/src/Depot/Notification/ValidationDepotTheseCorrigeeNotification.php index bd80dc30ce30c19c0f1cf394950682e6912c783d..4d9acd0dac11e9ddd9a87e38dcf13ff667271c9f 100644 --- a/module/Depot/src/Depot/Notification/ValidationDepotTheseCorrigeeNotification.php +++ b/module/Depot/src/Depot/Notification/ValidationDepotTheseCorrigeeNotification.php @@ -3,7 +3,6 @@ namespace Depot\Notification; use Application\Entity\Db\Utilisateur; -use Individu\Entity\Db\Individu; use Notification\Notification; use These\Entity\Db\Interfaces\TheseAwareTrait; @@ -11,66 +10,39 @@ class ValidationDepotTheseCorrigeeNotification extends Notification { use TheseAwareTrait; - protected $templatePath = 'application/notification/mail/notif-validation-depot-these-corrigee'; + protected ?string $templatePath = 'application/notification/mail/notif-validation-depot-these-corrigee'; private ?Utilisateur $destinataire = null; /** * @return static */ - public function prepare() + public function prepare(): self { - /** @var Individu[] $unknownMails */ - $unknownMails = []; - $to = $this->destinataire ? $this->destinataire->getEmail() : $this->these->getPresidentJuryEmail($unknownMails); - $cc = $this->emailBdd; + $to = $this->destinataire ? $this->destinataire->getEmail() : $this->these->getPresidentJuryEmail(); + $cc = $this->emailsBdd; - $infoMessage = sprintf( - "Un mail de notification vient d'être envoyé au(x) directeur(s) de thèse (%s) avec copie à la Maison du doctorat (%s)", + $successMessage = sprintf( + "Un mail de notification vient d'être envoyé au président du jury (%s) avec copie à la Maison du doctorat (%s)", $to, $cc ); - $errorMessage = null; - if (count($unknownMails)) { - $temp = current($unknownMails); - $source = $temp->getSource(); - $errorMessage = sprintf( - "<strong>NB:</strong> Les directeurs de thèses suivants n'ont pas pu être notifiés " . - "car leur adresse électronique n'est pas connue dans %s : <br> %s", - $source, - implode(',', $unknownMails) - ); - } - $this ->setSubject("Validation du dépôt de la thèse corrigée") ->setTo($to) - ->setCc($cc) - ->setTemplateVariables([ - 'message' => $errorMessage, - ]); + ->setCc($cc); - $this->setInfoMessages($infoMessage); - if ($errorMessage) { - $this->setWarningMessages($errorMessage); - } + $this->addSuccessMessage($successMessage); return $this; } - /** - * @var string - */ - protected $emailBdd; + protected array $emailsBdd = []; - /** - * @param mixed $emailBdd - * @return self - */ - public function setEmailBdd($emailBdd) + public function setEmailsBdd(array $emailsBdd): self { - $this->emailBdd = $emailBdd; + $this->emailsBdd = $emailsBdd; return $this; } diff --git a/module/Depot/src/Depot/Notification/ValidationPageDeCouvertureNotification.php b/module/Depot/src/Depot/Notification/ValidationPageDeCouvertureNotification.php index bfb3ef307d2ae57078b7351ff6dba1a821743c10..81c9bc33475c31118a4579174161808ab326a185 100644 --- a/module/Depot/src/Depot/Notification/ValidationPageDeCouvertureNotification.php +++ b/module/Depot/src/Depot/Notification/ValidationPageDeCouvertureNotification.php @@ -3,6 +3,7 @@ namespace Depot\Notification; use Individu\Entity\Db\Individu; +use Notification\Exception\RuntimeException; use Notification\Notification; use These\Entity\Db\Interfaces\TheseAwareTrait; use UnicaenApp\Exception\LogicException; @@ -14,22 +15,17 @@ class ValidationPageDeCouvertureNotification extends Notification const ACTION_VALIDER = 'valider'; const ACTION_DEVALIDER = 'devalider'; - protected $templatePath = 'application/notification/mail/notif-validation-page-couverture'; - - private $action; - - /** - * @var string - */ - private $emailBu; + protected ?string $templatePath = 'application/notification/mail/notif-validation-page-couverture'; + private string $action; + private array $emailsBu = []; /** - * @param string $emailBu + * @param string[] $emailsBu * @return self */ - public function setEmailBu(string $emailBu): self + public function setEmailsBu(array $emailsBu): self { - $this->emailBu = $emailBu; + $this->emailsBu = $emailsBu; return $this; } @@ -63,18 +59,22 @@ class ValidationPageDeCouvertureNotification extends Notification $emailsDirecteurs = $this->these->getDirecteursTheseEmails($individusSansMail); $individu = $this->these->getDoctorant()->getIndividu(); - $to = $individu->getEmailContact() ?: $individu->getEmailPro() ?: $individu->getEmailUtilisateur(); + $email = $individu->getEmailContact() ?: $individu->getEmailPro() ?: $individu->getEmailUtilisateur(); + if (!$email) { + throw new RuntimeException("Aucune adresse mail trouvée pour le doctorant {$this->these->getDoctorant()}"); + } + $cc = array_merge( $emailsDirecteurs, - [$this->emailBu => $this->emailBu] + $this->emailsBu, ); - $infoMessage = sprintf( + $successMessage = sprintf( "Un mail de notification vient d'être envoyé au doctorant (%s), avec copie à la direction de thèse (%s) " . "et à %s", - $to, + $email, implode(',', $emailsDirecteurs), - $this->emailBu + implode(',', $this->emailsBu), ); $errorMessage = null; @@ -93,7 +93,7 @@ class ValidationPageDeCouvertureNotification extends Notification $this ->setSubject("Page de couverture de votre thèse") - ->setTo($to) + ->setTo($email) ->setCc($cc) ->setTemplateVariables([ 'these' => $this->these, @@ -101,9 +101,9 @@ class ValidationPageDeCouvertureNotification extends Notification 'message' => $errorMessage, ]); - $this->setInfoMessages($infoMessage); + $this->addSuccessMessage($successMessage); if ($errorMessage) { - $this->setWarningMessages($errorMessage); + $this->addErrorMessage($errorMessage); } return $this; diff --git a/module/Depot/src/Depot/Notification/ValidationRdvBuNotification.php b/module/Depot/src/Depot/Notification/ValidationRdvBuNotification.php index a349a85ff285efb5ff53dcaf212049bf85571c13..1e3a21db783394c02018812de8c6c01b772c4a4b 100644 --- a/module/Depot/src/Depot/Notification/ValidationRdvBuNotification.php +++ b/module/Depot/src/Depot/Notification/ValidationRdvBuNotification.php @@ -9,39 +9,74 @@ class ValidationRdvBuNotification extends Notification { use TheseAwareTrait; - protected $templatePath = 'depot/depot/mail/notif-validation-rdv-bu'; - protected $estDevalidation = false; - protected $notifierDoctorant = false; - protected $notifierDoctorantImpossibleMessage; + protected ?string $templatePath = 'depot/depot/mail/notif-validation-rdv-bu'; + protected bool $estDevalidation = false; + protected bool $notifierDoctorant = false; + protected ?string $notifierDoctorantImpossibleMessage = null; + + public function setEstDevalidation(bool $estDevalidation = true): self + { + $this->estDevalidation = $estDevalidation; + + return $this; + } + + public function setNotifierDoctorant(bool $notifierDoctorant = true): self + { + $this->notifierDoctorant = $notifierDoctorant; + + return $this; + } + + private array $emailsBdd = []; + + /** + * @param string[] $emailsBdd + */ + public function setEmailsBdd(array $emailsBdd): self + { + $this->emailsBdd = $emailsBdd; + + return $this; + } + + private array $emailsBu = []; /** - * @return static + * @param string[] $emailsBu */ - public function prepare() + public function setEmailsBu(array $emailsBu): self + { + $this->emailsBu = $emailsBu; + + return $this; + } + + public function prepare(): self { - $emailBDD = $this->emailBdd; - $emailBU = $this->emailBu; + $emailsBDD = $this->emailsBdd; + $emailsBU = $this->emailsBu; $doctorant = $this->these->getDoctorant(); $individu = $doctorant->getIndividu(); if ($this->estDevalidation) { - $to = $emailBU; - $cc = $emailBDD; + $to = $emailsBU; + $cc = $emailsBDD; } else { if ($this->notifierDoctorant) { $emailDoctorant = $individu->getEmailContact() ?: $individu->getEmailPro() ?: $individu->getEmailUtilisateur(); if ($emailDoctorant) { $to = $emailDoctorant; - $cc = $emailBDD; + $cc = $emailsBDD; } else { $this->notifierDoctorantImpossibleMessage = "NB: il n'a pas été possible d'envoyer ce mail à $doctorant car ce doctorant n'a aucune adresse électronique."; - $to = $emailBDD; + $to = $emailsBDD; $cc = []; } } else { - $to = $emailBDD; + $to = $emailsBDD; $cc = []; } } @@ -65,86 +100,29 @@ class ValidationRdvBuNotification extends Notification return $this; } - /** - * @return self - */ - public function createMessages() + public function createMessages(): self { if ($this->estDevalidation) { - $this->infoMessages[] = sprintf( + $this->addSuccessMessage(sprintf( "Un mail de notification vient d'être envoyé à la bibliothèque universitaire (%s) avec copie à la Maison du doctorat (%s).", $this->getTo(), $this->getCc() - ); + )); } else { if ($this->notifierDoctorant) { - $this->infoMessages[] = sprintf( + $this->addSuccessMessage(sprintf( "Un mail de notification vient d'être envoyé à %s avec copie à la Maison du doctorat (%s)", $this->these->getDoctorant(), $this->getCc() - ); + )); } else { - $this->infoMessages[] = sprintf( + $this->addSuccessMessage(sprintf( "Un mail de notification vient d'être envoyé à la Maison du doctorat (%s).", $this->getTo() - ); + )); } } return $this; } - - /** - * @param bool $estDevalidation - * @return static - */ - public function setEstDevalidation($estDevalidation = true) - { - $this->estDevalidation = $estDevalidation; - - return $this; - } - - /** - * @param bool $notifierDoctorant - * @return static - */ - public function setNotifierDoctorant($notifierDoctorant = true) - { - $this->notifierDoctorant = $notifierDoctorant; - - return $this; - } - - /** - * @var string - */ - private $emailBdd; - - /** - * @param string $emailBdd - * @return self - */ - public function setEmailBdd($emailBdd) - { - $this->emailBdd = $emailBdd; - - return $this; - } - - /** - * @var string - */ - private $emailBu; - - /** - * @param string $emailBu - * @return self - */ - public function setEmailBu($emailBu) - { - $this->emailBu = $emailBu; - - return $this; - } } \ No newline at end of file diff --git a/module/Depot/src/Depot/Rule/NotificationDepotVersionCorrigeeAttenduRule.php b/module/Depot/src/Depot/Rule/NotificationDepotVersionCorrigeeAttenduRule.php index 3dfec8e6f1bf70f23c4400dfdd3356a598143bbc..38c54f005270d8bdb6194e01124907d65c6a853a 100644 --- a/module/Depot/src/Depot/Rule/NotificationDepotVersionCorrigeeAttenduRule.php +++ b/module/Depot/src/Depot/Rule/NotificationDepotVersionCorrigeeAttenduRule.php @@ -115,7 +115,7 @@ class NotificationDepotVersionCorrigeeAttenduRule implements RuleInterface $this->estPremiereNotif = false; switch ($this->these->getCorrectionAutorisee()) { - case These::CORRECTION_AUTORISEE_OBLIGATOIRE: + case These::$CORRECTION_AUTORISEE_OBLIGATOIRE: $spec = self::SPEC_INTERVAL_ENTRE_DATE_NOTIF_ET_BUTOIRE; try { $interval = new DateInterval($spec); @@ -124,7 +124,7 @@ class NotificationDepotVersionCorrigeeAttenduRule implements RuleInterface } $dateProchaineNotif = $dateButoir->sub($interval); // Date butoir - interval break; - case These::CORRECTION_AUTORISEE_FACULTATIVE: + case These::$CORRECTION_AUTORISEE_FACULTATIVE: // Une seule notification pour des corrections facultatives $dateProchaineNotif = null; break; diff --git a/module/Depot/src/Depot/Service/FichierThese/FichierTheseService.php b/module/Depot/src/Depot/Service/FichierThese/FichierTheseService.php index 65613d4f6f64ea3f8a1cd341820d17f26c28769e..b443ec825ffd7a401409ffe6ed5904034f2b1d88 100644 --- a/module/Depot/src/Depot/Service/FichierThese/FichierTheseService.php +++ b/module/Depot/src/Depot/Service/FichierThese/FichierTheseService.php @@ -6,7 +6,6 @@ use Application\Command\ShellCommandRunner; use Application\Command\ShellCommandRunnerTrait; use Application\Entity\Db\ValiditeFichier; use Application\Service\BaseService; -use Application\Service\Notification\NotifierServiceAwareTrait; use Depot\Entity\Db\FichierThese; use Depot\Entity\Db\Repository\FichierTheseRepository; use Depot\Filter\NomFichierTheseFormatter; @@ -46,7 +45,6 @@ class FichierTheseService extends BaseService use ValiditeFichierServiceAwareTrait; use RetraitementServiceAwareTrait; use EtablissementServiceAwareTrait; - use NotifierServiceAwareTrait; use PageDeCouverturePdfExporterAwareTrait; use ShellCommandRunnerTrait; diff --git a/module/Depot/src/Depot/Service/FichierThese/FichierTheseServiceFactory.php b/module/Depot/src/Depot/Service/FichierThese/FichierTheseServiceFactory.php index 6c40f654c06eea6fda68b77b7e37804d49ffdbcb..268145630d6b71c206269634345219a3421f320e 100644 --- a/module/Depot/src/Depot/Service/FichierThese/FichierTheseServiceFactory.php +++ b/module/Depot/src/Depot/Service/FichierThese/FichierTheseServiceFactory.php @@ -2,7 +2,6 @@ namespace Depot\Service\FichierThese; -use Application\Service\Notification\NotifierService; use Depot\Service\PageDeCouverture\PageDeCouverturePdfExporter; use Fichier\Service\Fichier\FichierService; use Fichier\Service\Fichier\FichierStorageService; @@ -31,7 +30,6 @@ class FichierTheseServiceFactory * @var \Fichier\Service\ValiditeFichier\ValiditeFichierService $validiteFichierService * @var RetraitementService $retraitementService * @var EtablissementService $etablissementService - * @var NotifierService $notifierService */ $fichierService = $container->get(FichierService::class); $fileService = $container->get(FichierStorageService::class); @@ -39,7 +37,6 @@ class FichierTheseServiceFactory $validiteFichierService = $container->get('ValiditeFichierService'); $retraitementService = $container->get('RetraitementService'); $etablissementService = $container->get('EtablissementService'); - $notifierService = $container->get(NotifierService::class); $pdcPdfExporter = $this->createPageDeCouverturePdfExporter($container); $service = new FichierTheseService(); @@ -51,7 +48,6 @@ class FichierTheseServiceFactory $service->setValiditeFichierService($validiteFichierService); $service->setRetraitementService($retraitementService); $service->setEtablissementService($etablissementService); - $service->setNotifierService($notifierService); $service->setPageDeCouverturePdfExporter($pdcPdfExporter); return $service; diff --git a/module/Depot/src/Depot/Service/Notification/DepotNotificationFactory.php b/module/Depot/src/Depot/Service/Notification/DepotNotificationFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..23d0aaa3ec7494c08a10ab7240e460b6527706e7 --- /dev/null +++ b/module/Depot/src/Depot/Service/Notification/DepotNotificationFactory.php @@ -0,0 +1,336 @@ +<?php + +namespace Depot\Service\Notification; + +use Application\Entity\Db\Role; +use Application\Entity\Db\Utilisateur; +use Application\Entity\Db\ValiditeFichier; +use Application\Service\Email\EmailTheseServiceAwareTrait; +use Application\Service\Role\RoleServiceAwareTrait; +use Application\Service\Variable\VariableServiceAwareTrait; +use Depot\Entity\Db\FichierThese; +use Depot\Notification\ValidationDepotTheseCorrigeeNotification; +use Depot\Notification\ValidationPageDeCouvertureNotification; +use Depot\Notification\ValidationRdvBuNotification; +use Fichier\Entity\Db\VersionFichier; +use Laminas\View\Helper\Url as UrlHelper; +use Notification\Exception\RuntimeException; +use Notification\Notification; +use Structure\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait; +use Structure\Service\UniteRecherche\UniteRechercheServiceAwareTrait; +use These\Entity\Db\These; +use UnicaenApp\Options\ModuleOptions; + +/** + * Classe de construction de notifications par mail. + * + * @author Unicaen + */ +class DepotNotificationFactory extends \Notification\Factory\NotificationFactory +{ + use VariableServiceAwareTrait; + use EcoleDoctoraleServiceAwareTrait; + use UniteRechercheServiceAwareTrait; + use RoleServiceAwareTrait; + use EmailTheseServiceAwareTrait; + + /** + * @var UrlHelper + */ + protected UrlHelper $urlHelper; + + /** + * @var ModuleOptions + */ + private ModuleOptions $appModuleOptions; + + /** + * @param UrlHelper $urlHelper + */ + public function setUrlHelper(UrlHelper $urlHelper) + { + $this->urlHelper = $urlHelper; + } + + /** + * @param ModuleOptions $options + */ + public function setAppModuleOptions(ModuleOptions $options) + { + $this->appModuleOptions = $options; + } + + /** + * {@inheritdoc} + */ + public function initNotification(Notification $notification) + { + parent::initNotification($notification); + + // injecte le nom de l'appli dans la variable 'appName' utilisée par tous les templates + $appInfos = $this->appModuleOptions->getAppInfos(); + $appName = $appInfos['nom']; + $notification->setTemplateVariables([ + 'appName' => $appName, + ]); + } + + /** + * Notifie que le retraitement automatique du fichier PDF est terminé. + * + * @param string $destinataires Emails séparés par une virgule + * @param FichierThese $fichierTheseRetraite Fichier retraité concerné + * @param ValiditeFichier|null $validite Résultat du test d'archivabilité éventuel + * @return Notification + * @return Notification + */ + public function createNotificationForRetraitementFini( + string $destinataires, + FichierThese $fichierTheseRetraite, + ValiditeFichier $validite = null): Notification + { + $to = array_map('trim', explode(',', $destinataires)); + + $notif = $this->createNotification(); + $notif + ->setSubject("Retraitement terminé") + ->setTo($to) + ->setTemplatePath('depot/depot/mail/notif-retraitement-fini') + ->setTemplateVariables([ + 'fichierRetraite' => $fichierTheseRetraite, + 'validite' => $validite, + 'url' => '', + ]); + + return $notif; + } + + /** + * Notification à l'issu du remplissage du formulaire RDV BU par le doctorant. + * + * @param These $these + * @param bool $estLaPremiereSaisie + * @return Notification + */ + public function createNotificationForRdvBuSaisiParDoctorant(These $these, bool $estLaPremiereSaisie): Notification + { + $subject = sprintf("%s Saisie des informations pour la prise de rendez-vous avec la bibliothèque universitaire", $these->getLibelleDiscipline()); + $to = $this->emailTheseService->fetchEmailBibliothequeUniv($these); + + $notif = $this->createNotification(); + $notif + ->setTo($to) + ->setSubject($subject) + ->setTemplatePath('depot/depot/mail/notif-modif-rdv-bu-doctorant') + ->setTemplateVariables([ + 'these' => $these, + 'updating' => !$estLaPremiereSaisie, + ]); + + $notif->addSuccessMessage( + sprintf("Un mail de notification vient d'être envoyé à la bibliothèque universitaire (%s).", $to) + ); + + return $notif; + } + + /** + * Notification à l'issue du dépôt d'un fichier de thèse. + * + * @param These $these + * @param VersionFichier $version + * @return Notification + */ + public function createNotificationForTheseTeleversee(These $these, VersionFichier $version): Notification + { + $to = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); + + $notif = $this->createNotification('notif-depot-these'); + $notif + ->setTo($to) + ->setSubject("Dépôt d'une thèse") +// ->setTemplatePath('depot/depot/mail/notif-depot-these') // le template est dans la NotifEntity + ->setTemplateVariables([ + 'these' => $these, + 'version' => $version, + ]); + + return $notif; + } + + /** + * Notification à l'issue du dépôt d'un fichier. + * + * @param These $these + * @return Notification + */ + public function createNotificationForFichierTeleverse(These $these): Notification + { + $to = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); + + $notif = $this->createNotification(); + $notif + ->setTo($to) + ->setTemplateVariables([ + 'these' => $these, + ]); + + return $notif; + } + + /** + * @param These $these + * @return Notification + */ + public function createNotificationForAccordSursisCorrection(These $these): Notification + { + $emailBDD = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); + $emailBU = $this->emailTheseService->fetchEmailBibliothequeUniv($these); + $emailsDirecteurs = $this->emailTheseService->fetchEmailEncadrants($these); + + $toLabel = "Maison du doctorat, Bibliothèque Universitaire et (co)directeur de thèse"; + $to = array_merge( + $emailBDD, + $emailBU, + $emailsDirecteurs, + ); + + return $this->createNotification() + ->setTo($to) + ->setToLabel($toLabel) + ->setSubject("Sursis accordé pour les corrections de thèse") + ->addSuccessMessage("Un mail de notification vient d'être envoyé aux destinataires suivants : $toLabel") + ->setTemplatePath('depot/depot/mail/notif-sursis-correction-accorde') + ->setTemplateVariables(compact('these')); + } + + /** + * Notifie que la fusion de la page de couverture avec la thèse PDF est terminée. + * + * @param string $destinataires Emails séparés par une virgule + * @param These $these + * @param string $outputFilePath Chemin vers le fichier stocké en local + * @return Notification + */ + public function createNotificationFusionFini(string $destinataires, These $these, string $outputFilePath): Notification + { + $to = array_map('trim', explode(',', $destinataires)); + + $notif = $this->createNotification(); + $notif + ->setSubject("Ajout de la page de couverture terminé") + ->setTo($to) + ->setTemplatePath('depot/depot/mail/notif-fusion-fini') + ->setTemplateVariables([ + 'these' => $these, + 'outputFilePath' => $outputFilePath, + 'url' => '', + ]); + + return $notif; + } + + /** + * Notification à l'issue de la validation de la page de couverture. + */ + public function createNotificationValidationPageDeCouverture(These $these, string $action): ValidationPageDeCouvertureNotification + { + $notification = new ValidationPageDeCouvertureNotification(); + $notification->setThese($these); + $notification->setAction($action); + $notification->setEmailsBu($this->emailTheseService->fetchEmailBibliothequeUniv($these)); + + return $notification; + } + + /** + * Notification concernant la validation à l'issue du RDV BU. + */ + public function createNotificationValidationRdvBu(These $these): ValidationRdvBuNotification + { + $notification = new ValidationRdvBuNotification(); + $notification->setThese($these); + + $notification->setEmailsBdd($this->emailTheseService->fetchEmailMaisonDuDoctorat($these)); + $notification->setEmailsBu($this->emailTheseService->fetchEmailBibliothequeUniv($these)); + + return $notification; + } + + /** + * Notification pour inviter à valider les corrections. + */ + public function createNotificationValidationDepotTheseCorrigee(These $these, ?Utilisateur $presidentJury = null): Notification + { + $targetedUrl = $this->urlHelper->__invoke( 'these/validation-these-corrigee', ['these' => $these->getId()], ['force_canonical' => true]); + $president = $this->getRoleService()->getRepository()->findOneByCodeAndStructureConcrete(Role::CODE_PRESIDENT_JURY, $these->getEtablissement()); + $url = $this->urlHelper->__invoke('zfcuser/login', ['type' => 'local'], ['query' => ['redirect' => $targetedUrl, 'role' => $president->getRoleId()], 'force_canonical' => true], true); + + // envoi de mail aux directeurs de thèse + $notif = new ValidationDepotTheseCorrigeeNotification(); + $notif + ->setThese($these) + ->setEmailsBdd($this->emailTheseService->fetchEmailMaisonDuDoctorat($these)) + ->setTemplateVariables([ + 'these' => $these, + 'url' => $url, + ]); + if ($presidentJury !== null) { + $notif->setDestinataire($presidentJury); + } + + return $notif; + } + + /** + * Notification à propos de la validation des corrections attendues. + */ + public function createNotificationValidationCorrectionThese(These $these): Notification + { + $notif = new Notification(); + $notif + ->setSubject("Validation des corrections de la thèse") + ->setTemplatePath('application/notification/mail/notif-validation-correction-these') + ->setTemplateVariables([ + 'these' => $these, + 'role' => $this->roleService->getRepository()->findOneBy(['code' => Role::CODE_PRESIDENT_JURY]), + 'url' => $this->urlHelper->__invoke('these/depot', ['these' => $these->getId()], ['force_canonical' => true]), + ]); + + $to = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); + $notif + ->addSuccessMessage(sprintf("Un mail de notification vient d'être envoyé à la Maison du doctorat (%s)", $to)) + ->setTo($to) + ->setTemplateVariables([ + 'these' => $these, + ]); + + return $notif; + } + + /** + * Notification à propos de la validation des corrections par le doctorant. + * + * @throws \Notification\Exception\RuntimeException Aucune adresse mail trouvée pour le doctorant + */ + public function createNotificationValidationCorrectionTheseEtudiant(These $these): Notification + { + $individu = $these->getDoctorant()->getIndividu(); + $email = $individu->getEmailContact() ?: $individu->getEmailPro() ?: $individu->getEmailUtilisateur(); + if (!$email) { + throw new RuntimeException("Aucune adresse mail trouvée pour le doctorant {$these->getDoctorant()}"); + } + + return (new Notification()) + ->setSubject("Validation des corrections de la thèse") + ->setTo($email) + ->addSuccessMessage(sprintf("Un mail de notification vient d'être envoyé au doctorant (%s)", $email)) + ->setTemplatePath('application/notification/mail/notif-validation-correction-these') + ->setTemplateVariables([ + 'these' => $these, + 'role' => $this->roleService->getRepository()->findOneBy(['code' => Role::CODE_PRESIDENT_JURY]), + 'url' => $this->urlHelper->__invoke('these/depot', ['these' => $these->getId()], ['force_canonical' => true]), + ]); + } + +} \ No newline at end of file diff --git a/module/Depot/src/Depot/Service/Notification/DepotNotificationFactoryAwareTrait.php b/module/Depot/src/Depot/Service/Notification/DepotNotificationFactoryAwareTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..5fa2580b9b54cc02f71a036a3e5a833087510e31 --- /dev/null +++ b/module/Depot/src/Depot/Service/Notification/DepotNotificationFactoryAwareTrait.php @@ -0,0 +1,13 @@ +<?php + +namespace Depot\Service\Notification; + +trait DepotNotificationFactoryAwareTrait +{ + protected DepotNotificationFactory $depotNotificationFactory; + + public function setDepotNotificationFactory(DepotNotificationFactory $depotNotificationFactory): void + { + $this->depotNotificationFactory = $depotNotificationFactory; + } +} \ No newline at end of file diff --git a/module/Application/src/Application/Service/Notification/NotificationFactoryFactory.php b/module/Depot/src/Depot/Service/Notification/DepotNotificationFactoryFactory.php similarity index 60% rename from module/Application/src/Application/Service/Notification/NotificationFactoryFactory.php rename to module/Depot/src/Depot/Service/Notification/DepotNotificationFactoryFactory.php index 87853ac09366293f7084aa3184678342baa45a8c..c8e9f600f3183761171244fc118632f6b43e244f 100644 --- a/module/Application/src/Application/Service/Notification/NotificationFactoryFactory.php +++ b/module/Depot/src/Depot/Service/Notification/DepotNotificationFactoryFactory.php @@ -1,35 +1,34 @@ <?php -namespace Application\Service\Notification; +namespace Depot\Service\Notification; -use Structure\Service\EcoleDoctorale\EcoleDoctoraleService; -use Structure\Service\UniteRecherche\UniteRechercheService; +use Application\Service\Email\EmailTheseService; +use Application\Service\Role\RoleService; use Application\Service\Variable\VariableService; use Interop\Container\ContainerInterface; -use UnicaenApp\Options\ModuleOptions; -use Laminas\Mvc\Console\View\ViewManager as ConsoleViewManager; -use Laminas\Mvc\View\Http\ViewManager as HttpViewManager; use Laminas\View\Helper\Url as UrlHelper; +use Notification\Factory\NotificationFactoryFactory; +use Structure\Service\EcoleDoctorale\EcoleDoctoraleService; +use Structure\Service\UniteRecherche\UniteRechercheService; +use UnicaenApp\Options\ModuleOptions; /** * @author Unicaen */ -class NotificationFactoryFactory extends \Notification\Service\NotificationFactoryFactory +class DepotNotificationFactoryFactory extends NotificationFactoryFactory { /** * @var string */ - protected $class = NotificationFactory::class; + protected string $class = DepotNotificationFactory::class; /** - * Create service. - * - * @param ContainerInterface $container - * @return NotificationFactory + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface */ - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container): DepotNotificationFactory { - /** @var NotificationFactory $factory */ + /** @var DepotNotificationFactory $factory */ $factory = parent::__invoke($container); /** @@ -41,10 +40,7 @@ class NotificationFactoryFactory extends \Notification\Service\NotificationFacto $ecoleDoctoraleService = $container->get('EcoleDoctoraleService'); $uniteRechercheService = $container->get('UniteRechercheService'); - /** @var HttpViewManager|ConsoleViewManager $vm */ - $vm = $container->get('ViewManager'); /** @var UrlHelper $urlHelper */ -// $urlHelper = $vm->getHelperManager()->get('Url'); $urlHelper = $container->get('ViewHelperManager')->get('Url'); /* @var ModuleOptions $moduleOptions */ @@ -56,6 +52,14 @@ class NotificationFactoryFactory extends \Notification\Service\NotificationFacto $factory->setUrlHelper($urlHelper); $factory->setAppModuleOptions($moduleOptions); + /** @var RoleService $roleService */ + $roleService = $container->get('RoleService'); + $factory->setRoleService($roleService); + + /** @var EmailTheseService $emailTheseService */ + $emailTheseService = $container->get(EmailTheseService::class); + $factory->setEmailTheseService($emailTheseService); + return $factory; } } diff --git a/module/Depot/src/Depot/Service/These/DepotService.php b/module/Depot/src/Depot/Service/These/DepotService.php index 1be34e833292ed1cb3d3fa5fbc3f32350e2b3d95..97d13777f55d732c5ffcfdf940ab6d9b01c96b3c 100644 --- a/module/Depot/src/Depot/Service/These/DepotService.php +++ b/module/Depot/src/Depot/Service/These/DepotService.php @@ -2,24 +2,23 @@ namespace Depot\Service\These; -use Application\Entity\Db\Utilisateur; use Application\Service\AuthorizeServiceAwareTrait; use Application\Service\BaseService; -use Application\Service\Notification\NotifierServiceAwareTrait; +use Application\Service\Notification\ApplicationNotificationFactoryAwareTrait; use Application\Service\UserContextServiceAwareTrait; use Application\Service\Utilisateur\UtilisateurServiceAwareTrait; use Application\Service\Variable\VariableServiceAwareTrait; use Assert\Assertion; use DateTime; -use Depot\Controller\FichierTheseController; use Depot\Entity\Db\Attestation; use Depot\Entity\Db\Diffusion; use Depot\Entity\Db\MetadonneeThese; use Depot\Entity\Db\RdvBu; -use Depot\Notification\ValidationRdvBuNotification; +use Depot\Event\EventsInterface; use Depot\Rule\AutorisationDiffusionRule; use Depot\Rule\SuppressionAttestationsRequiseRule; use Depot\Service\FichierThese\FichierTheseServiceAwareTrait; +use Depot\Service\Notification\DepotNotificationFactoryAwareTrait; use Depot\Service\Validation\DepotValidationServiceAwareTrait; use Doctrine\DBAL\DBALException; use Doctrine\ORM\OptimisticLockException; @@ -27,16 +26,18 @@ use Doctrine\ORM\ORMException; use Fichier\Entity\Db\NatureFichier; use Fichier\Entity\Db\VersionFichier; use Fichier\Service\Fichier\FichierStorageServiceAwareTrait; +use InvalidArgumentException; use Laminas\EventManager\Event; use Laminas\EventManager\EventManagerInterface; use Laminas\EventManager\ListenerAggregateInterface; use Laminas\EventManager\ListenerAggregateTrait; -use Notification\Exception\NotificationImpossibleException; +use Notification\Service\NotifierServiceAwareTrait; use Soutenance\Service\Membre\MembreServiceAwareTrait; use Structure\Service\Etablissement\EtablissementServiceAwareTrait; use These\Entity\Db\Repository\TheseRepository; use These\Entity\Db\These; use These\Service\Acteur\ActeurServiceAwareTrait; +use These\Service\Notification\TheseNotificationFactoryAwareTrait; use These\Service\These\TheseServiceAwareTrait; use UnicaenApp\Exception\LogicException; use UnicaenApp\Exception\RuntimeException; @@ -48,7 +49,10 @@ class DepotService extends BaseService implements ListenerAggregateInterface use TheseServiceAwareTrait; use ListenerAggregateTrait; use DepotValidationServiceAwareTrait; + use ApplicationNotificationFactoryAwareTrait; + use TheseNotificationFactoryAwareTrait; use NotifierServiceAwareTrait; + use DepotNotificationFactoryAwareTrait; use FichierTheseServiceAwareTrait; use VariableServiceAwareTrait; use UserContextServiceAwareTrait; @@ -99,8 +103,8 @@ class DepotService extends BaseService implements ListenerAggregateInterface */ public function attach(EventManagerInterface $events, $priority = 1) { - // réaction à l'événement de dépôt d'un fichier de thèse - $events->attach(FichierTheseController::FICHIER_THESE_TELEVERSE, [$this, 'onFichierTheseTeleverse']); + $events->attach(EventsInterface::EVENT__FICHIER_THESE_TELEVERSE, [$this, 'onFichierTheseTeleverse']); + $events->attach(EventsInterface::EVENT__SURSIS_CORRECTION_ACCORDE, [$this, 'onSursisCorrectionAccorde']); } /** @@ -122,9 +126,9 @@ class DepotService extends BaseService implements ListenerAggregateInterface { if ($forcage !== null) { Assertion::inArray($forcage, [ - These::CORRECTION_AUTORISEE_FORCAGE_AUCUNE, - These::CORRECTION_AUTORISEE_FORCAGE_FACULTATIVE, - These::CORRECTION_AUTORISEE_FORCAGE_OBLIGATOIRE, + These::$CORRECTION_AUTORISEE_FORCAGE_AUCUNE, + These::$CORRECTION_AUTORISEE_FORCAGE_FACULTATIVE, + These::$CORRECTION_AUTORISEE_FORCAGE_OBLIGATOIRE, ]); } @@ -178,6 +182,20 @@ class DepotService extends BaseService implements ListenerAggregateInterface } } + public function onSursisCorrectionAccorde(Event $event) + { + /** @var \These\Entity\Db\These $these */ + $these = $event->getTarget(); + + $notif = $this->depotNotificationFactory->createNotificationForAccordSursisCorrection($these); + $result = $this->notifierService->trigger($notif); + + $event->setParam('logs', array_filter([ + 'success' => $result->getSuccessMessages(), + 'danger' => $result->getErrorMessages(), + ])); + } + /** * Lors du dépôt d'une version originale corrigée, selon la config de l'appli, il peut être nécessaire de créer * automatiquement Diffusion et Attestation. @@ -424,14 +442,12 @@ class DepotService extends BaseService implements ListenerAggregateInterface // notification BDD et BU + doctorant (à la 1ere validation seulement) $notifierDoctorant = ! $this->depotValidationService->existsValidationRdvBuHistorisee($these); - $notification = new ValidationRdvBuNotification(); - $notification->setThese($these); + $notification = $this->depotNotificationFactory + ->createNotificationValidationRdvBu($these); $notification->setNotifierDoctorant($notifierDoctorant); - $this->notifierService->triggerValidationRdvBu($notification); -// $notificationLog = $this->notifierService->getMessage('<br>', 'info'); + $this->notifierService->trigger($notification); $this->addMessage($successMessage, MessageAwareInterface::SUCCESS); -// $this->addMessage($notificationLog, MessageAwareInterface::INFO); } } @@ -469,15 +485,13 @@ EOS; /** * @param These $these - * @param \Application\Entity\Db\Utilisateur|null $utilisateur * @return array - * @throws \Notification\Exception\NotificationImpossibleException */ - public function notifierCorrectionsApportees(These $these, ?Utilisateur $utilisateur = null): array + public function notifierCorrectionsApportees(These $these): array { $president = $these->getPresidentJury(); if ($president === null) { - throw new NotificationImpossibleException("Aucun président du jury pour la thèse [".$these->getId()."]"); + throw new InvalidArgumentException("Aucun président du jury pour la thèse [".$these->getId()."]"); } //Recherche de l'utilisateur associé à l'individu @@ -486,8 +500,9 @@ EOS; // Notification directe de l'utilisateur déjà existant if (!empty($utilisateurs)) { - $this->getNotifierService()->triggerValidationDepotTheseCorrigee($these, end($utilisateurs)); - return ['success', "Notification des corrections faite à <strong>".end($utilisateurs)->getEmail()."</strong>"]; + $notification = $this->depotNotificationFactory->createNotificationValidationDepotTheseCorrigee($these, end($utilisateurs)); + $result = $this->notifierService->trigger($notification); + return ['success', $result->getSuccessMessages()[0], $result]; } else { // Recupération du "meilleur" email @@ -500,14 +515,21 @@ EOS; $individu->setEmailPro($email); $username = ($individu->getNomUsuel() ?: $individu->getNomPatronymique()) . "_" . $president->getId(); $user = $this->utilisateurService->createFromIndividu($individu, $username, 'none'); + $token = $this->userService->updateUserPasswordResetToken($user); - $this->getNotifierService()->triggerInitialisationCompte($user, $token); - $this->getNotifierService()->triggerValidationDepotTheseCorrigee($these); - return ['success', "Création de compte initialisée et notification des corrections faite à <strong>" . $email . "</strong>"]; + $notification = $this->applicationNotificationFactory->createNotificationInitialisationCompte($user, $token); + $this->notifierService->trigger($notification); + + $notification = $this->depotNotificationFactory->createNotificationValidationDepotTheseCorrigee($these); + $result = $this->notifierService->trigger($notification); + + return ['success', "Création de compte initialisée. " . ($result->getSuccessMessages()[0] ?? '')]; } else { // Echec (si aucun mail, faudra le renseigner dans un membre fictif par exemple) - $this->getNotifierService()->triggerPasDeMailPresidentJury($these, $president); - return ['error', "Aucune action de réalisée car aucun email de trouvé."]; + $notif = $this->theseNotificationFactory->createNotificationPasDeMailPresidentJury($these, $president); + $result = $this->notifierService->trigger($notif); + + return ['error', "Aucune action réalisée car aucun email n'a été trouvé. " . ($result->getSuccessMessages()[0] ?? '')]; } } } diff --git a/module/Depot/src/Depot/Service/These/Factory/DepotServiceFactory.php b/module/Depot/src/Depot/Service/These/Factory/DepotServiceFactory.php index 62681457f159d4238c6e1e4b4e954e379c2ee3ba..3f6f35e36f8a788c8e2e9b06b24319e8f835aaf4 100644 --- a/module/Depot/src/Depot/Service/These/Factory/DepotServiceFactory.php +++ b/module/Depot/src/Depot/Service/These/Factory/DepotServiceFactory.php @@ -2,18 +2,21 @@ namespace Depot\Service\These\Factory; -use Application\Service\Notification\NotifierService; +use Application\Service\Notification\ApplicationNotificationFactory; use Application\Service\UserContextService; use Application\Service\Utilisateur\UtilisateurService; use Application\Service\Variable\VariableService; use Depot\Service\FichierThese\FichierTheseService; +use Depot\Service\Notification\DepotNotificationFactory; use Depot\Service\These\DepotService; use Depot\Service\Validation\DepotValidationService; use Fichier\Service\Fichier\FichierStorageService; use Interop\Container\ContainerInterface; +use Notification\Service\NotifierService; use Soutenance\Service\Membre\MembreService; use Structure\Service\Etablissement\EtablissementService; use These\Service\Acteur\ActeurService; +use These\Service\Notification\TheseNotificationFactory; use These\Service\These\TheseService; use UnicaenAuth\Service\AuthorizeService; use UnicaenAuth\Service\User as UserService; @@ -22,10 +25,8 @@ use Webmozart\Assert\Assert; class DepotServiceFactory { /** - * Create service - * - * @param ContainerInterface $container - * @return DepotService + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface */ public function __invoke(ContainerInterface $container): DepotService { @@ -76,6 +77,18 @@ class DepotServiceFactory $theseService = $container->get(TheseService::class); $service->setTheseService($theseService); + /** @var \Application\Service\Notification\ApplicationNotificationFactory $applicationNotificationFactory */ + $applicationNotificationFactory = $container->get(ApplicationNotificationFactory::class); + $service->setApplicationNotificationFactory($applicationNotificationFactory); + + /** @var \These\Service\Notification\TheseNotificationFactory $theseNotificationFactory */ + $theseNotificationFactory = $container->get(TheseNotificationFactory::class); + $service->setTheseNotificationFactory($theseNotificationFactory); + + /** @var \Depot\Service\Notification\DepotNotificationFactory $depotNotificationFactory */ + $depotNotificationFactory = $container->get(DepotNotificationFactory::class); + $service->setDepotNotificationFactory($depotNotificationFactory); + $this->injectConfig($service, $container); return $service; diff --git a/module/Depot/src/Depot/Service/These/Factory/TheseObserverServiceFactory.php b/module/Depot/src/Depot/Service/These/Factory/TheseObserverServiceFactory.php index 07d52d0cd43aa55d10febeb01456107eef350c5b..68a2ef20cfa11d9c4dd1ee44a5edfa3afcde2aa5 100644 --- a/module/Depot/src/Depot/Service/These/Factory/TheseObserverServiceFactory.php +++ b/module/Depot/src/Depot/Service/These/Factory/TheseObserverServiceFactory.php @@ -2,32 +2,35 @@ namespace Depot\Service\These\Factory; -use Application\Service\Notification\NotifierService; +use Notification\Service\NotifierService; use Depot\Service\These\TheseObserverService; -use Laminas\ServiceManager\ServiceManager; +use Psr\Container\ContainerInterface; +use These\Service\Notification\TheseNotificationFactory; use These\Service\These\TheseService; class TheseObserverServiceFactory { /** - * Create service - * - * @param ServiceManager $serviveManager - * @return TheseObserverService + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface */ - public function __invoke(ServiceManager $serviveManager) + public function __invoke(ContainerInterface $container): TheseObserverService { /** * @var TheseService $theseService * @var NotifierService $notifierService */ - $theseService = $serviveManager->get('TheseService'); - $notifierService = $serviveManager->get(NotifierService::class); + $theseService = $container->get('TheseService'); + $notifierService = $container->get(NotifierService::class); $service = new TheseObserverService(); $service->setTheseService($theseService); $service->setNotifierService($notifierService); + /** @var \These\Service\Notification\TheseNotificationFactory $theseNotificationFactory */ + $theseNotificationFactory = $container->get(TheseNotificationFactory::class); + $service->setTheseNotificationFactory($theseNotificationFactory); + return $service; } } \ No newline at end of file diff --git a/module/Depot/src/Depot/Service/These/TheseObserverService.php b/module/Depot/src/Depot/Service/These/TheseObserverService.php index 07b5cc7f63574eaa378851f264d8d07b2da2de4c..6045bad420eda65772fef543e48fbf122b633bc0 100644 --- a/module/Depot/src/Depot/Service/These/TheseObserverService.php +++ b/module/Depot/src/Depot/Service/These/TheseObserverService.php @@ -2,13 +2,16 @@ namespace Depot\Service\These; -use Application\Service\Notification\NotifierServiceAwareTrait; +use Notification\Exception\RuntimeException; +use Notification\Service\NotifierServiceAwareTrait; +use These\Service\Notification\TheseNotificationFactoryAwareTrait; use These\Service\These\TheseServiceAwareTrait; class TheseObserverService { use TheseServiceAwareTrait; use NotifierServiceAwareTrait; + use TheseNotificationFactoryAwareTrait; /** * Notification systématique à propos des thèses dont la date butoir pour le dépôt de la version corrigée est dépassée. @@ -18,10 +21,12 @@ class TheseObserverService $theses = $this->theseService->getRepository()->fetchThesesWithDateButoirDepotVersionCorrigeeDepassee(); foreach ($theses as $these) { -// $viewModel = new ViewModel([ -// 'subject' => "Corrections " . lcfirst($these->getCorrectionAutoriseeToString(true)) . " non faites", -// ]); - $this->notifierService->triggerDateButoirCorrectionDepassee($these); + try { + $notif = $this->theseNotificationFactory->createNotificationDateButoirCorrectionDepassee($these); + $this->notifierService->trigger($notif); + } catch (RuntimeException $e) { + // aucun destinataire, todo : gérer le cas ! + } } } } \ No newline at end of file diff --git a/module/Depot/view/depot/depot/mail/notif-sursis-correction-accorde.phtml b/module/Depot/view/depot/depot/mail/notif-sursis-correction-accorde.phtml new file mode 100644 index 0000000000000000000000000000000000000000..225d64a00d709ac3ac9a52ca6027beae90545254 --- /dev/null +++ b/module/Depot/view/depot/depot/mail/notif-sursis-correction-accorde.phtml @@ -0,0 +1,27 @@ +<?php + +use Application\View\Renderer\PhpRenderer; +use These\Entity\Db\These; + +/** + * @var PhpRenderer $this + * @var These $these + */ +?> + +<p> + Bonjour, +</p> +<p> + Ceci est un mail envoyé automatiquement par l'application <?php echo $this->appInfos()->nom ?>. +</p> +<p> + Vous êtes informé-e qu'un sursis vient d'être accordé pour les corrections de la thèse + de <?php echo $these->getDoctorant() ?>. <br> + La date limite pour les corrections est désormais le + <?php echo $these->getDateButoirDepotVersionCorrigeeAvecSursisToString() ?>. +</p> +<p> + Pour rappel, la thèse de <?php echo $these->getDoctorant() ?> est en attente de corrections + <?php echo lcfirst($these->getCorrectionAutoriseeToString(true)) ?>. +</p> diff --git a/module/Doctorant/src/Doctorant/Service/DoctorantService.php b/module/Doctorant/src/Doctorant/Service/DoctorantService.php index 6c537d0b96d0300880deaff4711fa8679c56f2ce..e0c28bd535e52b769777641c20b0603dd1de9ee4 100644 --- a/module/Doctorant/src/Doctorant/Service/DoctorantService.php +++ b/module/Doctorant/src/Doctorant/Service/DoctorantService.php @@ -2,11 +2,14 @@ namespace Doctorant\Service; +use Application\Entity\Db\Utilisateur; use Application\Entity\UserWrapper; use Application\Service\BaseService; use Application\SourceCodeStringHelperAwareTrait; use Doctorant\Entity\Db\Doctorant; use Doctorant\Entity\Db\Repository\DoctorantRepository; +use Doctrine\ORM\NonUniqueResultException; +use RuntimeException; use Structure\Service\Etablissement\EtablissementServiceAwareTrait; class DoctorantService extends BaseService @@ -26,6 +29,11 @@ class DoctorantService extends BaseService } /** + * On recherche un doctorant dont le SOURCE_CODE égale '{PREFIX_ETAB}::{supannId}, où : + * - {PREFIX_ETAB} (ex : 'INSA') : code de l'établissement/structure dont le domaine égale celui extrait de l'EPPN (ex: 'insa-rouen.fr') ; + * - {supannId} (ex : '000020533') : supannEtuId, supannEmpId ou autre (cf. {@see \UnicaenAuth\Service\ShibService::extractShibUserIdValueForDomainFromShibData()} + * issue des données d'identité. + * * @param UserWrapper $user * @return Doctorant|null */ @@ -70,4 +78,26 @@ class DoctorantService extends BaseService return $qb->getQuery()->getResult(); } + + public function getDoctorantsByUser(?Utilisateur $user) : ?Doctorant + { + if ($user === null OR $user->getIndividu() === null) return null; + + $qb = $this->getEntityManager()->getRepository(Doctorant::class)->createQueryBuilder('doctorant') + ->leftJoin('doctorant.individu','individu') + ->andWhere('individu.id = :id')->setParameter('id', $user->getIndividu()->getId()) + ->andWhere('individu.histoDestruction IS NULL') + ->andWhere('doctorant.histoDestruction IS NULL') + ; + + /** @var Doctorant $result */ + try { + $result = $qb->getQuery()->getOneOrNullResult(); + } catch (NonUniqueResultException $e) { + throw new RuntimeException("Plusieurs doctorants sont liés au mếme individu [".$user->getIndividu()->getId()."]"); + } + return $result; + + + } } \ No newline at end of file diff --git a/module/Doctorant/view/doctorant/mail/demande-confirmation-mail.phtml b/module/Doctorant/view/doctorant/mail/demande-confirmation-mail.phtml index 9e9f9818d7a8e3e063e61446cdecd8ea2a8a8a65..e8c46b54efb1e738f9f14a7ed0433aa4919b5315 100644 --- a/module/Doctorant/view/doctorant/mail/demande-confirmation-mail.phtml +++ b/module/Doctorant/view/doctorant/mail/demande-confirmation-mail.phtml @@ -3,7 +3,7 @@ use Application\View\Renderer\PhpRenderer; /** - * @see \Application\Service\Notification\NotifierService::triggerMailConfirmation() + * @see \Application\Service\Notification\ApplicationNotificationFactory::createNotificationMailConfirmation() * @var PhpRenderer $this * @var string $confirmUrl */ diff --git a/module/Formation/config/module.config.php b/module/Formation/config/module.config.php index 63c8201c0c67004bfc4fd8bbe4447281dabcb16f..5977bb55b77d2ee54e327d28717649e7b5988c90 100644 --- a/module/Formation/config/module.config.php +++ b/module/Formation/config/module.config.php @@ -1,28 +1,14 @@ -<?php /** @noinspection PhpUnusedAliasInspection */ -/** @noinspection PhpUnusedAliasInspection */ -/** @noinspection PhpUnusedAliasInspection */ -/** @noinspection PhpUnusedAliasInspection */ -/** @noinspection PhpUnusedAliasInspection */ -/** @noinspection PhpUnusedAliasInspection */ -/** @noinspection PhpUnusedAliasInspection */ -/** @noinspection PhpUnusedAliasInspection */ -/** @noinspection PhpUnusedAliasInspection */ -/** @noinspection PhpUnusedAliasInspection */ -/** @noinspection PhpUnusedAliasInspection */ -/** @noinspection PhpUnusedAliasInspection */ - -/** @noinspection PhpUnusedAliasInspection */ +<?php namespace Formation; -use Application\Navigation\ApplicationNavigationFactory; use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain; use Doctrine\DBAL\Driver\OCI8\Driver as OCI8; use Doctrine\ORM\Mapping\Driver\XmlDriver; use Formation\Provider\IdentityProvider; use Formation\Provider\IdentityProviderFactory; -use Formation\Service\Notification\NotificationService; -use Formation\Service\Notification\NotificationServiceFactory; +use Formation\Service\Notification\FormationNotificationFactory; +use Formation\Service\Notification\FormationNotificationFactoryFactory; use Formation\View\Helper\EtatViewHelper; use Formation\View\Helper\FormateursViewHelper; use Formation\View\Helper\ModaliteViewHelper; @@ -31,18 +17,6 @@ use Formation\View\Helper\SessionInscriptionViewHelper; use Formation\View\Helper\SessionLibelleViewHelper; use Formation\View\Helper\SiteViewHelper; use Formation\View\Helper\TypeViewHelper; -use Soutenance\Controller\AvisController; -use Soutenance\Controller\EngagementImpartialiteController; -use Soutenance\Provider\Privilege\IndexPrivileges; -use Soutenance\Provider\Privilege\PresoutenancePrivileges; -use Soutenance\Provider\Privilege\PropositionPrivileges; -use Soutenance\Service\Membre\MembreService; -use Soutenance\Service\Membre\MembreServiceFactory; -use Soutenance\Service\Notifier\NotifierSoutenanceService; -use Soutenance\Service\Notifier\NotifierSoutenanceServiceFactory; -use Soutenance\Service\Validation\ValidationService; -use Soutenance\Service\Validation\ValidationServiceFactory; -use UnicaenAuth\Guard\PrivilegeController; use UnicaenAuth\Provider\Rule\PrivilegeRuleProvider; return array( @@ -87,7 +61,7 @@ return array( 'service_manager' => [ 'factories' => [ - NotificationService::class => NotificationServiceFactory::class, + FormationNotificationFactory::class => FormationNotificationFactoryFactory::class, IdentityProvider::class => IdentityProviderFactory::class, ], ], diff --git a/module/Formation/src/Formation/Controller/IndexController.php b/module/Formation/src/Formation/Controller/IndexController.php index 17f7be57d3a30f3420eff8d20426e98a232fb320..c8368ff908ed7c9a4e31fb6206801bfa37f948c5 100644 --- a/module/Formation/src/Formation/Controller/IndexController.php +++ b/module/Formation/src/Formation/Controller/IndexController.php @@ -4,15 +4,17 @@ namespace Formation\Controller; use Application\Controller\AbstractController; use Doctorant\Entity\Db\Doctorant; -use Individu\Entity\Db\Individu; +use Doctorant\Service\DoctorantServiceAwareTrait; use Formation\Entity\Db\Inscription; use Formation\Entity\Db\Session; -use UnicaenApp\Service\EntityManagerAwareTrait; +use Individu\Entity\Db\Individu; use Laminas\View\Model\ViewModel; +use UnicaenApp\Service\EntityManagerAwareTrait; class IndexController extends AbstractController { use EntityManagerAwareTrait; + use DoctorantServiceAwareTrait; public function indexAction() : ViewModel { @@ -26,7 +28,8 @@ class IndexController extends AbstractController if ($doctorantId !== null) { $doctorant = $this->getEntityManager()->getRepository(Doctorant::class)->find($doctorantId); } else { - $doctorant = null; + $user = $this->userContextService->getIdentityDb(); + $doctorant = $this->doctorantService->getDoctorantsByUser($user); } if($doctorant) { diff --git a/module/Formation/src/Formation/Controller/IndexControllerFactory.php b/module/Formation/src/Formation/Controller/IndexControllerFactory.php index 45b440c72953b2c43f90205b62f7b30739bd4dff..49c9a0341a9e8cbdbc7acafafd85d6aed28746f6 100644 --- a/module/Formation/src/Formation/Controller/IndexControllerFactory.php +++ b/module/Formation/src/Formation/Controller/IndexControllerFactory.php @@ -2,6 +2,7 @@ namespace Formation\Controller; +use Doctorant\Service\DoctorantService; use Doctrine\ORM\EntityManager; use Interop\Container\ContainerInterface; use Psr\Container\ContainerExceptionInterface; @@ -19,11 +20,14 @@ class IndexControllerFactory { { /** * @var EntityManager $entityManager + * @var DoctorantService $doctorantService */ $entityManager = $container->get('doctrine.entitymanager.orm_default'); + $doctorantService = $container->get(DoctorantService::class); $controller = new IndexController(); $controller->setEntityManager($entityManager); + $controller->setDoctorantService($doctorantService); return $controller; } diff --git a/module/Formation/src/Formation/Controller/InscriptionController.php b/module/Formation/src/Formation/Controller/InscriptionController.php index a30a6ed9b39900ec8e7ad9e084c304401808f8e5..a293a6b7dcbe8eb228899932e18819df37baa885 100644 --- a/module/Formation/src/Formation/Controller/InscriptionController.php +++ b/module/Formation/src/Formation/Controller/InscriptionController.php @@ -12,7 +12,8 @@ use Formation\Provider\NatureFichier\NatureFichier; use Formation\Service\Exporter\Attestation\AttestationExporter; use Formation\Service\Exporter\Convocation\ConvocationExporter; use Formation\Service\Inscription\InscriptionServiceAwareTrait; -use Formation\Service\Notification\NotificationServiceAwareTrait; +use Formation\Service\Notification\FormationNotificationFactoryAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; use Formation\Service\Presence\PresenceServiceAwareTrait; use Formation\Service\Session\SessionServiceAwareTrait; use Individu\Entity\Db\Individu; @@ -34,7 +35,8 @@ class InscriptionController extends AbstractController use FichierStorageServiceAwareTrait; use IndividuServiceAwareTrait; use InscriptionServiceAwareTrait; - use NotificationServiceAwareTrait; + use NotifierServiceAwareTrait; + use FormationNotificationFactoryAwareTrait; use PresenceServiceAwareTrait; use SessionServiceAwareTrait; use StructureDocumentServiceAwareTrait; @@ -84,7 +86,12 @@ class InscriptionController extends AbstractController } else { $this->getInscriptionService()->create($inscription); $this->flashMessenger()->addSuccessMessage("Inscription à la formation <strong>".$libelle."</strong> faite."); - $this->getNotificationService()->triggerInscriptionEnregistree($inscription); + try { + $notif = $this->formationNotificationFactory->createNotificationInscriptionEnregistree($inscription); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire trouvé lors de la construction de la notif : cas à gérer ! + } } $retour=$this->params()->fromQuery('retour'); @@ -174,7 +181,14 @@ class InscriptionController extends AbstractController if (count($listePrincipale) < $session->getTailleListePrincipale()) { $inscription->setListe(Inscription::LISTE_PRINCIPALE); $this->getInscriptionService()->update($inscription); - if ($session->isFinInscription()) $this->getNotificationService()->triggerInscriptionListePrincipale($inscription); + if ($session->isFinInscription()) { + try { + $notif = $this->formationNotificationFactory->createNotificationInscriptionListePrincipale($inscription); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire trouvé lors de la construction de la notif : cas à gérer ! + } + } } else { $this->flashMessenger()->addErrorMessage('La liste principale est déjà complète.'); } @@ -193,7 +207,14 @@ class InscriptionController extends AbstractController if (count($listePrincipale) < $session->getTailleListeComplementaire()) { $inscription->setListe(Inscription::LISTE_COMPLEMENTAIRE); $this->getInscriptionService()->update($inscription); - if ($session->isFinInscription()) $this->getNotificationService()->triggerInscriptionListeComplementaire($inscription); + if ($session->isFinInscription()) { + try { + $notif = $this->formationNotificationFactory->createNotificationInscriptionListeComplementaire($inscription); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire trouvé lors de la construction de la notif : cas à gérer ! + } + } } else { $this->flashMessenger()->addErrorMessage('La liste complémentaire est déjà complète.'); } diff --git a/module/Formation/src/Formation/Controller/InscriptionControllerFactory.php b/module/Formation/src/Formation/Controller/InscriptionControllerFactory.php index 8a2e4e95a14e29dd3b8146e92bbaa7c8c8d9cf79..17b3710d2d6820ffe2089ac63f5f0b8613779a38 100644 --- a/module/Formation/src/Formation/Controller/InscriptionControllerFactory.php +++ b/module/Formation/src/Formation/Controller/InscriptionControllerFactory.php @@ -3,6 +3,7 @@ namespace Formation\Controller; use Fichier\Service\Fichier\FichierStorageService; +use Formation\Service\Notification\FormationNotificationFactory; use Formation\Service\Session\SessionService; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; @@ -12,7 +13,7 @@ use Structure\Service\StructureDocument\StructureDocumentService; use Doctorant\Service\DoctorantService; use Doctrine\ORM\EntityManager; use Formation\Service\Inscription\InscriptionService; -use Formation\Service\Notification\NotificationService; +use Notification\Service\NotifierService; use Formation\Service\Presence\PresenceService; use Interop\Container\ContainerInterface; use Laminas\View\Renderer\PhpRenderer; @@ -34,7 +35,7 @@ class InscriptionControllerFactory { * @var \Fichier\Service\Fichier\FichierStorageService $fichierStorageService * @var InscriptionService $inscriptionService * @var IndividuService $individuService - * @var NotificationService $notificationService + * @var NotifierService $notificationService * @var PresenceService $presenceService * @var SessionService $sessionService * @var StructureDocumentService $structureDocumentService @@ -45,7 +46,7 @@ class InscriptionControllerFactory { $fichierStorageService = $container->get(FichierStorageService::class); $individuService = $container->get(IndividuService::class); $inscriptionService = $container->get(InscriptionService::class); - $notificationService = $container->get(NotificationService::class); + $notificationService = $container->get(NotifierService::class); $presenceService = $container->get(PresenceService::class); $sessionService = $container->get(SessionService::class); $structureDocumentService = $container->get(StructureDocumentService::class); @@ -61,7 +62,7 @@ class InscriptionControllerFactory { $controller->setFichierStorageService($fichierStorageService); $controller->setIndividuService($individuService); $controller->setInscriptionService($inscriptionService); - $controller->setNotificationService($notificationService); + $controller->setNotifierService($notificationService); $controller->setPresenceService($presenceService); $controller->setSessionService($sessionService); $controller->setStructureDocumentService($structureDocumentService); @@ -69,6 +70,10 @@ class InscriptionControllerFactory { /** autres*****************************************************************************************************/ $controller->setRenderer($renderer); + /** @var \Formation\Service\Notification\FormationNotificationFactory $formationNotificationFactory */ + $formationNotificationFactory = $container->get(FormationNotificationFactory::class); + $controller->setFormationNotificationFactory($formationNotificationFactory); + return $controller; } } \ No newline at end of file diff --git a/module/Formation/src/Formation/Controller/Recherche/EnqueteReponseRechercheController.php b/module/Formation/src/Formation/Controller/Recherche/EnqueteReponseRechercheController.php index e78152286b7f61298556fdb7f4da1b3c2482f891..61432da5d16e5a7ac5963fe381ff5ad8ad1cf129 100644 --- a/module/Formation/src/Formation/Controller/Recherche/EnqueteReponseRechercheController.php +++ b/module/Formation/src/Formation/Controller/Recherche/EnqueteReponseRechercheController.php @@ -74,7 +74,9 @@ class EnqueteReponseRechercheController extends AbstractRechercheController return $model; } + /** @var \Application\Search\SearchResultPaginator $reponses */ $reponses = $model->getVariable('paginator'); + $reponses->setItemCountPerPage(-1); $questions = $this->enqueteQuestionRepository->findAll(); $questions = array_filter($questions, function (EnqueteQuestion $a) { diff --git a/module/Formation/src/Formation/Controller/SessionController.php b/module/Formation/src/Formation/Controller/SessionController.php index d0183800998e2776c594877e9a9855d9cfa48995..9367e681477afbd1efcb50d176f4a18cab5c6b6e 100644 --- a/module/Formation/src/Formation/Controller/SessionController.php +++ b/module/Formation/src/Formation/Controller/SessionController.php @@ -3,6 +3,7 @@ namespace Formation\Controller; use Application\Controller\AbstractController; +use Formation\Service\Notification\FormationNotificationFactoryAwareTrait; use These\Entity\Db\These; use Fichier\Service\Fichier\FichierStorageServiceAwareTrait; use Fichier\Service\Storage\Adapter\Exception\StorageAdapterException; @@ -12,9 +13,7 @@ use Formation\Service\Formation\FormationServiceAwareTrait; use Formation\Service\Presence\PresenceServiceAwareTrait; use Formation\Service\SessionStructureValide\SessionStructureValideServiceAwareTrait; use Laminas\Http\Response; -use Notification\Exception\NotificationException; use Structure\Service\Etablissement\EtablissementServiceAwareTrait; -use Fichier\Service\Fichier\FichierStorageService; use DateTime; use Formation\Entity\Db\Etat; use Formation\Entity\Db\Inscription; @@ -23,7 +22,7 @@ use Formation\Entity\Db\Session; use Formation\Form\Session\SessionFormAwareTrait; use Formation\Service\Exporter\Emargement\EmargementExporter; use Formation\Service\Inscription\InscriptionServiceAwareTrait; -use Formation\Service\Notification\NotificationServiceAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; use Formation\Service\Session\SessionServiceAwareTrait; use UnicaenApp\Service\EntityManagerAwareTrait; use Laminas\View\Model\ViewModel; @@ -37,7 +36,8 @@ class SessionController extends AbstractController use FichierStorageServiceAwareTrait; use FormationServiceAwareTrait; use InscriptionServiceAwareTrait; - use NotificationServiceAwareTrait; + use NotifierServiceAwareTrait; + use FormationNotificationFactoryAwareTrait; use PresenceServiceAwareTrait; use SessionServiceAwareTrait; use SessionStructureValideServiceAwareTrait; @@ -193,9 +193,6 @@ class SessionController extends AbstractController return $vm; } - /** - * @throws NotificationException - */ public function changerEtatAction() { $session = $this->getSessionService()->getRepository()->getRequestedSession($this); @@ -224,19 +221,19 @@ class SessionController extends AbstractController switch ($session->getEtat()->getCode()) { case Etat::CODE_FERME : - $this->getNotificationService()->triggerInscriptionsListePrincipale($session); - $this->getNotificationService()->triggerInscriptionsListeComplementaire($session); - $this->getNotificationService()->triggerInscriptionClose($session); + $this->triggerNotificationInscriptionsListePrincipale($session); + $this->triggerNotificationInscriptionsListeComplementaire($session); + $this->triggerNotificationInscriptionClose($session); break; case Etat::CODE_IMMINENT : - $this->getNotificationService()->triggerSessionImminente($session); - $this->getNotificationService()->triggerInscriptionEchec($session); + $this->triggerNotificationSessionImminente($session); + $this->triggerNotificationInscriptionEchec($session); break; case Etat::CODE_CLOTURER : - $this->getNotificationService()->triggerSessionTerminee($session); + $this->triggerNotificationSessionTerminee($session); break; case Etat::CODE_ANNULEE : - $this->getNotificationService()->triggerSessionAnnulee($session); + $this->triggerNotificationSessionAnnulee($session); break; } } @@ -249,9 +246,105 @@ class SessionController extends AbstractController ]); } - /** - * @throws NotificationException - */ + private function triggerNotificationInscriptionsListePrincipale(Session $session) + { + $inscriptions = $session->getInscriptionsByListe(Inscription::LISTE_PRINCIPALE); + foreach ($inscriptions as $inscription) { + try { + $notif = $this->formationNotificationFactory->createNotificationInscriptionListePrincipale($inscription); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire trouvé lors de la construction de la notif : cas à gérer ! + } + } + } + + private function triggerNotificationInscriptionsListeComplementaire(Session $session) + { + $inscriptions = $session->getInscriptionsByListe(Inscription::LISTE_COMPLEMENTAIRE); + foreach ($inscriptions as $inscription) { + try { + $notif = $this->formationNotificationFactory->createNotificationInscriptionListeComplementaire($inscription); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire trouvé lors de la construction de la notif : cas à gérer ! + } + } + } + + private function triggerNotificationInscriptionClose(Session $session) + { + $nonClasses = $session->getNonClasses(); + + foreach ($nonClasses as $inscription) { + try { + $notif = $this->formationNotificationFactory->createNotificationInscriptionClose($inscription); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire trouvé lors de la construction de la notif : cas à gérer ! + } + } + } + + private function triggerNotificationInscriptionEchec(Session $session) + { + $complementaire = $session->getListeComplementaire(); + $nonClasses = $session->getNonClasses(); + + $inscriptions = array_merge($nonClasses, $complementaire); + + foreach ($inscriptions as $inscription) { + try { + $notif = $this->formationNotificationFactory->createNotificationInscriptionEchec($inscription); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire trouvé lors de la construction de la notif : cas à gérer ! + } + } + } + + private function triggerNotificationSessionImminente(Session $session) + { + $inscriptions = $session->getListePrincipale(); + + foreach ($inscriptions as $inscription) { + try { + $notif = $this->formationNotificationFactory->createNotificationSessionImminente($inscription); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire trouvé lors de la construction de la notif : cas à gérer ! + } + } + } + + private function triggerNotificationSessionTerminee(Session $session) + { + $inscriptions = $session->getListePrincipale(); + + foreach ($inscriptions as $inscription) { + try { + $notif = $this->formationNotificationFactory->createNotificationSessionTerminee($inscription); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire trouvé lors de la construction de la notif : cas à gérer ! + } + } + } + + private function triggerNotificationSessionAnnulee(Session $session) + { + $inscriptions = array_merge($session->getListePrincipale(), $session->getListeComplementaire()); + + foreach ($inscriptions as $inscription) { + try { + $notif = $this->formationNotificationFactory->createNotificationSessionAnnulee($inscription); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire trouvé lors de la construction de la notif : cas à gérer ! + } + } + } + public function classerInscriptionsAction() : Response { $session = $this->getSessionService()->getRepository()->getRequestedSession($this); @@ -273,13 +366,27 @@ class SessionController extends AbstractController if ($positionPrincipale < $session->getTailleListePrincipale()) { $inscription->setListe(Inscription::LISTE_PRINCIPALE); $this->getInscriptionService()->update($inscription); - if ($session->isFinInscription()) $this->getNotificationService()->triggerInscriptionListePrincipale($inscription); + if ($session->isFinInscription()) { + try { + $notif = $this->formationNotificationFactory->createNotificationInscriptionListePrincipale($inscription); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire trouvé lors de la construction de la notif : cas à gérer ! + } + } $positionPrincipale++; } else { if ($positionComplementaire < $session->getTailleListeComplementaire()) { $inscription->setListe(Inscription::LISTE_COMPLEMENTAIRE); $this->getInscriptionService()->update($inscription); - if ($session->isFinInscription()) $this->getNotificationService()->triggerInscriptionListeComplementaire($inscription); + if ($session->isFinInscription()) { + try { + $notif = $this->formationNotificationFactory->createNotificationInscriptionListeComplementaire($inscription); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire trouvé lors de la construction de la notif : cas à gérer ! + } + } $positionComplementaire++; } else { diff --git a/module/Formation/src/Formation/Controller/SessionControllerFactory.php b/module/Formation/src/Formation/Controller/SessionControllerFactory.php index deab90a91f98595b6f42007d9e349a830223db3e..c91830c01e3a6b5b15fe169765d60baee7664cc1 100644 --- a/module/Formation/src/Formation/Controller/SessionControllerFactory.php +++ b/module/Formation/src/Formation/Controller/SessionControllerFactory.php @@ -4,6 +4,7 @@ namespace Formation\Controller; use Fichier\Service\Fichier\FichierStorageService; use Formation\Service\Formation\FormationService; +use Formation\Service\Notification\FormationNotificationFactory; use Formation\Service\Presence\PresenceService; use Formation\Service\SessionStructureValide\SessionStructureValideService; use Psr\Container\ContainerExceptionInterface; @@ -12,7 +13,7 @@ use Structure\Service\Etablissement\EtablissementService; use Doctrine\ORM\EntityManager; use Formation\Form\Session\SessionForm; use Formation\Service\Inscription\InscriptionService; -use Formation\Service\Notification\NotificationService; +use Notification\Service\NotifierService; use Formation\Service\Session\SessionService; use Interop\Container\ContainerInterface; use Laminas\View\Renderer\PhpRenderer; @@ -33,7 +34,7 @@ class SessionControllerFactory { * @var \Fichier\Service\Fichier\FichierStorageService $fichierStorageService * @var FormationService $formationService * @var InscriptionService $inscriptionService - * @var NotificationService $notificationService + * @var NotifierService $notificationService * @var PresenceService $presenceService * @var SessionService $sessionService * @var SessionStructureValideService $sessionStructureComplementaireService @@ -43,7 +44,7 @@ class SessionControllerFactory { $fichierStorageService = $container->get(FichierStorageService::class); $formationService = $container->get(FormationService::class); $inscriptionService = $container->get(InscriptionService::class); - $notificationService = $container->get(NotificationService::class); + $notificationService = $container->get(NotifierService::class); $presenceService = $container->get(PresenceService::class); $sessionService = $container->get(SessionService::class); $sessionStructureComplementaireService = $container->get(SessionStructureValideService::class); @@ -63,7 +64,7 @@ class SessionControllerFactory { $controller->setFichierStorageService($fichierStorageService); $controller->setFormationService($formationService); $controller->setInscriptionService($inscriptionService); - $controller->setNotificationService($notificationService); + $controller->setNotifierService($notificationService); $controller->setPresenceService($presenceService); $controller->setSessionService($sessionService); $controller->setSessionStructureValideService($sessionStructureComplementaireService); @@ -72,6 +73,10 @@ class SessionControllerFactory { /** Autre *****************************************************************************************************/ $controller->setRenderer($renderer); + /** @var \Formation\Service\Notification\FormationNotificationFactory $formationNotificationFactory */ + $formationNotificationFactory = $container->get(FormationNotificationFactory::class); + $controller->setFormationNotificationFactory($formationNotificationFactory); + return $controller; } } \ No newline at end of file diff --git a/module/Formation/src/Formation/Form/Session/SessionHydrator.php b/module/Formation/src/Formation/Form/Session/SessionHydrator.php index e578ed606c245d705ffa1d27f31ab0e17e26fe34..db5e916bff0c95693f0f117718634ad7b0787105 100644 --- a/module/Formation/src/Formation/Form/Session/SessionHydrator.php +++ b/module/Formation/src/Formation/Form/Session/SessionHydrator.php @@ -56,7 +56,7 @@ class SessionHydrator implements HydratorInterface { $structure = (isset($data['type_structure']) AND trim($data['type_structure']) !== "")?$this->getStructureService()->getRepository()->find($data['type_structure']):null; $tailleListePrincipale = (isset($data['taille_liste_principale']) AND trim($data['taille_liste_principale']) !== '')?trim($data['taille_liste_principale']):null; $tailleListeComplementaire = (isset($data['taille_liste_complementaire']) AND trim($data['taille_liste_complementaire']) !== '')?trim($data['taille_liste_complementaire']):null; - $dateFermetureInscription = (isset($data['date_fermeture_inscription']))?DateTime::createFromFormat('d/m/Y', $data['date_fermeture_inscription']):null; + $dateFermetureInscription = (isset($data['date_fermeture_inscription']) AND trim($data['date_fermeture_inscription']) !== '')?DateTime::createFromFormat('d/m/Y', $data['date_fermeture_inscription']):null; $object->setDescription($description); $object->setSite($site); diff --git a/module/Formation/src/Formation/Service/EnqueteReponse/Search/EnqueteReponseSearchService.php b/module/Formation/src/Formation/Service/EnqueteReponse/Search/EnqueteReponseSearchService.php index d22f08d9230de7569388c551234faf007ec1b26b..b80919750e4d5a60a100babdba7db06c66a5c2ca 100644 --- a/module/Formation/src/Formation/Service/EnqueteReponse/Search/EnqueteReponseSearchService.php +++ b/module/Formation/src/Formation/Service/EnqueteReponse/Search/EnqueteReponseSearchService.php @@ -76,12 +76,12 @@ class EnqueteReponseSearchService extends SearchService // ATTENTION à bien sélectionner les relations utilisées par les filtres/tris et parcourues côté vue. return $this->enqueteReponseRepository->createQueryBuilder('er') ->addSelect('q, insc, sess, form, resp, site') - ->join('er.question', 'q') - ->join('er.inscription', 'insc') - ->join('insc.session', 'sess') - ->join("sess.formation", 'form') - ->join("sess.formateurs", 'formateur') - ->join("formateur.individu", 'indf') + ->leftjoin('er.question', 'q') + ->leftjoin('er.inscription', 'insc') + ->leftjoin('insc.session', 'sess') + ->leftjoin("sess.formation", 'form') + ->leftjoin("sess.formateurs", 'formateur') + ->leftjoin("formateur.individu", 'indf') ->leftJoin("form.responsable", 'resp') ->leftJoin("form.site", 'site') ->leftJoin("site.structure", 'site_structure')->addSelect('site_structure') diff --git a/module/Formation/src/Formation/Service/Notification/FormationNotificationFactory.php b/module/Formation/src/Formation/Service/Notification/FormationNotificationFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..85bb886e30b1a644713ac3f4fb121808826302cf --- /dev/null +++ b/module/Formation/src/Formation/Service/Notification/FormationNotificationFactory.php @@ -0,0 +1,218 @@ +<?php + +namespace Formation\Service\Notification; + +use Formation\Entity\Db\Inscription; +use Formation\Provider\Template\MailTemplates; +use Notification\Exception\RuntimeException; +use Notification\Factory\NotificationFactory; +use Notification\Notification; +use UnicaenRenderer\Service\Rendu\RenduServiceAwareTrait; + +/** + * Classe de construction de notifications par mail. + * + * @author Unicaen + */ +class FormationNotificationFactory extends NotificationFactory +{ + use RenduServiceAwareTrait; + + /** INSCRIPTION ***************************************************************************************************/ + + public function createNotificationInscriptionEnregistree(Inscription $inscription) : Notification + { + $vars = [ + 'doctorant' => $inscription->getDoctorant(), + 'formation' => $inscription->getSession()->getFormation(), + 'session' => $inscription->getSession(), + ]; + + $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_ENREGISTREE, $vars); + $mail = $inscription->getDoctorant()->getIndividu()->getEmailPro(); + + if (!$mail) { + throw new RuntimeException("Aucune adresse mail trouvée pour le doctorant {$inscription->getDoctorant()}."); + } + + $notif = new Notification(); + $notif + ->setTo($mail) + ->setSubject($rendu->getSujet()) + ->setBody($rendu->getCorps()) + ; + + return $notif; + } + + public function createNotificationInscriptionListePrincipale(Inscription $inscription) : Notification + { + $vars = [ + 'doctorant' => $inscription->getDoctorant(), + 'formation' => $inscription->getSession()->getFormation(), + 'session' => $inscription->getSession(), + ]; + + $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_LISTE_PRINCIPALE, $vars); + $mail = $inscription->getDoctorant()->getIndividu()->getEmailPro(); + + if (!$mail) { + throw new RuntimeException("Aucune adresse mail trouvée pour le doctorant {$inscription->getDoctorant()}."); + } + + $notif = new Notification(); + $notif + ->setTo($mail) + ->setSubject($rendu->getSujet()) + ->setBody($rendu->getCorps()) + ; + + return $notif; + } + + public function createNotificationInscriptionListeComplementaire(Inscription $inscription) : Notification + { + $vars = [ + 'doctorant' => $inscription->getDoctorant(), + 'formation' => $inscription->getSession()->getFormation(), + 'session' => $inscription->getSession(), + 'inscription' => $inscription, + ]; + + $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_LISTE_COMPLEMENTAIRE, $vars); + $mail = $inscription->getDoctorant()->getIndividu()->getEmailPro(); + + if (!$mail) { + throw new RuntimeException("Aucune adresse mail trouvée pour le doctorant {$inscription->getDoctorant()}."); + } + + $notif = new Notification(); + $notif + ->setTo($mail) + ->setSubject($rendu->getSujet()) + ->setBody($rendu->getCorps()) + ; + + return $notif; + } + + public function createNotificationInscriptionClose(Inscription $inscription) : Notification + { + $vars = [ + 'doctorant' => $inscription->getDoctorant(), + 'formation' => $inscription->getSession()->getFormation(), + 'session' => $inscription->getSession(), + ]; + $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_CLOSE, $vars); + $mail = $inscription->getDoctorant()->getIndividu()->getEmailPro(); + + if (!$mail) { + throw new RuntimeException("Aucune adresse mail trouvée pour le doctorant {$inscription->getDoctorant()}."); + } + + $notif = new Notification(); + $notif + ->setTo($mail) + ->setSubject($rendu->getSujet()) + ->setBody($rendu->getCorps()); + + return $notif; + } + + public function createNotificationInscriptionEchec(Inscription $inscription) : Notification + { + $vars = [ + 'doctorant' => $inscription->getDoctorant(), + 'formation' => $inscription->getSession()->getFormation(), + 'session' => $inscription->getSession(), + ]; + $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_ECHEC, $vars); + $mail = $inscription->getDoctorant()->getIndividu()->getEmailPro(); + + if (!$mail) { + throw new RuntimeException("Aucune adresse mail trouvée pour le doctorant {$inscription->getDoctorant()}."); + } + + $notif = new Notification(); + $notif + ->setTo($mail) + ->setSubject($rendu->getSujet()) + ->setBody($rendu->getCorps()) + ; + + return $notif; + } + + /** SESSIONS ******************************************************************************************************/ + + public function createNotificationSessionImminente(Inscription $inscription) : Notification + { + $vars = [ + 'doctorant' => $inscription->getDoctorant(), + 'formation' => $inscription->getSession()->getFormation(), + 'session' => $inscription->getSession(), + ]; + $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SESSION_IMMINENTE, $vars); + $mail = $inscription->getDoctorant()->getIndividu()->getEmailPro(); + + if (!$mail) { + throw new RuntimeException("Aucune adresse mail trouvée pour le doctorant {$inscription->getDoctorant()}."); + } + + $notif = new Notification(); + $notif + ->setTo($mail) + ->setSubject($rendu->getSujet()) + ->setBody($rendu->getCorps()) + ; + + return $notif; + } + + public function createNotificationSessionTerminee(Inscription $inscription) : Notification + { + $vars = [ + 'doctorant' => $inscription->getDoctorant(), + 'formation' => $inscription->getSession()->getFormation(), + 'session' => $inscription->getSession(), + ]; + $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SESSION_TERMINEE, $vars); + $mail = $inscription->getDoctorant()->getIndividu()->getEmailPro(); + + if (!$mail) { + throw new RuntimeException("Aucune adresse mail trouvée pour le doctorant {$inscription->getDoctorant()}."); + } + + $notif = new Notification(); + $notif + ->setTo($mail) + ->setSubject($rendu->getSujet()) + ->setBody($rendu->getCorps()) + ; + + return $notif; + } + + public function createNotificationSessionAnnulee(Inscription $inscription): Notification + { + $vars = [ + 'doctorant' => $inscription->getDoctorant(), + 'formation' => $inscription->getSession()->getFormation(), + 'session' => $inscription->getSession(), + ]; + $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SESSION_ANNULEE, $vars); + $mail = $inscription->getDoctorant()->getIndividu()->getEmailPro(); + + if (!$mail) { + throw new RuntimeException("Aucune adresse mail trouvée pour le doctorant {$inscription->getDoctorant()}."); + } + + $notif = new Notification(); + $notif + ->setTo($mail) + ->setSubject($rendu->getSujet()) + ->setBody($rendu->getCorps()); + + return $notif; + } +} \ No newline at end of file diff --git a/module/Formation/src/Formation/Service/Notification/FormationNotificationFactoryAwareTrait.php b/module/Formation/src/Formation/Service/Notification/FormationNotificationFactoryAwareTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..b27cbc97f5f516e2efa8dce6d7ea169d14c00bc5 --- /dev/null +++ b/module/Formation/src/Formation/Service/Notification/FormationNotificationFactoryAwareTrait.php @@ -0,0 +1,13 @@ +<?php + +namespace Formation\Service\Notification; + +trait FormationNotificationFactoryAwareTrait +{ + protected FormationNotificationFactory $formationNotificationFactory; + + public function setFormationNotificationFactory(FormationNotificationFactory $formationNotificationFactory): void + { + $this->formationNotificationFactory = $formationNotificationFactory; + } +} \ No newline at end of file diff --git a/module/Formation/src/Formation/Service/Notification/FormationNotificationFactoryFactory.php b/module/Formation/src/Formation/Service/Notification/FormationNotificationFactoryFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..61453d5ea5e9cb61306de5d3ce6938dc98a0f578 --- /dev/null +++ b/module/Formation/src/Formation/Service/Notification/FormationNotificationFactoryFactory.php @@ -0,0 +1,34 @@ +<?php + +namespace Formation\Service\Notification; + +use Interop\Container\ContainerInterface; +use Notification\Factory\NotificationFactoryFactory; +use UnicaenRenderer\Service\Rendu\RenduService; + +/** + * @author Unicaen + */ +class FormationNotificationFactoryFactory extends NotificationFactoryFactory +{ + /** + * @var string + */ + protected string $class = FormationNotificationFactory::class; + + /** + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface + */ + public function __invoke(ContainerInterface $container): FormationNotificationFactory + { + /** @var FormationNotificationFactory $factory */ + $factory = parent::__invoke($container); + + /** @var RenduService $renduService */ + $renduService = $container->get(RenduService::class); + $factory->setRenduService($renduService); + + return $factory; + } +} diff --git a/module/Formation/src/Formation/Service/Notification/NotificationService.php b/module/Formation/src/Formation/Service/Notification/NotificationService.php deleted file mode 100644 index cf3b7a3a781b45ce06d18f552569a29dc0880fa5..0000000000000000000000000000000000000000 --- a/module/Formation/src/Formation/Service/Notification/NotificationService.php +++ /dev/null @@ -1,263 +0,0 @@ -<?php - -namespace Formation\Service\Notification; - -use Formation\Entity\Db\Inscription; -use Formation\Entity\Db\Session; -use Formation\Provider\Template\MailTemplates; -use Notification\Exception\NotificationException; -use Notification\Notification; -use Notification\Service\NotifierService; -use UnicaenRenderer\Service\Rendu\RenduServiceAwareTrait; - -class NotificationService extends NotifierService -{ - use RenduServiceAwareTrait; - - /** INSCRIPTION ***************************************************************************************************/ - - /** - * @param Inscription $inscription - * @return void - * @throws NotificationException - */ - public function triggerInscriptionEnregistree(Inscription $inscription) : void - { - $vars = [ - 'doctorant' => $inscription->getDoctorant(), - 'formation' => $inscription->getSession()->getFormation(), - 'session' => $inscription->getSession(), - ]; - - $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_ENREGISTREE, $vars); - $mail = $inscription->getDoctorant()->getIndividu()->getEmailPro(); - - if ($mail !== null) { - $notif = new Notification(); - $notif - ->setTo($mail) - ->setSubject($rendu->getSujet()) - ->setBody($rendu->getCorps()) - ; - $this->trigger($notif); - } - } - - public function triggerInscriptionsListePrincipale(Session $session) : void - { - $inscriptions = $session->getInscriptionsByListe(Inscription::LISTE_PRINCIPALE); - foreach ($inscriptions as $inscription) $this->triggerInscriptionListePrincipale($inscription); - } - - /** - * @param Inscription $inscription - * @return void - * @throws NotificationException - */ - public function triggerInscriptionListePrincipale(Inscription $inscription) : void - { - $vars = [ - 'doctorant' => $inscription->getDoctorant(), - 'formation' => $inscription->getSession()->getFormation(), - 'session' => $inscription->getSession(), - ]; - - $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_LISTE_PRINCIPALE, $vars); - $mail = $inscription->getDoctorant()->getIndividu()->getEmailPro(); - - if ($mail !== null) { - $notif = new Notification(); - $notif - ->setTo($mail) - ->setSubject($rendu->getSujet()) - ->setBody($rendu->getCorps()) - ; - $this->trigger($notif); - } - } - - public function triggerInscriptionsListeComplementaire(Session $session) : void - { - $inscriptions = $session->getInscriptionsByListe(Inscription::LISTE_COMPLEMENTAIRE); - foreach ($inscriptions as $inscription) $this->triggerInscriptionListeComplementaire($inscription); - } - - /** - * @param Inscription $inscription - * @return void - * @throws NotificationException - */ - public function triggerInscriptionListeComplementaire(Inscription $inscription) : void - { - $vars = [ - 'doctorant' => $inscription->getDoctorant(), - 'formation' => $inscription->getSession()->getFormation(), - 'session' => $inscription->getSession(), - 'inscription' => $inscription, - ]; - - $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_LISTE_COMPLEMENTAIRE, $vars); - $mail = $inscription->getDoctorant()->getIndividu()->getEmailPro(); - - if ($mail !== null) { - $notif = new Notification(); - $notif - ->setTo($mail) - ->setSubject($rendu->getSujet()) - ->setBody($rendu->getCorps()) - ; - $this->trigger($notif); - } - } - - /** - * @param Session $session - * @return void - * @throws NotificationException - */ - public function triggerInscriptionClose(Session $session) : void - { - $nonClasses = $session->getNonClasses(); - - foreach ($nonClasses as $inscription) { - $vars = [ - 'doctorant' => $inscription->getDoctorant(), - 'formation' => $inscription->getSession()->getFormation(), - 'session' => $inscription->getSession(), - ]; - $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_CLOSE, $vars); - $mail = $inscription->getDoctorant()->getIndividu()->getEmail(); - - if ($mail !== null) { - $notif = new Notification(); - $notif - ->setTo($mail) - ->setSubject($rendu->getSujet()) - ->setBody($rendu->getCorps()) - ; - $this->trigger($notif); - } - } - } - - /** - * @param Session $session - * @return void - * @throws NotificationException - */ - public function triggerInscriptionEchec(Session $session) : void - { - $complementaire = $session->getListeComplementaire(); - $nonClasses = $session->getNonClasses(); - - $inscriptions = array_merge($nonClasses, $complementaire); - - foreach ($inscriptions as $inscription) { - $vars = [ - 'doctorant' => $inscription->getDoctorant(), - 'formation' => $inscription->getSession()->getFormation(), - 'session' => $inscription->getSession(), - ]; - $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_ECHEC, $vars); - $mail = $inscription->getDoctorant()->getIndividu()->getEmail(); - - if ($mail !== null) { - $notif = new Notification(); - $notif - ->setTo($mail) - ->setSubject($rendu->getSujet()) - ->setBody($rendu->getCorps()) - ; - $this->trigger($notif); - } - } - } - - /** SESSIONS ******************************************************************************************************/ - - /** - * @param Session $session - * @return void - * @throws NotificationException - */ - public function triggerSessionImminente(Session $session) : void - { - $inscriptions = $session->getListePrincipale(); - - foreach ($inscriptions as $inscription) { - $vars = [ - 'doctorant' => $inscription->getDoctorant(), - 'formation' => $inscription->getSession()->getFormation(), - 'session' => $inscription->getSession(), - ]; - $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SESSION_IMMINENTE, $vars); - $mail = $inscription->getDoctorant()->getIndividu()->getEmail(); - - if ($mail !== null) { - $notif = new Notification(); - $notif - ->setTo($mail) - ->setSubject($rendu->getSujet()) - ->setBody($rendu->getCorps()) - ; - $this->trigger($notif); - } - } - } - - /** - * @param Session $session - * @return void - * @throws NotificationException - */ - public function triggerSessionTerminee(Session $session) : void - { - $inscriptions = $session->getListePrincipale(); - - foreach ($inscriptions as $inscription) { - $vars = [ - 'doctorant' => $inscription->getDoctorant(), - 'formation' => $inscription->getSession()->getFormation(), - 'session' => $inscription->getSession(), - ]; - $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SESSION_TERMINEE, $vars); - $mail = $inscription->getDoctorant()->getIndividu()->getEmail(); - - if ($mail !== null) { - $notif = new Notification(); - $notif - ->setTo($mail) - ->setSubject($rendu->getSujet()) - ->setBody($rendu->getCorps()) - ; - $this->trigger($notif); - } - } - } - - public function triggerSessionAnnulee(?Session $session) - { - $inscriptions = array_merge($session->getListePrincipale(), $session->getListeComplementaire()); - - foreach ($inscriptions as $inscription) { - $vars = [ - 'doctorant' => $inscription->getDoctorant(), - 'formation' => $inscription->getSession()->getFormation(), - 'session' => $inscription->getSession(), - ]; - $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SESSION_ANNULEE, $vars); - $mail = $inscription->getDoctorant()->getIndividu()->getEmail(); - - if ($mail !== null) { - $notif = new Notification(); - $notif - ->setTo($mail) - ->setSubject($rendu->getSujet()) - ->setBody($rendu->getCorps()) - ; - $this->trigger($notif); - } - } - } - -} \ No newline at end of file diff --git a/module/Formation/src/Formation/Service/Notification/NotificationServiceAwareTrait.php b/module/Formation/src/Formation/Service/Notification/NotificationServiceAwareTrait.php deleted file mode 100644 index 611b8b7c4a3aa8222a767541412588f87500a9a8..0000000000000000000000000000000000000000 --- a/module/Formation/src/Formation/Service/Notification/NotificationServiceAwareTrait.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -namespace Formation\Service\Notification; - -trait NotificationServiceAwareTrait { - - /** @var NotificationService */ - private $notificationService; - - /** - * @return NotificationService - */ - public function getNotificationService(): NotificationService - { - return $this->notificationService; - } - - /** - * @param NotificationService $notificationService - * @return NotificationService - */ - public function setNotificationService(NotificationService $notificationService): NotificationService - { - $this->notificationService = $notificationService; - return $this->notificationService; - } - - -} \ No newline at end of file diff --git a/module/Formation/src/Formation/Service/Notification/NotificationServiceFactory.php b/module/Formation/src/Formation/Service/Notification/NotificationServiceFactory.php deleted file mode 100644 index 748a2cfcdd1347ba6d909f54535bdd8411ee8e65..0000000000000000000000000000000000000000 --- a/module/Formation/src/Formation/Service/Notification/NotificationServiceFactory.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -namespace Formation\Service\Notification; - -use Application\Service\Notification\NotificationFactory; -use Interop\Container\ContainerInterface; -use Notification\Service\NotifierServiceFactory; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; -use UnicaenRenderer\Service\Rendu\RenduService; - -class NotificationServiceFactory extends NotifierServiceFactory -{ - - protected $notifierServiceClass = NotificationService::class; - - /** - * @param ContainerInterface $container - * @return NotificationService - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface - */ - public function __invoke(ContainerInterface $container) : NotificationService - { - /** - * @var NotificationService $service - * @var RenduService $renduService - */ - $service = parent::__invoke($container); - $renduService = $container->get(RenduService::class); - - /** @var NotificationFactory $notificationFactory */ - $notificationFactory = $container->get(NotificationFactory::class); - - $service->setNotificationFactory($notificationFactory); - $service->setRenduService($renduService); - - return $service; - } -} \ No newline at end of file diff --git a/module/Formation/view/formation/index/index-doctorant.phtml b/module/Formation/view/formation/index/index-doctorant.phtml index ba59577fe1e232a269f13719a7c7d416143a4587..6865dfd25b42bdb34076a7df19286da77e890a42 100644 --- a/module/Formation/view/formation/index/index-doctorant.phtml +++ b/module/Formation/view/formation/index/index-doctorant.phtml @@ -55,10 +55,10 @@ $canCatalogueAfficher = $this->isAllowed(ModulePrivileges::getResourceId(ModuleP Aucun·e doctorant·e de trouvé·e. </p> - <p> - <u>N.B.:</u> Mon cobaye est Josselin GUENERON dans l'id est <code>38108</code> - → <a href="<?php echo $this->url('formation/index-doctorant', ['doctorant' => 38108], [], true); ?>">Cas du cobaye</a> - </p> +<!-- <p>--> +<!-- <u>N.B.:</u> Mon cobaye est Josselin GUENERON dans l'id est <code>38108</code>--> +<!-- → <a href="--><?php //echo $this->url('formation/index-doctorant', ['doctorant' => 38108], [], true); ?><!--">Cas du cobaye</a>--> +<!-- </p>--> <?php else : ?> <div class="row"> diff --git a/module/Import/src/Import/Model/Service/ImportObservResultService.php b/module/Import/src/Import/Model/Service/ImportObservResultService.php index 5a4bc08e432bddee5f532580d04d257463029345..d7eb9fc4f8a820b1dcbec3f1d9511df324122a42 100644 --- a/module/Import/src/Import/Model/Service/ImportObservResultService.php +++ b/module/Import/src/Import/Model/Service/ImportObservResultService.php @@ -5,9 +5,11 @@ namespace Import\Model\Service; use Application\Constants; use Import\Model\ImportObserv; use Import\Model\ImportObservResult; +use Notification\NotificationResult; use These\Entity\Db\These; use Depot\Rule\NotificationDepotVersionCorrigeeAttenduRule; -use Application\Service\Notification\NotifierServiceAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; +use These\Service\Notification\TheseNotificationFactoryAwareTrait; use These\Service\These\TheseServiceAwareTrait; use Application\Service\Variable\VariableServiceAwareTrait; use Doctrine\ORM\OptimisticLockException; @@ -22,6 +24,7 @@ class ImportObservResultService extends \UnicaenDbImport\Entity\Db\Service\Impor { use TheseServiceAwareTrait; use NotifierServiceAwareTrait; + use TheseNotificationFactoryAwareTrait; use VariableServiceAwareTrait; use LoggerAwareTrait; @@ -108,20 +111,33 @@ class ImportObservResultService extends \UnicaenDbImport\Entity\Db\Service\Impor } // Notification des doctorants dont le résultat de la thèse est passé à Admis. - $notifs = $this->notifierService->triggerChangementResultatThesesAdmis($data); - $this->logAboutNotifications($notifs); - // Notification concernant l'évolution des résultats de thèses. - $notif = $this->notifierService->triggerChangementResultatTheses($data); - $this->logAboutNotifications([$notif]); - - // Enregistrement de la date de dernière notification - foreach ($records as $record) { - $record->setDateNotif($notif->getSendDate()); + try { + $notifs = $this->theseNotificationFactory->createNotificationsChangementResultatThesesAdmis($data); + foreach ($notifs as $notif) { + $this->notifierService->trigger($notif); + } + $this->logAboutNotifications($notifs); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! } + + // Notification concernant l'évolution des résultats de thèses. try { - $this->getEntityManager()->flush($records); - } catch (OptimisticLockException $e) { - throw new RuntimeException("Enregistrement des ImportObservResultEtab impossible", null, $e); + $notif = $this->theseNotificationFactory->createNotificationChangementResultatTheses($data); + $result = $this->notifierService->trigger($notif); + $this->logAboutNotifications([$notif]); + + // Enregistrement de la date de dernière notification + foreach ($records as $record) { + $record->setDateNotif($result->getSendDate()); + } + try { + $this->getEntityManager()->flush($records); + } catch (OptimisticLockException $e) { + throw new RuntimeException("Enregistrement des ImportObservResultEtab impossible", null, $e); + } + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! } } @@ -253,18 +269,20 @@ class ImportObservResultService extends \UnicaenDbImport\Entity\Db\Service\Impor $these->setCorrectionAutorisee($ior->getImportObserv()->getToValue()); // anticipation nécessaire ! // notification - $notif = $this->notifierService->triggerCorrectionAttendue($ior, $these, $message); - if ($notif === null) { - $this->logger->info(sprintf("Aucune notif n'est nécessaire pour la thèse '%s'. ", $these->getSourceCode()) . $message); - continue; // si le service de notif renvoie null, aucune notif n'était nécessaire, on passe au suivant + try { + $notif = $this->theseNotificationFactory->createNotificationCorrectionAttendue($ior, $these, $message); + if ($notif === null) { + $this->logger->info(sprintf("Aucune notif n'est nécessaire pour la thèse '%s'. ", $these->getSourceCode()) . $message); + continue; // si le service de notif renvoie null, aucune notif n'était nécessaire, on passe au suivant + } + $result = $this->notifierService->trigger($notif); + $this->logAboutNotifications([$notif]);// Enregistrement de la date de dernière notification + + $ior->setDateNotif($result->getSendDate()); + $recordsToFlush[] = $ior; + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! } - - $this->logAboutNotifications([$notif]); - - // Enregistrement de la date de dernière notification - $ior->setDateNotif($notif->getSendDate()); - - $recordsToFlush[] = $ior; } try { diff --git a/module/Import/src/Import/Model/Service/ImportObservResultServiceFactory.php b/module/Import/src/Import/Model/Service/ImportObservResultServiceFactory.php index 5e7c40c4d09a4ebfb0fca102efb0d4bdf7e75c24..4dffc309479d533cb65e5814c716a5fb68a00368 100644 --- a/module/Import/src/Import/Model/Service/ImportObservResultServiceFactory.php +++ b/module/Import/src/Import/Model/Service/ImportObservResultServiceFactory.php @@ -2,11 +2,11 @@ namespace Import\Model\Service; -use Application\Service\Notification\NotifierService; +use Notification\Service\NotifierService; +use These\Service\Notification\TheseNotificationFactory; use These\Service\These\TheseService; use Application\Service\Variable\VariableService; use Doctrine\ORM\EntityManager; -use Import\Model\Service\ImportObservResultService; use Interop\Container\ContainerInterface; use UnicaenDbImport\Config\Config; use Laminas\Console\Request as ConsoleRequest; @@ -16,7 +16,11 @@ use Laminas\Log\Writer\Stream; class ImportObservResultServiceFactory { - public function __invoke(ContainerInterface $container) + /** + * @throws \Psr\Container\NotFoundExceptionInterface + * @throws \Psr\Container\ContainerExceptionInterface + */ + public function __invoke(ContainerInterface $container): ImportObservResultService { /** @var EntityManager $em */ $em = $container->get('doctrine.entitymanager.orm_default'); @@ -40,6 +44,10 @@ class ImportObservResultServiceFactory $service->setNotifierService($notifierService); $service->setVariableService($variableService); + /** @var \These\Service\Notification\TheseNotificationFactory $theseNotificationFactory */ + $theseNotificationFactory = $container->get(TheseNotificationFactory::class); + $service->setTheseNotificationFactory($theseNotificationFactory); + if ($logger = $this->getLogger($container)) { $service->setLogger($logger); } diff --git a/module/Notification/src/Notification/Exception/ExceptionInterface.php b/module/Notification/src/Notification/Exception/ExceptionInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..beaa21dcfad03ac84993c1c13b661264456c7a4c --- /dev/null +++ b/module/Notification/src/Notification/Exception/ExceptionInterface.php @@ -0,0 +1,7 @@ +<?php + +namespace Notification\Exception; + +interface ExceptionInterface extends \Throwable +{ +} diff --git a/module/Notification/src/Notification/Exception/NotificationException.php b/module/Notification/src/Notification/Exception/NotificationException.php deleted file mode 100644 index 9e5413dbf929ed2d643d4c3a1822f28170391985..0000000000000000000000000000000000000000 --- a/module/Notification/src/Notification/Exception/NotificationException.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php - -namespace Notification\Exception; - -class NotificationException extends \Exception -{ - -} \ No newline at end of file diff --git a/module/Notification/src/Notification/Exception/NotificationImpossibleException.php b/module/Notification/src/Notification/Exception/NotificationImpossibleException.php deleted file mode 100644 index ad8f01595378d72eb39824f7dc9d6531f4a37cdb..0000000000000000000000000000000000000000 --- a/module/Notification/src/Notification/Exception/NotificationImpossibleException.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php - -namespace Notification\Exception; - -class NotificationImpossibleException extends NotificationException -{ - -} \ No newline at end of file diff --git a/module/Notification/src/Notification/Exception/RuntimeException.php b/module/Notification/src/Notification/Exception/RuntimeException.php new file mode 100644 index 0000000000000000000000000000000000000000..13038c23d1d318a94c4b110075e63d2bc172db1f --- /dev/null +++ b/module/Notification/src/Notification/Exception/RuntimeException.php @@ -0,0 +1,8 @@ +<?php + +namespace Notification\Exception; + +class RuntimeException extends \RuntimeException implements ExceptionInterface +{ + +} \ No newline at end of file diff --git a/module/Notification/src/Notification/Service/NotificationFactory.php b/module/Notification/src/Notification/Factory/NotificationFactory.php similarity index 80% rename from module/Notification/src/Notification/Service/NotificationFactory.php rename to module/Notification/src/Notification/Factory/NotificationFactory.php index 256fb680e5789f9ab70e921c3ae25cd10ae10b11..f6ac1d49ace249119deb9e161db277331a1b72d1 100644 --- a/module/Notification/src/Notification/Service/NotificationFactory.php +++ b/module/Notification/src/Notification/Factory/NotificationFactory.php @@ -1,6 +1,6 @@ <?php -namespace Notification\Service; +namespace Notification\Factory; use Notification\Entity\NotifEntity; use Notification\Entity\Service\NotifEntityServiceAwareTrait; @@ -16,12 +16,10 @@ class NotificationFactory use NotifEntityServiceAwareTrait; /** - * @param string $code - * @return Notification + * Instancie et initialise une nouvelle notification. */ - public function createNotification($code = null) + public function createNotification(?string $code = null): Notification { - /** @var Notification $notification */ $notification = new Notification($code); $this->initNotification($notification); @@ -31,8 +29,6 @@ class NotificationFactory /** * Initialisation indispensable d'une notification. - * - * @param Notification $notification */ public function initNotification(Notification $notification) { diff --git a/module/Notification/src/Notification/Factory/NotificationFactoryAwareTrait.php b/module/Notification/src/Notification/Factory/NotificationFactoryAwareTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..2a4885a753a1ec8222fc78a177b7a27bcee07b78 --- /dev/null +++ b/module/Notification/src/Notification/Factory/NotificationFactoryAwareTrait.php @@ -0,0 +1,13 @@ +<?php + +namespace Notification\Factory; + +trait NotificationFactoryAwareTrait +{ + protected NotificationFactory $otificationFactory; + + public function setNotifierService(NotificationFactory $otificationFactory) + { + $this->otificationFactory = $otificationFactory; + } +} \ No newline at end of file diff --git a/module/Notification/src/Notification/Service/NotificationFactoryFactory.php b/module/Notification/src/Notification/Factory/NotificationFactoryFactory.php similarity index 61% rename from module/Notification/src/Notification/Service/NotificationFactoryFactory.php rename to module/Notification/src/Notification/Factory/NotificationFactoryFactory.php index 3eb710940df0854fc122dee7a9819d0c505e79c3..cdabcc2bd20346be4c387abc1ed6e3fd97044569 100644 --- a/module/Notification/src/Notification/Service/NotificationFactoryFactory.php +++ b/module/Notification/src/Notification/Factory/NotificationFactoryFactory.php @@ -1,9 +1,9 @@ <?php -namespace Notification\Service; +namespace Notification\Factory; -use Interop\Container\ContainerInterface; use Notification\Entity\Service\NotifEntityService; +use Psr\Container\ContainerInterface; /** * @author Unicaen @@ -13,15 +13,13 @@ class NotificationFactoryFactory /** * @var string */ - protected $class = NotificationFactory::class; + protected string $class = NotificationFactory::class; /** - * Create service. - * - * @param ContainerInterface $container - * @return NotificationFactory + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface */ - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container): NotificationFactory { /** @var NotifEntityService $notifEntityService */ $notifEntityService = $container->get(NotifEntityService::class); diff --git a/module/Notification/src/Notification/Notification.php b/module/Notification/src/Notification/Notification.php index 3eb7760d02306e5af4f6e3ecdba168be3acfbd34..2a2863e36a8624c04a1dd88172e744ff7ae912b6 100644 --- a/module/Notification/src/Notification/Notification.php +++ b/module/Notification/src/Notification/Notification.php @@ -2,10 +2,8 @@ namespace Notification; -use Depot\Notification\ValidationDepotTheseCorrigeeNotification; -use Depot\Notification\ValidationRdvBuNotification; -use Notification\Entity\NotifEntity; use Laminas\View\Model\ViewModel; +use Notification\Entity\NotifEntity; /** * Classe représentant une notification. @@ -14,72 +12,44 @@ use Laminas\View\Model\ViewModel; */ class Notification { - /** - * @var string - */ - protected $code; - - /** - * @var NotifEntity - */ - protected $notifEntity; - - /** - * @var string - */ - protected $templatePath; - - /** - * @var array - */ - protected $templateVariables = []; - - /** - * @var string - */ - protected $subject; - - /** - * @var string - */ - protected $body = null; - - /** - * @var array - */ - protected $to; - - /** - * @var array - */ - protected $cc; + protected ?string $code = null; + protected ?NotifEntity $notifEntity = null; + protected ?string $templatePath = null; + protected array $templateVariables = []; + protected string $subject; + protected ?string $body = null; + protected array $to = []; + protected array $cc = []; + protected array $bcc = []; + protected ?string $toLabel = null; + protected ?string $ccLabel = null; + protected ?string $bccLabel = null; /** - * @var array + * @var string[] */ - protected $bcc; + protected array $errorMessages = []; /** * @var string[] */ - protected $warningMessages = []; + protected array $successMessages = []; /** * @var string[] */ - protected $infoMessages = []; + protected array $informationMessages = []; /** * @var \DateTime + * @deprecated */ protected $sendDate; /** * Notification constructor. - * - * @param string|null $code */ - public function __construct($code = null) + public function __construct(?string $code = null) { $this->code = $code; } @@ -118,7 +88,7 @@ class Notification /** * @return array */ - private function createTemplateVariables() + private function createTemplateVariables(): array { $variables = []; @@ -127,9 +97,7 @@ class Notification $variables['cc'] = $this->getCc(); $variables['bcc'] = $this->getBcc(); - $variables = array_merge($variables, $this->getTemplateVariables()); - - return $variables; + return array_merge($variables, $this->getTemplateVariables()); } /** @@ -137,7 +105,7 @@ class Notification * * @return ViewModel */ - public function createViewModel() + public function createViewModel(): ViewModel { $variables = $this->createTemplateVariables(); @@ -148,11 +116,7 @@ class Notification return $viewModel; } - /** - * @param string $code - * @return static - */ - public function setCode($code) + public function setCode(string $code): self { $this->code = $code; $this->notifEntity = null; @@ -160,43 +124,30 @@ class Notification return $this; } - /** - * @return string - */ - public function getCode() + public function getCode(): ?string { return $this->code; } - /** - * @param NotifEntity $notifEntity - */ - public function setNotifEntity(NotifEntity $notifEntity = null) + public function setNotifEntity(?NotifEntity $notifEntity = null) { $this->notifEntity = $notifEntity; $this->code = $notifEntity ? $notifEntity->getCode() : null; } - /** - * @return NotifEntity - */ - public function getNotifEntity() + public function getNotifEntity(): ?NotifEntity { return $this->notifEntity; } - /** - * @param string $subject - * @return static - */ - public function setSubject($subject) + public function setSubject(string $subject): self { $this->subject = $subject; return $this; } - public function setBody(string $body) + public function setBody(string $body): self { $this->body = $body; return $this; @@ -204,9 +155,8 @@ class Notification /** * @param string|array $to - * @return static */ - public function setTo($to) + public function setTo($to): self { $this->to = (array) $to; @@ -215,9 +165,8 @@ class Notification /** * @param string|array $cc - * @return static */ - public function setCc($cc) + public function setCc($cc): self { $this->cc = (array) $cc; @@ -226,9 +175,8 @@ class Notification /** * @param string|array $bcc - * @return static */ - public function setBcc($bcc) + public function setBcc($bcc): self { $this->bcc = (array) $bcc; @@ -236,58 +184,66 @@ class Notification } /** - * @return string + * Fournit un libellé explicitant qui sont les destinataires, ex : "Direction de thèse et Maison du doctorat". */ - public function getSubject() + public function setToLabel(string $toLabel): self { - return $this->subject; + $this->toLabel = $toLabel; + + return $this; } /** - * @return string|null + * Fournit un libellé explicitant qui sont les destinataires, ex : "Direction de thèse et Maison du doctorat". */ - public function getBody() + public function setCcLabel(string $ccLabel): self { - return $this->body; + $this->ccLabel = $ccLabel; + + return $this; } /** - * @return array + * Fournit un libellé explicitant qui sont les destinataires, ex : "Direction de thèse et Maison du doctorat". */ - public function getTo() + public function setBccLabel(string $bccLabel): self + { + $this->bccLabel = $bccLabel; + + return $this; + } + + public function getSubject(): string + { + return $this->subject; + } + + public function getBody(): ?string + { + return $this->body; + } + + public function getTo(): array { return $this->to; } - /** - * @return array - */ - public function getCc() + public function getCc(): array { return $this->cc; } - /** - * @return array - */ - public function getBcc() + public function getBcc(): array { return $this->bcc; } - /** - * @return string - */ - public function getTemplatePath() + public function getTemplatePath(): ?string { return $this->templatePath; } - /** - * @param string $templatePath - * @return Notification - */ - public function setTemplatePath($templatePath) + public function setTemplatePath(string $templatePath): self { $this->templatePath = $templatePath; @@ -302,18 +258,11 @@ class Notification return $this->templateVariables[$name] ?? null; } - /** - * @return array - */ public function getTemplateVariables(): array { return $this->templateVariables; } - /** - * @param array $templateVariables - * @return static - */ public function setTemplateVariables(array $templateVariables = []): Notification { $this->templateVariables = array_merge($this->templateVariables, $templateVariables); @@ -322,66 +271,106 @@ class Notification } /** - * @param string|string[] $warningMessages - * @return self + * Spécifie les messages exprimant le succès de l'envoi de cette notification. + * + * Ces messages seront collectés et disponibles dans le {@see \Notification\NotificationResult} à l'issu de l'envoi + * de la notification. + * + * @param string[] $successMessages + * @return \Notification\Notification */ - public function setWarningMessages($warningMessages) + public function setSuccessMessages(array $successMessages): self { - $this->warningMessages = (array) $warningMessages; + $this->successMessages = $successMessages; return $this; } /** - * @param string|string[] $infoMessages - * @return self + * Ajoute un message exprimant le succès de l'envoi de cette notification. + * + * Ces messages seront collectés et disponibles dans le {@see \Notification\NotificationResult} à l'issu de l'envoi + * de la notification. + * + * @param string $successMessage + * @return \Notification\Notification */ - public function setInfoMessages($infoMessages) + public function addSuccessMessage(string $successMessage): self { - $this->infoMessages = (array) $infoMessages; + $this->successMessages[] = $successMessage; return $this; } /** - * Retourne les éventuels messages d'avertissements signalés par cette notification - * et pouvant être affichés une fois la notification envoyée. + * Retourne les messages à collecter en cas de succès de l'envoi de cette notification. + * Ces messages n'ont de sens que si l'envoi de la notification a réussi. + * Si vous ne savez pas ce que vous faites, utiliser {@see \Notification\NotificationResult::getSuccessMessages()}. * * @return string[] */ - public function getWarningMessages() + public function getSuccessMessages(): array { - return $this->warningMessages; + return $this->successMessages; } /** - * Retourne les éventuels messages d'information signalés par cette notification - * et pouvant être affichés une fois la notification envoyée. + * Spécifie les messages d'erreur concernant les problèmes rencontrés par cette notification INDÉPENDAMMENT + * de l'envoi de celle-ci. + * Exemple d'erreur rencontrable : l'adresse mail d'un des destinataires n'a pas été trouvée. * - * @return string[] + * NB : L'existence de tels messages d'erreurs ne signifie pas l'impossibilité d'envoyer la notification. + * En cas d'erreur majeure empêchant l'envoi de la notification, il convient de lancer une + * {@see \Notification\Exception\RuntimeException}. + * + * @param string[] $errorMessages */ - public function getInfoMessages() + public function setErrorMessages(array $errorMessages): self { - return $this->infoMessages; + $this->errorMessages = $errorMessages; + + return $this; } /** - * Renseigne la date d'envoi éventuelle de cette notification. + * Ajoute un message d'erreur concernant un problème rencontré par cette notification INDÉPENDAMMENT + * de l'envoi de celle-ci. + * Exemple d'erreur rencontrable : l'adresse mail d'un des destinataires n'a pas été trouvée. + * + * NB : L'existence de tels messages d'erreurs ne signifie pas l'impossibilité d'envoyer la notification. + * En cas d'erreur majeure empêchant l'envoi de la notification, il convient de lancer une + * {@see \Notification\Exception\RuntimeException}. * - * @param \DateTime $sendDate - * @return self + * @param string $errorMessage + * @return \Notification\Notification */ - public function setSendDate(\DateTime $sendDate) + public function addErrorMessage(string $errorMessage): self { - $this->sendDate = $sendDate; + $this->errorMessages[] = $errorMessage; return $this; } + /** + * Retourne les éventuels messages d'avertissements rencontrés par cette notification *INDÉPENDAMMENT de son envoi* + * Exemple d'erreur rencontrable : l'adresse mail d'un des destinataires n'a pas été trouvée. + * + * NB : L'existence de tels messages d'erreurs ne signifie pas l'impossibilité d'envoyer la notification. + * En cas d'erreur majeure empêchant l'envoi de la notification, il convient de lancer une + * {@see \Notification\Exception\RuntimeException}. + * + * @return string[] + */ + public function getErrorMessages(): array + { + return $this->errorMessages; + } + /** * Retourne la date d'envoi éventuelle de cette notification. * * @return \DateTime + * @deprecated Utiliser {@see \Notification\NotificationResult::getSendDate()} */ public function getSendDate() { diff --git a/module/Notification/src/Notification/NotificationResult.php b/module/Notification/src/Notification/NotificationResult.php new file mode 100644 index 0000000000000000000000000000000000000000..f94dfbcd4b0867bf77596baa482b3a52cd5b0925 --- /dev/null +++ b/module/Notification/src/Notification/NotificationResult.php @@ -0,0 +1,126 @@ +<?php + +namespace Notification; + +use DateTime; +use Laminas\Mvc\Plugin\FlashMessenger\FlashMessenger; + +/** + * Classe représentant le résultat d'un envoi de notification. + * + * @author Unicaen + */ +class NotificationResult +{ + protected bool $isSuccess; + protected Notification $notification; + protected array $successMessages = []; + protected array $errorMessages = []; + protected ?DateTime $sendDate = null; + + /** + * Notification constructor. + */ + public function __construct(Notification $notification) + { + $this->notification = $notification; + } + + public function getNotification(): Notification + { + return $this->notification; + } + + public function setIsSuccess(bool $isSuccess = true): self + { + $this->isSuccess = $isSuccess; + return $this; + } + + public function isSuccess(): bool + { + return $this->isSuccess; + } + + /** + * Spécifie les éventuels messages d'information signalés par cette notification + * et pouvant être affichés une fois la notification envoyée. + * + * @param string[] $successMessages + * @return self + */ + public function setSuccessMessages(array $successMessages): self + { + $this->successMessages = $successMessages; + + return $this; + } + + /** + * Retourne les éventuels messages d'information signalés par cette notification + * et pouvant être affichés une fois la notification envoyée. + * + * @return string[] + */ + public function getSuccessMessages(): array + { + return $this->successMessages; + } + + /** + * Spécifie les éventuels messages d'avertissement signalés par cette notification + * et pouvant être affichés une fois la notification envoyée. + * + * @param string[] $errorMessages + * @return self + */ + public function setErrorMessages(array $errorMessages): self + { + $this->errorMessages = $errorMessages; + + return $this; + } + + /** + * Retourne les éventuels messages des erreurs/problèmes rencontrés par cette notification + * et pouvant être affichés une fois la notification envoyée. + * + * @return string[] + */ + public function getErrorMessages(): array + { + return $this->errorMessages; + } + + /** + * Renseigne la date d'envoi théorique de cette notification. + */ + public function setSendDate(DateTime $sendDate): self + { + $this->sendDate = $sendDate; + + return $this; + } + + /** + * Retourne la date d'envoi théorique de cette notification. + */ + public function getSendDate(): DateTime + { + return $this->sendDate; + } + + /** + * Alimente un {@see \Laminas\Mvc\Plugin\FlashMessenger\FlashMessenger} avec les éventuelles messages existants + * dans ce résultat de notification. + */ + public function feedFlashMessenger(FlashMessenger $flashMessenger, string $namespacePrefix = '') + { + foreach ($this->getSuccessMessages() as $successMessage) { + $flashMessenger->addMessage($successMessage, $namespacePrefix . 'success'); + } + foreach ($this->getErrorMessages() as $failureMessage) { + $flashMessenger->addMessage($failureMessage, $namespacePrefix . 'danger'); + } + } +} \ No newline at end of file diff --git a/module/Notification/src/Notification/Service/NotifierService.php b/module/Notification/src/Notification/Service/NotifierService.php index dc3c9cf67a9c1d094a84e25f01d227bc1e0b19b3..d9d604160f7ec09a6b9643f89c45d3f17ab89b28 100644 --- a/module/Notification/src/Notification/Service/NotifierService.php +++ b/module/Notification/src/Notification/Service/NotifierService.php @@ -3,47 +3,41 @@ namespace Notification\Service; use DateTime; -use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\ORMException; +use Laminas\Mail\Message; use Notification\Entity\NotifMail; use Notification\Entity\Service\NotifEntityServiceAwareTrait; -use Notification\Exception\NotificationException; +use Notification\Exception\ExceptionInterface; +use Notification\Exception\RuntimeException; +use Notification\Factory\NotificationFactory; use Notification\MessageContainer; use Notification\Notification; +use Notification\NotificationResult; +use Throwable; use UnicaenApp\Service\EntityManagerAwareTrait; use UnicaenApp\Service\Mailer\MailerServiceAwareTrait; -use Laminas\Mail\Message; /** * Service d'envoi de notification par mail. * * @author Unicaen */ -class NotifierService +final class NotifierService { use NotifEntityServiceAwareTrait; use MailerServiceAwareTrait; use EntityManagerAwareTrait; /** - * @var MessageContainer + * @var \Notification\MessageContainer + * @deprecated */ - protected $messageContainer; + protected MessageContainer $messageContainer; - /** - * @var NotificationRenderingService - */ - protected $renderingService; - - /** - * @var NotificationFactory - */ - protected $notificationFactory; + protected NotificationRenderingService $renderingService; + protected NotificationFactory $notificationFactory; - /** - * @var array - */ - protected $defaultOptions = [ + protected array $defaultOptions = [ // préfixe à ajouter systématiquement devant le sujet des mails, ex: '[Sygal] ' 'subject_prefix' => '', @@ -52,55 +46,62 @@ class NotifierService 'bcc' => [], ]; - /** - * @var array - */ - protected $options = []; + protected array $options = []; /** * NotifierService constructor. - * - * @param NotificationRenderingService $renderingService */ public function __construct(NotificationRenderingService $renderingService) { $this->renderingService = $renderingService; - $this->messageContainer = new MessageContainer(); } - /** - * @param array $options - */ - public function setOptions($options) + public function setOptions(array $options) { $this->options = array_merge($this->defaultOptions, $options); } - /** - * @param Notification $notification - * @throws \Notification\Exception\NotificationException - */ - public function trigger(Notification $notification) + public function trigger(Notification $notification): NotificationResult { - $notification->prepare(); - $this->sendNotification($notification); + $result = new NotificationResult($notification); - // collecte des éventuels messages exposés par la notification - foreach ($notification->getInfoMessages() as $message) { - $this->messageContainer->setMessage($message, 'info'); + $notification->prepare(); + try { + $message = $this->sendNotification($notification); + $sendDate = $this->extractDateFromMessage($message) ?: new DateTime(); + $result + ->setSendDate($sendDate) + ->setIsSuccess() + ->setSuccessMessages($notification->getSuccessMessages()); + } catch (ExceptionInterface $e) { + $result + ->setIsSuccess(false) + ->setErrorMessages([$e->getMessage()]); } - foreach ($notification->getWarningMessages() as $message) { - $this->messageContainer->setMessage($message, 'warning'); + + return $result; + } + + protected function sendNotification(Notification $notification): Message + { + $email = $this->createMailMessageForNotification($notification); + + $this->saveNotifMail($email); + + try { + $message = $this->mailerService->send($email); + } catch (Throwable $e) { + throw new RuntimeException("Erreur rencontrée lors de l'envoi de la notification", null, $e); } + + return $message; } /** - * @param Notification $notification - * @throws \Notification\Exception\NotificationException + * todo: mécanisme d'événement, ou bien passer à unicaen/mail. */ - protected function sendNotification(Notification $notification) + private function saveNotifMail(Message $email) { - $email = $this->createMailForNotification($notification); $nMail = new NotifMail(); $mails = []; @@ -119,39 +120,22 @@ class NotifierService $this->entityManager->persist($nMail); $this->entityManager->flush($nMail); } catch (ORMException $e) { - throw new NotificationException("Erreur rencontrée lors de l'enregistrement dans NotifMail", null, $e); + throw new RuntimeException("Erreur rencontrée lors de l'enregistrement dans NotifMail", null, $e); } - - try { - $message = $this->mailerService->send($email); - } catch (\Exception $e) { - throw new NotificationException("Erreur rencontrée lors de l'envoi de la notification", null, $e); - } - - $sendDate = $this->extractDateFromMessage($message) ?: new \DateTime(); - $notification->setSendDate($sendDate); } - /** - * @param Message $message - * @return \DateTime|null - */ - private function extractDateFromMessage(Message $message) + private function extractDateFromMessage(Message $message): ?DateTime { - if ($message->getHeaders()->has('Date')) { - $messageDate = $message->getHeaders()->get('Date')->getFieldValue(); - - return date_create_from_format($messageDate, 'r'); + if (!$message->getHeaders()->has('Date')) { + return null; } - return null; + $messageDate = $message->getHeaders()->get('Date')->getFieldValue(); + + return date_create($messageDate) ?: null; } - /** - * @param Notification $notification - * @return \Laminas\Mail\Message - */ - protected function createMailForNotification(Notification $notification) + protected function createMailMessageForNotification(Notification $notification): Message { $subjectPrefix = ''; if (isset($this->options['subject_prefix'])) { @@ -184,35 +168,4 @@ class NotifierService return $mail; } - - /** - * Retourne les éventuels messages exposés lors de la notification. - * - * @see MessageContainer::getMessages() - * - * @return array - */ - public function getLogs() - { - return $this->messageContainer->getMessages(); - } - - /** - * @param NotificationFactory $notificationFactory - * @return self - */ - public function setNotificationFactory(NotificationFactory $notificationFactory) - { - $this->notificationFactory = $notificationFactory; - - return $this; - } - - /** - * @return NotificationFactory - */ - public function getNotificationFactory() - { - return $this->notificationFactory; - } } \ No newline at end of file diff --git a/module/Notification/src/Notification/Service/NotifierServiceAwareTrait.php b/module/Notification/src/Notification/Service/NotifierServiceAwareTrait.php index 2df5fea8afdeb0af89815885071c517c6ddc7541..110b608fb00130207dbf33716198b81b08ae80cc 100644 --- a/module/Notification/src/Notification/Service/NotifierServiceAwareTrait.php +++ b/module/Notification/src/Notification/Service/NotifierServiceAwareTrait.php @@ -4,26 +4,10 @@ namespace Notification\Service; trait NotifierServiceAwareTrait { - /** - * @var NotifierService - */ - protected $notifierService; + protected NotifierService $notifierService; - /** - * @param NotifierService $notifierService - */ public function setNotifierService(NotifierService $notifierService) { $this->notifierService = $notifierService; } - - /** - * @return NotifierService - */ - public function getNotifierService(): NotifierService - { - return $this->notifierService; - } - - } \ No newline at end of file diff --git a/module/Notification/src/Notification/Service/NotifierServiceFactory.php b/module/Notification/src/Notification/Service/NotifierServiceFactory.php index fd672bba7250b1d64a75a4f8660db71ad121c34b..701e297aa38ee66f30b712c4c15ef4447f53b22c 100644 --- a/module/Notification/src/Notification/Service/NotifierServiceFactory.php +++ b/module/Notification/src/Notification/Service/NotifierServiceFactory.php @@ -12,20 +12,16 @@ use UnicaenApp\Service\Mailer\MailerService; */ class NotifierServiceFactory { - protected $notifierServiceClass = NotifierService::class; + protected string $notifierServiceClass = NotifierService::class; /** - * Create service. - * - * @param ContainerInterface $container - * @return NotifierService + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface */ - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container): NotifierService { $notifierServiceClass = $this->notifierServiceClass; - $notificationFactory = new NotificationFactory(); - /** @var MailerService $mailerService */ $mailerService = $container->get(MailerService::class); @@ -39,7 +35,6 @@ class NotifierServiceFactory /** @var NotifierService $service */ $service = new $notifierServiceClass($notificationRenderer); - $service->setNotificationFactory($notificationFactory); $service->setNotifEntityService($notifEntityService); $service->setMailerService($mailerService); $service->setOptions($options); @@ -49,10 +44,10 @@ class NotifierServiceFactory } /** - * @param ContainerInterface $container - * @return array + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface */ - private function getOptions(ContainerInterface $container) + private function getOptions(ContainerInterface $container): array { $config = $container->get('config'); diff --git a/module/RapportActivite/src/RapportActivite/Controller/Avis/RapportActiviteAvisController.php b/module/RapportActivite/src/RapportActivite/Controller/Avis/RapportActiviteAvisController.php index 4889f32caff4c16c1e585c9c0135fd8cfb67a7ed..43358eca945314bea8897da8ef9ee16c568d5ad3 100644 --- a/module/RapportActivite/src/RapportActivite/Controller/Avis/RapportActiviteAvisController.php +++ b/module/RapportActivite/src/RapportActivite/Controller/Avis/RapportActiviteAvisController.php @@ -5,11 +5,11 @@ namespace RapportActivite\Controller\Avis; use Application\Controller\AbstractController; use Application\EventRouterReplacerAwareTrait; use Application\Filter\IdifyFilterAwareTrait; -use Individu\Service\IndividuServiceAwareTrait; -use Application\Service\Notification\NotifierServiceAwareTrait; use Application\Service\Validation\ValidationServiceAwareTrait; use Closure; use Doctrine\ORM\NoResultException; +use Individu\Service\IndividuServiceAwareTrait; +use Laminas\EventManager\EventInterface; use Laminas\Http\Response; use RapportActivite\Entity\Db\RapportActivite; use RapportActivite\Entity\Db\RapportActiviteAvis; @@ -30,9 +30,7 @@ class RapportActiviteAvisController extends AbstractController use RapportActiviteAvisServiceAwareTrait; use RapportActiviteValidationServiceAwareTrait; use ValidationServiceAwareTrait; - use NotifierServiceAwareTrait; use IndividuServiceAwareTrait; - use NotifierServiceAwareTrait; use IdifyFilterAwareTrait; use EventRouterReplacerAwareTrait; @@ -203,7 +201,11 @@ class RapportActiviteAvisController extends AbstractController return $this->redirect()->toRoute('these/identite', ['these' => $these->getId()]); } - private function flashMessengerAddMessagesFromEvent(RapportActiviteAvisEvent $event) + /** + * @param RapportActiviteAvisEvent $event + * @param string $paramName + */ + protected function flashMessengerAddMessagesFromEvent(EventInterface $event, string $paramName = 'logs') { if ($messages = $event->getMessages()) { foreach ($messages as $namespace => $message) { diff --git a/module/RapportActivite/src/RapportActivite/Controller/Avis/RapportActiviteAvisControllerFactory.php b/module/RapportActivite/src/RapportActivite/Controller/Avis/RapportActiviteAvisControllerFactory.php index 01bd6e71711ec64dabbc80dece6f53b91ca97fcd..0de0b57b2462050f9cdf0875165a116608b54114 100644 --- a/module/RapportActivite/src/RapportActivite/Controller/Avis/RapportActiviteAvisControllerFactory.php +++ b/module/RapportActivite/src/RapportActivite/Controller/Avis/RapportActiviteAvisControllerFactory.php @@ -2,7 +2,6 @@ namespace RapportActivite\Controller\Avis; -use Application\Service\Notification\NotifierService; use Application\Service\Validation\ValidationService; use Psr\Container\ContainerInterface; use RapportActivite\Rule\Avis\RapportActiviteAvisNotificationRule; @@ -25,7 +24,6 @@ class RapportActiviteAvisControllerFactory $avisForm = $container->get('FormElementManager')->get(AvisForm::class); $rapportValidationService = $container->get(RapportActiviteValidationService::class); $validationService = $container->get(ValidationService::class); - $notifierService = $container->get(NotifierService::class); $rapportActiviteAvisNotificationRule = $container->get(RapportActiviteAvisNotificationRule::class); $rapportActiviteValidationRule = $container->get(RapportActiviteValidationRule::class); @@ -35,7 +33,6 @@ class RapportActiviteAvisControllerFactory $controller->setRapportActiviteAvisService($rapportAvisService); $controller->setRapportActiviteValidationService($rapportValidationService); $controller->setValidationService($validationService); - $controller->setNotifierService($notifierService); $controller->setForm($avisForm); diff --git a/module/RapportActivite/src/RapportActivite/Event/Avis/RapportActiviteAvisEventListener.php b/module/RapportActivite/src/RapportActivite/Event/Avis/RapportActiviteAvisEventListener.php index 9b72652688eeb8f5f71f0fa977f0ad549e647fcb..eef1134d57d3dbbf5928f04ce314d56a042c3d5d 100644 --- a/module/RapportActivite/src/RapportActivite/Event/Avis/RapportActiviteAvisEventListener.php +++ b/module/RapportActivite/src/RapportActivite/Event/Avis/RapportActiviteAvisEventListener.php @@ -2,18 +2,16 @@ namespace RapportActivite\Event\Avis; -use Application\Service\Notification\NotifierServiceAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; use Laminas\EventManager\EventManagerInterface; use Laminas\EventManager\ListenerAggregateInterface; use Laminas\EventManager\ListenerAggregateTrait; -use Notification\Exception\NotificationException; use RapportActivite\Entity\Db\RapportActiviteAvis; use RapportActivite\Rule\Avis\RapportActiviteAvisNotificationRuleAwareTrait; use RapportActivite\Rule\Validation\RapportActiviteValidationRuleAwareTrait; use RapportActivite\Service\Avis\RapportActiviteAvisService; use RapportActivite\Service\Avis\RapportActiviteAvisServiceAwareTrait; use RapportActivite\Service\Validation\RapportActiviteValidationServiceAwareTrait; -use UnicaenApp\Exception\RuntimeException; use Webmozart\Assert\Assert; class RapportActiviteAvisEventListener implements ListenerAggregateInterface @@ -113,14 +111,10 @@ class RapportActiviteAvisEventListener implements ListenerAggregateInterface $notif = $this->rapportActiviteAvisService->newRapportActiviteAvisNotification($rapportActiviteAvis); $this->rapportActiviteAvisNotificationRule->configureNotification($notif); - try { - $this->notifierService->trigger($notif); - } catch (NotificationException $e) { - throw new RuntimeException("Impossible d'envoyer le mail de notification", null, $e); - } + $result = $this->notifierService->trigger($notif); - $messages['info'] = ($notif->getInfoMessages()[0] ?? null); - $messages['warning'] = ($notif->getWarningMessages()[0] ?? null); + $messages['info'] = ($result->getSuccessMessages()[0] ?? null); + $messages['warning'] = ($result->getErrorMessages()[0] ?? null); $event->setMessages(array_filter($messages)); } } \ No newline at end of file diff --git a/module/RapportActivite/src/RapportActivite/Event/Avis/RapportActiviteAvisEventListenerFactory.php b/module/RapportActivite/src/RapportActivite/Event/Avis/RapportActiviteAvisEventListenerFactory.php index a2ac9d42b6725461ecc8b5e11702417e31f9fdcf..7a8d007aeba81d9ab347ca83961983539a8dc9c7 100644 --- a/module/RapportActivite/src/RapportActivite/Event/Avis/RapportActiviteAvisEventListenerFactory.php +++ b/module/RapportActivite/src/RapportActivite/Event/Avis/RapportActiviteAvisEventListenerFactory.php @@ -2,7 +2,7 @@ namespace RapportActivite\Event\Avis; -use Application\Service\Notification\NotifierService; +use Notification\Service\NotifierService; use Psr\Container\ContainerInterface; use RapportActivite\Rule\Avis\RapportActiviteAvisNotificationRule; use RapportActivite\Rule\Validation\RapportActiviteValidationRule; diff --git a/module/RapportActivite/src/RapportActivite/Event/RapportActiviteEventListener.php b/module/RapportActivite/src/RapportActivite/Event/RapportActiviteEventListener.php index 36b1cc2fb43330e4a2ba877b66e66be0e682aca5..ff8aec01092d38bf3c7ec7a079367d5c649c9b6a 100644 --- a/module/RapportActivite/src/RapportActivite/Event/RapportActiviteEventListener.php +++ b/module/RapportActivite/src/RapportActivite/Event/RapportActiviteEventListener.php @@ -2,16 +2,14 @@ namespace RapportActivite\Event; -use Application\Service\Notification\NotifierServiceAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; use Application\Service\UserContextServiceAwareTrait; use Laminas\EventManager\EventManagerInterface; use Laminas\EventManager\ListenerAggregateInterface; use Laminas\EventManager\ListenerAggregateTrait; -use Notification\Exception\NotificationException; use RapportActivite\Entity\Db\RapportActivite; use RapportActivite\Service\RapportActiviteService; use RapportActivite\Service\RapportActiviteServiceAwareTrait; -use UnicaenApp\Exception\RuntimeException; use Webmozart\Assert\Assert; class RapportActiviteEventListener implements ListenerAggregateInterface @@ -63,14 +61,10 @@ class RapportActiviteEventListener implements ListenerAggregateInterface } $notif = $this->rapportActiviteService->newRapportActiviteSupprimeNotification($rapportActivite); - try { - $this->notifierService->trigger($notif); - } catch (NotificationException $e) { - throw new RuntimeException("Impossible d'envoyer le mail de notification", null, $e); - } + $result = $this->notifierService->trigger($notif); - $messages['info'] = ($notif->getInfoMessages()[0] ?? null); - $messages['warning'] = ($notif->getWarningMessages()[0] ?? null); + $messages['info'] = ($result->getSuccessMessages()[0] ?? null); + $messages['warning'] = ($result->getErrorMessages()[0] ?? null); $event->setMessages(array_filter($messages)); } } \ No newline at end of file diff --git a/module/RapportActivite/src/RapportActivite/Event/RapportActiviteEventListenerFactory.php b/module/RapportActivite/src/RapportActivite/Event/RapportActiviteEventListenerFactory.php index c1f8893ee2e6f603cfd85811e2b05d6b851da77e..2aec62e4210a5856e960845cfacfc20bdf44bf3c 100644 --- a/module/RapportActivite/src/RapportActivite/Event/RapportActiviteEventListenerFactory.php +++ b/module/RapportActivite/src/RapportActivite/Event/RapportActiviteEventListenerFactory.php @@ -2,7 +2,7 @@ namespace RapportActivite\Event; -use Application\Service\Notification\NotifierService; +use Notification\Service\NotifierService; use Application\Service\UserContextService; use Psr\Container\ContainerInterface; use RapportActivite\Service\RapportActiviteService; @@ -25,7 +25,7 @@ class RapportActiviteEventListenerFactory $rapportActiviteService = $container->get(RapportActiviteService::class); $listener->setRapportActiviteService($rapportActiviteService); - /** @var \Application\Service\Notification\NotifierService $notifierService */ + /** @var \Notification\Service\NotifierService $notifierService */ $notifierService = $container->get(NotifierService::class); $listener->setNotifierService($notifierService); diff --git a/module/RapportActivite/src/RapportActivite/Event/Validation/RapportActiviteValidationEventListener.php b/module/RapportActivite/src/RapportActivite/Event/Validation/RapportActiviteValidationEventListener.php index 70cfb1416448f850affbd6ad60ab2d14910c1bb7..661a3a570156b1edb203792a1cfaf854aee5b7ab 100644 --- a/module/RapportActivite/src/RapportActivite/Event/Validation/RapportActiviteValidationEventListener.php +++ b/module/RapportActivite/src/RapportActivite/Event/Validation/RapportActiviteValidationEventListener.php @@ -2,17 +2,15 @@ namespace RapportActivite\Event\Validation; -use Application\Service\Notification\NotifierServiceAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; use Laminas\EventManager\EventManagerInterface; use Laminas\EventManager\ListenerAggregateInterface; use Laminas\EventManager\ListenerAggregateTrait; -use Notification\Exception\NotificationException; use RapportActivite\Entity\Db\RapportActiviteAvis; use RapportActivite\Entity\Db\RapportActiviteValidation; use RapportActivite\Service\Avis\RapportActiviteAvisServiceAwareTrait; use RapportActivite\Service\Validation\RapportActiviteValidationService; use RapportActivite\Service\Validation\RapportActiviteValidationServiceAwareTrait; -use UnicaenApp\Exception\RuntimeException; use Webmozart\Assert\Assert; class RapportActiviteValidationEventListener implements ListenerAggregateInterface @@ -104,14 +102,10 @@ class RapportActiviteValidationEventListener implements ListenerAggregateInterfa $rapportActiviteAvis ); - try { - $this->notifierService->trigger($notif); - } catch (NotificationException $e) { - throw new RuntimeException("Impossible d'envoyer le mail de notification", null, $e); - } + $this->notifierService->trigger($notif); - $messages['info'] = ($notif->getInfoMessages()[0] ?? null); - $messages['warning'] = ($notif->getWarningMessages()[0] ?? null); + $messages['info'] = ($notif->getSuccessMessages()[0] ?? null); + $messages['warning'] = ($notif->getErrorMessages()[0] ?? null); $event->setMessages(array_filter($messages)); } } diff --git a/module/RapportActivite/src/RapportActivite/Event/Validation/RapportActiviteValidationEventListenerFactory.php b/module/RapportActivite/src/RapportActivite/Event/Validation/RapportActiviteValidationEventListenerFactory.php index 03f51b818089003bf87b057fd88483b5cf3a1be7..d0d81c1c4032afc2c666bb1a0ea63a8532daf9a1 100644 --- a/module/RapportActivite/src/RapportActivite/Event/Validation/RapportActiviteValidationEventListenerFactory.php +++ b/module/RapportActivite/src/RapportActivite/Event/Validation/RapportActiviteValidationEventListenerFactory.php @@ -2,7 +2,7 @@ namespace RapportActivite\Event\Validation; -use Application\Service\Notification\NotifierService; +use Notification\Service\NotifierService; use Psr\Container\ContainerInterface; use RapportActivite\Service\Avis\RapportActiviteAvisService; use RapportActivite\Service\Validation\RapportActiviteValidationService; @@ -25,7 +25,7 @@ class RapportActiviteValidationEventListenerFactory $rapportActiviteValidationService = $container->get(RapportActiviteValidationService::class); $listener->setRapportActiviteValidationService($rapportActiviteValidationService); - /** @var \Application\Service\Notification\NotifierService $notifierService */ + /** @var \Notification\Service\NotifierService $notifierService */ $notifierService = $container->get(NotifierService::class); $listener->setNotifierService($notifierService); diff --git a/module/RapportActivite/src/RapportActivite/Notification/RapportActiviteAvisNotification.php b/module/RapportActivite/src/RapportActivite/Notification/RapportActiviteAvisNotification.php index 00f6ef4948ae497e4f5d57dd965f94f13f0d5893..421b7c90a8ea9e4e8dc21e15b9d67989e94ae8b2 100644 --- a/module/RapportActivite/src/RapportActivite/Notification/RapportActiviteAvisNotification.php +++ b/module/RapportActivite/src/RapportActivite/Notification/RapportActiviteAvisNotification.php @@ -7,7 +7,7 @@ use RapportActivite\Entity\Db\RapportActiviteAvis; class RapportActiviteAvisNotification extends Notification { - protected $templatePath = 'rapport-activite/notification/avis'; + protected ?string $templatePath = 'rapport-activite/notification/avis'; private RapportActiviteAvis $rapportActiviteAvis; private array $messagesByAvisValeurBool = []; @@ -32,7 +32,7 @@ class RapportActiviteAvisNotification extends Notification */ public function prepare(): self { - $infoMessage = sprintf( + $successMessage = sprintf( "Un mail de notification vient d'être envoyé aux personnes suivantes : %s", implode(', ', array_reduce(array_keys($this->to), function(array $accu, string $key) { $accu[] = sprintf('%s (%s)', $this->to[$key], $key); @@ -45,7 +45,7 @@ class RapportActiviteAvisNotification extends Notification 'messagesByAvisValeurBool' => $this->messagesByAvisValeurBool, ]); - $this->setInfoMessages($infoMessage); + $this->addSuccessMessage($successMessage); return $this; } diff --git a/module/RapportActivite/src/RapportActivite/Notification/RapportActiviteSupprimeNotification.php b/module/RapportActivite/src/RapportActivite/Notification/RapportActiviteSupprimeNotification.php index b692c93eddca53081d30fed409b4ba4e62d0dc5a..9e4237a01fe5d6e1b70e6743b9f78dfd0b417be6 100644 --- a/module/RapportActivite/src/RapportActivite/Notification/RapportActiviteSupprimeNotification.php +++ b/module/RapportActivite/src/RapportActivite/Notification/RapportActiviteSupprimeNotification.php @@ -7,7 +7,7 @@ use RapportActivite\Entity\Db\RapportActivite; class RapportActiviteSupprimeNotification extends Notification { - protected $templatePath = 'rapport-activite/notification/rapport-supprime'; + protected ?string $templatePath = 'rapport-activite/notification/rapport-supprime'; private RapportActivite $rapportActivite; /** @@ -23,7 +23,7 @@ class RapportActiviteSupprimeNotification extends Notification */ public function prepare(): self { - $infoMessage = sprintf( + $successMessage = sprintf( "Un mail de notification vient d'être envoyé aux personnes suivantes : %s", implode(', ', array_reduce(array_keys($this->to), function(array $accu, string $key) { $accu[] = sprintf('%s (%s)', $this->to[$key], $key); @@ -35,7 +35,7 @@ class RapportActiviteSupprimeNotification extends Notification 'rapportActivite' => $this->rapportActivite, ]); - $this->setInfoMessages($infoMessage); + $this->addSuccessMessage($successMessage); return $this; } diff --git a/module/RapportActivite/src/RapportActivite/Notification/RapportActiviteValidationNotification.php b/module/RapportActivite/src/RapportActivite/Notification/RapportActiviteValidationNotification.php index 0aaf33e856e42276f11263806ee72b1701254263..6eea2167e829e5ff0a4d2974a92660f95ae1fce7 100644 --- a/module/RapportActivite/src/RapportActivite/Notification/RapportActiviteValidationNotification.php +++ b/module/RapportActivite/src/RapportActivite/Notification/RapportActiviteValidationNotification.php @@ -8,7 +8,7 @@ use RapportActivite\Entity\Db\RapportActiviteValidation; class RapportActiviteValidationNotification extends Notification { - protected $templatePath = 'rapport-activite/notification/validation'; + protected ?string $templatePath = 'rapport-activite/notification/validation'; private RapportActiviteValidation $rapportActiviteValidation; private RapportActiviteAvis $rapportActiviteAvis; @@ -33,7 +33,7 @@ class RapportActiviteValidationNotification extends Notification */ public function prepare(): self { - $infoMessage = sprintf( + $successMessage = sprintf( "Un mail de notification vient d'être envoyé aux personnes suivantes : %s", implode(', ', array_reduce(array_keys($this->to), function(array $accu, string $key) { $accu[] = sprintf('%s (%s)', $this->to[$key], $key); @@ -46,7 +46,7 @@ class RapportActiviteValidationNotification extends Notification 'rapportActiviteAvis' => $this->rapportActiviteAvis, ]); - $this->setInfoMessages($infoMessage); + $this->addSuccessMessage($successMessage); return $this; } diff --git a/module/RapportActivite/src/RapportActivite/Service/Avis/RapportActiviteAvisService.php b/module/RapportActivite/src/RapportActivite/Service/Avis/RapportActiviteAvisService.php index 7b57e2dddf1c7616b1deb9324aeb7192a89dde68..2fa3e01a8e108712432874de801c796b344cbb3b 100644 --- a/module/RapportActivite/src/RapportActivite/Service/Avis/RapportActiviteAvisService.php +++ b/module/RapportActivite/src/RapportActivite/Service/Avis/RapportActiviteAvisService.php @@ -362,6 +362,9 @@ class RapportActiviteAvisService extends BaseService } } + /** + * @deprecated todo : à déplacer dans une RapportActiviteNotificationFactory + */ public function newRapportActiviteAvisNotification(RapportActiviteAvis $rapportActiviteAvis): RapportActiviteAvisNotification { $notif = new RapportActiviteAvisNotification(); diff --git a/module/RapportActivite/src/RapportActivite/Service/RapportActiviteService.php b/module/RapportActivite/src/RapportActivite/Service/RapportActiviteService.php index 03c7459de9c7c113d012c5d92f19f79cf5a86842..b0ec3cbbb19470353c7c32695fc3c30b61ee395c 100644 --- a/module/RapportActivite/src/RapportActivite/Service/RapportActiviteService.php +++ b/module/RapportActivite/src/RapportActivite/Service/RapportActiviteService.php @@ -16,7 +16,6 @@ use Fichier\Service\Fichier\Exception\FichierServiceException; use Fichier\Service\Fichier\FichierServiceAwareTrait; use Fichier\Service\Fichier\FichierStorageServiceAwareTrait; use Fichier\Service\NatureFichier\NatureFichierServiceAwareTrait; -use Application\Service\Notification\NotifierServiceAwareTrait; use Application\Service\Role\RoleServiceAwareTrait; use Structure\Service\StructureDocument\StructureDocumentServiceAwareTrait; use Fichier\Service\Storage\Adapter\Exception\StorageAdapterException; @@ -43,7 +42,6 @@ class RapportActiviteService extends BaseService use FichierStorageServiceAwareTrait; use VersionFichierServiceAwareTrait; use EtablissementServiceAwareTrait; - use NotifierServiceAwareTrait; use NatureFichierServiceAwareTrait; use RapportActiviteAvisServiceAwareTrait; use RapportActiviteValidationServiceAwareTrait; @@ -395,6 +393,9 @@ class RapportActiviteService extends BaseService return $event; } + /** + * @deprecated todo : à déplacer dans une RapportActiviteNotificationFactory + */ public function newRapportActiviteSupprimeNotification(RapportActivite $rapportActivite): RapportActiviteSupprimeNotification { $doctorant = $rapportActivite->getThese()->getDoctorant(); diff --git a/module/RapportActivite/src/RapportActivite/Service/RapportActiviteServiceFactory.php b/module/RapportActivite/src/RapportActivite/Service/RapportActiviteServiceFactory.php index 5f20d0c42ffe80b6e9de9669f20fc99a1d51ac76..d8cc4e80484c0c46e215ff970344de393e6c1414 100644 --- a/module/RapportActivite/src/RapportActivite/Service/RapportActiviteServiceFactory.php +++ b/module/RapportActivite/src/RapportActivite/Service/RapportActiviteServiceFactory.php @@ -6,7 +6,6 @@ use Structure\Service\Etablissement\EtablissementService; use Fichier\Service\Fichier\FichierService; use Fichier\Service\Fichier\FichierStorageService; use Fichier\Service\NatureFichier\NatureFichierService; -use Application\Service\Notification\NotifierService; use Structure\Service\StructureDocument\StructureDocumentService; use Fichier\Service\ValiditeFichier\ValiditeFichierService; use Fichier\Service\VersionFichier\VersionFichierService; @@ -35,7 +34,6 @@ class RapportActiviteServiceFactory * @var \Fichier\Service\ValiditeFichier\ValiditeFichierService $validiteFichierService * @var RetraitementService $retraitementService * @var EtablissementService $etablissementService - * @var NotifierService $notifierService * @var NatureFichierService $natureFichierService * @var RapportActiviteAvisService $rapportActiviteAvisService * @var RapportActiviteValidationService $rapportValidationService @@ -45,7 +43,6 @@ class RapportActiviteServiceFactory $fileService = $container->get(FichierStorageService::class); $versionFichierService = $container->get('VersionFichierService'); $etablissementService = $container->get('EtablissementService'); - $notifierService = $container->get(NotifierService::class); $natureFichierService = $container->get('NatureFichierService'); $rapportActiviteAvisService = $container->get(RapportActiviteAvisService::class); $rapportValidationService = $container->get(RapportActiviteValidationService::class); @@ -58,7 +55,6 @@ class RapportActiviteServiceFactory $service->setFichierStorageService($fileService); $service->setVersionFichierService($versionFichierService); $service->setEtablissementService($etablissementService); - $service->setNotifierService($notifierService); $service->setNatureFichierService($natureFichierService); $service->setRapportActiviteAvisService($rapportActiviteAvisService); $service->setRapportActiviteValidationService($rapportValidationService); diff --git a/module/RapportActivite/src/RapportActivite/Service/Validation/RapportActiviteValidationService.php b/module/RapportActivite/src/RapportActivite/Service/Validation/RapportActiviteValidationService.php index 7978c375de926263a6753508a4eb1d0d7b6e43a7..adb14f5d8b4dc684c86c48b8efad420d47b1a5d9 100644 --- a/module/RapportActivite/src/RapportActivite/Service/Validation/RapportActiviteValidationService.php +++ b/module/RapportActivite/src/RapportActivite/Service/Validation/RapportActiviteValidationService.php @@ -147,6 +147,9 @@ class RapportActiviteValidationService extends BaseService } } + /** + * @deprecated todo : à déplacer dans une RapportActiviteNotificationFactory + */ public function createRapportActiviteValidationNotification( RapportActiviteValidation $rapportActiviteValidation, RapportActiviteAvis $rapportActiviteAvis): RapportActiviteValidationNotification diff --git a/module/Retraitement/src/Retraitement/Controller/IndexController.php b/module/Retraitement/src/Retraitement/Controller/IndexController.php index 0b40409cd4519d43fed1823fa7a1208c0de7f07d..cdc07a4c6b06f6118cdff4249dad0c6c00757c32 100755 --- a/module/Retraitement/src/Retraitement/Controller/IndexController.php +++ b/module/Retraitement/src/Retraitement/Controller/IndexController.php @@ -3,16 +3,17 @@ namespace Retraitement\Controller; use Application\Controller\AbstractController; -use Depot\Entity\Db\FichierThese; use Application\EventRouterReplacerAwareTrait; +use Depot\Entity\Db\FichierThese; use Depot\Service\FichierThese\FichierTheseServiceAwareInterface; use Depot\Service\FichierThese\FichierTheseServiceAwareTrait; -use Application\Service\Notification\NotifierServiceAwareTrait; +use Depot\Service\Notification\DepotNotificationFactoryAwareTrait; +use Laminas\Console\Request as ConsoleRequest; +use Notification\Service\NotifierServiceAwareTrait; use Retraitement\Form\Retraitement; use UnicaenApp\Exception\RuntimeException; use UnicaenApp\Filter\BytesFormatter; use UnicaenAuth\ORM\Event\Listeners\HistoriqueListener; -use Laminas\Console\Request as ConsoleRequest; class IndexController extends AbstractController implements FichierTheseServiceAwareInterface @@ -20,6 +21,7 @@ class IndexController extends AbstractController use EventRouterReplacerAwareTrait; use FichierTheseServiceAwareTrait; use NotifierServiceAwareTrait; + use DepotNotificationFactoryAwareTrait; public function indexAction() { @@ -113,7 +115,7 @@ class IndexController extends AbstractController if ($notifier) { $destinataires = $notifier; - $notif = $this->notifierService->getNotificationFactory()->createNotificationForRetraitementFini($destinataires, $fichierTheseRetraite, $validite); + $notif = $this->depotNotificationFactory->createNotificationForRetraitementFini($destinataires, $fichierTheseRetraite, $validite); $this->notifierService->trigger($notif); echo "Destinataires du courriel envoyé: " . implode(",",$notif->getTo()); echo PHP_EOL; diff --git a/module/Retraitement/src/Retraitement/Controller/IndexControllerFactory.php b/module/Retraitement/src/Retraitement/Controller/IndexControllerFactory.php index 84ff7a09b4f8371d6f0411edf175eb6411a0ab09..4c09f99e97b9725873a33d877de76f1ef842a544 100644 --- a/module/Retraitement/src/Retraitement/Controller/IndexControllerFactory.php +++ b/module/Retraitement/src/Retraitement/Controller/IndexControllerFactory.php @@ -4,11 +4,12 @@ namespace Retraitement\Controller; use Application\Entity\Db\Utilisateur; use Application\EventRouterReplacer; -use Application\Service\Notification\NotifierService; use Application\Service\Utilisateur\UtilisateurService; +use Depot\Service\Notification\DepotNotificationFactory; use Interop\Container\ContainerInterface; -use UnicaenApp\Exception\RuntimeException; use Laminas\Router\Http\TreeRouteStack; +use Notification\Service\NotifierService; +use UnicaenApp\Exception\RuntimeException; class IndexControllerFactory { @@ -34,6 +35,10 @@ class IndexControllerFactory $controller->setEventRouterReplacer($routerReplacer); $controller->setNotifierService($notifierService); + /** @var \Depot\Service\Notification\DepotNotificationFactory $depotNotificationFactory */ + $depotNotificationFactory = $container->get(DepotNotificationFactory::class); + $controller->setDepotNotificationFactory($depotNotificationFactory); + return $controller; } diff --git a/module/Soutenance/config/module.config.php b/module/Soutenance/config/module.config.php index 2ec5ce02193cfc486309bce3710f71e41f06b0c0..8d1e7e7796d8014d3fff0185e191a8e9b6dec279 100644 --- a/module/Soutenance/config/module.config.php +++ b/module/Soutenance/config/module.config.php @@ -12,8 +12,10 @@ use Soutenance\Provider\Privilege\PresoutenancePrivileges; use Soutenance\Provider\Privilege\PropositionPrivileges; use Soutenance\Service\Membre\MembreService; use Soutenance\Service\Membre\MembreServiceFactory; -use Soutenance\Service\Notifier\NotifierSoutenanceService; -use Soutenance\Service\Notifier\NotifierSoutenanceServiceFactory; +use Soutenance\Service\Notification\SoutenanceNotificationFactory; +use Soutenance\Service\Notification\SoutenanceNotificationFactoryFactory; +use Soutenance\Service\Url\UrlService; +use Soutenance\Service\Url\UrlServiceFactory; use Soutenance\Service\Validation\ValidationService; use Soutenance\Service\Validation\ValidationServiceFactory; use UnicaenAuth\Guard\PrivilegeController; @@ -202,8 +204,9 @@ return array( 'factories' => [ //service MembreService::class => MembreServiceFactory::class, - NotifierSoutenanceService::class => NotifierSoutenanceServiceFactory::class, + SoutenanceNotificationFactory::class => SoutenanceNotificationFactoryFactory::class, ValidationService::class => ValidationServiceFactory::class, + UrlService::class => UrlServiceFactory::class, ], ], diff --git a/module/Soutenance/config/others/presoutenance.config.php b/module/Soutenance/config/others/presoutenance.config.php index e4bb946715e6e17cf4ed7ae2144a4314272c8076..ee372ed29beaf0f158d727bf15c96377249b62f0 100644 --- a/module/Soutenance/config/others/presoutenance.config.php +++ b/module/Soutenance/config/others/presoutenance.config.php @@ -68,11 +68,10 @@ return [ 'stopper-demarche', 'avis-soutenance', 'convocations', - 'proces-verbal-soutenance', 'modifier-adresse', 'envoyer-convocation', - 'rapport-soutenance', 'rapport-technique', + 'transmettre-documents-direction-these', ], 'privileges' => PresoutenancePrivileges::PRESOUTENANCE_DATE_RETOUR_MODIFICATION, ], @@ -81,6 +80,8 @@ return [ 'action' => [ 'convocation-doctorant', 'convocation-membre', + 'proces-verbal-soutenance', + 'rapport-soutenance', ], 'roles' => [], ], @@ -254,6 +255,17 @@ return [ ], ], ], + 'transmettre-documents-direction-these' => [ + 'type' => Segment::class, + 'may_terminate' => true, + 'options' => [ + 'route' => '/transmettre-documents-direction-these', + 'defaults' => [ + 'controller' => PresoutenanceController::class, + 'action' => 'transmettre-documents-direction-these', + ], + ], + ], 'date-rendu-rapport' => [ 'type' => Segment::class, 'may_terminate' => true, diff --git a/module/Soutenance/src/Soutenance/Controller/AvisController.php b/module/Soutenance/src/Soutenance/Controller/AvisController.php index 124f7db5439752e08d2a58b0017ceada98fa9077..500eb9181dcbb8df34983e8fba661e0b91006e09 100644 --- a/module/Soutenance/src/Soutenance/Controller/AvisController.php +++ b/module/Soutenance/src/Soutenance/Controller/AvisController.php @@ -6,6 +6,7 @@ use Application\Controller\AbstractController; use Fichier\Service\Fichier\FichierServiceAwareTrait; use Fichier\Service\Fichier\FichierStorageServiceAwareTrait; use Fichier\Service\Storage\Adapter\Exception\StorageAdapterException; +use Soutenance\Service\Notification\SoutenanceNotificationFactoryAwareTrait; use These\Service\Acteur\ActeurServiceAwareTrait; use These\Service\These\TheseServiceAwareTrait; use Soutenance\Entity\Avis; @@ -14,7 +15,7 @@ use Soutenance\Form\Avis\AvisForm; use Soutenance\Form\Avis\AvisFormAwareTrait; use Soutenance\Service\Avis\AvisServiceAwareTrait; use Soutenance\Service\Membre\MembreServiceAwareTrait; -use Soutenance\Service\Notifier\NotifierSoutenanceServiceAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; use Soutenance\Service\Proposition\PropositionServiceAwareTrait; use Soutenance\Service\Validation\ValidatationServiceAwareTrait; use Laminas\Http\Request; @@ -26,7 +27,8 @@ class AvisController extends AbstractController use ActeurServiceAwareTrait; use AvisServiceAwareTrait; use MembreServiceAwareTrait; - use NotifierSoutenanceServiceAwareTrait; + use NotifierServiceAwareTrait; + use SoutenanceNotificationFactoryAwareTrait; use PropositionServiceAwareTrait; use TheseServiceAwareTrait; use ValidatationServiceAwareTrait; @@ -90,15 +92,30 @@ class AvisController extends AbstractController $allRapporteurs = $this->getMembreService()->getRapporteursByProposition($proposition); if ($avis->getAvis() === Avis::FAVORABLE) { - $this->getNotifierSoutenanceService()->triggerAvisFavorable($these, $avis); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationAvisFavorable($these, $avis); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } } if ($avis->getAvis() === Avis::DEFAVORABLE) { - $this->getNotifierSoutenanceService()->triggerAvisDefavorable($these, $avis); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationAvisDefavorable($these, $avis); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } } /** TODO ajouter un prédicat dans thèse ou soutenance ??? */ if (count($allAvis) === count($allRapporteurs)) { - $this->getNotifierSoutenanceService()->triggerAvisRendus($these); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationAvisRendus($these); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } } $this->redirect()->toRoute('soutenance/avis-soutenance/afficher', ['these' => $these->getId(), 'membre' => $membre->getId()], [], true); diff --git a/module/Soutenance/src/Soutenance/Controller/AvisControllerFactory.php b/module/Soutenance/src/Soutenance/Controller/AvisControllerFactory.php index 4c353974962fa7f54a78bde88ede595ac56051e1..ef36a15a8f483a672a809f8c5093af9ea54648f0 100644 --- a/module/Soutenance/src/Soutenance/Controller/AvisControllerFactory.php +++ b/module/Soutenance/src/Soutenance/Controller/AvisControllerFactory.php @@ -6,13 +6,14 @@ use Fichier\Service\Fichier\FichierService; use Fichier\Service\Fichier\FichierStorageService; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; +use Soutenance\Service\Notification\SoutenanceNotificationFactory; use These\Service\Acteur\ActeurService; use These\Service\These\TheseService; use Interop\Container\ContainerInterface; use Soutenance\Form\Avis\AvisForm; use Soutenance\Service\Avis\AvisService; use Soutenance\Service\Membre\MembreService; -use Soutenance\Service\Notifier\NotifierSoutenanceService; +use Notification\Service\NotifierService; use Soutenance\Service\Proposition\PropositionService; use Soutenance\Service\Validation\ValidationService; @@ -31,7 +32,7 @@ class AvisControllerFactory * @var ActeurService $acteurService * @var AvisService $avisService * @var MembreService $membreService - * @var NotifierSoutenanceService $notifierSoutenanceService + * @var NotifierService $notifierSoutenanceService * @var PropositionService $propositionService * @var TheseService $theseService * @var ValidationService $validationService @@ -39,7 +40,7 @@ class AvisControllerFactory $acteurService = $container->get(ActeurService::class); $avisService = $container->get(AvisService::class); $membreService = $container->get(MembreService::class); - $notifierSoutenanceService = $container->get(NotifierSoutenanceService::class); + $notifierSoutenanceService = $container->get(NotifierService::class); $propositionService = $container->get(PropositionService::class); $theseService = $container->get('TheseService'); $validationService = $container->get(ValidationService::class); @@ -59,7 +60,7 @@ class AvisControllerFactory $controller->setTheseService($theseService); $controller->setValidationService($validationService); $controller->setActeurService($acteurService); - $controller->setNotifierSoutenanceService($notifierSoutenanceService); + $controller->setNotifierService($notifierSoutenanceService); $controller->setPropositionService($propositionService); $controller->setAvisService($avisService); $controller->setMembreService($membreService); @@ -69,6 +70,10 @@ class AvisControllerFactory $controller->setAvisForm($avisForm); + /** @var \Soutenance\Service\Notification\SoutenanceNotificationFactory $soutenanceNotificationFactory */ + $soutenanceNotificationFactory = $container->get(SoutenanceNotificationFactory::class); + $controller->setSoutenanceNotificationFactory($soutenanceNotificationFactory); + return $controller; } } \ No newline at end of file diff --git a/module/Soutenance/src/Soutenance/Controller/EngagementImpartialiteController.php b/module/Soutenance/src/Soutenance/Controller/EngagementImpartialiteController.php index 07337efd36240652fdb062fb6d01340cae28ff76..75855ef4fa5166bcd2c79e5c580e83d25b485064 100644 --- a/module/Soutenance/src/Soutenance/Controller/EngagementImpartialiteController.php +++ b/module/Soutenance/src/Soutenance/Controller/EngagementImpartialiteController.php @@ -4,14 +4,16 @@ namespace Soutenance\Controller; use Application\Controller\AbstractController; use Application\Entity\Db\Validation; +use Notification\Exception\RuntimeException; use Soutenance\Provider\Template\TexteTemplates; +use Soutenance\Service\Notification\SoutenanceNotificationFactoryAwareTrait; use These\Service\Acteur\ActeurServiceAwareTrait; use Soutenance\Entity\Evenement; use Soutenance\Entity\Membre; use Soutenance\Service\EngagementImpartialite\EngagementImpartialiteServiceAwareTrait; use Soutenance\Service\Evenement\EvenementServiceAwareTrait; use Soutenance\Service\Membre\MembreServiceAwareTrait; -use Soutenance\Service\Notifier\NotifierSoutenanceServiceAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; use Soutenance\Service\Proposition\PropositionServiceAwareTrait; use UnicaenAuthToken\Service\TokenServiceAwareTrait; use Laminas\View\Model\ViewModel; @@ -28,7 +30,8 @@ class EngagementImpartialiteController extends AbstractController use EvenementServiceAwareTrait; use EngagementImpartialiteServiceAwareTrait; use MembreServiceAwareTrait; - use NotifierSoutenanceServiceAwareTrait; + use NotifierServiceAwareTrait; + use SoutenanceNotificationFactoryAwareTrait; use PropositionServiceAwareTrait; use RenduServiceAwareTrait; use TokenServiceAwareTrait; @@ -73,7 +76,12 @@ class EngagementImpartialiteController extends AbstractController $token = $this->getMembreService()->retrieveOrCreateToken($membre); $url_rapporteur = $this->url()->fromRoute("soutenance/index-rapporteur", ['these' => $these->getId()], ['force_canonical' => true], true); $url = $this->url()->fromRoute('zfcuser/login', ['type' => 'token'], ['query' => ['token' => $token->getToken(), 'redirect' => $url_rapporteur, 'role' => $membre->getActeur()->getRole()->getRoleId()], 'force_canonical' => true], true); - $this->getNotifierSoutenanceService()->triggerDemandeSignatureEngagementImpartialite($these, $proposition, $membre, $url); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationDemandeSignatureEngagementImpartialite($these, $proposition, $membre, $url); + $this->notifierService->trigger($notif); + } catch (RuntimeException $e) { + // aucun destintaire, todo : cas à gérer ! + } } } } @@ -92,7 +100,12 @@ class EngagementImpartialiteController extends AbstractController $token = $this->getMembreService()->retrieveOrCreateToken($membre); $url_rapporteur = $this->url()->fromRoute("soutenance/index-rapporteur", ['these' => $these->getId()], ['force_canonical' => true], true); $url = $this->url()->fromRoute('zfcuser/login', ['type' => 'token'], ['query' => ['token' => $token->getToken(), 'redirect' => $url_rapporteur, 'role' => $membre->getActeur()->getRole()->getRoleId()], 'force_canonical' => true], true); - $this->getNotifierSoutenanceService()->triggerDemandeSignatureEngagementImpartialite($these, $proposition, $membre, $url); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationDemandeSignatureEngagementImpartialite($these, $proposition, $membre, $url); + $this->notifierService->trigger($notif); + } catch (RuntimeException $e) { + // aucun destintaire, todo : cas à gérer ! + } } $this->redirect()->toRoute('soutenance/presoutenance', ['these' => $these->getId()], [], true); @@ -107,8 +120,12 @@ class EngagementImpartialiteController extends AbstractController $signature = $this->getEngagementImpartialiteService()->getEngagementImpartialiteByMembre($these, $membre); if ($signature === null) { $this->getEngagementImpartialiteService()->create($membre, $these); - $this->getNotifierSoutenanceService()->triggerSignatureEngagementImpartialite($these, $proposition, $membre); -// $this->getNotifierSoutenanceService()->triggerDemandeAvisSoutenance($these, $proposition, $membre); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationSignatureEngagementImpartialite($these, $proposition, $membre); + $this->notifierService->trigger($notif); + } catch (RuntimeException $e) { + // aucun destintaire, todo : cas à gérer ! + } } $this->redirect()->toRoute('soutenance/engagement-impartialite', ['these' => $these->getId(), 'membre' => $membre->getId()], [], true); @@ -122,7 +139,12 @@ class EngagementImpartialiteController extends AbstractController $this->getEngagementImpartialiteService()->createRefus($membre, $these); $this->getPropositionService()->annulerValidationsForProposition($proposition); - $this->getNotifierSoutenanceService()->triggerRefusEngagementImpartialite($these, $proposition, $membre); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationRefusEngagementImpartialite($these, $proposition, $membre); + $this->notifierService->trigger($notif); + } catch (RuntimeException $e) { + // aucun destintaire, todo : cas à gérer ! + } $this->redirect()->toRoute('soutenance/engagement-impartialite', ['these' => $these->getId(), 'membre' => $membre->getId()], [], true); @@ -136,7 +158,12 @@ class EngagementImpartialiteController extends AbstractController /** @var Validation[] $validations */ $this->getEngagementImpartialiteService()->delete($membre); - $this->getNotifierSoutenanceService()->triggerAnnulationEngagementImpartialite($these, $proposition, $membre); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationAnnulationEngagementImpartialite($these, $proposition, $membre); + $this->notifierService->trigger($notif); + } catch (RuntimeException $e) { + // aucun destintaire, todo : cas à gérer ! + } $this->redirect()->toRoute('soutenance/presoutenance', ['these' => $these->getId()], [], true); } diff --git a/module/Soutenance/src/Soutenance/Controller/EngagementImpartialiteControllerFactory.php b/module/Soutenance/src/Soutenance/Controller/EngagementImpartialiteControllerFactory.php index 29952574b5945f550ffbaac1e8be006953169a35..b9328fd84b71c22b1f1fe4f3b82734cf80f532a4 100644 --- a/module/Soutenance/src/Soutenance/Controller/EngagementImpartialiteControllerFactory.php +++ b/module/Soutenance/src/Soutenance/Controller/EngagementImpartialiteControllerFactory.php @@ -4,12 +4,13 @@ namespace Soutenance\Controller; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; +use Soutenance\Service\Notification\SoutenanceNotificationFactory; use These\Service\Acteur\ActeurService; use Interop\Container\ContainerInterface; use Soutenance\Service\EngagementImpartialite\EngagementImpartialiteService; use Soutenance\Service\Evenement\EvenementService; use Soutenance\Service\Membre\MembreService; -use Soutenance\Service\Notifier\NotifierSoutenanceService; +use Notification\Service\NotifierService; use Soutenance\Service\Proposition\PropositionService; use UnicaenAuthToken\Service\TokenService; use UnicaenAuthToken\Service\TokenServiceAwareTrait; @@ -30,7 +31,7 @@ class EngagementImpartialiteControllerFactory * @var EvenementService $evenementService * @var PropositionService $propositionService * @var MembreService $membreService - * @var NotifierSoutenanceService $notifierService + * @var NotifierService $notifierService * @var EngagementImpartialiteService $engagementImpartialiteService * @var RenduService $renduService * @var TokenService $tokenService @@ -39,7 +40,7 @@ class EngagementImpartialiteControllerFactory $evenementService = $container->get(EvenementService::class); $propositionService = $container->get(PropositionService::class); $membreService = $container->get(MembreService::class); - $notifierService = $container->get(NotifierSoutenanceService::class); + $notifierService = $container->get(NotifierService::class); $engagementImpartialiteService = $container->get(EngagementImpartialiteService::class); $renduService = $container->get(RenduService::class); $tokenService = $container->get(TokenService::class); @@ -49,11 +50,15 @@ class EngagementImpartialiteControllerFactory $controller->setEvenementService($evenementService); $controller->setPropositionService($propositionService); $controller->setMembreService($membreService); - $controller->setNotifierSoutenanceService($notifierService); + $controller->setNotifierService($notifierService); $controller->setEngagementImpartialiteService($engagementImpartialiteService); $controller->setRenduService($renduService); $controller->setTokenService($tokenService); + /** @var \Soutenance\Service\Notification\SoutenanceNotificationFactory $soutenanceNotificationFactory */ + $soutenanceNotificationFactory = $container->get(SoutenanceNotificationFactory::class); + $controller->setSoutenanceNotificationFactory($soutenanceNotificationFactory); + return $controller; } } \ No newline at end of file diff --git a/module/Soutenance/src/Soutenance/Controller/PresoutenanceController.php b/module/Soutenance/src/Soutenance/Controller/PresoutenanceController.php index c386be66d20390f9a20d889daa466fb43569bf04..598fb4e237688f96c3ad8122a63495809ad99643 100644 --- a/module/Soutenance/src/Soutenance/Controller/PresoutenanceController.php +++ b/module/Soutenance/src/Soutenance/Controller/PresoutenanceController.php @@ -37,7 +37,8 @@ use Soutenance\Service\Exporter\RapportSoutenance\RapportSoutenancePdfExporter; use Soutenance\Service\Exporter\RapportTechnique\RapportTechniquePdfExporter; use Soutenance\Service\Justificatif\JustificatifServiceAwareTrait; use Soutenance\Service\Membre\MembreServiceAwareTrait; -use Soutenance\Service\Notifier\NotifierSoutenanceServiceAwareTrait; +use Soutenance\Service\Notification\SoutenanceNotificationFactoryAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; use Soutenance\Service\Parametre\ParametreServiceAwareTrait; use Soutenance\Service\Proposition\PropositionServiceAwareTrait; use Soutenance\Service\Validation\ValidatationServiceAwareTrait; @@ -59,7 +60,8 @@ class PresoutenanceController extends AbstractController use TheseServiceAwareTrait; use MembreServiceAwareTrait; use IndividuServiceAwareTrait; - use NotifierSoutenanceServiceAwareTrait; + use NotifierServiceAwareTrait; + use SoutenanceNotificationFactoryAwareTrait; use PropositionServiceAwareTrait; use ActeurServiceAwareTrait; use ValidatationServiceAwareTrait; @@ -245,7 +247,12 @@ class PresoutenanceController extends AbstractController $token = $this->getMembreService()->retrieveOrCreateToken($membre); $url_rapporteur = $this->url()->fromRoute("soutenance/index-rapporteur", ['these' => $these->getId()], ['force_canonical' => true], true); $url = $this->url()->fromRoute('zfcuser/login', ['type' => 'token'], ['query' => ['token' => $token->getToken(), 'redirect' => $url_rapporteur, 'role' => $acteur->getRole()->getRoleId()], 'force_canonical' => true], true); - $this->getNotifierSoutenanceService()->triggerConnexionRapporteur($proposition, $user, $url); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationConnexionRapporteur($proposition, $user, $url); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } } } @@ -308,7 +315,12 @@ class PresoutenanceController extends AbstractController $token = $this->getMembreService()->retrieveOrCreateToken($rapporteur); $url_rapporteur = $this->url()->fromRoute("soutenance/index-rapporteur", ['these' => $these->getId()], ['force_canonical' => true], true); $url = $this->url()->fromRoute('zfcuser/login', ['type' => 'token'], ['query' => ['token' => $token->getToken(), 'redirect' => $url_rapporteur, 'role' => $rapporteur->getActeur()->getRole()->getRoleId()], 'force_canonical' => true], true); - $this->getNotifierSoutenanceService()->triggerDemandeAvisSoutenance($these, $proposition, $rapporteur, $url); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationDemandeAvisSoutenance($these, $proposition, $rapporteur, $url); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } } } @@ -337,7 +349,12 @@ class PresoutenanceController extends AbstractController $avis = $this->getAvisService()->getAvisByThese($these); - $this->getNotifierSoutenanceService()->triggerFeuVertSoutenance($these, $proposition, $avis); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationFeuVertSoutenance($these, $proposition, $avis); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } $this->flashMessenger() //->setNamespace('presoutenance') ->addSuccessMessage("Notifications d'accord de soutenance envoyées"); @@ -354,7 +371,12 @@ class PresoutenanceController extends AbstractController $proposition->setEtat($etat); $this->getPropositionService()->update($proposition); - $this->getNotifierSoutenanceService()->triggerStopperDemarcheSoutenance($these, $proposition); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationStopperDemarcheSoutenance($these, $proposition); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } $this->flashMessenger() //->setNamespace('presoutenance') ->addSuccessMessage("Notifications d'arrêt des démarches de soutenance soutenance envoyées"); @@ -627,7 +649,12 @@ class PresoutenanceController extends AbstractController $doctorant->getIndividu()->getEmailUtilisateur(); /** @see PresoutenanceController::convocationDoctorantAction() */ $url = $this->url()->fromRoute('soutenance/presoutenance/convocation-doctorant', ['proposition' => $proposition->getId()], ['force_canonical' => true], true); - $this->getNotifierSoutenanceService()->triggerEnvoiConvocationDoctorant($doctorant, $proposition, $dateValidation, $email, $url, $avisArray); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationEnvoiConvocationDoctorant($doctorant, $proposition, $dateValidation, $email, $url, $avisArray); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } //membres /** @var Membre $membre */ @@ -636,7 +663,12 @@ class PresoutenanceController extends AbstractController $email = ($membre->getIndividu() and $membre->getIndividu()->getEmailPro()) ? $membre->getIndividu()->getEmailPro() : $membre->getEmail(); /** @see PresoutenanceController::convocationMembreAction() */ $url = $this->url()->fromRoute('soutenance/presoutenance/convocation-membre', ['proposition' => $proposition->getId(), 'membre' => $membre->getId()], ['force_canonical' => true], true); - $this->getNotifierSoutenanceService()->triggerEnvoiConvocationMembre($membre, $proposition, $dateValidation, $email, $url, $avisArray); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationEnvoiConvocationMembre($membre, $proposition, $dateValidation, $email, $url, $avisArray); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } } } return $this->redirect()->toRoute('soutenance/presoutenance', ['these' => $these->getId()], [], true); @@ -650,11 +682,33 @@ class PresoutenanceController extends AbstractController $url = $this->url()->fromRoute('soutenances/index-rapporteur', [], ['force_canonical' => true], true); foreach ($membres as $membre) { - $this->getNotifierSoutenanceService()->triggerNotificationRapporteurRetard($membre, $url); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationNotificationRapporteurRetard($membre, $url); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } } exit(); } + public function transmettreDocumentsDirectionTheseAction() : Response + { + $these = $this->requestedThese(); + $proposition = $this->getPropositionService()->findOneForThese($these); + + try { + $notif = $this->soutenanceNotificationFactory->createNotificationTransmettreDocumentsDirectionThese($these, $proposition); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } + + return $this->redirect()->toRoute('soutenance/presoutenance', ['these' => $these->getId()], [], true); + } + + /** SIMULATION DE JURY ********************************************************************************************/ + public function genererSimulationAction() : Response { $these = $this->requestedThese(); diff --git a/module/Soutenance/src/Soutenance/Controller/PresoutenanceControllerFactory.php b/module/Soutenance/src/Soutenance/Controller/PresoutenanceControllerFactory.php index 75fc08dd0cfbc86c781b729a76240afc2e22dd67..f224b73f424247b2988e7d7443c54a89ac9fd813 100644 --- a/module/Soutenance/src/Soutenance/Controller/PresoutenanceControllerFactory.php +++ b/module/Soutenance/src/Soutenance/Controller/PresoutenanceControllerFactory.php @@ -4,6 +4,7 @@ namespace Soutenance\Controller; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; +use Soutenance\Service\Notification\SoutenanceNotificationFactory; use These\Service\Acteur\ActeurService; use Fichier\Service\Fichier\FichierService; use Fichier\Service\Fichier\FichierStorageService; @@ -21,7 +22,7 @@ use Soutenance\Service\EngagementImpartialite\EngagementImpartialiteService; use Soutenance\Service\Evenement\EvenementService; use Soutenance\Service\Justificatif\JustificatifService; use Soutenance\Service\Membre\MembreService; -use Soutenance\Service\Notifier\NotifierSoutenanceService; +use Notification\Service\NotifierService; use Soutenance\Service\Parametre\ParametreService; use Soutenance\Service\Proposition\PropositionService; use Soutenance\Service\Validation\ValidationService; @@ -47,7 +48,7 @@ class PresoutenanceControllerFactory * @var MembreService $membreService * @var TheseService $theseService * @var IndividuService $individuService - * @var NotifierSoutenanceService $notifierService + * @var NotifierService $notifierService * @var ActeurService $acteurService * @var ValidationService $validationService * @var RoleService $roleService @@ -68,7 +69,7 @@ class PresoutenanceControllerFactory $theseService = $container->get('TheseService'); $individuService = $container->get(IndividuService::class); $acteurService = $container->get(ActeurService::class); - $notifierService = $container->get(NotifierSoutenanceService::class); + $notifierService = $container->get(NotifierService::class); $validationService = $container->get(ValidationService::class); $roleService = $container->get('RoleService'); $avisService = $container->get(AvisService::class); @@ -100,7 +101,7 @@ class PresoutenanceControllerFactory $controller->setTheseService($theseService); $controller->setIndividuService($individuService); $controller->setActeurService($acteurService); - $controller->setNotifierSoutenanceService($notifierService); + $controller->setNotifierService($notifierService); $controller->setValidationService($validationService); $controller->setSourceService($sourceService); $controller->setRoleService($roleService); @@ -119,6 +120,11 @@ class PresoutenanceControllerFactory $controller->setAdresseSoutenanceForm($adresseSoutenanceForm); $controller->setRenderer($renderer); + + /** @var \Soutenance\Service\Notification\SoutenanceNotificationFactory $soutenanceNotificationFactory */ + $soutenanceNotificationFactory = $container->get(SoutenanceNotificationFactory::class); + $controller->setSoutenanceNotificationFactory($soutenanceNotificationFactory); + return $controller; } } \ No newline at end of file diff --git a/module/Soutenance/src/Soutenance/Controller/PropositionController.php b/module/Soutenance/src/Soutenance/Controller/PropositionController.php index af10e6524f5bb7bdc84faac806c5583709e1fc3d..18c4362bd83159acb546ddeb8f2708b2fd0c4460 100644 --- a/module/Soutenance/src/Soutenance/Controller/PropositionController.php +++ b/module/Soutenance/src/Soutenance/Controller/PropositionController.php @@ -8,6 +8,7 @@ use Information\Service\InformationServiceAwareTrait; use Soutenance\Provider\Template\PdfTemplates; use Soutenance\Service\Avis\AvisServiceAwareTrait; use Soutenance\Service\Exporter\SermentExporter\SermentPdfExporter; +use Soutenance\Service\Notification\SoutenanceNotificationFactoryAwareTrait; use Structure\Service\Etablissement\EtablissementServiceAwareTrait; use Structure\Service\Structure\StructureServiceAwareTrait; use These\Entity\Db\Acteur; @@ -41,7 +42,7 @@ use Soutenance\Provider\Validation\TypeValidation; use Soutenance\Service\Evenement\EvenementServiceAwareTrait; use Soutenance\Service\Justificatif\JustificatifServiceAwareTrait; use Soutenance\Service\Membre\MembreServiceAwareTrait; -use Soutenance\Service\Notifier\NotifierSoutenanceServiceAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; use Soutenance\Service\Parametre\ParametreServiceAwareTrait; use Soutenance\Service\Proposition\PropositionServiceAwareTrait; use Soutenance\Service\SignaturePresident\SiganturePresidentPdfExporter; @@ -62,7 +63,8 @@ class PropositionController extends AbstractController use InformationServiceAwareTrait; use JustificatifServiceAwareTrait; use MembreServiceAwareTrait; - use NotifierSoutenanceServiceAwareTrait; + use NotifierServiceAwareTrait; + use SoutenanceNotificationFactoryAwareTrait; use ParametreServiceAwareTrait; use PropositionServiceAwareTrait; use RoleServiceAwareTrait; @@ -426,7 +428,12 @@ class PropositionController extends AbstractController if ($autorisation !== null) return $autorisation; $validation = $this->getValidationService()->validatePropositionSoutenance($these); - $this->getNotifierSoutenanceService()->triggerValidationProposition($these, $validation); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationValidationProposition($these, $validation); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire , todo : cas à gérer ! + } $doctorant = $these->getDoctorant(); @@ -442,7 +449,14 @@ class PropositionController extends AbstractController break; } } - if ($allValidated) $this->getNotifierSoutenanceService()->triggerNotificationUniteRechercheProposition($these); + if ($allValidated) { + try { + $notif = $this->soutenanceNotificationFactory->createNotificationUniteRechercheProposition($these); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire , todo : cas à gérer ! + } + } return $this->redirect()->toRoute('soutenance/proposition', ['these' => $these->getId()], [], true); @@ -466,17 +480,37 @@ class PropositionController extends AbstractController switch ($role->getCode()) { case Role::CODE_RESP_UR : $this->getValidationService()->validateValidationUR($these, $individu); - $this->getNotifierSoutenanceService()->triggerNotificationEcoleDoctoraleProposition($these); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationEcoleDoctoraleProposition($these); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire , todo : cas à gérer ! + } break; case Role::CODE_RESP_ED : case Role::CODE_GEST_ED : $this->getValidationService()->validateValidationED($these, $individu); - $this->getNotifierSoutenanceService()->triggerNotificationBureauDesDoctoratsProposition($these); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationBureauDesDoctoratsProposition($these); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire , todo : cas à gérer ! + } break; case Role::CODE_BDD : $this->getValidationService()->validateValidationBDD($these, $individu); - $this->getNotifierSoutenanceService()->triggerNotificationPropositionValidee($these); - $this->getNotifierSoutenanceService()->triggerNotificationPresoutenance($these); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationPropositionValidee($these); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire , todo : cas à gérer ! + } + try { + $notif = $this->soutenanceNotificationFactory->createNotificationPresoutenance($these); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire , todo : cas à gérer ! + } $proposition = $this->getPropositionService()->findOneForThese($these); $proposition->setEtat($this->getPropositionService()->findPropositionEtatByCode(Etat::ETABLISSEMENT)); @@ -509,7 +543,12 @@ class PropositionController extends AbstractController $currentUser = $this->userContextService->getIdentityIndividu(); /** @var RoleInterface $currentRole */ $currentRole = $this->userContextService->getSelectedIdentityRole(); - $this->getNotifierSoutenanceService()->triggerRefusPropositionSoutenance($these, $currentUser, $currentRole, $data['motif']); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationRefusPropositionSoutenance($these, $currentUser, $currentRole, $data['motif']); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire , todo : cas à gérer ! + } } } diff --git a/module/Soutenance/src/Soutenance/Controller/PropositionControllerFactory.php b/module/Soutenance/src/Soutenance/Controller/PropositionControllerFactory.php index cfa8b8fe7c84ca9b945d43210a733d5949995f65..41958edc21b1f915975ba38022fe0fd20945d87b 100644 --- a/module/Soutenance/src/Soutenance/Controller/PropositionControllerFactory.php +++ b/module/Soutenance/src/Soutenance/Controller/PropositionControllerFactory.php @@ -8,6 +8,7 @@ use Information\Service\InformationService; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use Soutenance\Service\Avis\AvisService; +use Soutenance\Service\Notification\SoutenanceNotificationFactory; use Structure\Service\Etablissement\EtablissementService; use These\Service\Acteur\ActeurService; use Structure\Service\EcoleDoctorale\EcoleDoctoraleService; @@ -25,7 +26,7 @@ use Soutenance\Form\Refus\RefusForm; use Soutenance\Service\Evenement\EvenementService; use Soutenance\Service\Justificatif\JustificatifService; use Soutenance\Service\Membre\MembreService; -use Soutenance\Service\Notifier\NotifierSoutenanceService; +use Notification\Service\NotifierService; use Soutenance\Service\Parametre\ParametreService; use Soutenance\Service\Proposition\PropositionService; use Soutenance\Service\Validation\ValidationService; @@ -52,7 +53,7 @@ class PropositionControllerFactory * @var EvenementService $evenementService * @var FichierStorageService $fichierStorageService * @var MembreService $membreService - * @var NotifierSoutenanceService $notificationSoutenanceService + * @var NotifierService $notifierService * @var PropositionService $propositionService * @var RoleService $roleService * @var UserContextService $userContextService @@ -69,7 +70,7 @@ class PropositionControllerFactory $fichierStorageService = $container->get(FichierStorageService::class); $informationService = $container->get(InformationService::class); $membreService = $container->get(MembreService::class); - $notificationSoutenanceService = $container->get(NotifierSoutenanceService::class); + $notifierService = $container->get(NotifierService::class); $propositionService = $container->get(PropositionService::class); $roleService = $container->get(RoleService::class); $userContextService = $container->get('UserContextService'); @@ -113,7 +114,7 @@ class PropositionControllerFactory $controller->setFichierStorageService($fichierStorageService); $controller->setInformationService($informationService); $controller->setMembreService($membreService); - $controller->setNotifierSoutenanceService($notificationSoutenanceService); + $controller->setNotifierService($notifierService); $controller->setPropositionService($propositionService); $controller->setRoleService($roleService); $controller->setUserContextService($userContextService); @@ -134,6 +135,10 @@ class PropositionControllerFactory $controller->setPropositionAssertion($propositionAssertion); + /** @var \Soutenance\Service\Notification\SoutenanceNotificationFactory $soutenanceNotificationFactory */ + $soutenanceNotificationFactory = $container->get(SoutenanceNotificationFactory::class); + $controller->setSoutenanceNotificationFactory($soutenanceNotificationFactory); + return $controller; } } \ No newline at end of file diff --git a/module/Soutenance/src/Soutenance/Provider/Template/MailTemplates.php b/module/Soutenance/src/Soutenance/Provider/Template/MailTemplates.php new file mode 100644 index 0000000000000000000000000000000000000000..9f0516f3500b3fcf45e500f0cc3c550530de3d56 --- /dev/null +++ b/module/Soutenance/src/Soutenance/Provider/Template/MailTemplates.php @@ -0,0 +1,8 @@ +<?php + +namespace Soutenance\Provider\Template; + +class MailTemplates +{ + const TRANSMETTRE_DOCUMENTS_DIRECTION = "TRANSMETTRE_DOCUMENTS_DIRECTION"; +} \ No newline at end of file diff --git a/module/Soutenance/src/Soutenance/Service/Exporter/SermentExporter/header.phtml b/module/Soutenance/src/Soutenance/Service/Exporter/SermentExporter/header.phtml index 92259b4f40e7f4fff68f1647d29fda0daf96472e..4735e9d5e6279d3d5d0eafff7a3a0833832c3b53 100644 --- a/module/Soutenance/src/Soutenance/Service/Exporter/SermentExporter/header.phtml +++ b/module/Soutenance/src/Soutenance/Service/Exporter/SermentExporter/header.phtml @@ -9,8 +9,8 @@ <?php if ($cheminLogoComue !== null) : ?> - <img src="<?php echo $cheminLogoComue; ?>" style="height:30mm;"/> + <img src="<?php echo $cheminLogoComue; ?>" style="max-height:40mm; max-width:60mm;"/> <?php endif; ?> <?php if ($cheminLogoEtablissement !== null) : ?> - <img src="<?php echo $cheminLogoEtablissement; ?>" style="height:30mm;"/> + <img src="<?php echo $cheminLogoEtablissement; ?>" style="max-height:40mm; max-width:60mm;"/> <?php endif; ?> diff --git a/module/Soutenance/src/Soutenance/Service/Notifier/NotifierSoutenanceService.php b/module/Soutenance/src/Soutenance/Service/Notification/SoutenanceNotificationFactory.php similarity index 59% rename from module/Soutenance/src/Soutenance/Service/Notifier/NotifierSoutenanceService.php rename to module/Soutenance/src/Soutenance/Service/Notification/SoutenanceNotificationFactory.php index 45fbf94714bab9988603f85c4a850e9be007a46e..148c20d666c5a37e9bc75e2947880ca4ff41fbbd 100644 --- a/module/Soutenance/src/Soutenance/Service/Notifier/NotifierSoutenanceService.php +++ b/module/Soutenance/src/Soutenance/Service/Notification/SoutenanceNotificationFactory.php @@ -1,63 +1,56 @@ <?php -namespace Soutenance\Service\Notifier; +namespace Soutenance\Service\Notification; -use Individu\Service\IndividuServiceAwareTrait; -use Doctorant\Entity\Db\Doctorant; -use Individu\Entity\Db\Individu; -use Individu\Entity\Db\IndividuRole; use Application\Entity\Db\Role; -use These\Entity\Db\These; -use Application\Entity\Db\Variable; use Application\Entity\Db\Utilisateur; use Application\Entity\Db\Validation; -use These\Service\Acteur\ActeurServiceAwareTrait; use Application\Service\Email\EmailTheseServiceAwareTrait; use Application\Service\Role\RoleServiceAwareTrait; -use These\Service\These\TheseServiceAwareTrait; use Application\Service\Utilisateur\UtilisateurServiceAwareTrait; -use Application\Service\Variable\VariableServiceAwareTrait; use DateTime; -use InvalidArgumentException; -use Laminas\View\Helper\Url as UrlHelper; -use Notification\Exception\NotificationException; +use Doctorant\Entity\Db\Doctorant; +use Individu\Entity\Db\Individu; +use Individu\Service\IndividuServiceAwareTrait; +use Notification\Exception\RuntimeException; +use Notification\Factory\NotificationFactory; use Notification\Notification; -use Notification\Service\NotifierService; use Soutenance\Entity\Avis; use Soutenance\Entity\Membre; use Soutenance\Entity\Proposition; +use Soutenance\Provider\Template\MailTemplates; use Soutenance\Service\Membre\MembreServiceAwareTrait; -use UnicaenApp\Exception\LogicException; -use UnicaenApp\Exception\RuntimeException; +use Soutenance\Service\Url\UrlServiceAwareTrait; +use These\Entity\Db\These; +use These\Service\Acteur\ActeurServiceAwareTrait; +use These\Service\These\TheseServiceAwareTrait; use UnicaenAuth\Entity\Db\RoleInterface; - -class NotifierSoutenanceService extends NotifierService +use UnicaenRenderer\Service\Rendu\RenduServiceAwareTrait; + +/** + * Classe de construction de notifications par mail. + * + * @author Unicaen + */ +class SoutenanceNotificationFactory extends NotificationFactory { use ActeurServiceAwareTrait; + use EmailTheseServiceAwareTrait; use IndividuServiceAwareTrait; use MembreServiceAwareTrait; use RoleServiceAwareTrait; - use VariableServiceAwareTrait; use TheseServiceAwareTrait; use EmailTheseServiceAwareTrait; use UtilisateurServiceAwareTrait; - - /** - * @var UrlHelper - */ - protected $urlHelper; - - public function setUrlHelper($urlHelper) - { - $this->urlHelper = $urlHelper; - } + use RenduServiceAwareTrait; + use UrlServiceAwareTrait; /** * @return string[] */ - protected function getEmailAdministrateurTechnique() : array + protected function getEmailAdministrateurTechnique(): array { - $individus = $this->getIndividuService()->getRepository()->findByRole(Role::CODE_ADMIN_TECH); + $individus = $this->individuService->getRepository()->findByRole(Role::CODE_ADMIN_TECH); $emails = []; foreach ($individus as $individu) { $email = $individu->getEmailUtilisateur(); @@ -65,205 +58,71 @@ class NotifierSoutenanceService extends NotifierService } return $emails; } - /** - * @param These $these - * @return string - */ - protected function fetchEmailBdd(These $these) : string - { - $variable = $this->variableService->getRepository()->findOneByCodeAndThese(Variable::CODE_EMAIL_BDD, $these); - return $variable->getValeur(); - } - - /** - * @param IndividuRole[] $individuRoles - * @param These $these - * @return bool - */ - protected function hasEmailsByEtablissement(array $individuRoles, These $these) : bool - { - foreach ($individuRoles as $individuRole) { - $individu = $individuRole->getIndividu(); - if ($individu->getEtablissement() === $these->getEtablissement()) { - if ($individu->getEmailPro() !== null) return true; - } - } - return false; - } - - /** - * @param IndividuRole[] $individuRoles - * @param These $these - * @return array - */ - protected function fetchEmailsByEtablissement(array $individuRoles, These $these) : array - { - $allEmails = []; - $emails = []; - foreach ($individuRoles as $individuRole) { - $individu = $individuRole->getIndividu(); - if ($individu->getEtablissement() === $these->getEtablissement()) { - if ($individu->getEmailPro() !== null) { - { - $emails[] = $individu->getEmailPro(); - $allEmails[] = $individu->getEmailPro(); - } - - } else { - $utilisateurs = $this->getUtilisateurService()->getRepository()->findByIndividu($individu); - foreach ($utilisateurs as $utilisateur) { - if ($utilisateur->getEmail()) { - $emails[] = $utilisateur->getEmail(); - $allEmails[] = $utilisateur->getEmail(); - break; - } - } - } - } - } - if (! empty($emails)) return $emails; - return $allEmails; - } - - /** - * @param These $these - * @return string[] - */ - protected function fetchEmailEcoleDoctorale(These $these) : array - { - /** @var IndividuRole[] $individuRoles */ - $individuRoles = $this->roleService->findIndividuRoleByStructure($these->getEcoleDoctorale()->getStructure()); - return $this->fetchEmailsByEtablissement($individuRoles, $these); - } - - /** - * @param These $these - * @return string[] - */ - protected function fetchEmailUniteRecherche(These $these) : array - { - /** @var IndividuRole[] $individuRoles */ - $individuRoles = $this->roleService->findIndividuRoleByStructure($these->getUniteRecherche()->getStructure()); - return $this->fetchEmailsByEtablissement($individuRoles, $these); - } - - /** - * @param These $these - * @return string[] - */ - protected function fetchEmailMaisonDuDoctorat(These $these) : array - { - /** @var IndividuRole[] $individuRoles */ - $individuRoles = $this->roleService->findIndividuRoleByStructure($these->getEtablissement()->getStructure()); - $individuRoles = array_filter($individuRoles, function (IndividuRole $ir) { return $ir->getRole()->getCode() === Role::CODE_BDD;}); - return $this->fetchEmailsByEtablissement($individuRoles, $these); - } - - /** - * @param These $these - * @return string[] - */ - protected function fetchEmailEncadrants(These $these) : array - { - $emails = []; - $encadrants = $this->getActeurService()->getRepository()->findEncadrementThese($these); - foreach ($encadrants as $encadrant) { - //tentative dans individu - $email = $encadrant->getIndividu()->getEmailPro(); - //tentative dans membre - if ($email === null) { - $membre = $this->getMembreService()->getMembreByActeur($encadrant); - if ($membre) $email = $membre->getEmail(); - } - //tentative dans utilisateur - if ($email === null) { - $utilisateurs = $this->getUtilisateurService()->getRepository()->findByIndividu($encadrant->getIndividu()); - foreach ($utilisateurs as $utilisateur) { - $email = $utilisateur->getEmail(); - if ($email !== null) break; - } - } - // echec ... - if ($email === null) { - throw new InvalidArgumentException("Pas de mail pour l'encadrant de thèse [".$encadrant->getIndividu()->getNomComplet()."]"); - } - $emails[] = $email; - } - return $emails; - } - - /** - * @param These $these - * @return array - */ - protected function fetchEmailActeursDirects(These $these) : array - { - $emails = []; - $emails[] = $these->getDoctorant()->getIndividu()->getEmailPro(); - - $encadrants = $this->fetchEmailEncadrants($these); - foreach ($encadrants as $encadrant) { - $emails[] = $encadrant; - } - return $emails; - } /** * @param Validation $validation + * @return \Notification\Notification * @see Application/view/soutenance/notification/devalidation.phtml */ - public function triggerDevalidationProposition($validation) + public function createNotificationDevalidationProposition(Validation $validation): Notification { $mail = $validation->getIndividu()->getEmailPro(); $these = $validation->getThese(); - if ($mail !== null) { - $notif = new Notification(); - $notif - ->setSubject("Votre validation de la proposition de soutenance a été annulée") - ->setTo($mail) - ->setTemplatePath('soutenance/notification/devalidation') - ->setTemplateVariables([ - 'validation' => $validation, - 'these' => $these, - ]); - $this->trigger($notif); + if (!$mail) { + throw new RuntimeException("Aucune adresse mail trouvée pour l'individu {$validation->getIndividu()}"); } + + $notif = new Notification(); + $notif + ->setSubject("Votre validation de la proposition de soutenance a été annulée") + ->setTo($mail) + ->setTemplatePath('soutenance/notification/devalidation') + ->setTemplateVariables([ + 'validation' => $validation, + 'these' => $these, + ]); + + return $notif; } /** * @param These $these * @param Validation $validation + * @return \Notification\Notification * @see Application/view/soutenance/notification/validation-acteur.phtml */ - public function triggerValidationProposition(These $these, Validation $validation) + public function createNotificationValidationProposition(These $these, Validation $validation): Notification { - $emails = $this->fetchEmailActeursDirects($these); + $emails = $this->emailTheseService->fetchEmailActeursDirects($these); $emails = array_filter($emails, function ($s) { return $s !== null; }); - if (!empty($emails)) { - $notif = new Notification(); - $notif - ->setSubject("Une validation de votre proposition de soutenance vient d'être faite") - ->setTo($emails) - ->setTemplatePath('soutenance/notification/validation-acteur') - ->setTemplateVariables([ - 'validation' => $validation, - 'these' => $these, - ]); - $this->trigger($notif); + if (empty($emails)) { + throw new RuntimeException("Aucune adresse mail trouvée pour les acteurs directs de la thèse {$these->getId()}"); } + + $notif = new Notification(); + $notif + ->setSubject("Une validation de votre proposition de soutenance vient d'être faite") + ->setTo($emails) + ->setTemplatePath('soutenance/notification/validation-acteur') + ->setTemplateVariables([ + 'validation' => $validation, + 'these' => $these, + ]); + + return $notif; } /** * @param These $these + * @return \Notification\Notification * @see Application/view/soutenance/notification/validation-structure.phtml - * @throws NotificationException */ - public function triggerNotificationUniteRechercheProposition(These $these) + public function createNotificationUniteRechercheProposition(These $these): Notification { $individuRoles = $this->roleService->findIndividuRoleByStructure($these->getUniteRecherche()->getStructure()); $panic = !($this->emailTheseService->hasEmailsByEtablissement($individuRoles, $these)); @@ -281,10 +140,11 @@ class NotifierSoutenanceService extends NotifierService 'type' => 'unité de recherche', 'panic' => $panic, ]); - $this->trigger($notif); + + return $notif; } else { $emailsAdmin = $this->getEmailAdministrateurTechnique(); - $emailsMdd = $this->fetchEmailMaisonDuDoctorat($these); + $emailsMdd = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); $emails = array_merge($emailsAdmin, $emailsMdd); $notif = new Notification(); @@ -297,15 +157,17 @@ class NotifierSoutenanceService extends NotifierService 'type' => 'unité de recherche', 'panic' => true, ]); - $this->trigger($notif); + + return $notif; } } /** * @param These $these + * @return \Notification\Notification * @see Application/view/soutenance/notification/validation-structure.phtml */ - public function triggerNotificationEcoleDoctoraleProposition(These $these) + public function createNotificationEcoleDoctoraleProposition(These $these): Notification { $individuRoles = $this->roleService->findIndividuRoleByStructure($these->getEcoleDoctorale()->getStructure()); $panic = !($this->emailTheseService->hasEmailsByEtablissement($individuRoles, $these)); @@ -323,10 +185,11 @@ class NotifierSoutenanceService extends NotifierService 'type' => 'école doctorale', 'panic' => $panic, ]); - $this->trigger($notif); + + return $notif; } else { $emailsAdmin = $this->getEmailAdministrateurTechnique(); - $emailsMdd = $this->fetchEmailMaisonDuDoctorat($these); + $emailsMdd = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); $emails = array_merge($emailsAdmin, $emailsMdd); $notif = new Notification(); @@ -339,15 +202,17 @@ class NotifierSoutenanceService extends NotifierService 'type' => 'école doctorale', 'panic' => true, ]); - $this->trigger($notif); + + return $notif; } } /** * @param These $these + * @return \Notification\Notification * @see Application/view/soutenance/notification/validation-structure.phtml */ - public function triggerNotificationBureauDesDoctoratsProposition(These $these) + public function createNotificationBureauDesDoctoratsProposition(These $these): Notification { $email = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); @@ -362,10 +227,11 @@ class NotifierSoutenanceService extends NotifierService 'type' => 'maison du doctorat', 'panic' => false, ]); - $this->trigger($notif); + + return $notif; } else { $emailsAdmin = $this->getEmailAdministrateurTechnique(); - $emailsMdd = $this->fetchEmailMaisonDuDoctorat($these); + $emailsMdd = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); $emails = array_merge($emailsAdmin, $emailsMdd); $notif = new Notification(); @@ -378,17 +244,21 @@ class NotifierSoutenanceService extends NotifierService 'type' => 'maison du doctorat', 'panic' => true, ]); - $this->trigger($notif); + + return $notif; } } - /** @param These $these */ - public function triggerNotificationPropositionValidee(These $these) + /** + * @param \These\Entity\Db\These $these + * @return \Notification\Notification + */ + public function createNotificationPropositionValidee(These $these): Notification { $emailsBDD = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); $emailsED = $this->emailTheseService->fetchEmailEcoleDoctorale($these); $emailsUR = $this->emailTheseService->fetchEmailUniteRecherche($these); - $emailsActeurs = $this->fetchEmailActeursDirects($these); + $emailsActeurs = $this->emailTheseService->fetchEmailActeursDirects($these); $emails = array_merge($emailsBDD, $emailsED, $emailsUR, $emailsActeurs); $emails = array_filter($emails, function ($s) { @@ -398,20 +268,24 @@ class NotifierSoutenanceService extends NotifierService if (!empty($emails)) { $notif = new Notification(); $notif - ->setSubject("Validation de proposition de soutenance de ".$these->getDoctorant()->getIndividu()->getNomComplet()) + ->setSubject("Validation de proposition de soutenance de " . $these->getDoctorant()->getIndividu()->getNomComplet()) ->setTo($emails) ->setTemplatePath('soutenance/notification/validation-soutenance') ->setTemplateVariables([ 'these' => $these, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } } - /** @param These $these */ - public function triggerNotificationPresoutenance($these) + /** + * @param $these + * @return \Notification\Notification + */ + public function createNotificationPresoutenance($these): Notification { $email = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); @@ -424,9 +298,10 @@ class NotifierSoutenanceService extends NotifierService ->setTemplateVariables([ 'these' => $these, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } } @@ -435,10 +310,11 @@ class NotifierSoutenanceService extends NotifierService * @param Individu $currentUser * @param RoleInterface $currentRole * @param string $motif + * @return \Notification\Notification */ - public function triggerRefusPropositionSoutenance($these, $currentUser, $currentRole, $motif) + public function createNotificationRefusPropositionSoutenance($these, $currentUser, $currentRole, $motif): Notification { - $emails = $this->fetchEmailActeursDirects($these); + $emails = $this->emailTheseService->fetchEmailActeursDirects($these); $emails = array_filter($emails, function ($s) { return $s !== null; @@ -456,13 +332,15 @@ class NotifierSoutenanceService extends NotifierService 'motif' => $motif, 'these' => $these, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } } + /** ENGAGEMENT IMPARTIALITE ***************************************************************************************/ /** @@ -470,8 +348,9 @@ class NotifierSoutenanceService extends NotifierService * @param Proposition $proposition * @param Membre $membre * @param string $url + * @return \Notification\Notification */ - public function triggerDemandeSignatureEngagementImpartialite(These $these, Proposition $proposition, Membre $membre, string $url) + public function createNotificationDemandeSignatureEngagementImpartialite(These $these, Proposition $proposition, Membre $membre, string $url): Notification { $email = $membre->getEmail(); @@ -487,9 +366,10 @@ class NotifierSoutenanceService extends NotifierService 'membre' => $membre, 'url' => $url, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } } @@ -499,7 +379,7 @@ class NotifierSoutenanceService extends NotifierService * @param Proposition $proposition * @param Membre $membre */ - public function triggerSignatureEngagementImpartialite($these, $proposition, $membre) + public function createNotificationSignatureEngagementImpartialite($these, $proposition, $membre): Notification { $email = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); @@ -514,9 +394,10 @@ class NotifierSoutenanceService extends NotifierService 'proposition' => $proposition, 'membre' => $membre, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } } @@ -526,10 +407,9 @@ class NotifierSoutenanceService extends NotifierService * @param Proposition $proposition * @param Membre $membre */ - public function triggerRefusEngagementImpartialite($these, $proposition, $membre) + public function createNotificationRefusEngagementImpartialite($these, $proposition, $membre): Notification { - - $emailsAD = $this->fetchEmailActeursDirects($these); + $emailsAD = $this->emailTheseService->fetchEmailActeursDirects($these); $emailsBDD = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); $emails = array_merge($emailsAD, $emailsBDD); @@ -548,9 +428,10 @@ class NotifierSoutenanceService extends NotifierService 'proposition' => $proposition, 'membre' => $membre, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } } @@ -560,7 +441,7 @@ class NotifierSoutenanceService extends NotifierService * @param Proposition $proposition * @param Membre $membre */ - public function triggerAnnulationEngagementImpartialite($these, $proposition, $membre) + public function createNotificationAnnulationEngagementImpartialite($these, $proposition, $membre): Notification { $email = $membre->getEmail(); @@ -575,46 +456,21 @@ class NotifierSoutenanceService extends NotifierService 'proposition' => $proposition, 'membre' => $membre, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } } - /** - * @param These $these - * @param Proposition $proposition - * @param Membre $rapporteur - * @param string $url - */ - public function triggerDemandeAvisSoutenance(These $these, Proposition $proposition, Membre $rapporteur, string $url) - { - $email = $rapporteur->getEmail(); - if ($email !== null) { - $notif = new Notification(); - $notif - ->setSubject("Demande de l'avis de soutenance de la thèse de " . $these->getDoctorant()->getIndividu()) - ->setTo($email) - ->setTemplatePath('soutenance/notification/demande-avis-soutenance') - ->setTemplateVariables([ - 'these' => $these, - 'proposition' => $proposition, - 'membre' => $rapporteur, - 'url' => $url, - ]); - $this->trigger($notif); - } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); - } - - } + /**************************** avis ***************************/ /** * @param These $these */ - public function triggerAvisRendus($these) + public function createNotificationAvisRendus($these): Notification { $email = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); @@ -627,9 +483,10 @@ class NotifierSoutenanceService extends NotifierService ->setTemplateVariables([ 'these' => $these, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } } @@ -639,10 +496,10 @@ class NotifierSoutenanceService extends NotifierService * @param Avis $avis * @param string $url */ - public function triggerAvisFavorable($these, $avis, $url = null) + public function createNotificationAvisFavorable($these, $avis, $url = null): Notification { $emailBDD = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); - $emailsDirecteurs = $this->fetchEmailEncadrants($these); + $emailsDirecteurs = $this->emailTheseService->fetchEmailEncadrants($these); $emailsED = $this->emailTheseService->fetchEmailEcoleDoctorale($these); $emailsUR = $this->emailTheseService->fetchEmailUniteRecherche($these); $emails = array_merge($emailBDD, $emailsDirecteurs, $emailsED, $emailsUR); @@ -662,9 +519,10 @@ class NotifierSoutenanceService extends NotifierService 'avis' => $avis, 'url' => $url, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } } @@ -674,9 +532,9 @@ class NotifierSoutenanceService extends NotifierService * @param Avis $avis * @param string $url */ - public function triggerAvisDefavorable($these, $avis, $url = null) + public function createNotificationAvisDefavorable($these, $avis, $url = null): Notification { - $emailsDirecteurs = $this->fetchEmailEncadrants($these); + $emailsDirecteurs = $this->emailTheseService->fetchEmailEncadrants($these); $emailsED = $this->emailTheseService->fetchEmailEcoleDoctorale($these); $emailsUR = $this->emailTheseService->fetchEmailUniteRecherche($these); $emails = array_merge($emailsDirecteurs, $emailsED, $emailsUR); @@ -696,23 +554,55 @@ class NotifierSoutenanceService extends NotifierService 'avis' => $avis, 'url' => $url, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } } + /**************************** présoutenance ***************************/ + /** * @param These $these * @param Proposition $proposition - * @param Avis[] $avis + * @param Membre $rapporteur + * @param string $url + * @return \Notification\Notification */ - public function triggerFeuVertSoutenance($these, $proposition, $avis) + public function createNotificationDemandeAvisSoutenance(These $these, Proposition $proposition, Membre $rapporteur, string $url): Notification { + $email = $rapporteur->getEmail(); - $emailsActeurs = $this->fetchEmailActeursDirects($these); + if ($email !== null) { + $notif = new Notification(); + $notif + ->setSubject("Demande de l'avis de soutenance de la thèse de " . $these->getDoctorant()->getIndividu()) + ->setTo($email) + ->setTemplatePath('soutenance/notification/demande-avis-soutenance') + ->setTemplateVariables([ + 'these' => $these, + 'proposition' => $proposition, + 'membre' => $rapporteur, + 'url' => $url, + ]); + + return $notif; + } else { + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); + } + } + + /** + * @param These $these + * @param Proposition $proposition + * @param Avis[] $avis + */ + public function createNotificationFeuVertSoutenance($these, $proposition, $avis): Notification + { + $emailsActeurs = $this->emailTheseService->fetchEmailActeursDirects($these); $emailsED = $this->emailTheseService->fetchEmailEcoleDoctorale($these); $emailsUR = $this->emailTheseService->fetchEmailUniteRecherche($these); $emails = array_merge($emailsActeurs, $emailsED, $emailsUR); @@ -732,21 +622,20 @@ class NotifierSoutenanceService extends NotifierService 'proposition' => $proposition, 'avis' => $avis, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } - } /** * @param These $these * @param Proposition $proposition */ - public function triggerStopperDemarcheSoutenance($these, $proposition) + public function createNotificationStopperDemarcheSoutenance($these, $proposition): Notification { - - $emailsActeurs = $this->fetchEmailActeursDirects($these); + $emailsActeurs = $this->emailTheseService->fetchEmailActeursDirects($these); $emailsED = $this->emailTheseService->fetchEmailEcoleDoctorale($these); $emailsUR = $this->emailTheseService->fetchEmailUniteRecherche($these); $emails = array_merge($emailsActeurs, $emailsED, $emailsUR); @@ -765,56 +654,25 @@ class NotifierSoutenanceService extends NotifierService 'these' => $these, 'proposition' => $proposition, ]); - $this->trigger($notif); - } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); - } - - } - - /** - * @param These $these - * @param Utilisateur $utilisateur - * @param string $url - * - * @deprecated Pas utilisée ! - */ - public function triggerInitialisationCompte($these, $utilisateur, $url) - { - $email = $utilisateur->getEmail(); - if ($email === null) throw new LogicException("Aucun email de fourni !"); - - $token = $utilisateur->getPasswordResetToken(); - if ($token === null) throw new LogicException("Aucun token de fourni !"); - - if (!empty($email)) { - $notif = new Notification(); - $notif - ->setSubject("Initialisation de votre compte pour la these de " . $these->getDoctorant()->getIndividu()->getNomComplet()) - ->setTo($email) - ->setTemplatePath('soutenance/notification/init-compte') - ->setTemplateVariables([ - 'these' => $these, - 'username' => $utilisateur->getUsername(), - 'url' => $url, - ]); - $this->trigger($notif); + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } - } /** * @param Proposition $proposition * @param Utilisateur $user * @param string $url + * @return \Notification\Notification */ - public function triggerConnexionRapporteur(Proposition $proposition, Utilisateur $user, string $url) + public function createNotificationConnexionRapporteur(Proposition $proposition, Utilisateur $user, string $url): Notification { $email = $user->getEmail(); - if ($email === null) throw new LogicException("Aucun email de fourni !"); + if ($email === null) { + throw new RuntimeException("Aucun email de fourni !"); + } if (!empty($email)) { $notif = new Notification(); @@ -828,24 +686,27 @@ class NotifierSoutenanceService extends NotifierService 'username' => $user->getUsername(), 'url' => $url, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$proposition->getThese()->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $proposition->getThese()->getId() . ")"); } - } /** * @param Membre $membre * @param string $url */ - public function triggerNotificationRapporteurRetard($membre, $url) + public function createNotificationNotificationRapporteurRetard($membre, $url): Notification { - if ($membre->getActeur() === null) throw new RuntimeException("Notification vers rapporteur [MembreId = " . $membre->getId() . "] impossible car aucun acteur n'est lié."); + if ($membre->getActeur() === null) { + throw new RuntimeException("Notification vers rapporteur [MembreId = " . $membre->getId() . "] impossible car aucun acteur n'est lié."); + } $email = $membre->getEmail(); - if ($email === null) throw new RuntimeException("Notification vers rapporteur [MembreId = " . $membre->getId() . "] impossible car aucun email est donné pour l'individu associé [IndividuId = " . $membre->getIndividu()->getId() . "]."); - + if ($email === null) { + throw new RuntimeException("Notification vers rapporteur [MembreId = " . $membre->getId() . "] impossible car aucun email est donné pour l'individu associé [IndividuId = " . $membre->getIndividu()->getId() . "]."); + } $these = $membre->getProposition()->getThese(); $doctorant = $these->getDoctorant()->getIndividu(); @@ -862,11 +723,11 @@ class NotifierSoutenanceService extends NotifierService 'proposition' => $membre->getProposition(), 'url' => $url, ]); - $this->trigger($notif); + + return $notif; } else { - throw new InvalidArgumentException("Aucun mail de disponible (".__METHOD__."::TheseId#".$these->getId().")"); + throw new RuntimeException("Aucun mail de disponible (" . __METHOD__ . "::TheseId#" . $these->getId() . ")"); } - } /** @@ -876,11 +737,10 @@ class NotifierSoutenanceService extends NotifierService * @param string $email * @param string $url * @param array $avisArray + * @return \Notification\Notification */ - public function triggerEnvoiConvocationDoctorant(Doctorant $doctorant, Proposition $proposition, DateTime $date, string $email, string $url, array $avisArray) + public function createNotificationEnvoiConvocationDoctorant(Doctorant $doctorant, Proposition $proposition, DateTime $date, string $email, string $url, array $avisArray): Notification { - if ($email === null) throw new LogicException("Aucun mail n'est fourni pour l'envoi de la convocation.", 0); - $these = $proposition->getThese(); $pdcData = $this->getTheseService()->fetchInformationsPageDeCouverture($these); @@ -900,7 +760,8 @@ class NotifierSoutenanceService extends NotifierService 'avisArray' => $avisArray, ]); - $this->trigger($notif); + + return $notif; } /** @@ -910,11 +771,10 @@ class NotifierSoutenanceService extends NotifierService * @param string $email * @param string $url * @param array $avisArray + * @return \Notification\Notification */ - public function triggerEnvoiConvocationMembre(Membre $membre, Proposition $proposition, DateTime $date, string $email, string $url, array $avisArray) + public function createNotificationEnvoiConvocationMembre(Membre $membre, Proposition $proposition, DateTime $date, string $email, string $url, array $avisArray): Notification { - if ($email === null) throw new LogicException("Aucun mail n'est fourni pour l'envoi de la convocation.", 0); - $doctorant = $proposition->getThese()->getDoctorant(); $these = $proposition->getThese(); $pdcData = $this->getTheseService()->fetchInformationsPageDeCouverture($these); @@ -934,7 +794,28 @@ class NotifierSoutenanceService extends NotifierService 'avisArray' => $avisArray, ]); - $this->trigger($notif); + + return $notif; } + public function createNotificationTransmettreDocumentsDirectionThese(These $these, Proposition $proposition) : Notification + { + $vars = ['these' => $these, 'proposition' => $proposition, 'doctorant' => $these->getDoctorant()]; + $url = $this->getUrlService()->setVariables($vars); + $vars['Url'] = $url; + + $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::TRANSMETTRE_DOCUMENTS_DIRECTION, $vars); + $mail = $these->getDirecteursTheseEmails(); + if (count($mail) === 0) { + throw new RuntimeException("Aucun mail trouvés pour les directeurs de thèse"); + } + + $notif = new Notification(); + $notif + ->setSubject($rendu->getSujet()) + ->setTo($mail) + ->setBody($rendu->getCorps()); + + return $notif; + } } \ No newline at end of file diff --git a/module/Soutenance/src/Soutenance/Service/Notification/SoutenanceNotificationFactoryAwareTrait.php b/module/Soutenance/src/Soutenance/Service/Notification/SoutenanceNotificationFactoryAwareTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..7d2fdadbc0bf44514c65da0a89a0ba8e8ddff7a4 --- /dev/null +++ b/module/Soutenance/src/Soutenance/Service/Notification/SoutenanceNotificationFactoryAwareTrait.php @@ -0,0 +1,13 @@ +<?php + +namespace Soutenance\Service\Notification; + +trait SoutenanceNotificationFactoryAwareTrait +{ + protected SoutenanceNotificationFactory $soutenanceNotificationFactory; + + public function setSoutenanceNotificationFactory(SoutenanceNotificationFactory $soutenanceNotificationFactory): void + { + $this->soutenanceNotificationFactory = $soutenanceNotificationFactory; + } +} \ No newline at end of file diff --git a/module/Soutenance/src/Soutenance/Service/Notification/SoutenanceNotificationFactoryFactory.php b/module/Soutenance/src/Soutenance/Service/Notification/SoutenanceNotificationFactoryFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..0ff321eacce4809c92c6a6764d703e62d6ff48eb --- /dev/null +++ b/module/Soutenance/src/Soutenance/Service/Notification/SoutenanceNotificationFactoryFactory.php @@ -0,0 +1,71 @@ +<?php + +namespace Soutenance\Service\Notification; + +use Application\Service\Email\EmailTheseService; +use Application\Service\Role\RoleService; +use Application\Service\Utilisateur\UtilisateurService; +use Application\Service\Variable\VariableService; +use Individu\Service\IndividuService; +use Interop\Container\ContainerInterface; +use Notification\Factory\NotificationFactoryFactory; +use Soutenance\Service\Membre\MembreService; +use Soutenance\Service\Url\UrlService; +use These\Service\Acteur\ActeurService; +use These\Service\These\TheseService; +use UnicaenRenderer\Service\Rendu\RenduService; + +/** + * @author Unicaen + */ +class SoutenanceNotificationFactoryFactory extends NotificationFactoryFactory +{ + /** + * @var string + */ + protected string $class = SoutenanceNotificationFactory::class; + + /** + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface + */ + public function __invoke(ContainerInterface $container): SoutenanceNotificationFactory + { + /** @var SoutenanceNotificationFactory $factory */ + $factory = parent::__invoke($container); + + /** + * @var ActeurService $acteurService + * @var EmailTheseService $emailTheseService + * @var MembreService $membreService + * @var RoleService $roleService + * @var VariableService $variableService + * @var TheseService $theseService + * @var UtilisateurService $utilisateurService + * @var IndividuService $individuService + */ + $acteurService = $container->get(ActeurService::class); + $emailTheseService = $container->get(EmailTheseService::class); + $membreService = $container->get(MembreService::class); + $roleService = $container->get('RoleService'); + $theseService = $container->get('TheseService'); + $individuService = $container->get(IndividuService::class); + + $factory->setActeurService($acteurService); + $factory->setEmailTheseService($emailTheseService); + $factory->setMembreService($membreService); + $factory->setRoleService($roleService); + $factory->setTheseService($theseService); + $factory->setIndividuService($individuService); + + /** @var RenduService $renduService */ + $renduService = $container->get(RenduService::class); + $factory->setRenduService($renduService); + + /** @var UrlService $urlService */ + $urlService = $container->get(UrlService::class); + $factory->setUrlService($urlService); + + return $factory; + } +} diff --git a/module/Soutenance/src/Soutenance/Service/Notifier/NotifierSoutenanceServiceAwareTrait.php b/module/Soutenance/src/Soutenance/Service/Notifier/NotifierSoutenanceServiceAwareTrait.php deleted file mode 100644 index 1f22b05a7625cfa9a5380647c891c8cf06a8d759..0000000000000000000000000000000000000000 --- a/module/Soutenance/src/Soutenance/Service/Notifier/NotifierSoutenanceServiceAwareTrait.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -namespace Soutenance\Service\Notifier; - -trait NotifierSoutenanceServiceAwareTrait { - - /** @var NotifierSoutenanceService $notifierSoutenanceService */ - private $notifierSoutenanceService; - - /** - * @return NotifierSoutenanceService - */ - public function getNotifierSoutenanceService() - { - return $this->notifierSoutenanceService; - } - - /** - * @param NotifierSoutenanceService $notifierSoutenanceService - * @return NotifierSoutenanceService - */ - public function setNotifierSoutenanceService($notifierSoutenanceService) - { - $this->notifierSoutenanceService = $notifierSoutenanceService; - return $this->getNotifierSoutenanceService(); - } - - -} \ No newline at end of file diff --git a/module/Soutenance/src/Soutenance/Service/Notifier/NotifierSoutenanceServiceFactory.php b/module/Soutenance/src/Soutenance/Service/Notifier/NotifierSoutenanceServiceFactory.php deleted file mode 100644 index 24dd57a83374a0c050e4d9ec02da0d39d9a77728..0000000000000000000000000000000000000000 --- a/module/Soutenance/src/Soutenance/Service/Notifier/NotifierSoutenanceServiceFactory.php +++ /dev/null @@ -1,66 +0,0 @@ -<?php - -namespace Soutenance\Service\Notifier; - -use These\Service\Acteur\ActeurService; -use Application\Service\Email\EmailTheseService; -use Application\Service\Notification\NotificationFactory; -use Application\Service\Role\RoleService; -use These\Service\These\TheseService; -use Application\Service\Utilisateur\UtilisateurService; -use Application\Service\Variable\VariableService; -use Interop\Container\ContainerInterface; -use Laminas\Mvc\Console\View\ViewManager as ConsoleViewManager; -use Laminas\Mvc\View\Http\ViewManager as HttpViewManager; -use Laminas\View\Helper\Url as UrlHelper; -use Notification\Service\NotifierServiceFactory; -use Soutenance\Service\Membre\MembreService; - -class NotifierSoutenanceServiceFactory extends NotifierServiceFactory -{ - - protected $notifierServiceClass = NotifierSoutenanceService::class; - - /** - * @param ContainerInterface $container - * @return NotifierSoutenanceService - */ - public function __invoke(ContainerInterface $container) - { - /** @var NotifierSoutenanceService $service */ - $service = parent::__invoke($container); - - /** - * @var ActeurService $acteurService - * @var MembreService $membreService - * @var RoleService $roleService - * @var VariableService $variableService - * @var TheseService $theseService - * @var UtilisateurService $utilisateurService - */ - $acteurService = $container->get(ActeurService::class); - $membreService = $container->get(MembreService::class); - $roleService = $container->get('RoleService'); - $theseService = $container->get('TheseService'); - $emailTheseService = $container->get(EmailTheseService::class); - - /** @var HttpViewManager|ConsoleViewManager $vm */ - $vm = $container->get('ViewManager'); - /** @var UrlHelper $urlHelper */ -// $urlHelper = $vm->getHelperManager()->get('Url'); - $urlHelper = $container->get('ViewHelperManager')->get('Url'); - - /** @var NotificationFactory $notificationFactory */ - $notificationFactory = $container->get(NotificationFactory::class); - - $service->setNotificationFactory($notificationFactory); - $service->setUrlHelper($urlHelper); - $service->setActeurService($acteurService); - $service->setMembreService($membreService); - $service->setRoleService($roleService); - $service->setTheseService($theseService); - $service->setEmailTheseService($emailTheseService); - - return $service; - } -} \ No newline at end of file diff --git a/module/Soutenance/src/Soutenance/Service/Proposition/PropositionService.php b/module/Soutenance/src/Soutenance/Service/Proposition/PropositionService.php index 56abb513783ff9e4967e0d8a4054c3f9a8db326c..377f696b26134b8c193a9e4c873f1d5f728e391f 100644 --- a/module/Soutenance/src/Soutenance/Service/Proposition/PropositionService.php +++ b/module/Soutenance/src/Soutenance/Service/Proposition/PropositionService.php @@ -10,7 +10,6 @@ use Application\Entity\Db\Validation; use Application\Entity\Db\Variable; use Application\QueryBuilder\DefaultQueryBuilder; use Application\Service\BaseService; -use Application\Service\Notification\NotifierServiceAwareTrait; use Application\Service\UserContextServiceAwareTrait; use Application\Service\Variable\VariableServiceAwareTrait; use DateInterval; @@ -28,7 +27,8 @@ use Soutenance\Entity\Membre; use Soutenance\Entity\Proposition; use Soutenance\Provider\Validation\TypeValidation as TypeValidationSoutenance; use Soutenance\Service\Membre\MembreServiceAwareTrait; -use Soutenance\Service\Notifier\NotifierSoutenanceServiceAwareTrait; +use Soutenance\Service\Notification\SoutenanceNotificationFactoryAwareTrait; +use Notification\Service\NotifierServiceAwareTrait; use Soutenance\Service\Parametre\ParametreServiceAwareTrait; use Soutenance\Service\Validation\ValidatationServiceAwareTrait; use Structure\Entity\Db\EcoleDoctorale; @@ -45,7 +45,7 @@ class PropositionService extends BaseService use ActeurServiceAwareTrait; use ValidatationServiceAwareTrait; use NotifierServiceAwareTrait; - use NotifierSoutenanceServiceAwareTrait; + use SoutenanceNotificationFactoryAwareTrait; use ParametreServiceAwareTrait; use VariableServiceAwareTrait; use FichierStorageServiceAwareTrait; @@ -282,22 +282,42 @@ class PropositionService extends BaseService $validations = $this->getValidationService()->findValidationPropositionSoutenanceByThese($these); foreach ($validations as $validation) { $this->getValidationService()->historise($validation); - $this->getNotifierSoutenanceService()->triggerDevalidationProposition($validation); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationDevalidationProposition($validation); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } } $validationED = current($this->getValidationService()->getRepository()->findValidationByCodeAndThese(TypeValidation::CODE_VALIDATION_PROPOSITION_ED, $these)); if ($validationED) { $this->getValidationService()->historise($validationED); - $this->getNotifierSoutenanceService()->triggerDevalidationProposition($validationED); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationDevalidationProposition($validationED); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } } $validationUR = current($this->getValidationService()->getRepository()->findValidationByCodeAndThese(TypeValidation::CODE_VALIDATION_PROPOSITION_UR, $these)); if ($validationUR) { $this->getValidationService()->historise($validationUR); - $this->getNotifierSoutenanceService()->triggerDevalidationProposition($validationUR); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationDevalidationProposition($validationUR); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } } $validationBDD = current($this->getValidationService()->getRepository()->findValidationByCodeAndThese(TypeValidation::CODE_VALIDATION_PROPOSITION_BDD, $these)); if ($validationBDD) { $this->getValidationService()->historise($validationBDD); - $this->getNotifierSoutenanceService()->triggerDevalidationProposition($validationBDD); + try { + $notif = $this->soutenanceNotificationFactory->createNotificationDevalidationProposition($validationBDD); + $this->notifierService->trigger($notif); + } catch (\Notification\Exception\RuntimeException $e) { + // aucun destinataire, todo : cas à gérer ! + } } } diff --git a/module/Soutenance/src/Soutenance/Service/Proposition/PropositionServiceFactory.php b/module/Soutenance/src/Soutenance/Service/Proposition/PropositionServiceFactory.php index 013ea86861ce64911af697e99d1385377f77d82a..802741e351038be381ca73b9f4f8470044696f81 100644 --- a/module/Soutenance/src/Soutenance/Service/Proposition/PropositionServiceFactory.php +++ b/module/Soutenance/src/Soutenance/Service/Proposition/PropositionServiceFactory.php @@ -2,33 +2,32 @@ namespace Soutenance\Service\Proposition; +use Soutenance\Service\Notification\SoutenanceNotificationFactory; use These\Service\Acteur\ActeurService; use Structure\Service\Etablissement\EtablissementService; use Fichier\Service\Fichier\FichierStorageService; -use Application\Service\Notification\NotifierService; use Application\Service\UserContextService; use Application\Service\Variable\VariableService; use Doctrine\ORM\EntityManager; -use Interop\Container\ContainerInterface; +use Psr\Container\ContainerInterface; use Soutenance\Service\Membre\MembreService; -use Soutenance\Service\Notifier\NotifierSoutenanceService; +use Notification\Service\NotifierService; use Soutenance\Service\Parametre\ParametreService; use Soutenance\Service\Validation\ValidationService; class PropositionServiceFactory { /** - * @param ContainerInterface $container - * @return PropositionService + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface */ - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container): PropositionService { /** * @var EntityManager $entityManager * @var ActeurService $acteurService * @var ValidationService $validationService * @var NotifierService $notifierService - * @var NotifierSoutenanceService $notifierSoutenanceService * @var ParametreService $parametreService * @var VariableService $variableService * @var FichierStorageService $fileService @@ -40,7 +39,6 @@ class PropositionServiceFactory $acteurService = $container->get(ActeurService::class); $validationService = $container->get(ValidationService::class); $notifierService = $container->get(NotifierService::class); - $notifierSoutenanceService = $container->get(NotifierSoutenanceService::class); $parametreService = $container->get(ParametreService::class); $variableService = $container->get('VariableService'); $fileService = $container->get(FichierStorageService::class); @@ -48,13 +46,11 @@ class PropositionServiceFactory $membreService = $container->get(MembreService::class); $userContextService = $container->get('UserContextService'); - /** @var PropositionService $service */ $service = new PropositionService(); $service->setEntityManager($entityManager); $service->setActeurService($acteurService); $service->setValidationService($validationService); $service->setNotifierService($notifierService); - $service->setNotifierSoutenanceService($notifierSoutenanceService); $service->setParametreService($parametreService); $service->setVariableService($variableService); $service->setFichierStorageService($fileService); @@ -62,6 +58,10 @@ class PropositionServiceFactory $service->setMembreService($membreService); $service->setUserContextService($userContextService); + /** @var \Soutenance\Service\Notification\SoutenanceNotificationFactory $soutenanceNotificationFactory */ + $soutenanceNotificationFactory = $container->get(SoutenanceNotificationFactory::class); + $service->setSoutenanceNotificationFactory($soutenanceNotificationFactory); + return $service; } } diff --git a/module/Soutenance/src/Soutenance/Service/Url/UrlService.php b/module/Soutenance/src/Soutenance/Service/Url/UrlService.php new file mode 100644 index 0000000000000000000000000000000000000000..fd1131b1ac690b26a99467d150640fbd3014b22b --- /dev/null +++ b/module/Soutenance/src/Soutenance/Service/Url/UrlService.php @@ -0,0 +1,85 @@ +<?php + +namespace Soutenance\Service\Url; + +use DateTime; +use Laminas\View\Renderer\PhpRenderer; +use Soutenance\Controller\PropositionController; + +/** + * TODO faire remonter un service père qui embarque la mécanique de base + */ +class UrlService { + + /** @var PhpRenderer */ + protected $renderer; + /** @var array */ + protected $variables; + + /** + * @param PhpRenderer $renderer + * @return UrlService + */ + public function setRenderer($renderer) : UrlService + { + $this->renderer = $renderer; + return $this; + } + + /** + * @param array $variables + * @return UrlService + */ + public function setVariables(array $variables): UrlService + { + $this->variables = $variables; + return $this; + } + + /** + * @param string + * @return mixed + */ + public function getVariable(string $key) + { + if (! isset($this->variables[$key])) return null; + return $this->variables[$key]; + } + + /** + * @noinspection PhpUnusedAliasInspection + * @return string + */ + public function getSermentDocteur() : string + { + $these = $this->variables['these']; + /** @see PropositionController::genererSermentAction() */ + $url = $this->renderer->url('soutenance/proposition/generer-serment', ['these' => $these->getId()], ['force_canonical' => 'true'], true); + return $url; + } + + /** + * @noinspection PhpUnusedAliasInspection + * @return string + */ + public function getProcesVerbal() : string + { + $these = $this->variables['these']; + /** @see \Soutenance\Controller\PresoutenanceController::procesVerbalSoutenanceAction() */ + $url = $this->renderer->url('soutenance/presoutenance/proces-verbal-soutenance', ['these' => $these->getId()], ['force_canonical' => 'true'], true); + return $url; + } + + /** + * @noinspection PhpUnusedAliasInspection + * @return string + */ + public function getRapportSoutenance() : string + { + $these = $this->variables['these']; + /** @see \Soutenance\Controller\PresoutenanceController::rapportSoutenanceAction() */ + $url = $this->renderer->url('soutenance/presoutenance/rapport-soutenance', ['these' => $these->getId()], ['force_canonical' => 'true'], true); + return $url; + } + +} \ No newline at end of file diff --git a/module/Soutenance/src/Soutenance/Service/Url/UrlServiceAwareTrait.php b/module/Soutenance/src/Soutenance/Service/Url/UrlServiceAwareTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..ce0ba0f501b8c1ef4f71bfc113f667432dd60a89 --- /dev/null +++ b/module/Soutenance/src/Soutenance/Service/Url/UrlServiceAwareTrait.php @@ -0,0 +1,24 @@ +<?php + +namespace Soutenance\Service\Url; + +trait UrlServiceAwareTrait { + + private UrlService $urlService; + + /** + * @return UrlService + */ + public function getUrlService(): UrlService + { + return $this->urlService; + } + + /** + * @param UrlService $urlService + */ + public function setUrlService(UrlService $urlService): void + { + $this->urlService = $urlService; + } +} \ No newline at end of file diff --git a/module/Soutenance/src/Soutenance/Service/Url/UrlServiceFactory.php b/module/Soutenance/src/Soutenance/Service/Url/UrlServiceFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..f7e38d058d3b328a656409e22fdaf45475e17c08 --- /dev/null +++ b/module/Soutenance/src/Soutenance/Service/Url/UrlServiceFactory.php @@ -0,0 +1,27 @@ +<?php + +namespace Soutenance\Service\Url; + +use Interop\Container\ContainerInterface; +use Laminas\View\Renderer\PhpRenderer; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; + +class UrlServiceFactory { + + /** + * @param ContainerInterface $container + * @return UrlService + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function __invoke(ContainerInterface $container) : UrlService + { + /* @var PhpRenderer $renderer */ + $renderer = $container->get('ViewRenderer'); + + $service = new UrlService(); + $service->setRenderer($renderer); + return $service; + } +} \ No newline at end of file diff --git a/module/Soutenance/view/soutenance/notification/avis-defavorable.phtml b/module/Soutenance/view/soutenance/notification/avis-defavorable.phtml index bfae5296a8b6961b535d9842b9bf812cb7987168..a7096d7dcb78ff3af9e7b883849e1e1c7a0f2783 100644 --- a/module/Soutenance/view/soutenance/notification/avis-defavorable.phtml +++ b/module/Soutenance/view/soutenance/notification/avis-defavorable.phtml @@ -7,7 +7,7 @@ use Soutenance\Entity\Avis; use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerAvisDefavorable() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationAvisDefavorable() * * @var PhpRenderer $this * @var These $these @@ -51,13 +51,6 @@ $justification = true; </li> </ul> -<?php - //$emailBDD = [ $this->fetchEmailBdd($these) ]; - //$emailsDirecteurs = $this->fetchEmailEncadrants($these); - //$emailsED = $this->fetchEmailEcoleDoctorale($these); - //$emailsUR = $this->fetchEmailUniteRecherche($these); -?> - <?php if ($justification) : ?> <p> Vous avez reçu ce mail car : diff --git a/module/Soutenance/view/soutenance/notification/avis-favorable.phtml b/module/Soutenance/view/soutenance/notification/avis-favorable.phtml index ad84a94e6d478eb98a662c070b1244eeda6b1033..bbd5a446d2154ddfda13ead493721dc05c7a77fc 100644 --- a/module/Soutenance/view/soutenance/notification/avis-favorable.phtml +++ b/module/Soutenance/view/soutenance/notification/avis-favorable.phtml @@ -7,7 +7,7 @@ use Soutenance\Entity\Avis; use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerAvisFavorable() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationAvisFavorable() * * @var PhpRenderer $this * @var These $these @@ -49,13 +49,6 @@ $justification = true; </li> </ul> -<?php -//$emailBDD = [ $this->fetchEmailBdd($these) ]; -//$emailsDirecteurs = $this->fetchEmailEncadrants($these); -//$emailsED = $this->fetchEmailEcoleDoctorale($these); -//$emailsUR = $this->fetchEmailUniteRecherche($these); -?> - <?php if ($justification) : ?> <p> Vous avez reçu ce mail car : diff --git a/module/Soutenance/view/soutenance/notification/connexion-rapporteur.phtml b/module/Soutenance/view/soutenance/notification/connexion-rapporteur.phtml index 719d8f3d83b7014a2dfd6ad7264adb7fd2a633be..bed133ad11278608525763681f56200597c138d1 100644 --- a/module/Soutenance/view/soutenance/notification/connexion-rapporteur.phtml +++ b/module/Soutenance/view/soutenance/notification/connexion-rapporteur.phtml @@ -4,7 +4,7 @@ use These\Entity\Db\These; use Application\View\Renderer\PhpRenderer;use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerConnexionRapporteur() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationConnexionRapporteur() * * @var PhpRenderer $this * @var Proposition $proposition diff --git a/module/Soutenance/view/soutenance/notification/convocation-doctorant.phtml b/module/Soutenance/view/soutenance/notification/convocation-doctorant.phtml index 4f6e25e48d830f595153ff9c3965e67917e4d72d..857091b6693fe1e015fb9ec33298ec11e81973ae 100644 --- a/module/Soutenance/view/soutenance/notification/convocation-doctorant.phtml +++ b/module/Soutenance/view/soutenance/notification/convocation-doctorant.phtml @@ -6,7 +6,7 @@ use Soutenance\Entity\Avis; use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerEnvoiConvocationDoctorant() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationEnvoiConvocationDoctorant() * @var These $these * @var Proposition $proposition * @var Doctorant $doctorant diff --git a/module/Soutenance/view/soutenance/notification/convocation-membre.phtml b/module/Soutenance/view/soutenance/notification/convocation-membre.phtml index 117de135e4fd48ed135ad3c533b16faf67704565..6e9917c5564f6bc293d7e49d4b2ef4c836f41b5b 100644 --- a/module/Soutenance/view/soutenance/notification/convocation-membre.phtml +++ b/module/Soutenance/view/soutenance/notification/convocation-membre.phtml @@ -7,7 +7,7 @@ use Soutenance\Entity\Membre; use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerEnvoiConvocationMembre() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationEnvoiConvocationMembre() * @var These $these * @var Proposition $proposition * @var Membre $membre diff --git a/module/Soutenance/view/soutenance/notification/demande-avis-soutenance.phtml b/module/Soutenance/view/soutenance/notification/demande-avis-soutenance.phtml index 3eff148934190e483820b713699010c3cb96e5dd..a00fb932409b891e996a5f360361874b0d3fd5fc 100644 --- a/module/Soutenance/view/soutenance/notification/demande-avis-soutenance.phtml +++ b/module/Soutenance/view/soutenance/notification/demande-avis-soutenance.phtml @@ -5,7 +5,7 @@ use Soutenance\Entity\Membre; use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerDemandeAvisSoutenance() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationDemandeAvisSoutenance() * @var These $these * @var Proposition $proposition * @var Membre $membre diff --git a/module/Soutenance/view/soutenance/notification/devalidation.phtml b/module/Soutenance/view/soutenance/notification/devalidation.phtml index 189fe085f462a93ffbd2e7be6d36f9fcb8ee63dc..7e2f3048ee0938f05f6f9136db049718f8afd1db 100644 --- a/module/Soutenance/view/soutenance/notification/devalidation.phtml +++ b/module/Soutenance/view/soutenance/notification/devalidation.phtml @@ -5,7 +5,7 @@ use Application\Entity\Db\Validation; use Application\View\Renderer\PhpRenderer; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerDevalidationProposition() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationDevalidationProposition() * @var PhpRenderer $this * @var Validation $validation * @var These $these diff --git a/module/Soutenance/view/soutenance/notification/engagement-impartialite-annulation.phtml b/module/Soutenance/view/soutenance/notification/engagement-impartialite-annulation.phtml index 031d5bdc90f881141e6d9e8248c8e46260c8386f..36f85e701a10414b24eae5bbbcbdc8ce37e1df44 100644 --- a/module/Soutenance/view/soutenance/notification/engagement-impartialite-annulation.phtml +++ b/module/Soutenance/view/soutenance/notification/engagement-impartialite-annulation.phtml @@ -5,7 +5,7 @@ use Soutenance\Entity\Membre; use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerAnnulationEngagementImpartialite() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationAnnulationEngagementImpartialite() * @var These $these * @var Proposition $proposition * @var Membre $membre diff --git a/module/Soutenance/view/soutenance/notification/engagement-impartialite-demande.phtml b/module/Soutenance/view/soutenance/notification/engagement-impartialite-demande.phtml index e534f697a3637a5f8f11993c749c4e087c565a5f..8b0d12789a22e3ac3c97580b32befb71156282a2 100644 --- a/module/Soutenance/view/soutenance/notification/engagement-impartialite-demande.phtml +++ b/module/Soutenance/view/soutenance/notification/engagement-impartialite-demande.phtml @@ -5,7 +5,7 @@ use Soutenance\Entity\Membre; use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerDemandeSignatureEngagementImpartialite() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationDemandeSignatureEngagementImpartialite() * @var These $these * @var Proposition $proposition * @var Membre $membre diff --git a/module/Soutenance/view/soutenance/notification/engagement-impartialite-refus.phtml b/module/Soutenance/view/soutenance/notification/engagement-impartialite-refus.phtml index 707cd82cdd293ad021d29cdcfa6fb2762b8f308e..16bedb0c14c8f24577cd44117aa6934f1425ed24 100644 --- a/module/Soutenance/view/soutenance/notification/engagement-impartialite-refus.phtml +++ b/module/Soutenance/view/soutenance/notification/engagement-impartialite-refus.phtml @@ -5,7 +5,7 @@ use Soutenance\Entity\Membre; use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerRefusEngagementImpartialite() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationRefusEngagementImpartialite() * @var These $these * @var Proposition $proposition * @var Membre $membre @@ -23,11 +23,6 @@ $justification = true; <strong><?php echo $these->getTitre(); ?></strong>. </p> -<?php - //$emails = $this->fetchEmailActeursDirects($these); - //$emails[] = $this->fetchEmailBdd($these); -?> -?> <?php if ($justification) : ?> <p> Vous avez reçu ce mail car : diff --git a/module/Soutenance/view/soutenance/notification/engagement-impartialite-signature.phtml b/module/Soutenance/view/soutenance/notification/engagement-impartialite-signature.phtml index da8eed004ce29f3921e0bbe842887364180d75b0..1e39542417f9532d231aaa4034e89dd1e0707bff 100644 --- a/module/Soutenance/view/soutenance/notification/engagement-impartialite-signature.phtml +++ b/module/Soutenance/view/soutenance/notification/engagement-impartialite-signature.phtml @@ -5,7 +5,7 @@ use Soutenance\Entity\Membre; use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerSignatureEngagementImpartialite() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationSignatureEngagementImpartialite() * @var These $these * @var Proposition $proposition * @var Membre $membre diff --git a/module/Soutenance/view/soutenance/notification/feu-vert-soutenance.phtml b/module/Soutenance/view/soutenance/notification/feu-vert-soutenance.phtml index bd82ab1f7461f41660792a58fdcf09fb68061736..4435246b7c3433e0dbfec4fe5bc3a5baa0a4b3aa 100644 --- a/module/Soutenance/view/soutenance/notification/feu-vert-soutenance.phtml +++ b/module/Soutenance/view/soutenance/notification/feu-vert-soutenance.phtml @@ -7,7 +7,7 @@ use Soutenance\Entity\Avis; use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerFeuVertSoutenance() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationFeuVertSoutenance() * * @var PhpRenderer $this * @var These $these diff --git a/module/Soutenance/view/soutenance/notification/init-compte.phtml b/module/Soutenance/view/soutenance/notification/init-compte.phtml index 486cbe98ddb4611e82021c63ea244cd9027567b9..a0f5de34d330493206421e63aadb0c7a566210a0 100644 --- a/module/Soutenance/view/soutenance/notification/init-compte.phtml +++ b/module/Soutenance/view/soutenance/notification/init-compte.phtml @@ -4,7 +4,7 @@ use These\Entity\Db\These; use Application\View\Renderer\PhpRenderer; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerInitialisationCompte() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationInitialisationCompte() * * @var PhpRenderer $this * @var These $these diff --git a/module/Soutenance/view/soutenance/notification/presoutenance.phtml b/module/Soutenance/view/soutenance/notification/presoutenance.phtml index 4edf9953d0d355cb4036b09dac73fc345b561894..09d5d08fcd980fe670982aec85adebe786e9eab8 100644 --- a/module/Soutenance/view/soutenance/notification/presoutenance.phtml +++ b/module/Soutenance/view/soutenance/notification/presoutenance.phtml @@ -4,7 +4,7 @@ use These\Entity\Db\These; use Application\View\Renderer\PhpRenderer; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerNotificationPresoutenance() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationPresoutenance() * @var PhpRenderer $this * @var These $these */ @@ -35,9 +35,6 @@ $justification = true; <p> Vous pouvez maintenance procéder à la saisie des informations liées à la soutenance : <a href="<?php echo $urlRetour;?>"> soutenance de <?php echo $these->getDoctorant()->getIndividu()->getNomComplet(false,false,false, true); ?></a>. </p> -<?php - // $email = $this->fetchEmailBdd($these); -?> <?php if ($justification) : ?> <p> Vous avez reçu ce mail car : diff --git a/module/Soutenance/view/soutenance/notification/refus.phtml b/module/Soutenance/view/soutenance/notification/refus.phtml index ed5311a210b96a7289c29ab62b3216dedd23b73a..f462b62b68313d5870b4c3c5e35f54029967aeac 100644 --- a/module/Soutenance/view/soutenance/notification/refus.phtml +++ b/module/Soutenance/view/soutenance/notification/refus.phtml @@ -8,7 +8,7 @@ use Application\View\Renderer\PhpRenderer; use UnicaenAuth\Entity\Db\RoleInterface; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerRefusPropositionSoutenance() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationRefusPropositionSoutenance() * @var PhpRenderer $this * @var These $these * @var Individu $acteur diff --git a/module/Soutenance/view/soutenance/notification/retard-rapporteur.phtml b/module/Soutenance/view/soutenance/notification/retard-rapporteur.phtml index 931bb29a34c10bb9d15512aaf63538d799577b97..052003541e08cdcfb1a41f5068a8fe80d3292510 100644 --- a/module/Soutenance/view/soutenance/notification/retard-rapporteur.phtml +++ b/module/Soutenance/view/soutenance/notification/retard-rapporteur.phtml @@ -5,7 +5,7 @@ use These\Entity\Db\These; use Application\View\Renderer\PhpRenderer;use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerNotificationRapporteurRetard() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationNotificationRapporteurRetard() * * @var PhpRenderer $this * @var These $these diff --git a/module/Soutenance/view/soutenance/notification/stopper-demarche-soutenance.phtml b/module/Soutenance/view/soutenance/notification/stopper-demarche-soutenance.phtml index 6f172423d34c5f05caed8a03cfe14500a0aeb9e3..215b520a5c531c1c400f6ed0f3757f6e5d2d6d91 100644 --- a/module/Soutenance/view/soutenance/notification/stopper-demarche-soutenance.phtml +++ b/module/Soutenance/view/soutenance/notification/stopper-demarche-soutenance.phtml @@ -7,7 +7,7 @@ use Soutenance\Entity\Avis; use Soutenance\Entity\Proposition; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerStopperDemarcheSoutenance() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationStopperDemarcheSoutenance() * * @var PhpRenderer $this * @var These $these diff --git a/module/Soutenance/view/soutenance/notification/tous-avis-soutenance.phtml b/module/Soutenance/view/soutenance/notification/tous-avis-soutenance.phtml index 76f30e45c9e07cc956b3e00b8bdaa58bfed81b26..9292a6e03a0333c327e08e9011ce30537afd1b96 100644 --- a/module/Soutenance/view/soutenance/notification/tous-avis-soutenance.phtml +++ b/module/Soutenance/view/soutenance/notification/tous-avis-soutenance.phtml @@ -3,7 +3,7 @@ use These\Entity\Db\These; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerAvisRendus() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationAvisRendus() * * @var These $these */ @@ -24,9 +24,6 @@ $justification = true; <a href="<?php echo $url; ?>">page de gestion de la soutenance</a>. </p> -<?php -// $email = $this->fetchEmailBdd($these); -?> <?php if ($justification) : ?> <p> Vous avez reçu ce mail car : diff --git a/module/Soutenance/view/soutenance/notification/validation-acteur.phtml b/module/Soutenance/view/soutenance/notification/validation-acteur.phtml index bd723e63f1052e7d7c65533fa73a1b9c4cee4db2..b1d3d1b3b0bc8c9a1d8aa65670b381992defc40d 100644 --- a/module/Soutenance/view/soutenance/notification/validation-acteur.phtml +++ b/module/Soutenance/view/soutenance/notification/validation-acteur.phtml @@ -5,7 +5,7 @@ use Application\Entity\Db\Validation; use Application\View\Renderer\PhpRenderer; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerValidationProposition() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationValidationProposition() * @var PhpRenderer $this * @var Validation $validation * @var These $these diff --git a/module/Soutenance/view/soutenance/notification/validation-soutenance.phtml b/module/Soutenance/view/soutenance/notification/validation-soutenance.phtml index 59322ae9e5527ee749510d49b75191c79a5676b3..a026c672739d290fa380bc81836f44b0363652dc 100644 --- a/module/Soutenance/view/soutenance/notification/validation-soutenance.phtml +++ b/module/Soutenance/view/soutenance/notification/validation-soutenance.phtml @@ -4,7 +4,7 @@ use These\Entity\Db\These; use Application\View\Renderer\PhpRenderer; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerNotificationPropositionValidee() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationPropositionValidee() * @var PhpRenderer $this * @var These $these */ @@ -52,12 +52,6 @@ $justification = true; </p> <?php endif; ?> -<?php - // $emailsBDD = [ $this->fetchEmailBdd($these) ]; - // $emailsED = $this->fetchEmailEcoleDoctorale($these); - // $emailsUR = $this->fetchEmailUniteRecherche($these); - // $emailsActeurs = $this->fetchEmailActeursDirects($these); -?> <?php if ($justification) : ?> <p> Vous avez reçu ce mail car : diff --git a/module/Soutenance/view/soutenance/notification/validation-structure.phtml b/module/Soutenance/view/soutenance/notification/validation-structure.phtml index 324ab77da7a8c1cce34d8b060b88fe951a580517..cc4f1351a58d2b0b0de32dda5dedb1cf494b7340 100644 --- a/module/Soutenance/view/soutenance/notification/validation-structure.phtml +++ b/module/Soutenance/view/soutenance/notification/validation-structure.phtml @@ -4,9 +4,9 @@ use These\Entity\Db\These; use Application\View\Renderer\PhpRenderer; /** - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerNotificationUniteRechercheProposition() - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerNotificationEcoleDoctoraleProposition() - * @see \Soutenance\Service\Notifier\NotifierSoutenanceService::triggerNotificationBureauDesDoctoratsProposition() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationUniteRechercheProposition() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationEcoleDoctoraleProposition() + * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationBureauDesDoctoratsProposition() * @var PhpRenderer $this * @var These $these * @var string $type diff --git a/module/Soutenance/view/soutenance/presoutenance/presoutenance.phtml b/module/Soutenance/view/soutenance/presoutenance/presoutenance.phtml index d6e04cbaa2e287c63e9cac5727fd557bf5588876..bea84b5b55bbbc0a898b78519cc118beedabb4fa 100644 --- a/module/Soutenance/view/soutenance/presoutenance/presoutenance.phtml +++ b/module/Soutenance/view/soutenance/presoutenance/presoutenance.phtml @@ -332,6 +332,15 @@ $canSimulerRemonter = $this->isAllowed(PresoutenancePrivileges::getResourceId(Pr <span class="fas fa-list-alt"></span>Générer les convocations </a> <?php endif; ?> + + <?php if ($canGenererDocument) : ?> + <a <?php /** @see \Soutenance\Controller\PresoutenanceController::transmettreDocumentsDirectionTheseAction() */ ?> + href="<?php echo $this->url('soutenance/presoutenance/transmettre-documents-direction-these', ['these' => $these->getId()], [], true); ?>" + class="btn btn-primary action" + > + <span class="icon icon-notifier"></span>Transmettre documents à la direction de thèse + </a> + <?php endif; ?> </div> </div> diff --git a/module/StepStar/config/module.config.php b/module/StepStar/config/module.config.php index 39ccee922c57ccb544a061f9f61e395874889291..173ccec08b3211e49d932bf8a453be05c4fec606 100755 --- a/module/StepStar/config/module.config.php +++ b/module/StepStar/config/module.config.php @@ -29,8 +29,6 @@ use StepStar\Service\Log\LogService; use StepStar\Service\Log\LogServiceFactory; use StepStar\Service\Log\Recherche\LogSearchService; use StepStar\Service\Log\Recherche\LogSearchServiceFactory; -use StepStar\Service\Notification\NotificationService; -use StepStar\Service\Notification\NotificationServiceFactory; use StepStar\Service\Oai\OaiService; use StepStar\Service\Oai\OaiServiceFactory; use StepStar\Service\Soap\SoapClient; @@ -423,7 +421,6 @@ return [ LogSearchService::class => LogSearchServiceFactory::class, FetchService::class => FetchServiceFactory::class, - NotificationService::class => NotificationServiceFactory::class, ], ], 'controllers' => [ diff --git a/module/StepStar/src/StepStar/Notification/EnvoisEnErreurNotification.php b/module/StepStar/src/StepStar/Notification/EnvoisEnErreurNotification.php deleted file mode 100644 index fc642c6a6f41de8126026cd51763ce1be84efcfb..0000000000000000000000000000000000000000 --- a/module/StepStar/src/StepStar/Notification/EnvoisEnErreurNotification.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -namespace StepStar\Notification; - -use Notification\Notification; - -class EnvoisEnErreurNotification extends Notification -{ - /** - * @var \StepStar\Entity\Db\Log[] - */ - private array $logs; - - /** - * @param \StepStar\Entity\Db\Log[] $logs - */ - public function setLogs(array $logs): void - { - $this->logs = $logs; - } - - public function prepare() - { - parent::prepare(); - - $this->setTemplateVariables([ - 'logs' => $this->logs, - ]); - } -} \ No newline at end of file diff --git a/module/StepStar/src/StepStar/Service/Notification/NotificationService.php b/module/StepStar/src/StepStar/Service/Notification/NotificationService.php deleted file mode 100644 index 11e7181b79eeda945a6809db602c57dfa9d9715e..0000000000000000000000000000000000000000 --- a/module/StepStar/src/StepStar/Service/Notification/NotificationService.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -namespace StepStar\Service\Notification; - -use Application\Service\Notification\NotifierServiceAwareTrait; -use StepStar\Notification\EnvoisEnErreurNotification; - -class NotificationService -{ - use NotifierServiceAwareTrait; - - /** - * @param \StepStar\Entity\Db\Log[] $logs - * @return \StepStar\Notification\EnvoisEnErreurNotification - */ - public function createEnvoisEnErreurNotification(array $logs): EnvoisEnErreurNotification - { - $notif = new EnvoisEnErreurNotification(); - $notif->setLogs($logs); - - return $notif; - } - - /** - * @param \StepStar\Notification\EnvoisEnErreurNotification $notif - * @throws \Notification\Exception\NotificationException - */ - public function sendEnvoisEnErreurNotification(EnvoisEnErreurNotification $notif) - { - $this->notifierService->trigger($notif); - } -} \ No newline at end of file diff --git a/module/StepStar/src/StepStar/Service/Notification/NotificationServiceFactory.php b/module/StepStar/src/StepStar/Service/Notification/NotificationServiceFactory.php deleted file mode 100644 index d9a91f97ffe9626967a8fb65f50a76b65f8c7fad..0000000000000000000000000000000000000000 --- a/module/StepStar/src/StepStar/Service/Notification/NotificationServiceFactory.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -namespace StepStar\Service\Notification; - -use Application\Service\Notification\NotifierService; -use Psr\Container\ContainerInterface; - -class NotificationServiceFactory -{ - /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - */ - public function __invoke(ContainerInterface $container): NotificationService - { - /** @var NotifierService $notifierService */ - $notifierService = $container->get(NotifierService::class); - - $service = new NotificationService(); - $service->setNotifierService($notifierService); - - return $service; - } -} \ No newline at end of file diff --git a/module/These/config/others/notification.config.php b/module/These/config/others/notification.config.php new file mode 100644 index 0000000000000000000000000000000000000000..1899cd18b48f32f1f4500ffa682f9de4548093ec --- /dev/null +++ b/module/These/config/others/notification.config.php @@ -0,0 +1,14 @@ +<?php + +namespace These; + +use These\Service\Notification\TheseNotificationFactory; +use These\Service\Notification\TheseNotificationFactoryFactory; + +return [ + 'service_manager' => [ + 'factories' => [ + TheseNotificationFactory::class => TheseNotificationFactoryFactory::class, + ], + ], +]; \ No newline at end of file diff --git a/module/These/src/These/Controller/CoEncadrantController.php b/module/These/src/These/Controller/CoEncadrantController.php index 1ecb654e5574fe55396dee689e89b99056c9e19e..bd4d4cca1cfbc1fe084894eb1a93d36413197fc0 100644 --- a/module/These/src/These/Controller/CoEncadrantController.php +++ b/module/These/src/These/Controller/CoEncadrantController.php @@ -2,6 +2,7 @@ namespace These\Controller; +use Application\Controller\UtilisateurController; use DateTime; use Fichier\Service\Fichier\FichierStorageServiceAwareTrait; use Fichier\Service\Storage\Adapter\Exception\StorageAdapterException; @@ -99,7 +100,8 @@ class CoEncadrantController extends AbstractActionController { $form = $this->getRechercherCoEncadrantForm(); $form->setAttribute('action', $this->url()->fromRoute('co-encadrant/ajouter-co-encadrant', [], [], true)); - $form->setUrlCoEncadrant($this->url()->fromRoute('utilisateur/rechercher-individu', [], ["query" => ['type' => Individu::TYPE_ACTEUR]], true)); + /** @see UtilisateurController::rechercherIndividuAction() */ + $form->setUrlCoEncadrant($this->url()->fromRoute('utilisateur/rechercher-individu', [], ["query" => []], true)); $request = $this->getRequest(); if ($request->isPost()) { diff --git a/module/These/src/These/Controller/PresidentJuryController.php b/module/These/src/These/Controller/PresidentJuryController.php index 6a53c7328e0dc83fdf3f3153ef3c5b302362e595..063a6700113ea63748509996f521536b074bda24 100644 --- a/module/These/src/These/Controller/PresidentJuryController.php +++ b/module/These/src/These/Controller/PresidentJuryController.php @@ -37,23 +37,17 @@ class PresidentJuryController extends AbstractActionController } /** - * @throws \Notification\Exception\NotificationImpossibleException * @todo : déplacer dans la module Depot. */ 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->depotService->notifierCorrectionsApportees($these, $utilisateur); - if ($message[0] === 'success') $this->flashMessenger()->addSuccessMessage($message[1]); - if ($message[0] === 'error') $this->flashMessenger()->addErrorMessage($message[1]); + $resultArray = $this->depotService->notifierCorrectionsApportees($these); + if ($resultArray[0] === 'success') $this->flashMessenger()->addSuccessMessage($resultArray[1]); + if ($resultArray[0] === 'error') $this->flashMessenger()->addErrorMessage($resultArray[1]); return $this->redirect()->toRoute('president-jury', [], [], true); } diff --git a/module/These/src/These/Entity/Db/Repository/TheseRepository.php b/module/These/src/These/Entity/Db/Repository/TheseRepository.php index 3ad23143fe8243cac23e0bb92bcca26b2a6be570..6bdb5c9fe545764e1df8dbc0e87bd787419aea15 100644 --- a/module/These/src/These/Entity/Db/Repository/TheseRepository.php +++ b/module/These/src/These/Entity/Db/Repository/TheseRepository.php @@ -37,7 +37,7 @@ class TheseRepository extends DefaultEntityRepository ->andWhere('t.dateSoutenance is not null'); return array_filter($qb->getQuery()->getResult(), function (These $these) { - return $these->isDateButoirDepotVersionCorrigeeDepassee(); + return $these->isDateButoirDepotVersionCorrigeeDepassee($these->getDateSoutenance()); }); } diff --git a/module/These/src/These/Entity/Db/These.php b/module/These/src/These/Entity/Db/These.php index 6e828850dffe024a7652e5cd9618a91755c0d105..84f49dbf927ba669163444ccfa07f3993248a906 100644 --- a/module/These/src/These/Entity/Db/These.php +++ b/module/These/src/These/Entity/Db/These.php @@ -2,16 +2,12 @@ namespace These\Entity\Db; -use Application\Constants; use Application\Entity\Db\Financement; use Application\Entity\Db\Rapport; use Application\Entity\Db\Role; use Application\Entity\Db\TitreAcces; use Application\Entity\Db\TypeValidation; use Application\Entity\Db\Validation; -use Assert\Assertion; -use BadMethodCallException; -use DateInterval; use DateTime; use Depot\Entity\Db\Attestation; use Depot\Entity\Db\Diffusion; @@ -44,6 +40,8 @@ class These implements HistoriqueAwareInterface, ResourceInterface { use HistoriqueAwareTrait; use SourceAwareTrait; + + use TheseCorrectionAwareTrait; const RESOURCE_ID = 'These'; @@ -71,31 +69,6 @@ class These implements HistoriqueAwareInterface, ResourceInterface self::RESULTAT_ADMIS => "ADM", ]; - const CORRECTION_AUTORISEE_OBLIGATOIRE = 'obligatoire'; - const CORRECTION_AUTORISEE_FACULTATIVE = 'facultative'; - - public static $correctionsLibelles = [ - self::CORRECTION_AUTORISEE_OBLIGATOIRE => "Obligatoire", - self::CORRECTION_AUTORISEE_FACULTATIVE => "Facultative", - ]; - public static $correctionsLibellesPluriels = [ - self::CORRECTION_AUTORISEE_OBLIGATOIRE => "Obligatoires", - self::CORRECTION_AUTORISEE_FACULTATIVE => "Facultatives", - ]; - - const CORRECTION_OBLIGATOIRE_INTERVAL = 'P3M'; - const CORRECTION_OBLIGATOIRE_INTERVAL_TO_STRING = '3 mois'; - const CORRECTION_FACULTATIVE_INTERVAL = 'P2M'; - const CORRECTION_FACULTATIVE_INTERVAL_TO_STRING = '2 mois'; - - const CORRECTION_SURSIS_INTERVAL = 'P7D'; - const CORRECTION_SURSIS_INTERVAL_TO_STRING = '1 semaine'; - - const CORRECTION_AUTORISEE_FORCAGE_NON = null; // pas de forçage - const CORRECTION_AUTORISEE_FORCAGE_AUCUNE = 'aucune'; // aucune correction autorisée - const CORRECTION_AUTORISEE_FORCAGE_OBLIGATOIRE = self::CORRECTION_AUTORISEE_OBLIGATOIRE; // corrections obligatoires autorisées - const CORRECTION_AUTORISEE_FORCAGE_FACULTATIVE = self::CORRECTION_AUTORISEE_FACULTATIVE; // corrections facultatives autorisées - /** * @var integer */ @@ -178,26 +151,6 @@ class These implements HistoriqueAwareInterface, ResourceInterface */ private $libelleUniteRecherche; - /** - * @var string - */ - private $correctionAutorisee; - - /** - * @var string - */ - private $correctionAutoriseeForcee; - - /** - * @var DateTime - */ - private $dateButoirDepotVersionCorrigeeAvecSursis = null; - - /** - * @var string - */ - private $correctionEffectuee; - /** * @var string */ @@ -477,7 +430,7 @@ class These implements HistoriqueAwareInterface, ResourceInterface /** * @return DateTime|null */ - public function getDateSoutenance() + public function getDateSoutenance(): ?DateTime { return $this->dateSoutenance; } @@ -485,16 +438,16 @@ class These implements HistoriqueAwareInterface, ResourceInterface /** * @return string */ - public function getDateSoutenanceToString() + public function getDateSoutenanceToString(): string { return Util::formattedDate($this->getDateSoutenance()); } /** - * @param DateTime $dateSoutenance + * @param \DateTime|null $dateSoutenance * @return self */ - public function setDateSoutenance(DateTime $dateSoutenance = null) + public function setDateSoutenance(?DateTime $dateSoutenance = null): self { $this->dateSoutenance = $dateSoutenance; @@ -644,192 +597,6 @@ class These implements HistoriqueAwareInterface, ResourceInterface return $this; } - /** - * Indique si le témoin indique que des corrections sont autorisées. - * NB: Par défaut le forçage du témoin est pris en compte - * - * @param bool $prendreEnCompteLeForcage Faut-il prendre en compte le forçage éventuel ? - * @return bool - */ - public function isCorrectionAutorisee(bool $prendreEnCompteLeForcage = true): bool - { - return (bool) $this->getCorrectionAutorisee($prendreEnCompteLeForcage); - } - - /** - * Indique si le témoin de corrections autorisées fait l'objet d'un forçage. - * - * @return bool - */ - public function isCorrectionAutoriseeForcee(): bool - { - return $this->getCorrectionAutoriseeForcee() !== null; - } - - /** - * Retourne la valeur du témoin de corrections autorisées. - * NB: Par défaut le forçage du témoin est pris en compte. - * - * @param bool $prendreEnCompteLeForcage Faut-il prendre en compte le forçage éventuel ? - * @return string|null 'facultative' ou 'obligatoire' ou null - * - * @see These::getCorrectionAutoriseeForcee() - */ - public function getCorrectionAutorisee(bool $prendreEnCompteLeForcage = true): ?string - { - if ($prendreEnCompteLeForcage === false) { - return $this->correctionAutorisee; - } - - if ($this->getCorrectionAutoriseeForcee() === self::CORRECTION_AUTORISEE_FORCAGE_AUCUNE) { - // si le forçage est à 'aucune', alors aucune correction autorisée! - return null; - } - - return $this->getCorrectionAutoriseeForcee() ?: $this->correctionAutorisee; - } - - /** - * @param bool $prendreEnCompteLeForcage Faut-il prendre en compte le forçage éventuel ? - * @return bool - */ - public function getCorrectionAutoriseeEstFacultative($prendreEnCompteLeForcage = true) - { - return in_array($this->getCorrectionAutorisee($prendreEnCompteLeForcage), [ - self::CORRECTION_AUTORISEE_FACULTATIVE - ]); - } - - /** - * @param bool $prendreEnCompteLeForcage Faut-il prendre en compte le forçage éventuel ? - * @return bool - */ - public function getCorrectionAutoriseeEstObligatoire($prendreEnCompteLeForcage = true) - { - return in_array($this->getCorrectionAutorisee($prendreEnCompteLeForcage), [ - self::CORRECTION_AUTORISEE_OBLIGATOIRE - ]); - } - - /** - * @param bool $plural - * @param bool $prendreEnCompteLeForcage Faut-il prendre en compte le forçage éventuel ? - * @return string - */ - public function getCorrectionAutoriseeToString($plural = false, $prendreEnCompteLeForcage = true) - { - $correctionAutorisee = $this->getCorrectionAutorisee($prendreEnCompteLeForcage); - - return $plural ? - self::$correctionsLibellesPluriels[$correctionAutorisee] : - self::$correctionsLibelles[$correctionAutorisee]; - } - - /** - * Change la valeur du témoin de corrections autorisées importé. - * NB: cette méthode ne devrait pas être utilisée, sauf pour les tests unitaires. - * - * @param string|null $correctionAutorisee - * @return These - */ - public function setCorrectionAutorisee(string $correctionAutorisee = null) - { - Assertion::inArray($correctionAutorisee, [ - null, - self::CORRECTION_AUTORISEE_FACULTATIVE, - self::CORRECTION_AUTORISEE_OBLIGATOIRE, - ]); - - $this->correctionAutorisee = $correctionAutorisee; - - return $this; - } - - /** - * Retourne la valeur du forçage du témoin de corrections autorisées. - * - * @return string - */ - public function getCorrectionAutoriseeForcee() - { - return $this->correctionAutoriseeForcee; - } - - /** - * Modifie la valeur du forçage du témoin de corrections autorisées. - * - * @param string|null $correctionAutoriseeForcee - * @return These - */ - public function setCorrectionAutoriseeForcee(string $correctionAutoriseeForcee = null) - { - Assertion::inArray($correctionAutoriseeForcee, [ - self::CORRECTION_AUTORISEE_FORCAGE_NON, - self::CORRECTION_AUTORISEE_FORCAGE_AUCUNE, - self::CORRECTION_AUTORISEE_FORCAGE_FACULTATIVE, - self::CORRECTION_AUTORISEE_FORCAGE_OBLIGATOIRE, - ]); - - $this->correctionAutoriseeForcee = $correctionAutoriseeForcee; - - return $this; - } - - /** - * @return null|DateTime - */ - public function getDateButoirDepotVersionCorrigeeAvecSursis(): ?DateTime - { - return $this->dateButoirDepotVersionCorrigeeAvecSursis; - } - - /** - * @return string - */ - public function getDateButoirDepotVersionCorrigeeAvecSursisToString(): string - { - return $this->dateButoirDepotVersionCorrigeeAvecSursis ? - $this->dateButoirDepotVersionCorrigeeAvecSursis->format(Constants::DATE_FORMAT) : - ''; - } - - /** - * @param \DateTime $date - * @return self - */ - public function setDateButoirDepotVersionCorrigeeAvecSursis(DateTime $date): self - { - $this->dateButoirDepotVersionCorrigeeAvecSursis = $date; - return $this; - } - - /** - * @return self - */ - public function unsetDateButoirDepotVersionCorrigeeAvecSursis(): self - { - $this->dateButoirDepotVersionCorrigeeAvecSursis = null; - return $this; - } - - /** - * @return string - */ - public function getCorrectionEffectuee() - { - return $this->correctionEffectuee; - } - - /** - * @param string $correctionEffectuee - * @return These - */ - public function setCorrectionEffectuee(string $correctionEffectuee) - { - $this->correctionEffectuee = $correctionEffectuee; - return $this; - } - /** * @return string */ @@ -1611,132 +1378,6 @@ class These implements HistoriqueAwareInterface, ResourceInterface return null; } - - - - - public function getDateButoirDepotVersionCorrigeeFromDateSoutenance(DateTime $dateSoutenance): DateTime - { - if ($this->getCorrectionAutorisee() === null) { - throw new BadMethodCallException("Appel de " . __METHOD__ . " illogique car aucune correction attendue"); - } - - $intervalSpec = $this->getDelaiDepotVersionCorrigeeInterval(); - - $date = clone $dateSoutenance; - $date - ->add(new DateInterval($intervalSpec)) - ->setTime(0, 0, 0); - - return $date; - } - - public function getDateButoirDepotVersionCorrigeeFromDateSoutenanceToString(DateTime $dateSoutenance): string - { - return $this->getDateButoirDepotVersionCorrigeeFromDateSoutenance($dateSoutenance)->format(Constants::DATE_FORMAT); - } - - public function getDelaiDepotVersionCorrigeeInterval(): string - { - switch ($val = $this->getCorrectionAutorisee()) { - case self::CORRECTION_AUTORISEE_OBLIGATOIRE: - return static::CORRECTION_OBLIGATOIRE_INTERVAL; // + 3 mois - case self::CORRECTION_AUTORISEE_FACULTATIVE: - return static::CORRECTION_FACULTATIVE_INTERVAL; // + 2 mois - default: - throw new RuntimeException("Valeur de correction attendue non prévue: " . $val); - } - } - - public function getDelaiDepotVersionCorrigeeToString(): string - { - switch ($spec = $this->getDelaiDepotVersionCorrigeeInterval()) { - case self::CORRECTION_OBLIGATOIRE_INTERVAL: - return static::CORRECTION_OBLIGATOIRE_INTERVAL_TO_STRING; - case self::CORRECTION_FACULTATIVE_INTERVAL: - return static::CORRECTION_FACULTATIVE_INTERVAL_TO_STRING; - default: - throw new RuntimeException("Interval rencontré non prévu: " . $spec); - } - } - - /** - * Détermine si la date butoir de dépôt de la verison corrigée est dépassée ou non. - * - * NB : Synthèse de - * {@see isDateButoirDepotVersionCorrigeeFromDateSoutenanceDepassee()} et - * {@see isDateButoirDepotVersionCorrigeeAvecSursisDepassee()} - * - * @return bool - */ - public function isDateButoirDepotVersionCorrigeeDepassee(): bool - { - $dateButoirFromSoutenanceDepassee = - $this->dateSoutenance && - $this->isDateButoirDepotVersionCorrigeeFromDateSoutenanceDepassee($this->dateSoutenance); - if (! $dateButoirFromSoutenanceDepassee) { - return false; - } - - if ($this->dateButoirDepotVersionCorrigeeAvecSursis !== null) { - return $this->isDateButoirDepotVersionCorrigeeAvecSursisDepassee(); - } - - return true; - } - - /** - * Détermine si la date butoir de dépôt de la verison corrigée DEDUITE DE LA DATE DE SOUTENANCE est dépassée ou non. - * - * NB : La date de soutenance est demandée en argument pour bien marquer le fait qu'une date de soutenance non null - * est requise. - * - * @param \DateTime $dateSoutenance - * @return bool - */ - public function isDateButoirDepotVersionCorrigeeFromDateSoutenanceDepassee(DateTime $dateSoutenance): bool - { - $dateButoir = $this->getDateButoirDepotVersionCorrigeeFromDateSoutenance($dateSoutenance); - $today = new \DateTime('today'); - - return $today > $dateButoir; - } - - /** - * Détermine si la date butoir de dépôt de la verison corrigée AVEC SURSIS UNQUEMENT est dépassée ou non. - * - * @return bool - */ - public function isDateButoirDepotVersionCorrigeeAvecSursisDepassee(): bool - { - if ($this->dateButoirDepotVersionCorrigeeAvecSursis === null) { - throw new BadMethodCallException("Appel de " . __METHOD__ . " illogique car aucun sursis n'a été accordé"); - } - - $today = new \DateTime('today'); - - return $today > $this->dateButoirDepotVersionCorrigeeAvecSursis; - } - - /** - * Applique à la date spécifiée le sursis (délai) de dépôt de la version corrigée. - * - * @return DateTime - */ - public function computeDateButoirDepotVersionCorrigeeAvecSursis(): DateTime - { - if ($this->dateSoutenance === null) { - throw new BadMethodCallException("Appel de " . __METHOD__ . " illogique car la date de soutenance est inconnue"); - } - - $today = new \DateTime('today'); - $date = $this->dateSoutenance < $today ? $today : clone $this->dateSoutenance; - - return $date - ->add(new DateInterval(self::CORRECTION_SURSIS_INTERVAL)) - ->setTime(0, 0); - } - /** * Predicat testant si une thèse est soutenue en utilisant la date du système * @return boolean diff --git a/module/These/src/These/Entity/Db/TheseCorrectionAwareTrait.php b/module/These/src/These/Entity/Db/TheseCorrectionAwareTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..f907a4b9cf108f2166303740ecf4e637b4debbec --- /dev/null +++ b/module/These/src/These/Entity/Db/TheseCorrectionAwareTrait.php @@ -0,0 +1,352 @@ +<?php + +namespace These\Entity\Db; + +use Application\Constants; +use Assert\Assertion; +use BadMethodCallException; +use DateInterval; +use DateTime; +use UnicaenApp\Exception\RuntimeException; + +trait TheseCorrectionAwareTrait +{ + public static string $CORRECTION_AUTORISEE_OBLIGATOIRE = 'obligatoire'; + public static string $CORRECTION_AUTORISEE_FACULTATIVE = 'facultative'; + + public static array $correctionsLibelles = [ + 'obligatoire' => "Obligatoire", + 'facultative' => "Facultative", + ]; + public static array $correctionsLibellesPluriels = [ + 'obligatoire' => "Obligatoires", + 'facultative' => "Facultatives", + ]; + + public static string $CORRECTION_OBLIGATOIRE_INTERVAL = 'P3M'; + public static string $CORRECTION_OBLIGATOIRE_INTERVAL_TO_STRING = '3 mois'; + public static string $CORRECTION_FACULTATIVE_INTERVAL = 'P2M'; + public static string $CORRECTION_FACULTATIVE_INTERVAL_TO_STRING = '2 mois'; + + public static string $CORRECTION_SURSIS_INTERVAL = 'P7D'; + public static string $CORRECTION_SURSIS_INTERVAL_TO_STRING = '1 semaine'; + + public static ?string $CORRECTION_AUTORISEE_FORCAGE_NON = null; // pas de forçage + public static string $CORRECTION_AUTORISEE_FORCAGE_AUCUNE = 'aucune'; // aucune correction autorisée + public static string $CORRECTION_AUTORISEE_FORCAGE_OBLIGATOIRE = 'obligatoire'; // corrections obligatoires autorisées + public static string $CORRECTION_AUTORISEE_FORCAGE_FACULTATIVE = 'facultative'; // corrections facultatives autorisées + + + private ?string $correctionAutorisee = null; + private ?string $correctionAutoriseeForcee = null; + private ?DateTime $dateButoirDepotVersionCorrigeeAvecSursis = null; + private ?string $correctionEffectuee = null; + + + /** + * Indique si le témoin indique que des corrections sont autorisées. + * NB: Par défaut le forçage du témoin est pris en compte + * + * @param bool $prendreEnCompteLeForcage Faut-il prendre en compte le forçage éventuel ? + * @return bool + */ + public function isCorrectionAutorisee(bool $prendreEnCompteLeForcage = true): bool + { + return (bool) $this->getCorrectionAutorisee($prendreEnCompteLeForcage); + } + + /** + * Indique si le témoin de corrections autorisées fait l'objet d'un forçage. + * + * @return bool + */ + public function isCorrectionAutoriseeForcee(): bool + { + return $this->getCorrectionAutoriseeForcee() !== null; + } + + /** + * Retourne la valeur du témoin de corrections autorisées. + * NB: Par défaut le forçage du témoin est pris en compte. + * + * @param bool $prendreEnCompteLeForcage Faut-il prendre en compte le forçage éventuel ? + * @return string|null 'facultative' ou 'obligatoire' ou null + * + * @see getCorrectionAutoriseeForcee() + */ + public function getCorrectionAutorisee(bool $prendreEnCompteLeForcage = true): ?string + { + if ($prendreEnCompteLeForcage === false) { + return $this->correctionAutorisee; + } + + if ($this->getCorrectionAutoriseeForcee() === self::$CORRECTION_AUTORISEE_FORCAGE_AUCUNE) { + // si le forçage est à 'aucune', alors aucune correction autorisée! + return null; + } + + return $this->getCorrectionAutoriseeForcee() ?: $this->correctionAutorisee; + } + + /** + * @param bool $prendreEnCompteLeForcage Faut-il prendre en compte le forçage éventuel ? + * @return bool + */ + public function getCorrectionAutoriseeEstFacultative(bool $prendreEnCompteLeForcage = true): bool + { + return $this->getCorrectionAutorisee($prendreEnCompteLeForcage) === self::$CORRECTION_AUTORISEE_FACULTATIVE; + } + + /** + * @param bool $prendreEnCompteLeForcage Faut-il prendre en compte le forçage éventuel ? + * @return bool + */ + public function getCorrectionAutoriseeEstObligatoire(bool $prendreEnCompteLeForcage = true): bool + { + return $this->getCorrectionAutorisee($prendreEnCompteLeForcage) === self::$CORRECTION_AUTORISEE_OBLIGATOIRE; + } + + /** + * @param bool $plural + * @param bool $prendreEnCompteLeForcage Faut-il prendre en compte le forçage éventuel ? + * @return string + */ + public function getCorrectionAutoriseeToString(bool $plural, bool $prendreEnCompteLeForcage = true): string + { + $correctionAutorisee = $this->getCorrectionAutorisee($prendreEnCompteLeForcage); + + return $plural ? + self::$correctionsLibellesPluriels[$correctionAutorisee] : + self::$correctionsLibelles[$correctionAutorisee]; + } + + /** + * Change la valeur du témoin de corrections autorisées importé. + * NB: cette méthode ne devrait pas être utilisée, sauf pour les tests unitaires. + * + * @param string|null $correctionAutorisee + * @return self + * @throws \Assert\AssertionFailedException + */ + public function setCorrectionAutorisee(string $correctionAutorisee = null): self + { + Assertion::inArray($correctionAutorisee, [ + null, + self::$CORRECTION_AUTORISEE_FACULTATIVE, + self::$CORRECTION_AUTORISEE_OBLIGATOIRE, + ]); + + $this->correctionAutorisee = $correctionAutorisee; + + return $this; + } + + /** + * Retourne la valeur du forçage du témoin de corrections autorisées. + * + * @return string|null + */ + public function getCorrectionAutoriseeForcee(): ?string + { + return $this->correctionAutoriseeForcee; + } + + /** + * Modifie la valeur du forçage du témoin de corrections autorisées. + * + * @param string|null $correctionAutoriseeForcee + * @return self + * @throws \Assert\AssertionFailedException + */ + public function setCorrectionAutoriseeForcee(string $correctionAutoriseeForcee = null): self + { + Assertion::inArray($correctionAutoriseeForcee, [ + self::$CORRECTION_AUTORISEE_FORCAGE_NON, + self::$CORRECTION_AUTORISEE_FORCAGE_AUCUNE, + self::$CORRECTION_AUTORISEE_FORCAGE_FACULTATIVE, + self::$CORRECTION_AUTORISEE_FORCAGE_OBLIGATOIRE, + ]); + + $this->correctionAutoriseeForcee = $correctionAutoriseeForcee; + + return $this; + } + + /** + * @return string + */ + public function getCorrectionEffectuee() + { + return $this->correctionEffectuee; + } + + /** + * @param string $correctionEffectuee + * @return self + */ + public function setCorrectionEffectuee(string $correctionEffectuee): self + { + $this->correctionEffectuee = $correctionEffectuee; + return $this; + } + + + + /** + * @return null|DateTime + */ + public function getDateButoirDepotVersionCorrigeeAvecSursis(): ?DateTime + { + return $this->dateButoirDepotVersionCorrigeeAvecSursis; + } + + /** + * @return string + */ + public function getDateButoirDepotVersionCorrigeeAvecSursisToString(): string + { + return $this->dateButoirDepotVersionCorrigeeAvecSursis ? + $this->dateButoirDepotVersionCorrigeeAvecSursis->format(Constants::DATE_FORMAT) : + ''; + } + + /** + * @param \DateTime $date + * @return self + */ + public function setDateButoirDepotVersionCorrigeeAvecSursis(DateTime $date): self + { + $this->dateButoirDepotVersionCorrigeeAvecSursis = $date; + return $this; + } + + /** + * @return self + */ + public function unsetDateButoirDepotVersionCorrigeeAvecSursis(): self + { + $this->dateButoirDepotVersionCorrigeeAvecSursis = null; + return $this; + } + + public function getDateButoirDepotVersionCorrigeeFromDateSoutenance(DateTime $dateSoutenance): DateTime + { + if ($this->getCorrectionAutorisee() === null) { + throw new BadMethodCallException("Appel de " . __METHOD__ . " illogique car aucune correction attendue"); + } + + $intervalSpec = $this->getDelaiDepotVersionCorrigeeInterval(); + + $date = clone $dateSoutenance; + $date + ->add(new DateInterval($intervalSpec)) + ->setTime(0, 0, 0); + + return $date; + } + + public function getDateButoirDepotVersionCorrigeeFromDateSoutenanceToString(DateTime $dateSoutenance): string + { + return $this->getDateButoirDepotVersionCorrigeeFromDateSoutenance($dateSoutenance)->format(Constants::DATE_FORMAT); + } + + public function getDelaiDepotVersionCorrigeeInterval(): string + { + switch ($val = $this->getCorrectionAutorisee()) { + case self::$CORRECTION_AUTORISEE_OBLIGATOIRE: + return static::$CORRECTION_OBLIGATOIRE_INTERVAL; // + 3 mois + case self::$CORRECTION_AUTORISEE_FACULTATIVE: + return static::$CORRECTION_FACULTATIVE_INTERVAL; // + 2 mois + default: + throw new RuntimeException("Valeur de correction attendue non prévue: " . $val); + } + } + + public function getDelaiDepotVersionCorrigeeToString(): string + { + switch ($spec = $this->getDelaiDepotVersionCorrigeeInterval()) { + case self::$CORRECTION_OBLIGATOIRE_INTERVAL: + return static::$CORRECTION_OBLIGATOIRE_INTERVAL_TO_STRING; + case self::$CORRECTION_FACULTATIVE_INTERVAL: + return static::$CORRECTION_FACULTATIVE_INTERVAL_TO_STRING; + default: + throw new RuntimeException("Interval rencontré non prévu: " . $spec); + } + } + + /** + * Détermine si la date butoir de dépôt de la verison corrigée est dépassée ou non, selon la date de soutenance + * spécifiée. + * + * NB : Synthèse de + * {@see isDateButoirDepotVersionCorrigeeFromDateSoutenanceDepassee()} et + * {@see isDateButoirDepotVersionCorrigeeAvecSursisDepassee()} + * + * @param \DateTime|null $dateSoutenance + * @return bool + */ + public function isDateButoirDepotVersionCorrigeeDepassee(?DateTime $dateSoutenance = null): bool + { + $dateButoirFromSoutenanceDepassee = + $dateSoutenance && + $this->isDateButoirDepotVersionCorrigeeFromDateSoutenanceDepassee($dateSoutenance); + if (! $dateButoirFromSoutenanceDepassee) { + return false; + } + + if ($this->dateButoirDepotVersionCorrigeeAvecSursis !== null) { + return $this->isDateButoirDepotVersionCorrigeeAvecSursisDepassee(); + } + + return true; + } + + /** + * Détermine si la date butoir de dépôt de la verison corrigée DEDUITE DE LA DATE DE SOUTENANCE est dépassée ou non. + * + * NB : La date de soutenance est demandée en argument pour bien marquer le fait qu'une date de soutenance non null + * est requise. + * + * @param \DateTime $dateSoutenance + * @return bool + */ + public function isDateButoirDepotVersionCorrigeeFromDateSoutenanceDepassee(DateTime $dateSoutenance): bool + { + $dateButoir = $this->getDateButoirDepotVersionCorrigeeFromDateSoutenance($dateSoutenance); + $today = new \DateTime('today'); + + return $today > $dateButoir; + } + + /** + * Détermine si la date butoir de dépôt de la verison corrigée AVEC SURSIS UNQUEMENT est dépassée ou non. + * + * @return bool + */ + public function isDateButoirDepotVersionCorrigeeAvecSursisDepassee(): bool + { + if ($this->dateButoirDepotVersionCorrigeeAvecSursis === null) { + throw new BadMethodCallException("Appel de " . __METHOD__ . " illogique car aucun sursis n'a été accordé"); + } + + $today = new \DateTime('today'); + + return $today > $this->dateButoirDepotVersionCorrigeeAvecSursis; + } + + /** + * Applique à la date de soutenance spécifiée le sursis (délai) de dépôt de la version corrigée. + * + * @param \DateTime $dateSoutenance + * @return DateTime + */ + public function computeDateButoirDepotVersionCorrigeeAvecSursis(DateTime $dateSoutenance): DateTime + { + $today = new \DateTime('today'); + $date = $dateSoutenance < $today ? $today : clone $dateSoutenance; + + return $date + ->add(new DateInterval(self::$CORRECTION_SURSIS_INTERVAL)) + ->setTime(0, 0); + } +} \ No newline at end of file diff --git a/module/These/src/These/Notification/ChangementsResultatsThesesNotification.php b/module/These/src/These/Notification/ChangementsResultatsThesesNotification.php index 8cb8459b4e34c4de90529d56894cb5c7cef1f2f1..8481479b868914c6f50b31b1d3f56eb681a730cf 100644 --- a/module/These/src/These/Notification/ChangementsResultatsThesesNotification.php +++ b/module/These/src/These/Notification/ChangementsResultatsThesesNotification.php @@ -9,7 +9,7 @@ class ChangementsResultatsThesesNotification extends Notification { use TheseAwareTrait; - protected $templatePath = 'these/these/mail/notif-evenement-import'; + protected ?string $templatePath = 'these/these/mail/notif-evenement-import'; /** * @return static diff --git a/module/These/src/These/Notification/ResultatTheseAdmisNotification.php b/module/These/src/These/Notification/ResultatTheseAdmisNotification.php index c2723d29fb4a8b56ba884c7f99dbad6ae58609df..81b4b17fe2313056dfc4fb87d7fef82387980c47 100644 --- a/module/These/src/These/Notification/ResultatTheseAdmisNotification.php +++ b/module/These/src/These/Notification/ResultatTheseAdmisNotification.php @@ -9,7 +9,7 @@ class ResultatTheseAdmisNotification extends Notification { use TheseAwareTrait; - protected $templatePath = 'these/these/mail/notif-resultat-admis-doctorant'; + protected ?string $templatePath = 'these/these/mail/notif-resultat-admis-doctorant'; /** * @var bool @@ -42,7 +42,7 @@ class ResultatTheseAdmisNotification extends Notification if (! $to) { // lorsque le doctorant n'a pas d'email, envoi au BDD (+ petit message d'alerte dans le mail) $this->emailDoctorantAbsent = true; - $to = $this->emailBdd; + $to = $this->emailsBdd; } $this->setTo($to); @@ -50,7 +50,6 @@ class ResultatTheseAdmisNotification extends Notification $this->setTemplateVariables([ 'these' => $this->these, - 'contact' => $this->emailBdd, 'doctorant' => $this->these->getDoctorant(), 'emailDoctorantAbsent' => $this->emailDoctorantAbsent, ]); @@ -58,26 +57,16 @@ class ResultatTheseAdmisNotification extends Notification return $this; } - /** - * @var string - */ - private $emailBdd; + private array $emailsBdd = []; - /** - * @param string $emailBdd - * @return self - */ - public function setEmailBdd($emailBdd) + public function setEmailsBdd(array $emailBdd): self { - $this->emailBdd = $emailBdd; + $this->emailsBdd = $emailBdd; return $this; } - /** - * @return bool - */ - public function isEmailDoctorantAbsent() + public function isEmailDoctorantAbsent(): bool { return $this->emailDoctorantAbsent; } diff --git a/module/These/src/These/QueryBuilder/TheseQueryBuilder.php b/module/These/src/These/QueryBuilder/TheseQueryBuilder.php index f6f139fd9e854988351163fe9db4ab7dbba128eb..09429f9f4ba69d3e9c073ea0e98f23539d633e86 100644 --- a/module/These/src/These/QueryBuilder/TheseQueryBuilder.php +++ b/module/These/src/These/QueryBuilder/TheseQueryBuilder.php @@ -58,7 +58,7 @@ class TheseQueryBuilder extends DefaultQueryBuilder // correction non autorisee si : correctionAutorisee === null OU correctionAutoriseeForcee === 'aucune' $this ->andWhere("NOT ($this->rootAlias.correctionAutorisee IS NULL OR $this->rootAlias.correctionAutoriseeForcee = :forceeAucune)") - ->setParameter('forceeAucune', These::CORRECTION_AUTORISEE_FORCAGE_AUCUNE); + ->setParameter('forceeAucune', These::$CORRECTION_AUTORISEE_FORCAGE_AUCUNE); return $this; } diff --git a/module/These/src/These/Service/Notification/TheseNotificationFactory.php b/module/These/src/These/Service/Notification/TheseNotificationFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..96a30607d54e29870609eee9ce284bad504c5ba9 --- /dev/null +++ b/module/These/src/These/Service/Notification/TheseNotificationFactory.php @@ -0,0 +1,176 @@ +<?php + +namespace These\Service\Notification; + +use Application\Service\Email\EmailTheseServiceAwareTrait; +use Depot\Notification\ChangementCorrectionAttendueNotification; +use Depot\Notification\PasDeMailPresidentJury; +use Depot\Rule\NotificationDepotVersionCorrigeeAttenduRule; +use Import\Model\ImportObservResult; +use Notification\Exception\RuntimeException; +use Notification\Factory\NotificationFactory; +use Notification\Notification; +use Notification\NotificationResult; +use These\Entity\Db\Acteur; +use These\Entity\Db\These; +use These\Notification\ChangementsResultatsThesesNotification; +use These\Notification\ResultatTheseAdmisNotification; + +/** + * Classe de construction de notifications par mail. + * + * @author Unicaen + */ +class TheseNotificationFactory extends NotificationFactory +{ + use EmailTheseServiceAwareTrait; + + /** + * Crée la notification concernant des changements quelconques de résultats de thèses. + * + * @param array $data Données concernant les thèses dont le résultat a changé + */ + public function createNotificationChangementResultatTheses(array $data): Notification + { + $these = current($data)['these']; + + $emailsBdd = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); + if (empty($emailsBdd)) { + throw new RuntimeException("Aucune adresse mail trouvée pour la MDD (thèse {$these->getId()})"); + } + + $emailsBu = $this->emailTheseService->fetchEmailBibliothequeUniv($these); + if (empty($emailsBu)) { + throw new RuntimeException("Aucune adresse mail trouvée pour la BU (thèse {$these->getId()})"); + } + + $notif = new ChangementsResultatsThesesNotification(); + $notif->setData($data); + $notif->setTo(array_merge($emailsBdd, $emailsBu)); + + return $notif; + } + + /** + * Crée les notifications à propos de résultats de thèses passés à 'Admis'. + * + * @param array $data + * @return \Notification\Notification[] + */ + public function createNotificationsChangementResultatThesesAdmis(array $data): array + { + $notifs = []; + + foreach ($data as $array) { + $these = $array['these']; + /* @var These $these */ + + $emailsBdd = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); + if (empty($emailsBdd)) { + throw new RuntimeException("Aucune adresse mail trouvée pour la Maison du doctorat (thèse {$these->getId()})"); + } + + $notif = new ResultatTheseAdmisNotification(); + $notif->setThese($these); + $notif->setEmailsBdd($emailsBdd); + + $notifs[] = $notif; + } + + return $notifs; + } + + + /** + * Notification à propos de corrections attendues. + * + * @param ImportObservResult $record + * @param These $these + * @param string|null $message + * @return \Notification\NotificationResult|null + */ + public function createNotificationCorrectionAttendue(ImportObservResult $record, These $these, ?string &$message = null): ?Notification + { + // interrogation de la règle métier pour savoir comment agir... + $rule = new NotificationDepotVersionCorrigeeAttenduRule(); + $rule + ->setThese($these) + ->setDateDerniereNotif($record->getDateNotif()) + ->execute(); + $message = $rule->getMessage(' '); + $estPremiereNotif = $rule->estPremiereNotif(); + $dateProchaineNotif = $rule->getDateProchaineNotif(); + + if ($dateProchaineNotif === null) { + return null; + } + + $dateProchaineNotif->setTime(0, 0, 0); + $now = (new \DateTime())->setTime(0, 0, 0); + + if ($now != $dateProchaineNotif) { + return null; + } + + $notif = new ChangementCorrectionAttendueNotification(); + $notif + ->setThese($these) + ->setEstPremiereNotif($estPremiereNotif); + + return $notif; + } + + /** + * Notification à propos du dépassement de la date butoir de dépôt de la version corrigée de la thèse. + * + * @param These $these + * @return \Notification\Notification + */ + public function createNotificationDateButoirCorrectionDepassee(These $these): Notification + { + $to = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); + if (empty($to)) { + throw new RuntimeException("Aucune adresse mail trouvée pour la Maison du doctorat (thèse {$these->getId()})"); + } + + $notif = new Notification(); + $notif + ->setSubject("Corrections " . lcfirst($these->getCorrectionAutoriseeToString(true)) . " non faites") + ->setTo($to) + ->setTemplatePath('depot/depot/mail/notif-date-butoir-correction-depassee') + ->setTemplateVariables([ + 'these' => $these, + ]); + + return $notif; + } + + + /** + * Notification à propos de l'absence de mail connu pour le président du jury. + * + * @param These $these + * @param Acteur $president + * @return \Notification\Notification + */ + public function createNotificationPasDeMailPresidentJury(These $these, Acteur $president): Notification + { + $emailsBdd = $this->emailTheseService->fetchEmailMaisonDuDoctorat($these); + if (empty($emailsBdd)) { + throw new RuntimeException("Aucune adresse mail trouvée pour la Maison du doctorat (thèse {$these->getId()})"); + } + + $notif = new PasDeMailPresidentJury(); + $notif + ->setThese($these) + ->setEmailsBdd($emailsBdd) + ->setPresident($president) + ->setTemplateVariables([ + 'these' => $these, + 'president' => $president, + ]); + + return $notif; + } + +} \ No newline at end of file diff --git a/module/These/src/These/Service/Notification/TheseNotificationFactoryAwareTrait.php b/module/These/src/These/Service/Notification/TheseNotificationFactoryAwareTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..e15cd7cf72906970e58a602e2b3a3d57aa7a4d01 --- /dev/null +++ b/module/These/src/These/Service/Notification/TheseNotificationFactoryAwareTrait.php @@ -0,0 +1,13 @@ +<?php + +namespace These\Service\Notification; + +trait TheseNotificationFactoryAwareTrait +{ + protected TheseNotificationFactory $theseNotificationFactory; + + public function setTheseNotificationFactory(TheseNotificationFactory $theseNotificationFactory): void + { + $this->theseNotificationFactory = $theseNotificationFactory; + } +} \ No newline at end of file diff --git a/module/These/src/These/Service/Notification/TheseNotificationFactoryFactory.php b/module/These/src/These/Service/Notification/TheseNotificationFactoryFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..6bb8b631e17be2628324bd48413a3badec4e0162 --- /dev/null +++ b/module/These/src/These/Service/Notification/TheseNotificationFactoryFactory.php @@ -0,0 +1,34 @@ +<?php + +namespace These\Service\Notification; + +use Application\Service\Email\EmailTheseService; +use Interop\Container\ContainerInterface; +use Notification\Factory\NotificationFactoryFactory; + +/** + * @author Unicaen + */ +class TheseNotificationFactoryFactory extends NotificationFactoryFactory +{ + /** + * @var string + */ + protected string $class = TheseNotificationFactory::class; + + /** + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface + */ + public function __invoke(ContainerInterface $container): TheseNotificationFactory + { + /** @var TheseNotificationFactory $factory */ + $factory = parent::__invoke($container); + + /** @var EmailTheseService $emailTheseService */ + $emailTheseService = $container->get(EmailTheseService::class); + $factory->setEmailTheseService($emailTheseService); + + return $factory; + } +} diff --git a/module/These/src/These/Service/These/Factory/TheseServiceFactory.php b/module/These/src/These/Service/These/Factory/TheseServiceFactory.php index 59f97810301e39b358c30580d6d758655ce4cbf9..d5c39d9b6b3a824eea79fc7fb8be5ecabd98dd2e 100644 --- a/module/These/src/These/Service/These/Factory/TheseServiceFactory.php +++ b/module/These/src/These/Service/These/Factory/TheseServiceFactory.php @@ -2,53 +2,27 @@ namespace These\Service\These\Factory; -use Application\Service\Notification\NotifierService; -use Application\Service\UserContextService; -use Application\Service\Utilisateur\UtilisateurService; -use Application\Service\Validation\ValidationService; -use Application\Service\Variable\VariableService; -use Depot\Service\FichierThese\FichierTheseService; use Fichier\Service\Fichier\FichierStorageService; use Interop\Container\ContainerInterface; use Soutenance\Service\Membre\MembreService; use Structure\Service\Etablissement\EtablissementService; use These\Service\Acteur\ActeurService; use These\Service\These\TheseService; -use UnicaenAuth\Service\AuthorizeService; -use UnicaenAuth\Service\User as UserService; class TheseServiceFactory { /** - * Create service - * - * @param ContainerInterface $container - * @return TheseService + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface */ public function __invoke(ContainerInterface $container): TheseService { /** * @var ActeurService $acteurService - * @var ValidationService $validationService * @var MembreService $membreService - * @var NotifierService $notifierService - * @var FichierTheseService $fichierTheseService - * @var VariableService $variableService - * @var UserContextService $userContextService - * @var UserService $userService - * @var UtilisateurService $utilisateurService - * @var AuthorizeService $authorizeService */ $acteurService = $container->get(ActeurService::class); -// $validationService = $container->get('ValidationService'); $membreService = $container->get(MembreService::class); -// $notifierService = $container->get(NotifierService::class); -// $fichierTheseService = $container->get('FichierTheseService'); -// $variableService = $container->get('VariableService'); -// $userContextService = $container->get('UserContextService'); -// $userService = $container->get('unicaen-auth_user_service'); -// $utilisateurService = $container->get(UtilisateurService::class); -// $authorizeService = $container->get('BjyAuthorize\Service\Authorize'); /** @var EtablissementService $etablissementService */ $etablissementService = $container->get(EtablissementService::class); @@ -58,34 +32,10 @@ class TheseServiceFactory $service = new TheseService(); $service->setActeurService($acteurService); -// $service->setValidationService($validationService); $service->setMembreService($membreService); -// $service->setNotifierService($notifierService); -// $service->setFichierTheseService($fichierTheseService); -// $service->setVariableService($variableService); -// $service->setUserContextService($userContextService); -// $service->setUserService($userService); -// $service->setUtilisateurService($utilisateurService); $service->setEtablissementService($etablissementService); $service->setFichierStorageService($fileService); -// $service->setAuthorizeService($authorizeService); - -// $this->injectConfig($service, $container); return $service; } - -// private function injectConfig(TheseService $service, ContainerInterface $container) -// { -// $config = $container->get('Config'); -// Assert::keyExists($config, 'sygal'); -// Assert::keyExists($config['sygal'], 'depot_version_corrigee'); -// -// $configDepotVersionCorrigee = $config['sygal']['depot_version_corrigee']; -// Assert::keyExists($configDepotVersionCorrigee, 'resaisir_autorisation_diffusion'); -// Assert::keyExists($configDepotVersionCorrigee, 'resaisir_attestations'); -// -// $service->setResaisirAutorisationDiffusionVersionCorrigee($configDepotVersionCorrigee['resaisir_autorisation_diffusion']); -// $service->setResaisirAttestationsVersionCorrigee($configDepotVersionCorrigee['resaisir_attestations']); -// } } diff --git a/module/These/view/these/these/identite.phtml b/module/These/view/these/these/identite.phtml index 3e1de132f54688a01786be2338bb88f96a8b3f80..faee3c808dee4753bbde59e7f736692d978b605d 100644 --- a/module/These/view/these/these/identite.phtml +++ b/module/These/view/these/these/identite.phtml @@ -192,7 +192,7 @@ $financementFormatter->setDisplayAs(FinancementFormatter::DISPLAY_AS_LINE); $ligne = implode(" – ", $ligne); echo $ligne; - if (($acteur->estDirecteur() || $acteur->estCodirecteur() || $acteur->estRapporteur() || $acteur->estRapporteurAbsent()) && ! isset($result['alerte-supann-id'])) { + if ($acteur->getRole()->estUsurpable() && ! isset($result['alerte-supann-id'])) { // bouton d'usurpation d'identité $individuUsurpationHelper = $this->plugin('individuUsurpation'); /* @var $individuUsurpationHelper IndividuUsurpationHelper */ @@ -402,7 +402,7 @@ $financementFormatter->setDisplayAs(FinancementFormatter::DISPLAY_AS_LINE); if ($these->isCorrectionAutorisee()) { $dateButoirDepassee = - $these->isDateButoirDepotVersionCorrigeeDepassee() && + $these->isDateButoirDepotVersionCorrigeeDepassee($these->getDateSoutenance()) && ! empty($validationsDesCorrectionsEnAttente); if ($these->getCorrectionAutoriseeEstFacultative()) { diff --git a/module/These/view/these/these/mail/notif-resultat-admis-doctorant.phtml b/module/These/view/these/these/mail/notif-resultat-admis-doctorant.phtml index f3fd58b0b35209e97e1982f735d86e70bf3715a3..1147d7dafa348fd3008bcf85d2d4727d4647b897 100644 --- a/module/These/view/these/these/mail/notif-resultat-admis-doctorant.phtml +++ b/module/These/view/these/these/mail/notif-resultat-admis-doctorant.phtml @@ -7,7 +7,6 @@ use Application\View\Renderer\PhpRenderer; /** * @var PhpRenderer $this * @var These $these - * @var string $contact * @var Doctorant $doctorant * @var bool $emailDoctorantAbsent */