Add basic search
This commit is contained in:
parent
3a317c5c0d
commit
d950a3241b
|
@ -67,6 +67,10 @@ Usage
|
||||||
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 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]
|
||||||
|
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]
|
||||||
|
bin/console user search guid <GUID> [-h|--help|-?] [-v]
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Modify user settings per console commands.
|
Modify user settings per console commands.
|
||||||
|
@ -124,6 +128,8 @@ HELP;
|
||||||
return $this->deleteUser();
|
return $this->deleteUser();
|
||||||
case 'list':
|
case 'list':
|
||||||
return $this->listUser();
|
return $this->listUser();
|
||||||
|
case 'search':
|
||||||
|
return $this->searchUser();
|
||||||
default:
|
default:
|
||||||
throw new \Asika\SimpleConsole\CommandArgsException('Wrong command.');
|
throw new \Asika\SimpleConsole\CommandArgsException('Wrong command.');
|
||||||
}
|
}
|
||||||
|
@ -313,7 +319,7 @@ HELP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List user of the current node
|
* List users of the current node
|
||||||
*
|
*
|
||||||
* @return bool True, if the command was successful
|
* @return bool True, if the command was successful
|
||||||
*/
|
*/
|
||||||
|
@ -343,7 +349,6 @@ HELP;
|
||||||
return true;
|
return true;
|
||||||
case 'all':
|
case 'all':
|
||||||
case 'removed':
|
case 'removed':
|
||||||
default:
|
|
||||||
$table->setHeaders(['Nick', 'Name', 'URL', 'E-Mail', 'Register', 'Login', 'Last Item']);
|
$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) {
|
||||||
|
@ -364,6 +369,58 @@ HELP;
|
||||||
}
|
}
|
||||||
$this->out($table->getTable());
|
$this->out($table->getTable());
|
||||||
return true;
|
return true;
|
||||||
|
default:
|
||||||
|
$this->out($this->getHelp());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a user based on search parameter
|
||||||
|
*
|
||||||
|
* @return bool True, if the command was successful
|
||||||
|
*/
|
||||||
|
private function searchUser()
|
||||||
|
{
|
||||||
|
$fields = [
|
||||||
|
'uid',
|
||||||
|
'guid',
|
||||||
|
'username',
|
||||||
|
'nickname',
|
||||||
|
'email',
|
||||||
|
'register_date',
|
||||||
|
'login_date',
|
||||||
|
'verified',
|
||||||
|
'blocked',
|
||||||
|
];
|
||||||
|
|
||||||
|
$subCmd = $this->getArgument(1);
|
||||||
|
$param = $this->getArgument(2);
|
||||||
|
|
||||||
|
$table = new Console_Table();
|
||||||
|
$table->setHeaders(['UID', 'GUID', 'Name', 'Nick', 'E-Mail', 'Register', 'Login', 'Verified', 'Blocked']);
|
||||||
|
|
||||||
|
switch ($subCmd) {
|
||||||
|
case 'id':
|
||||||
|
$user = UserModel::getById($param, $fields);
|
||||||
|
break;
|
||||||
|
case 'guid':
|
||||||
|
$user = UserModel::getByGuid($param, $fields);
|
||||||
|
break;
|
||||||
|
case 'email':
|
||||||
|
$user = UserModel::getByEmail($param, $fields);
|
||||||
|
break;
|
||||||
|
case 'nick':
|
||||||
|
$user = UserModel::getByNickname($param, $fields);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->out($this->getHelp());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$table->addRow($user);
|
||||||
|
$this->out($table->getTable());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user