Commit 33ac0baa authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Factorisations et refactorisations ; poursuite de la traque des chemins de logos en dur!

parent a9f86023
Loading
Loading
Loading
Loading
+7 −3
Changes for composer.lock: 7 added lines, 3 removed lines.
Original line number Diff line number Diff line
{
    "_readme": [
        "This file locks the dependencies of your project to a known state",
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
        "This file is @generated automatically"
    ],
    "content-hash": "bd8c3d3e91508f7df99c5680292ae9d2",
    "content-hash": "f887ed33b669d08f32be78e1333d31ee",
    "packages": [
        {
            "name": "beberlei/assert",
@@ -3841,6 +3841,10 @@
    },
    "prefer-stable": false,
    "prefer-lowest": false,
    "platform": [],
    "platform": {
        "ext-fileinfo": "*",
        "ext-json": "*",
        "ext-imagick": "*"
    },
    "platform-dev": []
}
+5 −3
Changes for module/Application/src/Application/Assertion/These/TheseEntityAssertion.php: 5 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -13,18 +13,21 @@ use Application\Entity\Db\VersionFichier;
use Application\Entity\Db\VSitu\DepotVersionCorrigeeValidationDirecteur;
use Application\Service\Fichier\FichierServiceAwareInterface;
use Application\Service\Fichier\FichierServiceAwareTrait;
use Application\Service\These\TheseServiceAwareInterface;
use Application\Service\These\TheseServiceAwareTrait;
use Application\Service\UserContextServiceAwareTrait;
use Application\Service\Validation\ValidationServiceAwareInterface;
use Application\Service\Validation\ValidationServiceAwareTrait;
use Zend\Log\LoggerAwareTrait;

class TheseEntityAssertion extends GeneratedTheseEntityAssertion
    implements EntityAssertionInterface, ValidationServiceAwareInterface, FichierServiceAwareInterface
    implements EntityAssertionInterface, ValidationServiceAwareInterface, FichierServiceAwareInterface, TheseServiceAwareInterface
{
    use UserContextServiceAwareTrait;
    use ValidationServiceAwareTrait;
    use ThrowsFailedAssertionExceptionTrait;
    use FichierServiceAwareTrait;
    use TheseServiceAwareTrait;
    use LoggerAwareTrait;

    /**
@@ -259,9 +262,8 @@ class TheseEntityAssertion extends GeneratedTheseEntityAssertion
     */
    protected function isPageDeCouvertureGenerable()
    {
        $informations = $this->fichierService->fetchInformationsPageDeCouverture($this->these);
        $informations = $this->theseService->fetchInformationsPageDeCouverture($this->these);

        $problemes = [];
        foreach ($informations as $clef => $information) {
            if ($information == "") {
                return false;
+6 −39
Changes for module/Application/src/Application/Controller/EcoleDoctoraleController.php: 6 added lines, 39 removed lines.
Original line number Diff line number Diff line
@@ -2,11 +2,11 @@

namespace Application\Controller;

use Application\Controller\Traits\LogoAwareControllerTrait;
use Application\Entity\Db\EcoleDoctorale;
use Application\Entity\Db\Individu;
use Application\Entity\Db\IndividuRole;
use Application\Entity\Db\Role;
use Application\Entity\Db\Structure;
use Application\Entity\Db\TypeStructure;
use Application\Form\EcoleDoctoraleForm;
use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait;
@@ -26,6 +26,7 @@ class EcoleDoctoraleController extends AbstractController
    use EtablissementServiceAwareTrait;
    use StructureServiceAwareTrait;
    use FileServiceAwareTrait;
    use LogoAwareControllerTrait;

    public function indexAction()
    {
@@ -73,6 +74,7 @@ class EcoleDoctoraleController extends AbstractController
            'ecole'           => $ecole,
            'roleListing'     => $roleListings,
            'individuListing' => $individuListings,
            'logoContent'     => $this->structureService->getLogoStructureContent($ecole),
        ]);
    }

@@ -130,6 +132,7 @@ class EcoleDoctoraleController extends AbstractController
        // envoie vers le formulaire de modification
        $viewModel = new ViewModel([
            'form' => $this->ecoleDoctoraleForm,
            'logoContent' => $this->structureService->getLogoStructureContent($ecole),
        ]);
        $viewModel->setTemplate('application/ecole-doctorale/modifier');

@@ -229,61 +232,25 @@ class EcoleDoctoraleController extends AbstractController
        return $this->redirect()->toRoute('ecole-doctorale', [], ['query' => ['selected' => $structureId], "fragment" => $structureId], true);
    }

    /**
     * Retire le logo associé à une école doctorale:
     * - modification base de donnée (champ CHEMIN_LOG <- null)
     * - effacement du fichier stocké sur le serveur
     */
    public function supprimerLogoEcoleDoctorale()
    {
        $ecoleId = $this->params()->fromRoute("ecoleDoctorale");
        $ecole = $this->getEcoleDoctoraleService()->getRepository()->findByStructureId($ecoleId);

        $this->getEcoleDoctoraleService()->deleteLogo($ecole);

        $logoFilepath = $this->fileService->computeLogoFilepathForStructure($ecole);
        if (file_exists($logoFilepath)) {
            $ok = unlink($logoFilepath);
            if ($ok) {
                $this->flashMessenger()->addSuccessMessage("Le logo de l'école doctorale {$ecole->getLibelle()} vient d'être supprimé.");
            } else {
                $this->flashMessenger()->addErrorMessage("Erreur lors de l'effacement du logo de l'école doctorale <strong>{$ecole->getLibelle()}.</strong>");
            }
        } else {
            $this->flashMessenger()->addWarningMessage("Aucun logo à supprimer pour l'école doctorale <strong>{$ecole->getLibelle()}.</strong>");
        }
        $this->supprimerLogoStructure($ecole);
    }

    /**
     * Ajoute le logo associé à une école doctorale:
     * - modification base de donnée (champ CHEMIN_LOG <- /public/Logos/ED/LOGO_NAME)
     * - enregistrement du fichier sur le serveur
     *
     * @param string         $cheminLogoUploade chemin vers le fichier temporaire associé au logo
     * @param EcoleDoctorale $ecole
     */
    public function ajouterLogoEcoleDoctorale($cheminLogoUploade, EcoleDoctorale $ecole = null)
    {
        if ($cheminLogoUploade === null || $cheminLogoUploade === '') {
            $this->flashMessenger()->addErrorMessage("Fichier logo invalide.");

            return;
        }

        if ($ecole === null) {
            $ecoleId = $this->params()->fromRoute("ecoleDoctorale");
            $ecole = $this->getEcoleDoctoraleService()->getRepository()->findByStructureId($ecoleId);
        }

        $logoFilename = $this->fileService->computeLogoFilenameForStructure($ecole);
        $logoFilepath = $this->fileService->computeLogoFilepathForStructure($ecole);

        $ok = rename($cheminLogoUploade, $logoFilepath);
        if ($ok) {
            $this->flashMessenger()->addSuccessMessage("Le logo de l'école doctorale {$ecole->getLibelle()} vient d'être ajouté.");
            $this->getEcoleDoctoraleService()->setLogo($ecole, $logoFilename);
        } else {
            $this->flashMessenger()->addErrorMessage("Erreur lors de l'enregistrement du logo de l'école doctorale <strong>{$ecole->getLibelle()}.</strong>");
        }
        $this->ajouterLogoStructure($ecole, $cheminLogoUploade);
    }
}
 No newline at end of file
+6 −43
Changes for module/Application/src/Application/Controller/EtablissementController.php: 6 added lines, 43 removed lines.
Original line number Diff line number Diff line
@@ -2,13 +2,11 @@

namespace Application\Controller;

use Application\Controller\Traits\LogoAwareControllerTrait;
use Application\Entity\Db\Etablissement;
use Application\Entity\Db\Individu;
use Application\Entity\Db\IndividuRole;
use Application\Entity\Db\Role;
use Application\Entity\Db\SourceInterface;
use Application\Entity\Db\Structure;
use Application\Entity\Db\StructureConcreteInterface;
use Application\Entity\Db\TypeStructure;
use Application\Form\EtablissementForm;
use Application\Service\Etablissement\EtablissementServiceAwareTrait;
@@ -29,6 +27,7 @@ class EtablissementController extends AbstractController
    use RoleServiceAwareTrait;
    use StructureServiceAwareTrait;
    use FileServiceAwareTrait;
    use LogoAwareControllerTrait;

    /**
     * @var EtablissementForm $etablissementForm
@@ -113,6 +112,7 @@ class EtablissementController extends AbstractController
            'etablissement'   => $etablissement,
            'roleListing'     => $roleListings,
            'individuListing' => $individuListings,
            'logoContent'     => $this->structureService->getLogoStructureContent($etablissement),
        ]);

    }
@@ -225,6 +225,7 @@ class EtablissementController extends AbstractController
        // envoie vers le formulaire de modification
        $viewModel = new ViewModel([
            'form' => $this->etablissementForm,
            'logoContent' => $this->structureService->getLogoStructureContent($etablissement),
        ]);
        $viewModel->setTemplate('application/etablissement/modifier');

@@ -252,63 +253,25 @@ class EtablissementController extends AbstractController
        return $this->redirect()->toRoute('etablissement', [], ['query' => ['selected' => $structureId], "fragment" => $structureId], true);
    }

    /**
     * Retire le logo associé à une établissement:
     * - modification base de donnée (champ CHEMIN_LOG <- null)
     * - effacement du fichier stocké sur le serveur
     */
    public function supprimerLogoEtablissement()
    {
        $structureId = $this->params()->fromRoute("etablissement");
        $etablissement = $this->getEtablissementService()->getRepository()->findByStructureId($structureId);

        $this->getEtablissementService()->deleteLogo($etablissement);

        $logoFilepath = $this->fileService->computeLogoFilepathForStructure($etablissement);

        if (file_exists($logoFilepath)) {
            $ok = unlink($logoFilepath);
            if ($ok) {
                $this->flashMessenger()->addSuccessMessage("Le logo de l'école doctorale {$etablissement->getLibelle()} vient d'être supprimé.");
            } else {
                $this->flashMessenger()->addErrorMessage("Erreur lors de l'effacement du logo de l'établissement <strong>{$etablissement->getLibelle()}.</strong>");
            }
        } else {
            $this->flashMessenger()->addWarningMessage("Aucun logo à supprimer pour l'établissement <strong>{$etablissement->getLibelle()}.</strong>");
        }

        $this->supprimerLogoStructure($etablissement);
    }

    /**
     * Ajoute le logo associé à une établissement:
     * - modification base de donnée (champ CHEMIN_LOG <- /public/Logos/Etab/LOGO_NAME)
     * - enregistrement du fichier sur le serveur
     *
     * @param string        $cheminLogoUploade chemin vers le fichier temporaire associé au logo
     * @param Etablissement $etablissement
     */
    public function ajouterLogoEtablissement($cheminLogoUploade, Etablissement $etablissement = null)
    {
        if ($cheminLogoUploade === null || $cheminLogoUploade === '') {
            $this->flashMessenger()->addErrorMessage("Fichier logo invalide.");

            return;
        }

        if ($etablissement === null) {
            $structureId = $this->params()->fromRoute("etablissement");
            $etablissement = $this->getEtablissementService()->getRepository()->findByStructureId($structureId);
        }

        $logoFilename = $this->fileService->computeLogoFilenameForStructure($etablissement);
        $logoFilepath = $this->fileService->computeLogoFilepathForStructure($etablissement);

        $ok = rename($cheminLogoUploade, $logoFilepath);
        if ($ok) {
            $this->flashMessenger()->addSuccessMessage("Le logo de l'établissement {$etablissement->getLibelle()} vient d'être ajouté.");
            $this->getEtablissementService()->setLogo($etablissement, $logoFilename);
        } else {
            $this->flashMessenger()->addErrorMessage("Erreur lors de l'enregistrement du logo de l'établissement <strong>{$etablissement->getLibelle()}.</strong> ");
        }
        $this->ajouterLogoStructure($etablissement, $cheminLogoUploade);
    }
}
 No newline at end of file
+2 −3
Changes for module/Application/src/Application/Controller/PrivilegeController.php: 2 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -56,9 +56,8 @@ class PrivilegeController extends AbstractController
    {
        $privilege_id = $this->params()->fromRoute("privilege");
        $role_id = $this->params()->fromRoute("role");
        $privilege = $this->entityManager->getRepository(Privilege::class)->findOneBy(["id" => $privilege_id]);
        $role = $this->entityManager->getRepository(Role::class)->findOneBy(["id" => $role_id]);

        $privilege = $this->entityManager->getRepository(Privilege::class)->find($privilege_id);
        $role = $this->entityManager->getRepository(Role::class)->find($role_id);

        $value = null;
        if( array_search($role, $privilege->getRole()->toArray()) !== false) {
Loading