Merge pull request #21343 from owncloud/ldap-showremnants-json-output
Add an option to occ ldap:showremnants to output a json encoded array…
This commit is contained in:
commit
470bf234c5
|
@ -24,6 +24,7 @@ namespace OCA\user_ldap\Command;
|
||||||
|
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
use OCA\user_ldap\lib\user\DeletedUsersIndex;
|
use OCA\user_ldap\lib\user\DeletedUsersIndex;
|
||||||
|
@ -50,7 +51,7 @@ class ShowRemnants extends Command {
|
||||||
$this
|
$this
|
||||||
->setName('ldap:show-remnants')
|
->setName('ldap:show-remnants')
|
||||||
->setDescription('shows which users are not available on LDAP anymore, but have remnants in ownCloud.')
|
->setDescription('shows which users are not available on LDAP anymore, but have remnants in ownCloud.')
|
||||||
;
|
->addOption('json', null, InputOption::VALUE_NONE, 'return JSON array instead of pretty table.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,18 +71,21 @@ class ShowRemnants extends Command {
|
||||||
$hAS = $user->getHasActiveShares() ? 'Y' : 'N';
|
$hAS = $user->getHasActiveShares() ? 'Y' : 'N';
|
||||||
$lastLogin = ($user->getLastLogin() > 0) ?
|
$lastLogin = ($user->getLastLogin() > 0) ?
|
||||||
$this->dateFormatter->formatDate($user->getLastLogin()) : '-';
|
$this->dateFormatter->formatDate($user->getLastLogin()) : '-';
|
||||||
$rows[] = array(
|
$rows[] = array('ocName' => $user->getOCName(),
|
||||||
$user->getOCName(),
|
'displayName' => $user->getDisplayName(),
|
||||||
$user->getDisplayName(),
|
'uid' => $user->getUid(),
|
||||||
$user->getUid(),
|
'dn' => $user->getDN(),
|
||||||
$user->getDN(),
|
'lastLogin' => $lastLogin,
|
||||||
$lastLogin,
|
'homePath' => $user->getHomePath(),
|
||||||
$user->getHomePath(),
|
'sharer' => $hAS
|
||||||
$hAS
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->setRows($rows);
|
if ($input->getOption('json')) {
|
||||||
$table->render($output);
|
$output->writeln(json_encode($rows));
|
||||||
|
} else {
|
||||||
|
$table->setRows($rows);
|
||||||
|
$table->render($output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue