mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00
add model option in user:list
This commit is contained in:
@@ -42,6 +42,7 @@ class UserListCommand extends Command
|
|||||||
->addOption('application', null, InputOption::VALUE_NONE, 'List application of user work only if --user_id is set')
|
->addOption('application', null, InputOption::VALUE_NONE, 'List application of user work only if --user_id is set')
|
||||||
->addOption('right', null, InputOption::VALUE_NONE, 'Show right information')
|
->addOption('right', null, InputOption::VALUE_NONE, 'Show right information')
|
||||||
->addOption('adress', null, InputOption::VALUE_NONE, 'Show adress information')
|
->addOption('adress', null, InputOption::VALUE_NONE, 'Show adress information')
|
||||||
|
->addOption('model', null, InputOption::VALUE_NONE, "Show only defined model, if --user_id is set with --model it's the template owner")
|
||||||
->addOption('jsonformat', null, InputOption::VALUE_NONE, 'Output in json format')
|
->addOption('jsonformat', null, InputOption::VALUE_NONE, 'Output in json format')
|
||||||
->setHelp('');
|
->setHelp('');
|
||||||
|
|
||||||
@@ -62,6 +63,7 @@ class UserListCommand extends Command
|
|||||||
$created = $input->getOption('created');
|
$created = $input->getOption('created');
|
||||||
$updated = $input->getOption('updated');
|
$updated = $input->getOption('updated');
|
||||||
$withRight = $input->getOption('right');
|
$withRight = $input->getOption('right');
|
||||||
|
$model = $input->getOption('model');
|
||||||
$jsonformat = $input->getOption('jsonformat');
|
$jsonformat = $input->getOption('jsonformat');
|
||||||
|
|
||||||
$query = $this->container['phraseanet.user-query'];
|
$query = $this->container['phraseanet.user-query'];
|
||||||
@@ -70,18 +72,26 @@ class UserListCommand extends Command
|
|||||||
if($collectionId) $query->on_sbas_ids([$collectionId]);
|
if($collectionId) $query->on_sbas_ids([$collectionId]);
|
||||||
if($created) $this->addFilterDate($created,'created',$query);
|
if($created) $this->addFilterDate($created,'created',$query);
|
||||||
if($updated) $this->addFilterDate($updated,'updated',$query);
|
if($updated) $this->addFilterDate($updated,'updated',$query);
|
||||||
if($userId) $query->addSqlFilter('Users.id = ?' ,[$userId]);
|
if($userId && !$model) $query->addSqlFilter('Users.id = ?' ,[$userId]);
|
||||||
if($userEmail) $query->addSqlFilter('Users.email = ?' ,[$userEmail]);
|
if($userEmail && !$model) $query->addSqlFilter('Users.email = ?' ,[$userEmail]);
|
||||||
if($lockStatus) $query->addSqlFilter('Users.mail_locked = 1');
|
if($lockStatus && !$model) $query->addSqlFilter('Users.mail_locked = 1');
|
||||||
if($guest) $query->include_invite(true)->addSqlFilter('Users.guest = 1');
|
if($guest && !$model) $query->include_invite(true)->addSqlFilter('Users.guest = 1');
|
||||||
|
|
||||||
if ($application and !$userId) {
|
if ($application and !$userId) {
|
||||||
$output->writeln('<error>You must provide --user_id when using --application option</error>');
|
$output->writeln('<error>You must provide --user_id when using --application option</error>');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = $query
|
/** @var UserRepository $userRepository */
|
||||||
->execute()->get_results();
|
$userRepository = $this->container['repo.users'];
|
||||||
|
|
||||||
|
if ($model && $userId) {
|
||||||
|
$users = $userRepository->findBy(['templateOwner' => $userId]);
|
||||||
|
} elseif ($model) {
|
||||||
|
$users = $userRepository->findTemplate();
|
||||||
|
} else {
|
||||||
|
$users = $query->execute()->get_results();
|
||||||
|
}
|
||||||
|
|
||||||
$userList = [];
|
$userList = [];
|
||||||
$showApplication = false;
|
$showApplication = false;
|
||||||
|
@@ -122,4 +122,15 @@ class UserRepository extends EntityRepository
|
|||||||
{
|
{
|
||||||
return $this->findBy(['templateOwner' => $user->getId()]);
|
return $this->findBy(['templateOwner' => $user->getId()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds all templates
|
||||||
|
*/
|
||||||
|
public function findTemplate()
|
||||||
|
{
|
||||||
|
$qb = $this->createQueryBuilder('u');
|
||||||
|
$qb->where('u.templateOwner is NOT NULL');
|
||||||
|
|
||||||
|
return $qb->getQuery()->getResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user