Merge branch 'master' into PHRAS-1648-user-password

This commit is contained in:
Nicolas Maillat
2020-02-28 18:42:45 +01:00
committed by GitHub
4 changed files with 189 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2016 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Command\Collection;
use Alchemy\Phrasea\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;
class PublishCollectionCommand extends Command
{
/**
* Constructor
*/
public function __construct($name = null)
{
parent::__construct('collection:publish');
$this->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, '<question> Do you want really publish this collection? (y/N)</question>', 'N'));
} while ( ! in_array($continue, ['y', 'n']));
if ($continue !== 'y') {
$output->writeln('Aborting !');
return;
}
$collection->enable($this->container->getApplicationBox());
$output->writeln('<info>Publish collection successful</info>');
} catch (\Exception $e) {
$output->writeln('<error>Publish collection failed : '.$e->getMessage().'</error>');
}
return 0;
}
}

View File

@@ -0,0 +1,61 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2016 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Command\Collection;
use Alchemy\Phrasea\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;
class UnPublishCollectionCommand extends Command
{
/**
* Constructor
*/
public function __construct($name = null)
{
parent::__construct('collection:unpublish');
$this->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, sprintf("<question> Do you want really unpublish the collection %s? (y/N)</question>", $collection->get_name()), 'N'));
} while ( ! in_array($continue, ['y', 'n']));
if ($continue !== 'y') {
$output->writeln('<info>Aborting !</>');
return;
}
$collection->disable($this->container->getApplicationBox());
$output->writeln('<info>Unpublish collection successful</info>');
} catch (\Exception $e) {
$output->writeln('<error>Unpublish collection failed : '.$e->getMessage().'</error>');
}
return 0;
}
}

View File

@@ -0,0 +1,60 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2016 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Command\Databox;
use Alchemy\Phrasea\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class UnMountDataboxCommand extends Command
{
/**
* Constructor
*/
public function __construct($name = null)
{
parent::__construct('databox:unmount');
$this->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, '<question> Do you want really unmount this databox? (y/N)</question>', 'N'));
} while ( ! in_array($continue, ['y', 'n']));
if ($continue !== 'y') {
$output->writeln('Aborting !');
return;
}
$databox->unmount_databox();
$output->writeln('<info>Unmount databox successful</info>');
} catch (\Exception $e) {
$output->writeln('<error>Unmount databox failed : '.$e->getMessage().'</error>');
}
return 0;
}
}