mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 22:43:19 +00:00
Merge branch 'master' into PHRAS-1661-user-list
This commit is contained in:
@@ -23,7 +23,9 @@ 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\ListCollectionCommand;
|
||||
use Alchemy\Phrasea\Command\Databox\CreateDataboxCommand;
|
||||
use Alchemy\Phrasea\Command\Databox\ListDataboxCommand;
|
||||
use Alchemy\Phrasea\Command\MailTest;
|
||||
use Alchemy\Phrasea\Command\Compile\Configuration;
|
||||
use Alchemy\Phrasea\Command\RecordAdd;
|
||||
@@ -109,6 +111,9 @@ $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 ListCollectionCommand('collection:list'));
|
||||
|
||||
$cli->command(new ListDataboxCommand('databox:list'));
|
||||
$cli->command(new CreateDataboxCommand('databox:create'));
|
||||
|
||||
$cli->command(new UserListCommand('user:list'));
|
||||
|
@@ -0,0 +1,76 @@
|
||||
<?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\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ListCollectionCommand extends Command
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct('collection:list');
|
||||
$this->setDescription('List all collection in Phraseanet')
|
||||
->addOption('databox_id', 'd', InputOption::VALUE_REQUIRED, 'The id of the databox to list collection')
|
||||
->setHelp('');
|
||||
return $this;
|
||||
}
|
||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
try {
|
||||
$databox = $this->container->findDataboxById($input->getOption('databox_id'));
|
||||
$collections = $this->listDataboxCollections($databox);
|
||||
|
||||
$table = $this->getHelperSet()->get('table');
|
||||
$table
|
||||
->setHeaders(['id local for API', 'id distant', 'name','label','status','total records'])
|
||||
->setRows($collections)
|
||||
->render($output);
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln("<error>{$e->getMessage()}</error>");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function listDataboxCollections(\databox $databox)
|
||||
{
|
||||
return array_map(function (\collection $collection) {
|
||||
return $this->listCollection($collection);
|
||||
}, array_merge($databox->get_collections(),$this->getUnabledCollection($databox->get_activable_colls())));
|
||||
}
|
||||
|
||||
private function getUnabledCollection($collections)
|
||||
{
|
||||
return array_map(function ($colId){
|
||||
return \collection::getByBaseId($this->container, $colId);
|
||||
},$collections);
|
||||
|
||||
}
|
||||
|
||||
private function listCollection(\collection $collection)
|
||||
{
|
||||
return [
|
||||
$collection->get_base_id(),
|
||||
$collection->get_coll_id(),
|
||||
$collection->get_name(),
|
||||
'en: ' . $collection->get_label('en') .
|
||||
', de: ' . $collection->get_label('de') .
|
||||
', fr: ' . $collection->get_label('fr') .
|
||||
', nl: ' . $collection->get_label('nl'),
|
||||
($collection->is_active()) ? 'enabled' : 'disabled',
|
||||
$collection->get_record_amount()
|
||||
];
|
||||
}
|
||||
}
|
62
lib/Alchemy/Phrasea/Command/Databox/ListDataboxCommand.php
Normal file
62
lib/Alchemy/Phrasea/Command/Databox/ListDataboxCommand.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ListDataboxCommand extends Command
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct('databox:list');
|
||||
|
||||
$this->setDescription('List all databox in Phraseanet')
|
||||
->setHelp('');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
try {
|
||||
$databoxes = array_map(function (\databox $databox) {
|
||||
return $this->listDatabox($databox);
|
||||
}, $this->container->getApplicationBox()->get_databoxes());
|
||||
|
||||
$table = $this->getHelperSet()->get('table');
|
||||
$table
|
||||
->setHeaders(['id', 'name', 'alias'])
|
||||
->setRows($databoxes)
|
||||
->render($output);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln('<error>Listing databox failed : '.$e->getMessage().'</error>');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function listDatabox(\databox $databox)
|
||||
{
|
||||
return [
|
||||
$databox->get_sbas_id(),
|
||||
$databox->get_dbname(),
|
||||
$databox->get_viewname()
|
||||
];
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user