Commit e218841f authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Merge branch 'feature_menu_csi_gest_ed_ur' into release_6.0.10

parents 924a3469 5b0a29c4
Loading
Loading
Loading
Loading
+23 −0
Changes for module/Application/config/others/rapports.config.php: 23 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ use Application\Form\Factory\RapportMiparcoursFormFactory;
use Application\Form\Rapport\RapportAvisForm;
use Application\Form\RapportCsiForm;
use Application\Form\RapportMiparcoursForm;
use Application\Navigation\ApplicationNavigationFactory;
use Application\Provider\Privilege\RapportPrivileges;
use Application\Search\Controller\SearchControllerPluginFactory;
use Application\Service\Rapport\Avis\RapportAvisService;
@@ -422,6 +423,28 @@ return [
        'default' => [
            'home' => [
                'pages' => [

                    /**
                     * Cette page aura une page fille 'these-1', 'these-2', etc. générées automatiquement.
                     * @see ApplicationNavigationFactory::processPage()
                     */
                    // DEPTH = 1
                    ApplicationNavigationFactory::NOS_THESES_PAGE_ID => [
                        'pages' => [
                            // DEPTH = 2
                            'RAPPORTS_CSI' => [
                                'label' => '(Rapports CSI Structure)',
                                'route'    => 'rapport-csi/recherche/index',
                                'resource' => PrivilegeController::getResourceId(RapportCsiRechercheController::class, 'index'),
                                'privilege' => [
                                    RapportPrivileges::RAPPORT_CSI_RECHERCHER_TOUT,
                                    RapportPrivileges::RAPPORT_CSI_RECHERCHER_SIEN,
                                ],
                                'visible' => 'Assertion\\Rapport',
                            ],
                        ],
                    ],

                    'admin' => [
                        'pages' => [
                            '-----------' => [
+23 −2
Changes for module/Application/src/Application/Controller/Rapport/RapportRechercheController.php: 23 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -6,13 +6,13 @@ use Application\Controller\AbstractController;
use Application\Entity\Db\Interfaces\TypeRapportAwareTrait;
use Application\Entity\Db\Interfaces\TypeValidationAwareTrait;
use Application\Entity\Db\Rapport;
use Fichier\Entity\FichierArchivable;
use Application\Search\Controller\SearchControllerInterface;
use Application\Search\Controller\SearchControllerTrait;
use Application\Search\SearchServiceAwareTrait;
use Application\Service\Rapport\RapportSearchService;
use Fichier\Entity\FichierArchivable;
use Fichier\Service\Fichier\FichierServiceAwareTrait;
use Fichier\Service\Fichier\FichierServiceException;
use Application\Service\Rapport\RapportSearchService;
use Laminas\Http\Response;
use Laminas\Paginator\Paginator as LaminasPaginator;
use Laminas\View\Model\ViewModel;
@@ -73,6 +73,7 @@ abstract class RapportRechercheController extends AbstractController implements
    public function indexAction()
    {
        $this->restrictEcolesDoctorales();
        $this->restrictUnitesRecherches();

        $text = $this->params()->fromQuery('text');

@@ -128,6 +129,7 @@ abstract class RapportRechercheController extends AbstractController implements
    public function filtersAction(): ViewModel
    {
        $this->restrictEcolesDoctorales();
        $this->restrictUnitesRecherches();

        $this->searchService->getValidationSearchFilter()->setVisible(false);

@@ -160,12 +162,31 @@ abstract class RapportRechercheController extends AbstractController implements
        }
    }

    private function restrictUnitesRecherches()
    {
        $filter = $this->searchService->getUniteRechercheSearchFilter();
        $protoRapport = new Rapport($this->typeRapport);

        if ($this->isAllowed($protoRapport, $this->privilege_LISTER_TOUT)) {
            // aucune restriction sur les UR sélectionnables
        } elseif ($this->isAllowed($protoRapport, $this->privilege_LISTER_SIEN)) {
            // restrictions en fonction du rôle
            if ($role = $this->userContextService->getSelectedRoleUniteRecherche()) {
                $ur = $role->getStructure()->getUniteRecherche();
                $filter->setData([$ur]);
                $filter->setDefaultValueAsObject($ur);
                $filter->setAllowsEmptyOption(false);
            }
        }
    }

    /**
     * @return void|Response
     */
    public function telechargerZipAction(): Response
    {
        $this->restrictEcolesDoctorales();
        $this->restrictUnitesRecherches();

        $result = $this->search();
        if ($result instanceof Response) {
+10 −0
Changes for module/Application/src/Application/Navigation/ApplicationNavigationFactory.php: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -276,6 +276,16 @@ class ApplicationNavigationFactory extends NavigationFactory
        $page['query'] = array_merge($page['query'], $query);
        $newPages[] = $page;

        // génération d'une page fille emmenant vers les rapports CSI
        $protoPage = $parentPage['pages']['RAPPORTS_CSI'];
        $page = $protoPage;
        // label
        $page['label'] = "Rapports CSI " . $label;
        // params
        $page['query'] = $page['query'] ?? [];
        $page['query'] = array_merge($page['query'], $query);
        $newPages[] = $page;

        // génération d'une page fille emmenant vers les soutenances
        $protoPage = $parentPage['pages']['SOUTENANCES'];
        $page = $protoPage;
+31 −6
Changes for module/Application/src/Application/Search/Filter/SelectSearchFilter.php: 31 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ namespace Application\Search\Filter;
use Doctrine\ORM\QueryBuilder;
use InvalidArgumentException;
use Throwable;
use Webmozart\Assert\Assert;

/**
 * Représente un filtre de type liste déroulante.
@@ -60,6 +61,24 @@ class SelectSearchFilter extends SearchFilter
            ->setDefaultValue($defaultValue);
    }

    public function setValue($value = null): SearchFilter
    {
        // si la liste de valeurs possibles est pré-remplie, verification que la valeur spécifiée est dedans.
        if ($value !== null && is_array($this->data)) {
            $options = $this->createValueOptionsFromData($this->data);
            $found = false;
            foreach ($options as $item) {
                if ($item['value'] === $value) {
                    $found = true;
                    break;
                }
            }
            Assert::true($found, "Valeur de filtre illégale : " . $value);
        }

        return parent::setValue($value);
    }

    /**
     * @param SearchFilterValueInterface|null $defaultValue
     * @return self
@@ -142,9 +161,18 @@ class SelectSearchFilter extends SearchFilter
            $options[] = static::valueOptionUnknown($this->getNoneOptionLabel());
        }
        foreach ($data as $key => $value) {
            $options[] = $this->createValueOption($value, $key);
        }

        return $options;
    }

    public function createValueOption($value, $key): array
    {
        if ($value instanceof SearchFilterValueInterface) {
                $options[] = $value->createSearchFilterValueOption();
            } else {
            return $value->createSearchFilterValueOption();
        }

        try {
            $valueToString = (string) $value;
        } catch (Throwable $e) {
@@ -154,11 +182,8 @@ class SelectSearchFilter extends SearchFilter
                SearchFilterValueInterface::class
            ));
        }
                $options[] = static::valueOption($valueToString, (string) $key);
            }
        }

        return $options;
        return static::valueOption($valueToString, (string) $key);
    }

    /**