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
public static
boolean
|
#
addUserToGroup( integer $userId, integer $groupId )
Method to add a user to a group.
Method to add a user to a group.
Parameters
- $userId
integer - $userId The id of the user.
- $groupId
integer - $groupId The id of the group.
Returns
boolean - True on success
Throws
Since
11.1
|
public static
array
|
#
getUserGroups( integer $userId )
Method to get a list of groups a user is in.
Method to get a list of groups a user is in.
Parameters
- $userId
integer - $userId The id of the user.
Returns
array - List of groups
Since
11.1
|
public static
boolean
|
#
removeUserFromGroup( integer $userId, integer $groupId )
Method to remove a user from a group.
Method to remove a user from a group.
Parameters
- $userId
integer - $userId The id of the user.
- $groupId
integer - $groupId The id of the group.
Returns
boolean - True on success
Since
11.1
|
public static
boolean
|
#
setUserGroups( integer $userId, array $groups )
Method to set the groups for a user.
Method to set the groups for a user.
Parameters
- $userId
integer - $userId The id of the user.
- $groups
array - $groups An array of group ids to put the user in.
Returns
boolean - True on success
Since
11.1
|
public static
object
|
#
getProfile( integer $userId = 0 )
Gets the user profile information
Gets the user profile information
Parameters
- $userId
integer - $userId The id of the user.
Returns
object
Since
11.1
|
public static
boolean
|
#
activateUser( string $activation )
Method to activate a user
Method to activate a user
Parameters
- $activation
string - $activation Activation string
Returns
boolean - True on success
Since
11.1
|
public static
integer
|
#
getUserId( string $username )
Returns userid if a user exists
Returns userid if a user exists
Parameters
- $username
string - $username The username to search on.
Returns
integer - The user id or 0 if not found.
Since
11.1
|
public static
string
|
#
hashPassword( string $password )
Hashes a password using the current encryption.
Hashes a password using the current encryption.
Parameters
- $password
string - $password The plaintext password to encrypt.
Returns
string - The encrypted password.
Since
3.2.1
|
public static
boolean
|
#
verifyPassword( string $password, string $hash, integer $user_id = 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.
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
- $password
string - $password The plaintext password to check.
- $hash
string - $hash The hash to verify against.
- $user_id
integer - $user_id ID of the user if the password hash should be updated
Returns
boolean - True if the password and hash match, false otherwise
Since
3.2.1
|
public static
string
|
#
getCryptedPassword( string $plaintext, string $salt = '', string $encryption = 'md5-hex', boolean $show_encrypt = false )
Formats a password using the old encryption methods.
Formats a password using the old encryption methods.
Deprecated
4.0
Parameters
- $plaintext
string - $plaintext The plaintext password to encrypt.
- $salt
string - $salt The salt to use to encrypt the password. [] If not present, a new salt
will be generated.
- $encryption
string - $encryption The kind of password encryption to use. Defaults to md5-hex.
- $show_encrypt
boolean - $show_encrypt Some password systems prepend the kind of encryption to the
crypted password ({SHA}, etc). Defaults to false.
Returns
string - The encrypted password.
Since
11.1
|
public static
string
|
#
getSalt( string $encryption = 'md5-hex', string $seed = '', string $plaintext = '' )
Returns a salt for the appropriate kind of password encryption using the old
encryption methods. Optionally takes a seed and a plaintext password, to extract
the seed of an existing password, or for encryption types that use the plaintext
in the generation of the salt.
Returns a salt for the appropriate kind of password encryption using the old
encryption methods. Optionally takes a seed and a plaintext password, to extract
the seed of an existing password, or for encryption types that use the plaintext
in the generation of the salt.
Deprecated
4.0
Parameters
- $encryption
string - $encryption The kind of password encryption to use. Defaults to md5-hex.
- $seed
string - $seed The seed to get the salt from (probably a previously generated password).
Defaults to generating a new seed.
- $plaintext
string - $plaintext The plaintext password that we're generating a salt for. Defaults to
none.
Returns
string - The generated or extracted salt.
Since
11.1
|
public static
string
|
#
genRandomPassword( integer $length = 8 )
Generate a random password
Generate a random password
Parameters
- $length
integer - $length Length of the password to generate
Returns
string - Random Password
Since
11.1
|
protected static
string
|
#
_toAPRMD5( string $value, integer $count )
Converts to allowed 64 characters for APRMD5 passwords.
Converts to allowed 64 characters for APRMD5 passwords.
Parameters
- $value
string - $value The value to convert.
- $count
integer - $count The number of characters to convert.
Returns
string - $value converted to the 64 MD5 characters.
Since
11.1
|
public static
boolean
|
#
invalidateCookie( string $userId, string $cookieName )
Method to remove a cookie record from the database and the browser
Method to remove a cookie record from the database and the browser
Deprecated
4.0 This is handled in the authentication plugin itself. The 'invalid' column in
the db should be removed as well
Parameters
- $userId
string - $userId User ID for this user
- $cookieName
string - $cookieName Series id (cookie name decoded)
Returns
boolean - True on success
Since
3.2
|
public static
mixed
|
#
clearExpiredTokens( )
Clear all expired tokens for all users.
Clear all expired tokens for all users.
Deprecated
4.0 This is handled in the authentication plugin itself
Returns
mixed - Database query result
Since
3.2
|
public static
mixed
|
#
getRememberCookieData( )
Method to get the remember me cookie data
Method to get the remember me cookie data
Deprecated
4.0 This is handled in the authentication plugin itself
Returns
mixed - An array of information from an authentication cookie or false if there is no
cookie
Since
3.2
|
public static
string
|
#
getShortHashedUserAgent( )
Method to get a hashed user agent string that does not include browser
version. Used when frequent version changes cause problems.
Method to get a hashed user agent string that does not include browser
version. Used when frequent version changes cause problems.
Returns
string - A hashed user agent string with version replaced by 'abcd'
Since
3.2
|
public static
boolean
|
#
checkSuperUserInUsers( array $userIds )
Check if there is a super user in the user ids.
Check if there is a super user in the user ids.
Parameters
- $userIds
array - $userIds An array of user IDs on which to operate
Returns
boolean - True on success, false on failure
Since
3.6.5
|