Commit 6184fca4 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Mode non interactif pour la mise à jour des privilèges

parent e165e78c
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -3,6 +3,9 @@ services:

  # OSCAR (sources)
  £CONTAINER_OSCAR:
    depends_on:
      - £CONTAINER_ELASTICSEARCH
      - £CONTAINER_POSTGRESQL
    container_name: £CONTAINER_OSCAR
    build:
        context: ./oscar/
@@ -47,8 +50,6 @@ services:
  # --------------------------------------------------------------------------------------------------------------------
  # POSTGRESQL
  £CONTAINER_POSTGRESQL:
    depends_on:
      - £CONTAINER_OSCAR
    container_name: £CONTAINER_POSTGRESQL
    build:
      context: ./postgresql/
@@ -81,6 +82,7 @@ services:
      - £CONTAINER_NETWORK
    tty: true


  # GEARMAN
  £CONTAINER_GEARMAN:
    container_name: £CONTAINER_GEARMAN
+2 −1
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@ chmod -R 777 data/DoctrineORMModule
### DEMO DATAS
php bin/oscar.php auth:sync install/demo/authentification.json
php bin/oscar.php organizations:sync-json install/demo/organizations.json
php bin/oscar.php persons:sync-json install/demo/organizations.json
php bin/oscar.php persons:sync-json install/demo/persons.json
php bin/oscar.php check:privileges -n
php bin/oscar.php check:privileges -n

exit 0
 No newline at end of file
+10 −4
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ use Oscar\Service\OrganizationService;
use Oscar\Service\OscarConfigurationService;
use Oscar\Service\PersonService;
use Oscar\Service\ProjectGrantService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -25,13 +26,13 @@ abstract class OscarAdvancedCommandAbstract extends OscarCommandAbstract
    const OPTION_VERBOSE = 'verbose';

    /** @var InputInterface */
    private $input;
    private InputInterface $input;

    /** @var OutputInterface */
    private $output;
    private OutputInterface $output;

    /** @var SymfonyStyle */
    private $io;
    private SymfonyStyle $io;

    protected function configure()
    {
@@ -62,9 +63,14 @@ abstract class OscarAdvancedCommandAbstract extends OscarCommandAbstract
        return $this->io;
    }

    protected function isNoInteraction() :bool
    {
        return !$this->input->isInteractive();
    }

    protected function isInteractive(): bool
    {
        return !($this->isForce() || $this->isQuiet());
        return !($this->isForce() || $this->isQuiet() || $this->isNoInteraction());
    }

    protected function isForce(): bool
+17 −33
Original line number Diff line number Diff line
@@ -8,33 +8,13 @@

namespace Oscar\Command;


use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\SchemaValidator;
use Moment\Moment;
use Oscar\Entity\Authentification;
use Oscar\Entity\LogActivity;
use Oscar\Entity\Person;
use Oscar\Entity\Role;
use Oscar\OscarVersion;
use Oscar\Service\ConfigurationParser;
use Oscar\Service\ConnectorService;
use Oscar\Service\MaintenanceService;
use Oscar\Service\OrganizationService;
use Oscar\Service\OscarConfigurationService;
use Oscar\Service\OscarUserContext;
use Oscar\Service\PersonService;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Yaml\Parser;
use Zend\Config\Reader\Yaml;

class OscarCheckPrivilegesCommand extends OscarCommandAbstract
class OscarCheckPrivilegesCommand extends OscarAdvancedCommandAbstract
{
    protected static $defaultName = 'check:privileges';

@@ -45,17 +25,21 @@ class OscarCheckPrivilegesCommand extends OscarCommandAbstract
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    protected function execute(InputInterface $input, OutputInterface $output) :int
    {
        $this->addOutputStyle($output);

        parent::execute($input, $output);
        try {
            /** @var MaintenanceService $maintenanceService */
            $maintenanceService = $this->getServicemanager()->get(MaintenanceService::class);

            $force = $this->isForce();
            $io = new SymfonyStyle($input, $output);

            $io->title("Synchronisation des privilèges");
            $todo = $maintenanceService->privilegesCheckUpdate($io, $this->isNoInteraction());

        $todo = $maintenanceService->privilegesCheckUpdate($io);
            return 0;
        } catch (\Exception $e) {
            $this->finalFatalError($e->getMessage());
            return 1;
        }
    }
}
 No newline at end of file
+6 −2
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ class MaintenanceService implements UseEntityManager
        return false;
    }

    public function privilegesCheckUpdate(OutputStyle $output){
    public function privilegesCheckUpdate(OutputStyle $output, bool $nointeraction = false){

        $cheminFichier = realpath(__DIR__ . '/../../../../../install/privileges.json');

@@ -155,7 +155,11 @@ class MaintenanceService implements UseEntityManager
            return;
        }

        if( !$nointeraction ){
            $confirm = $output->confirm("Mettre à jour les privilèges ?", false);
        } else {
            $confirm = true;
        }

        if ($confirm !== true) {
            $output->warning("Opération abandonnée");