Back to Joomla project (class list)

Class UserHelper - list of methods

Authorisation helper class, provides static methods to perform various tasks relevant to the Joomla user and authorisation classes
This class has influences and some method logic from the Horde Auth package
Package: Joomla\CMS\User
Copyright: (C) 2007 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/User/UserHelper.php
Project: Joomla

Method Summary

public static bool
(mixed $userId, mixed $groupId)

Method to add a user to a group.
Parameters
  • int $userId The id of the user.
  • int $groupId The id of the group.
Returns
  • bool True on success
Since
  • 1.7.0
-
  • \RuntimeException
Show source code of this method: addUserToGroup Source Code

public static array
(mixed $userId)

Method to get a list of groups a user is in.
Parameters
  • int $userId The id of the user.
Returns
  • array List of groups
Since
  • 1.7.0
Show source code of this method: getUserGroups Source Code

public static bool
(mixed $userId, mixed $groupId)

Method to remove a user from a group.
Parameters
  • int $userId The id of the user.
  • int $groupId The id of the group.
Returns
  • bool True on success
Since
  • 1.7.0
Show source code of this method: removeUserFromGroup Source Code

public static bool
(mixed $userId, mixed $groups)

Method to set the groups for a user.
Parameters
  • int $userId The id of the user.
  • array $groups An array of group ids to put the user in.
Returns
  • bool True on success
Since
  • 1.7.0
Show source code of this method: setUserGroups Source Code

public static object
(mixed $userId = 0)

Gets the user profile information
Parameters
  • int $userId The id of the user.
Returns
  • object
Since
  • 1.7.0
Show source code of this method: getProfile Source Code

public static bool
(mixed $activation)

Method to activate a user
Parameters
  • string $activation Activation string
Returns
  • bool True on success
Since
  • 1.7.0
Show source code of this method: activateUser Source Code

public static int
(mixed $username)

Returns userid if a user exists
Parameters
  • string $username The username to search on.
Returns
  • int The user id or 0 if not found.
Since
  • 1.7.0
Show source code of this method: getUserId Source Code

public static string
(mixed $password, mixed $algorithm = self::HASH_BCRYPT, array $options = array())

Hashes a password using the current encryption.
Parameters
  • string $password The plaintext password to encrypt.
  • string|int $algorithm The hashing algorithm to use, represented by `HASH_*` class constants, or a container service ID.
  • array $options The options for the algorithm to use.
Returns
  • string The encrypted password.
Since
  • 3.2.1
-
  • \InvalidArgumentException when the algorithm is not supported
Show source code of this method: hashPassword Source Code

public static bool
(mixed $password, mixed $hash, mixed $userId = 0)

Formats a password using the current encryption. If the user ID is given and the hash does not fit the current hashing algorithm, it automatically updates the hash.
Parameters
  • string $password The plaintext password to check.
  • string $hash The hash to verify against.
  • int $userId ID of the user if the password hash should be updated
Returns
  • bool True if the password and hash match, false otherwise
Since
  • 3.2.1
Show source code of this method: verifyPassword Source Code

public static string
(mixed $length = 8)

Generate a random password
Parameters
  • int $length Length of the password to generate
Returns
  • string Random Password
Since
  • 1.7.0
Show source code of this method: genRandomPassword Source Code

public static string
()

Method to get a hashed user agent string that does not include browser version.
Returns
  • string A hashed user agent string with version replaced by 'abcd'
Since
  • 3.2
Show source code of this method: getShortHashedUserAgent Source Code

public static bool
(array $userIds)

Check if there is a super user in the user ids.
Parameters
  • array $userIds An array of user IDs on which to operate
Returns
  • bool True on success, false on failure
Since
  • 3.6.5
Show source code of this method: checkSuperUserInUsers Source Code

public static bool
(mixed $userId, mixed $keepCurrent = false, mixed $clientId = null)

Destroy all active session for a given user id
Parameters
  • int $userId Id of user
  • bool $keepCurrent Keep the session of the currently acting user
  • int $clientId Application client id
Returns
  • bool
Since
  • 3.9.28
Show source code of this method: destroyUserSessions Source Code

Constants Summary

public string
$HASH_ARGON2I
Constant defining the Argon2i password algorithm for use with password hashes
Since
  • 4.0.0
public int
$HASH_ARGON2I_BC
B/C constant `PASSWORD_ARGON2I` for PHP < 7.4 (using integer)
Since
  • 4.0.0
-
  • int
public string
$HASH_ARGON2ID
Constant defining the Argon2id password algorithm for use with password hashes
Since
  • 4.0.0
public int
$HASH_ARGON2ID_BC
B/C constant `PASSWORD_ARGON2ID` for PHP < 7.4 (using integer)
Since
  • 4.0.0
-
  • int
public string
$HASH_BCRYPT
Constant defining the BCrypt password algorithm for use with password hashes
Since
  • 4.0.0
public int
$HASH_BCRYPT_BC
B/C constant `PASSWORD_BCRYPT` for PHP < 7.4 (using integer)
Since
  • 4.0.0
-
  • int
public string
$HASH_MD5
Constant defining the MD5 password algorithm for use with password hashes
Since
  • 4.0.0
-
  • string
public string
$HASH_PHPASS
Constant defining the PHPass password algorithm for use with password hashes
Since
  • 4.0.0
-
  • string
public array
$HASH_ALGORITHMS
Mapping array for the algorithm handler
Since
  • 4.0.0

Tags Summary

Since
1.7.0