More list sub commands

This commit is contained in:
nupplaPhil 2020-02-25 22:28:02 +01:00
parent 2adc6a0974
commit 3a317c5c0d
No known key found for this signature in database
GPG Key ID: D8365C3D36B77D90
2 changed files with 14 additions and 5 deletions

View File

@ -28,6 +28,7 @@ use Friendica\Core\L10n;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Model\Register; use Friendica\Model\Register;
use Friendica\Model\User as UserModel; use Friendica\Model\User as UserModel;
use Friendica\Util\Temporal;
use RuntimeException; use RuntimeException;
use Seld\CliPrompt\CliPrompt; use Seld\CliPrompt\CliPrompt;
@ -64,6 +65,7 @@ Usage
bin/console user block [<nickname>] [-h|--help|-?] [-v] bin/console user block [<nickname>] [-h|--help|-?] [-v]
bin/console user unblock [<nickname>] [-h|--help|-?] [-v] bin/console user unblock [<nickname>] [-h|--help|-?] [-v]
bin/console user list pending [start=0 [count=50]] [-h|--help|-?] [-v] bin/console user list pending [start=0 [count=50]] [-h|--help|-?] [-v]
bin/console user list removed [start=0 [count=50]] [-h|--help|-?] [-v]
bin/console user list all [start=0 [count=50]] [-h|--help|-?] [-v] bin/console user list all [start=0 [count=50]] [-h|--help|-?] [-v]
Description Description
@ -333,24 +335,31 @@ HELP;
$contact['name'], $contact['name'],
$contact['url'], $contact['url'],
$contact['email'], $contact['email'],
$contact['created'], Temporal::getRelativeDate($contact['created']),
$contact['note'], $contact['note'],
]); ]);
} }
$this->out($table->getTable()); $this->out($table->getTable());
return true; return true;
case 'all': case 'all':
case 'removed':
default: default:
$table->setHeaders(['Nick', 'Name', 'URL', 'E-Mail', 'Register Date', 'Comment']); $table->setHeaders(['Nick', 'Name', 'URL', 'E-Mail', 'Register', 'Login', 'Last Item']);
$contacts = UserModel::getUsers($start, $count); $contacts = UserModel::getUsers($start, $count);
foreach ($contacts as $contact) { foreach ($contacts as $contact) {
if (($subCmd != 'removed') && !empty($contact['account_removed']) ||
($subCmd == 'removed') && empty($contact['account_removed'])) {
continue;
}
$table->addRow([ $table->addRow([
$contact['nick'], $contact['nick'],
$contact['name'], $contact['name'],
$contact['url'], $contact['url'],
$contact['email'], $contact['email'],
$contact['created'], Temporal::getRelativeDate($contact['created']),
$contact['note'], Temporal::getRelativeDate($contact['login_date']),
Temporal::getRelativeDate($contact['lastitem_date']),
]); ]);
} }
$this->out($table->getTable()); $this->out($table->getTable());

View File

@ -1334,7 +1334,7 @@ class User
$sql_order = '`' . str_replace('.', '`.`', $order) . '`'; $sql_order = '`' . str_replace('.', '`.`', $order) . '`';
$sql_order_direction = ($order_direction === '+') ? 'ASC' : 'DESC'; $sql_order_direction = ($order_direction === '+') ? 'ASC' : 'DESC';
$usersStmt = DBA::p("SELECT `user`.*, `contact`.`name`, `contact`.`url`, `contact`.`micro`, `user`.`account_expired`, `contact`.`last-item` AS `lastitem_date`, `contact`.`nick` $usersStmt = DBA::p("SELECT `user`.*, `contact`.`name`, `contact`.`url`, `contact`.`micro`, `user`.`account_expired`, `contact`.`last-item` AS `lastitem_date`, `contact`.`nick`, `contact`.`created`
FROM `user` FROM `user`
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self` INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
WHERE `user`.`verified` WHERE `user`.`verified`