\FrontEndUsers

The FrontEndUsers module, besides being a module to provide authentication services to the frontend of a CMSMS website also has a complete and flexible API.

Summary

Methods
Properties
Constants
GetAdminMenuItems()
AddGroup()
AddGroupPropertyRelation()
AddPropertyDefn()
AddSelectOptions()
AddUser()
AssignUserToGroup()
CountUsersInGroup()
DeletePropertyDefn()
DeleteSelectOptions()
DeleteUserFull()
DeleteUserPropertyByName()
DeleteUserProperty()
DeleteAllUserPropertiesFull()
DeleteUserPropertyFull()
DeleteGroupFull()
DeleteUser()
GenerateRandomUsername()
GetUserProperties()
GetMemberGroupsArray()
GetUserProperty()
GetUserPropertyFull()
GetPropertyGroupRelations()
GetUserPropertyRelations()
GetGroupPropertyRelations()
GetGroupInfo()
GetUserHistory()
GetLoggedInUsers()
GetBulkUserInfo()
GetUserInfo()
GetUserInfoByName()
GetFullUsersInGroup()
GroupExistsByID()
GroupExistsByName()
LoggedInEmail()
GetEmail()
GetPropertyDefns()
GetPropertyDefn()
GetSelectOptions()
GetUserName()
GetUserID()
GetGroupName()
GetGroupDesc()
GetGroupList()
GetGroupListFull()
GetGroupID()
GetMemberGroups()
GetExpiryDate()
IsAccountExpired()
IsValidPassword()
GetUsernamePrompt()
IsValidEmailAddress()
IsValidUsername()
CheckPassword()
Login()
LoggedInName()
Logout()
LogoutUser()
LoggedInId()
LoggedIn()
MemberOfGroup()
RemoveUserFromGroup()
SetPropertyDefnExtra()
SetGroup()
EncryptPassword()
SetUserPassword()
SetUserDisabled()
ForcePasswordChange()
ForceChangeSettings()
ForceVerify()
SetUser()
SetUserGroups()
AddUserToGroup()
SetUserProperties()
SetUserProperty()
IsUserPropertyValueUnique()
SetUserPropertyFull()
UserExistsByID()
SetEncryptionKey()
No public properties found
FIELDTYPE_TEXT
FIELDTYPE_CHECKBOX
FIELDTYPE_EMAIL
FIELDTYPE_TEXTAREA
FIELDTYPE_DROPDOWN
FIELDTYPE_MULTISELECT
FIELDTYPE_IMAGE
FIELDTYPE_RADIOBUTNS
FIELDTYPE_DATE
FIELDTYPE_DATA
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

FIELDTYPE_TEXT

FIELDTYPE_TEXT

Constant to indentify a text property.

FIELDTYPE_CHECKBOX

FIELDTYPE_CHECKBOX

Constant to indentify a checkbox property.

FIELDTYPE_EMAIL

FIELDTYPE_EMAIL

Constant to indentify an email property.

FIELDTYPE_TEXTAREA

FIELDTYPE_TEXTAREA

Constant to indentify a textarea property.

FIELDTYPE_DROPDOWN

FIELDTYPE_DROPDOWN

Constant to indentify a dropdown property.

FIELDTYPE_MULTISELECT

FIELDTYPE_MULTISELECT

Constant to indentify a multiselect property.

FIELDTYPE_IMAGE

FIELDTYPE_IMAGE

Constant to indentify an image property.

FIELDTYPE_RADIOBUTNS

FIELDTYPE_RADIOBUTNS

Constant to indentify a radio button group property.

FIELDTYPE_DATE

FIELDTYPE_DATE

Constant to indentify a date property.

FIELDTYPE_DATA

FIELDTYPE_DATA

Constant to indentify a data property.

Methods

GetAdminMenuItems()

GetAdminMenuItems()

AddGroup()

AddGroup(string $name, string $description) : array

Add a new group

Parameters

string $name

The group name

string $description

The group description

Returns

array —

Array containing two elements. The first element is the return status of the function (boolean), the second element is either a message in the case of an error, or the group id (integer) on success.

AddGroupPropertyRelation()

AddGroupPropertyRelation(int $grpid, string $propname, int $sortkey, boolean $lostun, int $required) : array

Add a new group property relation.

Parameters

int $grpid

The group id

string $propname

The property name

int $sortkey

The sorting order for this relationship

boolean $lostun

Wether this relationship should be used for the lostun stuff (deprecated)

int $required

The required flag for this relationship. 0==off 1==optional, 2==required

Returns

array —

First element of the array is the return status, second element is the error message, if any.

AddPropertyDefn()

AddPropertyDefn(string $name, string $prompt, int $type, int $length, int $maxlength, string $attribs, bool $force_unique, bool $encrypt)

Add a new property definition

Parameters

string $name

The property name

string $prompt

The property prompt for use in various views

int $type

The field type

int $length

The default length for rendering the property

int $maxlength

The maximum length for rendering the property

string $attribs

A serialized array of attributes for the property

bool $force_unique

Whether or not the value for this property should be unique across all users.

bool $encrypt

Whether or not this data should be encrypted in the database.

AddSelectOptions()

AddSelectOptions(string $name, array $seloptions)

Set select options for a dropdown/radio-button-group or multiselect property.

Parameters

string $name

The property name

array $seloptions

the Select options.

AddUser()

AddUser(string $name, string $password, int $expires) : array

Add a user to the syetem

Parameters

string $name

The new username

string $password

The plain text password

int $expires

the Unix timestamp of the expiry date

Returns

array —

The first element of the array is a boolean indicating success or failure, the second element is an error message, or the new UID.

AssignUserToGroup()

AssignUserToGroup(int $uid, int $gid) : boolean

Assign the specified user to the specified group

Parameters

int $uid

The user identifier

int $gid

The group identifier

Returns

boolean

CountUsersInGroup()

CountUsersInGroup(int $gid) : int

Count the number of non disabled users in a group, or in the entire system.

Parameters

int $gid

Optional group identifier.

Returns

int

DeletePropertyDefn()

DeletePropertyDefn(string $name) : boolean

Permanently remove a property

Parameters

string $name

The property name

Returns

boolean

DeleteSelectOptions()

DeleteSelectOptions(string $name) : array

Delete the select options (if any) for a property

Parameters

string $name

The property name

Returns

array —

The first element of the array is a boolean status, the second element (if any) is an error message.

DeleteUserFull()

DeleteUserFull(int $uid) : array

Completely delete a user from the database. Including all properties, group memberships, etc.

Parameters

int $uid

The user identifier to delete.

Returns

array —

The first element of the array is a boolean status, the second element (if any) is an error message.

DeleteUserPropertyByName()

DeleteUserPropertyByName(string $title) : boolean

Remove a specified property for all users, but do not remove the property definition.

Parameters

string $title

The property name

Returns

boolean

DeleteUserProperty()

DeleteUserProperty(string $title, boolean $all) : boolean

Delete a user property for a specific user.

Parameters

string $title

The property name

boolean $all

Wether or not to delete all properties for the user.

Returns

boolean

DeleteAllUserPropertiesFull()

DeleteAllUserPropertiesFull(int $userid) : boolean

Delete all user properties for the specified user.

Parameters

int $userid

The userid

Returns

boolean

DeleteUserPropertyFull()

DeleteUserPropertyFull(string $title, int $userid, boolean $all)

Delete specified user properties for the specified user.

Parameters

string $title

The property name

int $userid

The userid

boolean $all

Wether or not to delete all properties for the specified user.

DeleteGroupFull()

DeleteGroupFull(int $gid) : array

Delete a specified group.

Parameters

int $gid

The group identifier

Returns

array —

The first element of the array is a boolean status, the second element (if any) is an error message.

DeleteUser()

DeleteUser(int $id) : array

Delete the specified user account.

Parameters

int $id

The uid

Returns

array —

The first element of the array is a boolean status, the second element (if any) is an error message.

GenerateRandomUsername()

GenerateRandomUsername(string $prefix) : string

Generate a random username

Parameters

string $prefix

an optional prefix for the username

Returns

string

GetUserProperties()

GetUserProperties(int $uid) : array

Get all properties for the specified user.

Parameters

int $uid

The user identifier

Returns

array —

The user properties as read from the database.

GetMemberGroupsArray()

GetMemberGroupsArray(int $userid) : null|array

Get a list of the specified users groups (if any)

Parameters

int $userid

The user identifier

Returns

null|array —

If the user is a member of any groups the resulting array will contail the userid, and the groupid in each element of the returned array.

GetUserProperty()

GetUserProperty(string $title, mixed $defaultvalue) : string

Get a property value for the currently logged in user.

Parameters

string $title

The property name

mixed $defaultvalue

An optional default value if the property is not set for the user. Note, an empty string may be a valid property value.

Returns

string —

(All properties are stored as strings in the database)

GetUserPropertyFull()

GetUserPropertyFull(string $title, int $userid, mixed $defaultvalue) : string

Get a property value for the specified user id

Parameters

string $title

the property name

int $userid

The user identifier

mixed $defaultvalue

An optional default value if the property is not set for the user. Note, an empty string may be a valid property value.

Returns

string —

(All properties are stored as strings in the database)

GetPropertyGroupRelations()

GetPropertyGroupRelations(string $title) : array

Get the group property relations for the specified property, for all groups.

Parameters

string $title

the property title.

Returns

array

GetUserPropertyRelations()

GetUserPropertyRelations(int $uid) : array

Get the property relations for the specified user

Parameters

int $uid

Returns

array

GetGroupPropertyRelations()

GetGroupPropertyRelations(int $grpid) : array

Get the property relations for the specified group

Parameters

int $grpid

The group identifier

Returns

array

GetGroupInfo()

GetGroupInfo(int $gid) : array

Get the group information for the specified group

Parameters

int $gid

The group identifier

Returns

array

GetUserHistory()

GetUserHistory(int $uid, string $action, int $count) : array

Get user history records, by descending date.

Warning: This could potentially return a very large array.

Parameters

int $uid
string $action

An optional action filter (such as login or logout)

int $count

An optional limit

Returns

array

GetLoggedInUsers()

GetLoggedInUsers(int $not_active_since) : int[]

Get a list of the currently logged in users.

Parameters

int $not_active_since

An optional unix timestamp filter indicating last activity.

Returns

int[] —

Array of logged in uids.

GetBulkUserInfo()

GetBulkUserInfo( $uids,  $deep)

Parameters

$uids
$deep

GetUserInfo()

GetUserInfo(int $uid, bool $deep) : array

Get user information for the specified user.

Parameters

int $uid
bool $deep

Optionally also retrieve property values.

Returns

array

GetUserInfoByName()

GetUserInfoByName(string $username) : array

Get user information for the specified user, by his username.

Parameters

string $username

Returns

array

GetFullUsersInGroup()

GetFullUsersInGroup(int $gid) : array

Get info for the users by their group.

Warning: This could potentially return alot of data.

Parameters

int $gid

Returns

array —

Array of userinfo data. One element per user.

GroupExistsByID()

GroupExistsByID(int $gid) : bool

Test if the guid specified is a valid, existing group id.

Parameters

int $gid

Returns

bool

GroupExistsByName()

GroupExistsByName(string $name) : bool

Test if the group name specified is a valid, existing group.

Parameters

string $name

The group name.

Returns

bool

LoggedInEmail()

LoggedInEmail() : string

The email of the currently logged in user for this request.

Returns

string

GetEmail()

GetEmail(int $uid) : string

Get the email address of the specified user.

Parameters

int $uid

Returns

string

GetPropertyDefns()

GetPropertyDefns() : array

Get all property definitions.

Returns

array

GetPropertyDefn()

GetPropertyDefn(string $name) : array

Get a property definition record by its name

Parameters

string $name

the property name.

Returns

array

GetSelectOptions()

GetSelectOptions(string $name, int $dim)

Return select options for a property as a simple, or a 2 dimensional array

Parameters

string $name

The property name

int $dim

If 1, return a simple associative array. If 2, return a multi-dimensional array with properties option_name, option_text and control_name

GetUserName()

GetUserName(int $userid) : string

Get the username for a specified uid

Parameters

int $userid

Returns

string

GetUserID()

GetUserID(string $username) : \it

Get the userid for a specified username

Parameters

string $username

Returns

\it

GetGroupName()

GetGroupName(int $groupid) : string

Get the group name for a specified group id

Parameters

int $groupid

Returns

string

GetGroupDesc()

GetGroupDesc(int $groupid) : string

Get the descriptionf or a specified group id

Parameters

int $groupid

Returns

string

GetGroupList()

GetGroupList() : array

Get a list of the groups, for use in a dropdown.

Returns

array

GetGroupListFull()

GetGroupListFull(bool $with_count) : array

Get a full group list, with all information about that group.

Parameters

bool $with_count

optionally include membership info.

Returns

array

GetGroupID()

GetGroupID(string $groupname) : int

Given a group name, get a group id.

Parameters

string $groupname

Returns

int

GetMemberGroups()

GetMemberGroups(int $userid) : string[]

Get the list of groups (by name) that a user is a member of.

Parameters

int $userid

Returns

string[]

GetExpiryDate()

GetExpiryDate(mixed $uid) : int

Get the date that a user account expires.

Parameters

mixed $uid

Returns

int —

A unix timestamp of the expiry date.

IsAccountExpired()

IsAccountExpired(int $uid) : bool

Test if the specified account is expired.

Parameters

int $uid

Returns

bool

IsValidPassword()

IsValidPassword(string $password) : bool

Test if the specified plain text password is suitable (matches module settings)

Parameters

string $password

Returns

bool

GetUsernamePrompt()

GetUsernamePrompt() : string

Get the prompt for a username.

This may change based on module settings.

Returns

string

IsValidEmailAddress()

IsValidEmailAddress(string $email, int $uid,  $check_existing) : boolean

Test if the email specified is valid, and optionally not used.

Parameters

string $email

The email address to test

int $uid

If speciied, this value will be used to ensure that the email addresss is stored in the database and not associated with any other users.

$check_existing

Returns

boolean —

indicating wether this email address can be used within the system.

IsValidUsername()

IsValidUsername(string $username, boolean $check, int $uid) : boolean

Test wether the specified username is valid for the system.

Parameters

string $username
boolean $check

Optionally test whether this username is in current use.

int $uid

If $check is true, indicate an optional uid to exclude from the check

Returns

boolean

CheckPassword()

CheckPassword(string $username, string $password, string $groups) : boolean

Validate the user password.

This is is not a login operation, but does perform the validation of the password.

Parameters

string $username

The user name

string $password

The plain text password.

string $groups

An optional comma separated list of group names. If specified, the user must also belong to one of these groups.

Returns

boolean

Login()

Login(string $username, string $password, string $groups, boolean $ignored,  $force_logout) : array

Log the user into the system.

Parameters

string $username
string $password

The plain text password

string $groups

An optional comma separated list of group names. If specified, the user must also belong to one of these groups.

boolean $ignored

No longer used

$force_logout

Returns

array —

The first element of the array is either the uid or FALSE. If false, the second element is an error string.

LoggedInName()

LoggedInName() : string

The username of the currently logged in user for this request.

Returns

string

Logout()

Logout(int $uid, string $message)

Logout the specified user, or the current user.

Parameters

int $uid

An optional uid. If not specified, the current logged in uid for this request will be used.

string $message

An optional string to include in thie history log.

LogoutUser()

LogoutUser(int $uid,  $eventmsg)

Logout the specified user.

Parameters

int $uid

An optional uid. If not specified, the current logged in uid for this request will be used.

$eventmsg

LoggedInId()

LoggedInId() : int

Return the uid of the current logged in user for this request.

Returns

int

LoggedIn()

LoggedIn() : boolean

Test whether the current site visitor is logged in to FrontEndUsers

Returns

boolean

MemberOfGroup()

MemberOfGroup(int $userid, int $groupid) : boolean

Test whether the specified user is a member of the specified group.

Parameters

int $userid
int $groupid

Returns

boolean

RemoveUserFromGroup()

RemoveUserFromGroup(int $uid, int $gid) : array

Remove the specified user from the specified group.

Parameters

int $uid
int $gid

Returns

array —

The first element of the array is a boolean status. If false, the second element is an error string.

SetPropertyDefnExtra()

SetPropertyDefnExtra(string $name, string $extra)

Set the extra information for a proerty.

Parameters

string $name

The property name

string $extra

The extra value.

SetGroup()

SetGroup(int $gid, string $name, string $desc) : array

Update a group definition.

Parameters

int $gid
string $name

The group name

string $desc

An optional group description

Returns

array —

The first element of the array is a boolean status. If false, the second element is an error string.

EncryptPassword()

EncryptPassword(int $uid,  $plain_password) : string

Given a plain text password, encrypt it for a user

Parameters

int $uid
$plain_password

Returns

string

SetUserPassword()

SetUserPassword(int $uid, string $password) : array

Set the password for a user

Parameters

int $uid
string $password

Returns

array —

The first element of the array is a boolean status. If false, the second element is an error string.

SetUserDisabled()

SetUserDisabled(int $uid, boolean $flag)

Toggle a user account as disbled.

Parameters

int $uid
boolean $flag

Whether or not the account is disabled.

ForcePasswordChange()

ForcePasswordChange(int $uid, boolean $flag)

Toggle whether a user is forced to change his password at the next login.

Parameters

int $uid
boolean $flag

ForceChangeSettings()

ForceChangeSettings(int $uid, boolean $flag)

Toggle whether a user is forced to change his settings in some way at the next login.

Parameters

int $uid
boolean $flag

ForceVerify()

ForceVerify(int $uid, boolean $flag)

Toggle whether a user is forced to revalidate themselves

Parameters

int $uid
boolean $flag

SetUser()

SetUser(int $uid, string $username, string $password, int $expires)

Adjust user details

Parameters

int $uid
string $username

The user name

string $password

The users plain text password

int $expires

An optional expiry date.

SetUserGroups()

SetUserGroups(int $uid, int[] $grpids)

Set explicit group membership.

This method does not alter the user properties.

Parameters

int $uid
int[] $grpids

AddUserToGroup()

AddUserToGroup( $uid,  $gid) : boolean

Add user to a group

does not effect user properties does not validate gid userid is validated

Parameters

$uid
$gid

Returns

boolean

SetUserProperties()

SetUserProperties( $uid,  $props)

Parameters

$uid
$props

SetUserProperty()

SetUserProperty( $title,  $data)

Parameters

$title
$data

IsUserPropertyValueUnique()

IsUserPropertyValueUnique( $uid,  $title,  $value)

Parameters

$uid
$title
$value

SetUserPropertyFull()

SetUserPropertyFull( $title,  $data,  $userid)

Parameters

$title
$data
$userid

UserExistsByID()

UserExistsByID( $uid)

Parameters

$uid

SetEncryptionKey()

SetEncryptionKey( $uid,  $force)

Parameters

$uid
$force