Improve start/count parameter
This commit is contained in:
parent
d950a3241b
commit
ed422be734
3 changed files with 29 additions and 15 deletions
|
@ -64,9 +64,10 @@ Usage
|
|||
bin/console user deny [<nickname>] [-h|--help|-?] [-v]
|
||||
bin/console user block [<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 removed [start=0 [count=50]] [-h|--help|-?] [-v]
|
||||
bin/console user list all [start=0 [count=50]] [-h|--help|-?] [-v]
|
||||
bin/console user list pending [-s|--start=0] [-c|--count=50] [-h|--help|-?] [-v]
|
||||
bin/console user list removed [-s|--start=0] [-c|--count=50] [-h|--help|-?] [-v]
|
||||
bin/console user list active [-s|--start=0] [-c|--count=50] [-h|--help|-?] [-v]
|
||||
bin/console user list all [-s|--start=0] [-c|--count=50] [-h|--help|-?] [-v]
|
||||
bin/console user search id <UID> [-h|--help|-?] [-v]
|
||||
bin/console user search nick <nick> [-h|--help|-?] [-v]
|
||||
bin/console user search mail <mail> [-h|--help|-?] [-v]
|
||||
|
@ -326,8 +327,8 @@ HELP;
|
|||
private function listUser()
|
||||
{
|
||||
$subCmd = $this->getArgument(1);
|
||||
$start = $this->getArgument(2, 0);
|
||||
$count = $this->getArgument(3, Pager::ITEMS_PER_PAGE);
|
||||
$start = $this->getOption(['s', 'start'], 0);
|
||||
$count = $this->getOption(['c', 'count'], Pager::ITEMS_PER_PAGE);
|
||||
|
||||
$table = new Console_Table();
|
||||
|
||||
|
@ -348,15 +349,11 @@ HELP;
|
|||
$this->out($table->getTable());
|
||||
return true;
|
||||
case 'all':
|
||||
case 'active':
|
||||
case 'removed':
|
||||
$table->setHeaders(['Nick', 'Name', 'URL', 'E-Mail', 'Register', 'Login', 'Last Item']);
|
||||
$contacts = UserModel::getUsers($start, $count);
|
||||
$contacts = UserModel::getUsers($start, $count, $subCmd);
|
||||
foreach ($contacts as $contact) {
|
||||
if (($subCmd != 'removed') && !empty($contact['account_removed']) ||
|
||||
($subCmd == 'removed') && empty($contact['account_removed'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$table->addRow([
|
||||
$contact['nick'],
|
||||
$contact['name'],
|
||||
|
|
|
@ -1323,21 +1323,38 @@ class User
|
|||
*
|
||||
* @param int $start Start count (Default is 0)
|
||||
* @param int $count Count of the items per page (Default is @see Pager::ITEMS_PER_PAGE)
|
||||
* @param string $type The type of users, which should get (all, bocked, removed)
|
||||
* @param string $order Order of the user list (Default is 'contact.name')
|
||||
* @param string $order_direction Order direction (Default is ASC)
|
||||
*
|
||||
* @return array The list of the users
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getUsers($start = 0, $count = Pager::ITEMS_PER_PAGE, $order = 'contact.name', $order_direction = '+')
|
||||
public static function getUsers($start = 0, $count = Pager::ITEMS_PER_PAGE, $type = 'all', $order = 'contact.name', $order_direction = '+')
|
||||
{
|
||||
$sql_order = '`' . str_replace('.', '`.`', $order) . '`';
|
||||
$sql_order_direction = ($order_direction === '+') ? 'ASC' : 'DESC';
|
||||
|
||||
switch ($type) {
|
||||
case 'active':
|
||||
$sql_extra = 'AND `user`.`blocked` = 0';
|
||||
break;
|
||||
case 'blocked':
|
||||
$sql_extra = 'AND `user`.`blocked` = 1';
|
||||
break;
|
||||
case 'removed':
|
||||
$sql_extra = 'AND `user`.`account_removed` = 1';
|
||||
break;
|
||||
case 'all':
|
||||
default:
|
||||
$sql_extra = '';
|
||||
break;
|
||||
}
|
||||
|
||||
$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`
|
||||
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
|
||||
WHERE `user`.`verified`
|
||||
WHERE `user`.`verified` $sql_extra
|
||||
ORDER BY $sql_order $sql_order_direction LIMIT ?, ?", $start, $count
|
||||
);
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ class Users extends BaseAdmin
|
|||
}
|
||||
}
|
||||
|
||||
$users = User::getUsers($pager->getStart(), $pager->getItemsPerPage(), $order, $order_direction);
|
||||
$users = User::getUsers($pager->getStart(), $pager->getItemsPerPage(), 'all', $order, $order_direction);
|
||||
|
||||
$adminlist = explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email')));
|
||||
$_setup_users = function ($e) use ($adminlist) {
|
||||
|
|
Loading…
Reference in a new issue