From f5adf02c557173611a765edaddcda6672f714d89 Mon Sep 17 00:00:00 2001 From: aynsix Date: Thu, 20 Feb 2020 16:10:15 +0300 Subject: [PATCH 1/4] command databox:unmount --- bin/console | 2 + .../Command/Databox/UnMountDataboxCommand.php | 60 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 lib/Alchemy/Phrasea/Command/Databox/UnMountDataboxCommand.php diff --git a/bin/console b/bin/console index 552cb672d0..e42afb9a99 100755 --- a/bin/console +++ b/bin/console @@ -24,6 +24,7 @@ use Alchemy\Phrasea\Command\Thesaurus\FindConceptsCommand; use Alchemy\Phrasea\Core\Version; use Alchemy\Phrasea\Command\CreateCollection; use Alchemy\Phrasea\Command\Databox\CreateDataboxCommand; +use Alchemy\Phrasea\Command\Databox\UnMountDataboxCommand; use Alchemy\Phrasea\Command\MailTest; use Alchemy\Phrasea\Command\Compile\Configuration; use Alchemy\Phrasea\Command\RecordAdd; @@ -109,6 +110,7 @@ $cli->command(new \module_console_fieldsMerge('fields:merge')); $cli->command(new CreateCollection('collection:create')); $cli->command(new CreateDataboxCommand('databox:create')); +$cli->command(new UnMountDataboxCommand('databox:unmount')); $cli->command(new RecordAdd('records:add')); $cli->command(new RescanTechnicalDatas('records:rescan-technical-datas')); diff --git a/lib/Alchemy/Phrasea/Command/Databox/UnMountDataboxCommand.php b/lib/Alchemy/Phrasea/Command/Databox/UnMountDataboxCommand.php new file mode 100644 index 0000000000..42199a519f --- /dev/null +++ b/lib/Alchemy/Phrasea/Command/Databox/UnMountDataboxCommand.php @@ -0,0 +1,60 @@ +setDescription('Unmount databox') + ->addArgument('databox_id', InputArgument::REQUIRED, 'The id of the databox to unmount', null) + ; + + return $this; + } + + protected function doExecute(InputInterface $input, OutputInterface $output) + { + try { + $databox = $this->container->findDataboxById($input->getArgument('databox_id')); + $dialog = $this->getHelperSet()->get('dialog'); + + do { + $continue = mb_strtolower($dialog->ask($output, ' Do you want really unmount this databox? (y/N)', 'N')); + } while ( ! in_array($continue, ['y', 'n'])); + + if ($continue !== 'y') { + $output->writeln('Aborting !'); + + return; + } + + $databox->unmount_databox(); + $output->writeln('Unmount databox successful'); + } catch (\Exception $e) { + $output->writeln('Unmount databox failed : '.$e->getMessage().''); + } + + return 0; + } + +} From f4bb9e706fc98f10eafc9708eb142f190c7ead17 Mon Sep 17 00:00:00 2001 From: aynsix Date: Thu, 20 Feb 2020 16:22:51 +0300 Subject: [PATCH 2/4] command collection:publish --- bin/console | 3 + .../Collection/PublishCollectionCommand.php | 61 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 lib/Alchemy/Phrasea/Command/Collection/PublishCollectionCommand.php diff --git a/bin/console b/bin/console index 552cb672d0..d5c3f4ac8a 100755 --- a/bin/console +++ b/bin/console @@ -23,6 +23,7 @@ use Alchemy\Phrasea\Command\SearchEngine\IndexPopulateCommand; use Alchemy\Phrasea\Command\Thesaurus\FindConceptsCommand; use Alchemy\Phrasea\Core\Version; use Alchemy\Phrasea\Command\CreateCollection; +use Alchemy\Phrasea\Command\Collection\PublishCollectionCommand; use Alchemy\Phrasea\Command\Databox\CreateDataboxCommand; use Alchemy\Phrasea\Command\MailTest; use Alchemy\Phrasea\Command\Compile\Configuration; @@ -108,6 +109,8 @@ $cli->command(new \module_console_fieldsRename('fields:rename')); $cli->command(new \module_console_fieldsMerge('fields:merge')); $cli->command(new CreateCollection('collection:create')); +$cli->command(new PublishCollectionCommand('collection:publish')); + $cli->command(new CreateDataboxCommand('databox:create')); $cli->command(new RecordAdd('records:add')); diff --git a/lib/Alchemy/Phrasea/Command/Collection/PublishCollectionCommand.php b/lib/Alchemy/Phrasea/Command/Collection/PublishCollectionCommand.php new file mode 100644 index 0000000000..6cfac3a388 --- /dev/null +++ b/lib/Alchemy/Phrasea/Command/Collection/PublishCollectionCommand.php @@ -0,0 +1,61 @@ +setDescription('Publish collection in Phraseanet') + ->addOption('collection_id', null, InputOption::VALUE_REQUIRED, 'The base_id of the collection to publish but keep with existing right into present in application box.') + ->setHelp(''); + + return $this; + } + + protected function doExecute(InputInterface $input, OutputInterface $output) + { + try { + + $collection = \collection::getByBaseId($this->container,(int)$input->getOption('collection_id')); + $dialog = $this->getHelperSet()->get('dialog'); + + do { + $continue = mb_strtolower($dialog->ask($output, ' Do you want really publish this collection? (y/N)', 'N')); + } while ( ! in_array($continue, ['y', 'n'])); + + if ($continue !== 'y') { + $output->writeln('Aborting !'); + + return; + } + + $collection->enable($this->container->getApplicationBox()); + $output->writeln('Publish collection successful'); + } catch (\Exception $e) { + $output->writeln('Publish collection failed : '.$e->getMessage().''); + } + + return 0; + } + +} From 57fdfd432e80d961b6cac2ad40fa58eaafea5eed Mon Sep 17 00:00:00 2001 From: aynsix Date: Thu, 20 Feb 2020 16:32:08 +0300 Subject: [PATCH 3/4] command collection:unpublish --- bin/console | 2 + .../Collection/UnPublishCollectionCommand.php | 61 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 lib/Alchemy/Phrasea/Command/Collection/UnPublishCollectionCommand.php diff --git a/bin/console b/bin/console index 552cb672d0..22811df67a 100755 --- a/bin/console +++ b/bin/console @@ -23,6 +23,7 @@ use Alchemy\Phrasea\Command\SearchEngine\IndexPopulateCommand; use Alchemy\Phrasea\Command\Thesaurus\FindConceptsCommand; use Alchemy\Phrasea\Core\Version; use Alchemy\Phrasea\Command\CreateCollection; +use Alchemy\Phrasea\Command\Collection\UnPublishCollectionCommand; use Alchemy\Phrasea\Command\Databox\CreateDataboxCommand; use Alchemy\Phrasea\Command\MailTest; use Alchemy\Phrasea\Command\Compile\Configuration; @@ -108,6 +109,7 @@ $cli->command(new \module_console_fieldsRename('fields:rename')); $cli->command(new \module_console_fieldsMerge('fields:merge')); $cli->command(new CreateCollection('collection:create')); +$cli->command(new UnPublishCollectionCommand('collection:unpublish')); $cli->command(new CreateDataboxCommand('databox:create')); $cli->command(new RecordAdd('records:add')); diff --git a/lib/Alchemy/Phrasea/Command/Collection/UnPublishCollectionCommand.php b/lib/Alchemy/Phrasea/Command/Collection/UnPublishCollectionCommand.php new file mode 100644 index 0000000000..70d857e5d1 --- /dev/null +++ b/lib/Alchemy/Phrasea/Command/Collection/UnPublishCollectionCommand.php @@ -0,0 +1,61 @@ +setDescription('Unpublish collection in Phraseanet') + ->addOption('collection_id', null, InputOption::VALUE_REQUIRED, 'The base_id of the collection to unpublish, the base_id is the same id used in API.') + ->setHelp(''); + + return $this; + } + + protected function doExecute(InputInterface $input, OutputInterface $output) + { + try { + + $collection = \collection::getByBaseId($this->container,(int)$input->getOption('collection_id')); + $dialog = $this->getHelperSet()->get('dialog'); + + do { + $continue = mb_strtolower($dialog->ask($output, ' Do you want really unpublish this collection? (y/N)', 'N')); + } while ( ! in_array($continue, ['y', 'n'])); + + if ($continue !== 'y') { + $output->writeln('Aborting !'); + + return; + } + + $collection->disable($this->container->getApplicationBox()); + $output->writeln('Unpublish collection successful'); + } catch (\Exception $e) { + $output->writeln('Unpublish collection failed : '.$e->getMessage().''); + } + + return 0; + } + +} From 1c081ea25cc9e27a646d71277af8e22b9b36c8a3 Mon Sep 17 00:00:00 2001 From: aynsix Date: Fri, 28 Feb 2020 16:54:49 +0300 Subject: [PATCH 4/4] fix confirmation message --- .../Phrasea/Command/Collection/UnPublishCollectionCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Alchemy/Phrasea/Command/Collection/UnPublishCollectionCommand.php b/lib/Alchemy/Phrasea/Command/Collection/UnPublishCollectionCommand.php index 70d857e5d1..ef0fc9dae5 100644 --- a/lib/Alchemy/Phrasea/Command/Collection/UnPublishCollectionCommand.php +++ b/lib/Alchemy/Phrasea/Command/Collection/UnPublishCollectionCommand.php @@ -40,11 +40,11 @@ class UnPublishCollectionCommand extends Command $dialog = $this->getHelperSet()->get('dialog'); do { - $continue = mb_strtolower($dialog->ask($output, ' Do you want really unpublish this collection? (y/N)', 'N')); + $continue = mb_strtolower($dialog->ask($output, sprintf(" Do you want really unpublish the collection %s? (y/N)", $collection->get_name()), 'N')); } while ( ! in_array($continue, ['y', 'n'])); if ($continue !== 'y') { - $output->writeln('Aborting !'); + $output->writeln('Aborting !'); return; }