<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2024, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\App;
use Friendica\Content\Pager;
use Friendica\Core\L10n;
-use Friendica\Core\PConfig\IPConfig;
+use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Model\Register;
use Friendica\Model\User as UserModel;
use Friendica\Util\Temporal;
*/
private $l10n;
/**
- * @var IPConfig
+ * @var IManagePersonalConfigValues
*/
private $pConfig;
console user - Modify user settings per console commands.
Usage
bin/console user password <nickname> [<password>] [-h|--help|-?] [-v]
- bin/console user add [<name> [<nickname> [<email> [<language>]]]] [-h|--help|-?] [-v]
+ bin/console user add [<name> [<nickname> [<email> [<language> [<avatar_url>]]]]] [-h|--help|-?] [-v]
bin/console user delete [<nickname>] [-y] [-h|--help|-?] [-v]
bin/console user allow [<nickname>] [-h|--help|-?] [-v]
bin/console user deny [<nickname>] [-h|--help|-?] [-v]
return $help;
}
- public function __construct(App\Mode $appMode, L10n $l10n, IPConfig $pConfig, array $argv = null)
+ public function __construct(App\Mode $appMode, L10n $l10n, IManagePersonalConfigValues $pConfig, array $argv = null)
{
parent::__construct($argv);
$this->pConfig = $pConfig;
}
- protected function doExecute()
+ protected function doExecute(): int
{
if ($this->getOption('v')) {
$this->out('Class: ' . __CLASS__);
$nick = $this->getNick($arg_index);
$user = UserModel::getByNickname($nick, ['uid']);
- if (!$user) {
+ if (empty($user)) {
throw new RuntimeException($this->l10n->t('User not found'));
}
try {
$result = UserModel::updatePassword($user['uid'], $password);
- if (!$result) {
+ if (empty($result)) {
throw new \Exception($this->l10n->t('Password update failed. Please try again.'));
}
*/
private function addUser()
{
- $name = $this->getArgument(1);
- $nick = $this->getArgument(2);
- $email = $this->getArgument(3);
- $lang = $this->getArgument(4);
+ $name = $this->getArgument(1);
+ $nick = $this->getArgument(2);
+ $email = $this->getArgument(3);
+ $lang = $this->getArgument(4);
+ $avatar = $this->getArgument(5);
if (empty($name)) {
$this->out($this->l10n->t('Enter user name: '));
$lang = CliPrompt::prompt();
}
+ if (empty($avatar)) {
+ $this->out($this->l10n->t('Enter URL of an image to use as avatar (optional): '));
+ $avatar = CliPrompt::prompt();
+ }
+
if (empty($lang)) {
return UserModel::createMinimal($name, $email, $nick);
} else {
- return UserModel::createMinimal($name, $email, $nick, $lang);
+ return UserModel::createMinimal($name, $email, $nick, $lang, $avatar);
}
}
/**
- * Allows or denys a user based on it's nickname
+ * Allows or denies a user based on it's nickname
*
* @param bool $allow True, if the pending user is allowed, false if denies
*
* @return bool True, if the delete was successful
* @throws \Exception
*/
- private function deleteUser()
+ private function deleteUser(): bool
{
$user = $this->getUserByNick(1);
$contact['url'],
$contact['email'],
Temporal::getRelativeDate($contact['created']),
- Temporal::getRelativeDate($contact['login_date']),
+ Temporal::getRelativeDate($contact['last-activity']),
Temporal::getRelativeDate($contact['last-item']),
]);
}
'nickname',
'email',
'register_date',
- 'login_date',
+ 'last-activity',
'verified',
'blocked',
];
return false;
}
- if ($user) {
+ if (!empty($user)) {
$table->addRow($user);
}
$this->out($table->getTable());