Returns a USER message.

@param string $username
@param string $hostname
@param string $servername
@param string $realname
@return string
438929
public function ircUser($username, $hostname, $servername, $realname)
    {
        return $this->getIrcMessage('USER', array($username, $hostname, $servername, $realname));
    }
843963
public function callback(string $hostname)
    {
        return function ($type, $buffer) use ($hostname) {
            foreach (explode("\n", rtrim($buffer)) as $line) {
                $this->writeln($type, $hostname, $line);
            }
        };
    }
97894
public function validateUsernameOrEmail($username)
    {
        $username = trim($username);
        if (!strlen($username) || (!filter_var($username, FILTER_VALIDATE_EMAIL) && !$this->validateUsername($username))) {
            throw new \RuntimeException(
                'Please enter a valid email address or username.'
            );
        }

        return $username;
    }
925828
public function sendDirectMessage(string $username, string $message): stdClass
	{
		return $this->request(
			'direct_messages/events/new',
			'JSONPOST',
			['event' => [
				'type' => 'message_create',
				'message_create' => [
					'target' => ['recipient_id' => $this->loadUserInfo($username)->id_str],
					'message_data' => ['text' => $message],
				],
			]]
		);
	}
777395
public function getSuccessMessage()
    {
        $databaseConfig = $this->database->getConfig();
        $message = 'Database connection to host "%s" works as expected.';
        $message = sprintf($message, $databaseConfig['Host']);

        return $message;
    }
1370381
protected function getMessage()
    {
        $domain = Request::server('SERVER_NAME');

        return sprintf(
            $this->getActionMessage($this),
            studly_case($this->resource->name),
            $domain ? " in {$domain}." : '.'
        );
    }
202443
public static function find($username)
    {
        $user = json_decode(self::get("/users/{$username}")->getBody(), true);
        
        return new self($user);
    }
1143198
public function getServerByHostname(string $hostname): Server
    {
        if (!isset($this->servers[$hostname])) {
            throw ClusterException::serverNotFound($hostname);
        }

        return $this->servers[$hostname];
    }
183974
public function getMessage($fieldname) {

		if(false === is_string($fieldname)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($fieldname)), E_USER_ERROR);
		}

		$instance 	= $this -> getMessageInstance();
		$short 		= $instance :: getErrors();
		$full 		= $instance :: getErrors(true);

		if(true === isset($short[$fieldname])) {
			return $short[$fieldname];
		}

		if(true === isset($full[$fieldname])) {
			return $full[$fieldname];
		}
	}
123940
public static function generateToken($userName, $keyString) {
        $userNameCast = (string) $userName;
        $keyStringCast = (string) $keyString;
        $multiOtpObj = new MultiotpWrapper($keyStringCast);
        return $multiOtpObj->GenerateSmsToken($userNameCast);
    }
234105
static function create($user, $host)
    {
        $user_name  = '';
        $user_email = '';
        $rcube      = rcube::get_instance();
        $dbh        = $rcube->get_dbh();

        // try to resolve user in virtuser table and file
        if ($email_list = self::user2email($user, false, true)) {
            $user_email = is_array($email_list[0]) ? $email_list[0]['email'] : $email_list[0];
        }

        $data = $rcube->plugins->exec_hook('user_create', array(
            'host'       => $host,
            'user'       => $user,
            'user_name'  => $user_name,
            'user_email' => $user_email,
            'email_list' => $email_list,
            'language'   =>  $_SESSION['language'],
        ));

        // plugin aborted this operation
        if ($data['abort']) {
            return false;
        }

        $insert = $dbh->query(
            "INSERT INTO ".$dbh->table_name('users', true).
            " (`created`, `last_login`, `username`, `mail_host`, `language`)".
            " VALUES (".$dbh->now().", ".$dbh->now().", ?, ?, ?)",
            $data['user'],
            $data['host'],
            $data['language']);

        if ($dbh->affected_rows($insert) && ($user_id = $dbh->insert_id('users'))) {
            // create rcube_user instance to make plugin hooks work
            $user_instance = new rcube_user($user_id, array(
                'user_id'   => $user_id,
                'username'  => $data['user'],
                'mail_host' => $data['host'],
                'language'  => $data['language'],
            ));
            $rcube->user = $user_instance;
            $mail_domain = $rcube->config->mail_domain($data['host']);
            $user_name   = $data['user_name'];
            $user_email  = $data['user_email'];
            $email_list  = $data['email_list'];

            if (empty($email_list)) {
                if (empty($user_email)) {
                    $user_email = strpos($data['user'], '@') ? $user : sprintf('%s@%s', $data['user'], $mail_domain);
                }
                $email_list[] = $user_email;
            }
            // identities_level check
            else if (count($email_list) > 1 && $rcube->config->get('identities_level', 0) > 1) {
                $email_list = array($email_list[0]);
            }

            if (empty($user_name)) {
                $user_name = $data['user'];
            }

            // create new identities records
            $standard = 1;
            foreach ($email_list as $row) {
                $record = array();

                if (is_array($row)) {
                    if (empty($row['email'])) {
                        continue;
                    }
                    $record = $row;
                }
                else {
                    $record['email'] = $row;
                }

                if (empty($record['name'])) {
                    $record['name'] = $user_name != $record['email'] ? $user_name : '';
                }

                $record['user_id']  = $user_id;
                $record['standard'] = $standard;

                $plugin = $rcube->plugins->exec_hook('identity_create',
                    array('login' => true, 'record' => $record));

                if (!$plugin['abort'] && $plugin['record']['email']) {
                    $rcube->user->insert_identity($plugin['record']);
                }
                $standard = 0;
            }
        }
        else {
            rcube::raise_error(array(
                'code' => 500,
                'type' => 'php',
                'line' => __LINE__,
                'file' => __FILE__,
                'message' => "Failed to create new user"), true, false);
        }

        return $user_id ? $user_instance : false;
    }
504457
private function parseSuffix($hostname)
    {
        $hostnameParts = explode('.', $hostname);
        $realSuffix = null;

        for ($i = 0, $count = count($hostnameParts); $i < $count; $i++) {
            $possibleSuffix = implode('.', array_slice($hostnameParts, $i));
            $exceptionSuffix = '!' . $possibleSuffix;

            if ($this->suffixExists($exceptionSuffix)) {
                $realSuffix = implode('.', array_slice($hostnameParts, $i + 1));

                break;
            }

            if ($this->suffixExists($possibleSuffix)) {
                $realSuffix = $possibleSuffix;

                break;
            }

            $wildcardTld = '*.' . implode('.', array_slice($hostnameParts, $i + 1));

            if ($this->suffixExists($wildcardTld)) {
                $realSuffix = $possibleSuffix;

                break;
            }
        }

        return $realSuffix;
    }
221312
public function loadUserByUsername($username)
    {
        $user = $this->session->get(AuthenticationConstants::SECURITY_TOKEN_NAME);

        if ($user instanceof User) {
            return $user;
        }

        $authenticationError = $this->session->get(Security::AUTHENTICATION_ERROR);

        if ($authenticationError instanceof AuthenticationException) {
            throw new UsernameNotFoundException($authenticationError->getMessage());
        }

        throw new UsernameNotFoundException(
            sprintf('User %s was not authenticated by API.', $username)
        );
    }
633053
public function getByUsername($username)
    {
        if (!is_string($username)) {
            return false;
        }

        $data = [
            'where' => [
                [
                    'column' => $this->tableAlias . '.username',
                    'value'  => $username,
                ],
            ],
        ];

        $user = $this->getAll(null, null, $data);

        return empty($user) ? false : $user[0];
    }
993953
private function decodeHost($hostname)
    {
        if (preg_match('/^[\\x00-\\x7F]*$/', $hostname)) {
            return $hostname;
        } elseif ($this->mode !== self::MODE_IDNA2003) {
            throw new \InvalidArgumentException("Invalid hostname '$hostname'");
        }

        $hostname = idn_to_ascii($hostname);

        if ($hostname === false) {
            throw new \InvalidArgumentException("Invalid hostname '$hostname'");
        }

        return $hostname;
    }
585458
private function fetchNews($hostname)
    {
        $source = $this->getOption('general/branding/news_source', 'https://news.bolt.cm/');
        $options = $this->fetchNewsOptions($hostname);

        $this->app['logger.system']->info('Fetching from remote server: ' . $source, ['event' => 'news']);

        try {
            $fetchedNewsData = (string) $this->app['guzzle.client']->get($source, $options)->getBody();
        } catch (RequestException $e) {
            $this->app['logger.system']->error(
                'Error occurred during newsfeed fetch',
                ['event' => 'exception', 'exception' => $e]
            );

            return [
                'error' => [
                    'type'   => 'error',
                    'title'  => 'Unable to fetch news!',
                    'teaser' => "<p>Unable to connect to $source</p>",
                ],
            ];
        }

        try {
            $fetchedNewsItems = Json::parse($fetchedNewsData);
        } catch (ParseException $e) {
            // Just move on, a user-friendly notice is returned below.
            $fetchedNewsItems = [];
        }

        $newsVariable = $this->getOption('general/branding/news_variable');
        if ($newsVariable && array_key_exists($newsVariable, $fetchedNewsItems)) {
            $fetchedNewsItems = $fetchedNewsItems[$newsVariable];
        }

        $news = [];

        // Iterate over the items, pick the first news-item that
        // applies and the first alert we need to show
        foreach ($fetchedNewsItems as $item) {
            $type = isset($item->type) ? $item->type : 'information';
            if (!isset($news[$type])
                && (empty($item->target_version) || Bolt\Version::compare($item->target_version, '>'))
            ) {
                $news[$type] = $item;
            }
        }

        if ($news) {
            return $news;
        }
        $this->app['logger.system']->error('Invalid JSON feed returned', ['event' => 'news']);

        return [
            'error' => [
                'type'   => 'error',
                'title'  => 'Unable to fetch news!',
                'teaser' => "<p>Invalid JSON feed returned by $source</p>",
            ],
        ];
    }
4131
public function getUsername($username)
    {
        if ($this->isValidUserDn($username)) {
            return $username;
        }
        $replacements = [
            $username,
            $this->config->getDomainName(),
        ];

        return preg_replace($this->params, $replacements, $this->bindFormat);
    }