Loading module/Oscar/src/Oscar/Controller/AdministrationController.php +17 −2 Original line number Diff line number Diff line Loading @@ -352,6 +352,16 @@ class AdministrationController extends AbstractOscarController implements UsePro if ($this->getHttpXMethod() == "POST") { $option = $this->params()->fromPost('parameter_name'); switch ($option) { case OscarConfigurationService::ORGANIZATION_REQUIRED: $this->getLoggerService()->info("Enregistrement des options des organisations"); $typeRequired = $this->params()->fromPost('organization_type') == "on"; $countryRequired = $this->params()->fromPost('organization_country') == "on"; $this->getOscarConfigurationService() ->saveEditableConfKey("organization_require_type", $typeRequired); $this->getOscarConfigurationService() ->saveEditableConfKey("organization_require_country", $countryRequired); return $this->redirect()->toRoute('administration/parameters'); case OscarConfigurationService::allow_node_selection: $value = $this->params()->fromPost('parameter_value') == "on"; $this->getOscarConfigurationService()->setAllowNodeSelection($value); Loading Loading @@ -427,9 +437,10 @@ class AdministrationController extends AbstractOscarController implements UsePro ); } return $this->redirect()->toRoute('administration/parameters'); case OscarConfigurationService::ORGANIZATION_REQUIRED: throw new OscarException("A faire"); default: return $this->getResponseBadRequest("Paramètres non-reconnue"); return $this->getResponseBadRequest("Paramètres $option non-reconnue"); } } Loading Loading @@ -466,6 +477,10 @@ class AdministrationController extends AbstractOscarController implements UsePro )->getConfiguration('validation.pfi'), "allow_node_selection" => $this->getOscarConfigurationService( )->isAllowNodeSelection(), "organizationRequire" => [ "type" => $this->getOscarConfigurationService()->getOrganizationRequired()['type'], "country" => $this->getOscarConfigurationService()->getOrganizationRequired()['country'] ] ]; } Loading module/Oscar/src/Oscar/Controller/OrganizationController.php +2 −0 Original line number Diff line number Diff line Loading @@ -498,6 +498,7 @@ class OrganizationController extends AbstractOscarController implements UseOrgan $this->getOrganizationService(), $this->getOrganizationService()->getOrganizationTypesObject() ); $form->configureRequired($this->getOscarConfigurationService()->getRequiredOrganization()); $entity = new Organization(); $form->init(); $form->bind($entity); Loading Loading @@ -883,6 +884,7 @@ class OrganizationController extends AbstractOscarController implements UseOrgan $this->getOrganizationService(), $this->getOrganizationService()->getOrganizationTypesObject() ); $form->configureRequired($this->getOscarConfigurationService()->getRequiredOrganization()); $form->init(); $form->bind($entity); Loading module/Oscar/src/Oscar/Entity/Country3166Repository.php +2 −2 Original line number Diff line number Diff line Loading @@ -29,9 +29,9 @@ class Country3166Repository extends EntityRepository return $q->getQuery()->getResult(); } public function getAllForSelects() public function getAllForSelects() :array { $out = ["" => "Non-définit"]; $out = ["" => "Non défini"]; /** @var Country3166 $country */ foreach ($this->getAll() as $country) { $out[$country->getFr()] = $country->getFr(); Loading module/Oscar/src/Oscar/Form/OrganizationIdentificationForm.php +110 −67 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace Oscar\Form; use Laminas\Validator\GreaterThan; use Laminas\Validator\NotEmpty; use Oscar\Hydrator\OrganizationFormHydrator; use Oscar\Service\OrganizationService; use Laminas\Form\Element; Loading @@ -19,8 +21,10 @@ class OrganizationIdentificationForm extends \Laminas\Form\Form implements Input private $connectors = []; private $types = []; private $countries = []; private bool $countryRequired = false; private bool $typeRequired = false; function __construct(OrganizationService $organizationService, $types = []) public function __construct(OrganizationService $organizationService, $types = []) { parent::__construct('organization'); $this->connectors = $organizationService->getConnectorsList(); Loading @@ -28,7 +32,14 @@ class OrganizationIdentificationForm extends \Laminas\Form\Form implements Input $this->types = $types; } public function init(){ public function configureRequired(array $params): void { $this->countryRequired = $params['country'] == true; $this->typeRequired = $params['type'] == true; } public function init(): void { $this->setHydrator(new OrganizationFormHydrator($this->connectors, $this->types, $this->countries)); $typesSelect = []; Loading Loading @@ -185,7 +196,6 @@ class OrganizationIdentificationForm extends \Laminas\Form\Form implements Input ]); $eotp = new Element\Text('code'); $eotp->setAttributes([ 'class' => 'form-control', Loading Loading @@ -285,7 +295,7 @@ class OrganizationIdentificationForm extends \Laminas\Form\Form implements Input public function getInputFilterSpecification() { return [ $filterSpecification = [ 'dateStart' => [ 'required' => false, ], Loading @@ -295,12 +305,45 @@ class OrganizationIdentificationForm extends \Laminas\Form\Form implements Input ], 'country' => [ 'required' => $this->countryRequired, 'validators' => [ [ 'name' => NotEmpty::class, 'options' => [ 'messages' => [ NotEmpty::IS_EMPTY => "Vous devez définir un pays" ] ] ] ] ], 'type' => [ 'required' => false ], 'type' => [ 'typeObj' => [ 'required' => false ] ]; if ($this->typeRequired) { $filterSpecification['typeObj'] = [ 'required' => true, 'validators' => [ [ 'name' => \Laminas\Validator\GreaterThan::class, 'options' => [ 'min' => 1, 'inclusive' => true, 'messages' => [ GreaterThan::NOT_GREATER_INCLUSIVE => "Vous devez choisir un type d'organisation" ] ] ] ] ]; } return $filterSpecification; } } No newline at end of file module/Oscar/src/Oscar/Service/OscarConfigurationService.php +31 −10 Original line number Diff line number Diff line Loading @@ -45,9 +45,19 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface const spent_effective_clause = 'spent_effective_clause'; const spent_predicted_clause = 'spent_predicted_clause'; const ORGANIZATION_REQUIRED = 'organization_required'; const theme = 'theme'; public function getOrganizationRequired(): array { return [ 'type' => $this->getEditableConfKey('organization_require_type', false), 'country' => $this->getEditableConfKey('organization_require_country', false), ]; } public function emptyProjectRequireValidation(): bool { return $this->getConfiguration(self::empty_project_require_validation); Loading Loading @@ -299,7 +309,9 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface $conf = $this->getEditableConfRoot(); $conf[$key] = $value; $writer = new Dumper(); file_put_contents($this->getYamlConfigPath(), $writer->dump($conf)); if (!file_put_contents($this->getYamlConfigPath(), $writer->dump($conf))) { throw new OscarException("Impossible d'enregistrer la configuration"); } return $this; } Loading Loading @@ -954,4 +966,13 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface { return $this->getServiceLocator()->get('Config')['unicaen-signature']['enabled'] == true; } public function getRequiredOrganization() { return [ 'type' => $this->getEditableConfKey('organization_require_type') == true, 'country' => $this->getEditableConfKey('organization_require_country') == true ]; } } No newline at end of file Loading
module/Oscar/src/Oscar/Controller/AdministrationController.php +17 −2 Original line number Diff line number Diff line Loading @@ -352,6 +352,16 @@ class AdministrationController extends AbstractOscarController implements UsePro if ($this->getHttpXMethod() == "POST") { $option = $this->params()->fromPost('parameter_name'); switch ($option) { case OscarConfigurationService::ORGANIZATION_REQUIRED: $this->getLoggerService()->info("Enregistrement des options des organisations"); $typeRequired = $this->params()->fromPost('organization_type') == "on"; $countryRequired = $this->params()->fromPost('organization_country') == "on"; $this->getOscarConfigurationService() ->saveEditableConfKey("organization_require_type", $typeRequired); $this->getOscarConfigurationService() ->saveEditableConfKey("organization_require_country", $countryRequired); return $this->redirect()->toRoute('administration/parameters'); case OscarConfigurationService::allow_node_selection: $value = $this->params()->fromPost('parameter_value') == "on"; $this->getOscarConfigurationService()->setAllowNodeSelection($value); Loading Loading @@ -427,9 +437,10 @@ class AdministrationController extends AbstractOscarController implements UsePro ); } return $this->redirect()->toRoute('administration/parameters'); case OscarConfigurationService::ORGANIZATION_REQUIRED: throw new OscarException("A faire"); default: return $this->getResponseBadRequest("Paramètres non-reconnue"); return $this->getResponseBadRequest("Paramètres $option non-reconnue"); } } Loading Loading @@ -466,6 +477,10 @@ class AdministrationController extends AbstractOscarController implements UsePro )->getConfiguration('validation.pfi'), "allow_node_selection" => $this->getOscarConfigurationService( )->isAllowNodeSelection(), "organizationRequire" => [ "type" => $this->getOscarConfigurationService()->getOrganizationRequired()['type'], "country" => $this->getOscarConfigurationService()->getOrganizationRequired()['country'] ] ]; } Loading
module/Oscar/src/Oscar/Controller/OrganizationController.php +2 −0 Original line number Diff line number Diff line Loading @@ -498,6 +498,7 @@ class OrganizationController extends AbstractOscarController implements UseOrgan $this->getOrganizationService(), $this->getOrganizationService()->getOrganizationTypesObject() ); $form->configureRequired($this->getOscarConfigurationService()->getRequiredOrganization()); $entity = new Organization(); $form->init(); $form->bind($entity); Loading Loading @@ -883,6 +884,7 @@ class OrganizationController extends AbstractOscarController implements UseOrgan $this->getOrganizationService(), $this->getOrganizationService()->getOrganizationTypesObject() ); $form->configureRequired($this->getOscarConfigurationService()->getRequiredOrganization()); $form->init(); $form->bind($entity); Loading
module/Oscar/src/Oscar/Entity/Country3166Repository.php +2 −2 Original line number Diff line number Diff line Loading @@ -29,9 +29,9 @@ class Country3166Repository extends EntityRepository return $q->getQuery()->getResult(); } public function getAllForSelects() public function getAllForSelects() :array { $out = ["" => "Non-définit"]; $out = ["" => "Non défini"]; /** @var Country3166 $country */ foreach ($this->getAll() as $country) { $out[$country->getFr()] = $country->getFr(); Loading
module/Oscar/src/Oscar/Form/OrganizationIdentificationForm.php +110 −67 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace Oscar\Form; use Laminas\Validator\GreaterThan; use Laminas\Validator\NotEmpty; use Oscar\Hydrator\OrganizationFormHydrator; use Oscar\Service\OrganizationService; use Laminas\Form\Element; Loading @@ -19,8 +21,10 @@ class OrganizationIdentificationForm extends \Laminas\Form\Form implements Input private $connectors = []; private $types = []; private $countries = []; private bool $countryRequired = false; private bool $typeRequired = false; function __construct(OrganizationService $organizationService, $types = []) public function __construct(OrganizationService $organizationService, $types = []) { parent::__construct('organization'); $this->connectors = $organizationService->getConnectorsList(); Loading @@ -28,7 +32,14 @@ class OrganizationIdentificationForm extends \Laminas\Form\Form implements Input $this->types = $types; } public function init(){ public function configureRequired(array $params): void { $this->countryRequired = $params['country'] == true; $this->typeRequired = $params['type'] == true; } public function init(): void { $this->setHydrator(new OrganizationFormHydrator($this->connectors, $this->types, $this->countries)); $typesSelect = []; Loading Loading @@ -185,7 +196,6 @@ class OrganizationIdentificationForm extends \Laminas\Form\Form implements Input ]); $eotp = new Element\Text('code'); $eotp->setAttributes([ 'class' => 'form-control', Loading Loading @@ -285,7 +295,7 @@ class OrganizationIdentificationForm extends \Laminas\Form\Form implements Input public function getInputFilterSpecification() { return [ $filterSpecification = [ 'dateStart' => [ 'required' => false, ], Loading @@ -295,12 +305,45 @@ class OrganizationIdentificationForm extends \Laminas\Form\Form implements Input ], 'country' => [ 'required' => $this->countryRequired, 'validators' => [ [ 'name' => NotEmpty::class, 'options' => [ 'messages' => [ NotEmpty::IS_EMPTY => "Vous devez définir un pays" ] ] ] ] ], 'type' => [ 'required' => false ], 'type' => [ 'typeObj' => [ 'required' => false ] ]; if ($this->typeRequired) { $filterSpecification['typeObj'] = [ 'required' => true, 'validators' => [ [ 'name' => \Laminas\Validator\GreaterThan::class, 'options' => [ 'min' => 1, 'inclusive' => true, 'messages' => [ GreaterThan::NOT_GREATER_INCLUSIVE => "Vous devez choisir un type d'organisation" ] ] ] ] ]; } return $filterSpecification; } } No newline at end of file
module/Oscar/src/Oscar/Service/OscarConfigurationService.php +31 −10 Original line number Diff line number Diff line Loading @@ -45,9 +45,19 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface const spent_effective_clause = 'spent_effective_clause'; const spent_predicted_clause = 'spent_predicted_clause'; const ORGANIZATION_REQUIRED = 'organization_required'; const theme = 'theme'; public function getOrganizationRequired(): array { return [ 'type' => $this->getEditableConfKey('organization_require_type', false), 'country' => $this->getEditableConfKey('organization_require_country', false), ]; } public function emptyProjectRequireValidation(): bool { return $this->getConfiguration(self::empty_project_require_validation); Loading Loading @@ -299,7 +309,9 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface $conf = $this->getEditableConfRoot(); $conf[$key] = $value; $writer = new Dumper(); file_put_contents($this->getYamlConfigPath(), $writer->dump($conf)); if (!file_put_contents($this->getYamlConfigPath(), $writer->dump($conf))) { throw new OscarException("Impossible d'enregistrer la configuration"); } return $this; } Loading Loading @@ -954,4 +966,13 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface { return $this->getServiceLocator()->get('Config')['unicaen-signature']['enabled'] == true; } public function getRequiredOrganization() { return [ 'type' => $this->getEditableConfKey('organization_require_type') == true, 'country' => $this->getEditableConfKey('organization_require_country') == true ]; } } No newline at end of file