Commit 97216245 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Formalisme du PFI depuis l'UI (et optionnel)

parent a1eef6e3
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -177,13 +177,13 @@ force_unsecure_http: false

#### Commande locale

Obtention des données via l'exécution d'une commande système locale (Ex : avec **Oscar Bridge**)
Obtention des données via l'exécution d'une commande système locale

```yml
# Commande pour obtenir sortie le JSON complet (toutes les personnes) - En une seule ligne
# Commande pour obtenir en sortie le JSON complet (toutes les personnes) - En une seule ligne
url_persons: '/usr/bin/php /var/OscarBridge/bin/console json:persons-get-all'

# Commande pour synchroniser une seule personne
# Commande pour obtenir les données d'une seule personne
url_person: '/usr/bin/php /var/OscarBridge/bin/console json:person-get-one-by-uid %s'

access_strategy: Oscar\Connector\Access\ConnectorLocalCommand
+3 −2
Original line number Diff line number Diff line
@@ -19,11 +19,12 @@ abstract class OscarCommandAbstract extends Command


    const COMMAND_ACTIVITY_SEARCH_REINDEX = 'activity:search:reindex';

    const COMMAND_ACTIVITY_SEARCH_REINDEX_ALL = 'activity:search-rebuild';

    const COMMAND_ACTIVITY_NOTIFICATION_UPDATE = 'activity:notification:update';

    const COMMAND_DATACONTROL_PFI = 'datacontrol:pfi';


    const COMMAND_NOTIFICATIONS_REBUILD = 'notifications:rebuild';

    const COMMAND_ORGANIZATION_SEARCH_REINDEX = 'organization:search:reindex';
+73 −0
Original line number Diff line number Diff line
<?php
/**
 * Created by PhpStorm.
 * User: bouvry
 * Date: 04/10/19
 * Time: 11:49
 */

namespace Oscar\Command;

use Exception;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class OscarDataControlPFICommand extends OscarAdvancedCommandAbstract
{
    protected static $defaultName = OscarCommandAbstract::COMMAND_DATACONTROL_PFI;

    protected function configure()
    {
        parent::configure();
        $this
            ->setDescription("Regarde si les PFI des activités correspondent au format spécifié dans le configuration");
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        parent::execute($input, $output);

        $strict = $this->getOscarConfigurationService()->isPfiStrict();
        $format = "%s";
        if( $strict ){
            $format = "<red>%s</red>";
        }
        $this->getIO()->writeln("Mode strict : <bold>" .($strict ? "<green>OUI</green>" : "<red>non</red>") . "</bold>");
        $regex = $this->getOscarConfigurationService()->getPfiRegex();
        $this->getIO()->writeln("Regex : <bold>" . $regex . "</bold>");


        if( $strict && !$regex ){
            $this->getIO()->error("Le mode STRICT a été activé sans regex défini");
        }

        if( !$regex ) {
            $this->getIO()->writeln('<warning>Pas de REGEX défini</warning>');
            $pfis = $this->getProjectGrantService()->getActivityRepository()->getDistinctPFI();
            foreach ($pfis as $pfi) {
                $this->getIO()->writeln(" - <bold>" . $pfi . "</bold>");
                return 0;
            }
        }

        $repport = $this->getProjectGrantService()->checkPFIRegex($regex, false);
        $sep = "";
        $this->getIO()->write("PFI conforme : ");
        foreach ($repport['valids'] as $pfi) {
            $this->getIO()->writeln("$sep<green>$pfi</green>");
            $sep = ", ";
        }

        $sep = "";
        $this->getIO()->write("PFI non-conforme : ");
        foreach ($repport['warnings'] as $pfi) {
            $this->getIO()->write("$sep<red>$pfi</red>");
            $sep = ", ";
        }
        $this->getIO()->writeln("");


        return 0;
    }
}
 No newline at end of file
+22 −2
Original line number Diff line number Diff line
@@ -266,6 +266,12 @@ class AdministrationController extends AbstractOscarController implements UsePro
            'roleOrganizationPrincipal' => $rolesOrganisationPrincipal
        ];

        if( $this->isAjax() && $this->params()->fromQuery('a') == 'verifypfi' ){
            $regex = $this->params()->fromQuery('reg');
            $pfis = $this->getProjectGrantService()->checkPFIRegex($regex);
            return $this->ajaxResponse(['pfi' => $pfis]);
        }

        if ($this->getHttpXMethod() == "POST") {
            $option = $this->params()->fromPost('parameter_name');
            switch ($option) {
@@ -316,11 +322,24 @@ class AdministrationController extends AbstractOscarController implements UsePro
                    $this->getOscarConfigurationService()->setDocumentUseVersionInName($value);
                    return $this->redirect()->toRoute('administration/parameters');

                case OscarConfigurationService::pfi_strict:
                    $strict = $this->params()->fromPost(OscarConfigurationService::pfi_strict) == "on";
                    $regex = $this->params()->fromPost(OscarConfigurationService::pfi_strict_format);
                    if( $strict == true && !$regex ){
                        throw new OscarException("Vous ne pouvez pas appliquer le mode strict avec une expression régulière vide");
                    } else {
                        // Contrôler la regex
                        $this->getOscarConfigurationService()->setStrict($strict);
                        $this->getOscarConfigurationService()->saveEditableConfKey(OscarConfigurationService::pfi_strict_format, $regex);
                    }
                    return $this->redirect()->toRoute('administration/parameters');

                default:
                    return $this->getResponseBadRequest("Paramètres non-reconnue");
            }
        }


        return [
            OscarConfigurationService::spents_account_filter => implode(
                ', ',
@@ -338,8 +357,9 @@ class AdministrationController extends AbstractOscarController implements UsePro
                'dateformat' => $this->getOscarConfigurationService()->getExportDateFormat()
            ],
            'organization_leader_role' => $organization_leader_role,
            OscarConfigurationService::document_use_version_in_name => $this->getOscarConfigurationService(
            )->getDocumentUseVersionInName()
            OscarConfigurationService::document_use_version_in_name => $this->getOscarConfigurationService()->getDocumentUseVersionInName(),
            OscarConfigurationService::pfi_strict => $this->getOscarConfigurationService()->isPfiStrict(),
            OscarConfigurationService::pfi_strict_format => $this->getOscarConfigurationService()->getPfiRegex(),
        ];
    }

+3 −3
Original line number Diff line number Diff line
@@ -845,8 +845,6 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        }
        $this->getOscarUserContextService()->checkWithorganizationDeep(Privileges::PROJECT_CREATE);

        die("ICI");

        // Création du projet
        $project = new Project();
        $this->getEntityManager()->persist($project);
@@ -2418,9 +2416,11 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                    $oscarNumSeparator = $this->getOscarConfigurationService()->getConfiguration("oscar_num_separator");

                    // La saisie est un PFI
                    if (preg_match($this->getOscarConfigurationService()->getValidationPFI(), $search)) {
                    if ( $this->getOscarConfigurationService()->isPfiStrict()
                        && preg_match($this->getOscarConfigurationService()->getValidationPFI(), $search)) {
                        $parameters['search'] = $search;
                        $qb->andWhere('c.codeEOTP = :search');
                        $qb->andWhere('c.codeEOTP = :search');
                    } elseif (preg_match('/(.*)=(.*)/', $search, $result)) {
                        $key = $result[1];
                        $value = $result[2];
Loading