]> git.mxchange.org Git - friendica.git/blobdiff - src/Console/User.php
Merge pull request #13832 from mexon/console-set-password
[friendica.git] / src / Console / User.php
index 586c300eaf295518e796057b004c8c204c6b241d..e175c54477afaf34a73f74f9826345e53e6be343 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2024, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -58,7 +58,7 @@ class User extends \Asika\SimpleConsole\Console
 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]
@@ -228,10 +228,11 @@ HELP;
         */
        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: '));
@@ -262,15 +263,20 @@ HELP;
                        $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
         *
@@ -310,7 +316,7 @@ HELP;
         * @return bool True, if the delete was successful
         * @throws \Exception
         */
-       private function deleteUser()
+       private function deleteUser(): bool
        {
                $user = $this->getUserByNick(1);
 
@@ -370,7 +376,7 @@ HELP;
                                                $contact['url'],
                                                $contact['email'],
                                                Temporal::getRelativeDate($contact['created']),
-                                               Temporal::getRelativeDate($contact['login_date']),
+                                               Temporal::getRelativeDate($contact['last-activity']),
                                                Temporal::getRelativeDate($contact['last-item']),
                                        ]);
                                }
@@ -396,7 +402,7 @@ HELP;
                        'nickname',
                        'email',
                        'register_date',
-                       'login_date',
+                       'last-activity',
                        'verified',
                        'blocked',
                ];