PHP Class UserModel, vanilla

Inheritance: extends Model
Show file Open project: vanilla/vanilla Class Usage Examples

Public Properties

Property Type Description
$SessionColumns
$UserMegaThreshold The number of users when extreme database optimizations kick in.
$UserThreshold The number of users when database optimizations kick in.

Public Methods

Method Description
__construct ( ) Class constructor. Defines the related database table name.
addInsertFields ( &$Fields ) Parent override.
addPasswordStrength ( Gdn_Controller $Controller ) Set password strength meter on a form.
approve ( integer $UserID, string $Email ) : boolean Approve a membership applicant.
attributes ( array | object $user ) : array Reliably get the attributes from any user array or object.
ban ( integer $UserID, array $Options ) Manually ban a user.
checkPermission ( mixed $User, mixed $Permission, array $Options = [] ) : boolean Checks the specified user's for the given permission. Returns a boolean value indicating if the action is permitted.
clearCache ( integer | null $UserID, $CacheTypesToClear = null ) : boolean Delete cached data for user.
clearNavigationPreferences ( string $userID = '' ) Clears navigation preferences for a user.
clearPermissions ( ) Clear the permission cache.
clearSectionNavigationPreference ( string $url = '', string $userID = '', boolean $resetSectionPreference = true ) Checks if a url is saved as a navigation preference and if so, deletes it.
compilePermissions ( array $rawPermissions ) : array Take raw permission definitions and create.
confirmEmail ( array | object $User, string $EmailKey ) : boolean Users respond to confirmation emails by clicking a link that takes them here.
connect ( string $UniqueID, string $ProviderKey, array $UserData, array $Options = [] ) : integer Connect a user with a foreign authentication system.
countEstimate ( ) : integer Approximate the number of users by checking the database table status.
counts ( string $Column, integer | null $UserID = null ) User counts.
decline ( integer $UserID ) : boolean Decline a user's application to join the forum.
definePermissions ( integer $UserID, boolean $Serialize = false ) : array Load and compile user permissions
delete ( $where = [], $options = [] ) Delete a user.
deleteContent ( integer $UserID, array $Options = [], array $Content = [] ) : boolean | integer Delete a user's content across many contexts.
deleteID ( integer $userID, array $options = [] ) Delete a single user.
filterForm ( array $data, boolean $register = false ) : array Filter dangerous fields out of user-submitted data.
fixGender ( string $Value ) : string Force gender to be a verified value.
get ( $OrderFields = '', $OrderDirection = 'asc', $Limit = false, $Offset = false ) : object Default Gdn_Model::get() behavior.
getActiveUsers ( integer $Limit = 5 ) : Gdn_DataSet Get the most recently active users.
getApplicantCount ( ) : integer Get the current number of applicants waiting to be approved.
getApplicants ( ) : Gdn_DataSet Returns all users in the applicant role.
getAttribute ( integer $UserID, string $Attribute, mixed $DefaultValue = false ) : mixed Get an Attribute from a single user.
getAuthentication ( string $UniqueID, string $Provider ) : array | false Get the a user authentication row.
getByEmail ( string $Email ) : array | boolean | stdClass Get user by email address.
getByRole ( integer | string $Role ) : Gdn_DataSet Get users by role.
getByUsername ( string $Username ) : boolean | object Get a user by their username.
getCountLike ( array | boolean $Like = false ) : integer
getCountWhere ( array | false $Where = false ) : integer
getDefaultAvatarUrl ( array $user = [], string $size = 'thumbnail' ) : string Returns the url to the default avatar for a user.
getDelete ( string $Table, array $Where, array &$Data ) Get rows from a table then delete them.
getID ( integer $ID, string | false $DatasetType = false, array $Options = [] ) : array | object | false Get a user by ID.
getIDs ( array $IDs, boolean $SkipCacheQuery = false ) : array
getIPs ( integer $userID ) : array Retrieve IP addresses associated with a user.
getInvitationCount ( integer $UserID ) : integer Get number of available invites a user has.
getLike ( boolean $Like = false, string $OrderFields = '', string $OrderDirection = 'asc', boolean $Limit = false, boolean $Offset = false ) : Gdn_DataSet
getMeta ( integer $UserID, string $Key, string $Prefix = '', string $Default = '' ) : array Retries UserMeta information for a UserID / Key pair.
getPermissions ( integer $userID ) : Vanilla\Permissions Get a user's permissions.
getPermissionsIncrement ( ) : boolean | integer | mixed
getRoles ( integer $userID ) : Gdn_DataSet Get the roles for a user.
getSession ( integer $UserID, boolean $Refresh = false ) : array | object | false
getSummary ( string $OrderFields = '', string $OrderDirection = 'asc', boolean $Limit = false, boolean $Offset = false ) : array | null Retrieve a summary of "safe" user information for external API calls.
getSystemUserID ( ) : integer Retrieves a "system user" id that can be used to perform non-real-person tasks.
getUserFromCache ( string | integer $UserToken, string $TokenType ) : array | false Get a user from the cache by name or ID
givePoints ( integer $UserID, integer $Points, string $Source = 'Other', integer | false $Timestamp = false ) Add points to a user's total.
increaseInviteCount ( integer $UserID, integer $IncreaseBy = 1 ) Increases the user's CountInvitations value by the specified amount.
insertForApproval ( array $FormPostValues, array $Options = [] ) : integer To be used for approval registration.
insertForBasic ( array $FormPostValues, boolean $CheckCaptcha = true, array $Options = [] ) : boolean | integer | string To be used for basic registration, and captcha registration.
insertForInvite ( array $FormPostValues, array $Options = [] ) : integer To be used for invitation registration.
joinUsers ( array | Gdn_DataSet &$Data, array $Columns, array $Options = [] ) Add user data to a result set.
merge ( integer $OldUserID, integer $NewUserID ) Merge the old user into the new user.
newUserRoleIDs ( ) : array
noEmail ( ) : boolean Whether or not users have email addresses.
passwordRequest ( string $Email ) : boolean Send forgot password email.
passwordReset ( integer $UserID, string $Password ) : array | false Do a password reset.
pastUserMegaThreshold ( ) : boolean Whether we're wandered into extreme database optimization territory with our user count.
pastUserThreshold ( ) : boolean Whether or not we are past the user threshold.
profileCount ( integer | string | object $User, string $Column ) : integer | false Get a user's counter.
rateLimit ( array $User, boolean $PasswordOK ) Check and apply login rate limiting
reduceInviteCount ( integer $UserID, integer $ReduceBy = 1 ) Reduces the user's CountInvitations value by the specified amount.
register ( array $FormPostValues, array $Options = [] ) : boolean | integer | string Register a new user.
removePicture ( integer $UserID ) Remove the photo from a user.
requireConfirmEmail ( ) : boolean Whether or not the application requires email confirmation.
save ( array $FormPostValues, array $Settings = [] ) Generic save procedure.
saveAbout ( integer $UserID, string $About ) Saves the user's About field.
saveAdminUser ( array $FormPostValues ) Create an admin user account.
saveAttribute ( integer $UserID, mixed $Attribute, mixed $Value = '' ) Saves a user attribute to the database.
saveAuthentication ( array $Data ) : Gdn_DataSet | string
saveIP ( integer $userID, string $IP, string $dateUpdated = false ) : boolean Record an IP address for a user.
savePreference ( integer $UserID, mixed $Preference, mixed $Value = '' ) Saves a user preference to the database.
saveRoles ( integer $UserID, array $RoleIDs, boolean $RecordEvent )
saveToSerializedColumn ( string $Column, integer $UserID, mixed $Name, mixed $Value = '' ) Saves a name/value to the user's specified $Column.
search ( array | string $Filter, string $OrderFields = '', string $OrderDirection = 'asc', boolean $Limit = false, boolean $Offset = false ) : Gdn_DataSet Search users.
searchCount ( array | string $Filter = '' ) : integer Count search results.
sendEmailConfirmationEmail ( integer | string | null $User = null, boolean $Force = false ) Send the confirmation email.
sendPasswordEmail ( integer $UserID, string $Password ) Send password email.
sendWelcomeEmail ( integer $UserID, string $Password, string $RegisterType = 'Add', array | null $AdditionalData = null ) Send welcome email to user.
setCalculatedFields ( &$User ) Set fields that need additional manipulation after retrieval.
setField ( integer $RowID, array | string $Property, boolean $Value = false ) : boolean Set a single user property.
setMeta ( integer $UserID, array $Meta, string $Prefix = '' )
setTransientKey ( integer $UserID, string $ExplicitKey = '' ) : string Set the TransientKey attribute on a user.
signinLabelCode ( ) : string
sso ( string $String, boolean $ThrowError = false ) : integer | void Initiate an SSO connection.
syncUser ( array | integer $CurrentUser, array $NewUser, boolean $Force = false ) Sync user data.
synchUser ( array | integer $CurrentUser, array $NewUser, boolean $Force = false ) Sync user data.
synchronize ( string $UserKey, array $Data ) : integer Synchronizes the user based on a given UserKey.
tagSearch ( string $Search, integer $Limit = 10 ) A simple search for tag queries.
unBan ( integer $UserID, array $Options = [] ) Unban a user.
updateUserCache ( integer $UserID, string | array $Field, mixed | null $Value = null )
updateVisit ( integer $UserID, string | integer | float $ClientHour = false ) Updates visit level information such as date last active and the user's ip address.
userCache ( array $User, $UserID = null ) : boolean Cache a user.
userCacheRoles ( integer $userID, array $roleIDs ) : boolean Cache a user's roles.
userQuery ( boolean $SafeData = false ) Query the user table.
validate ( array $FormPostValues, boolean $Insert = false ) : boolean | array Validate submitted user data.
validateCredentials ( string $Email = '', $ID, string $Password ) : object | false Validate User Credential.
validateSpamRegistration ( array $User ) : boolean | string
validateUniqueFields ( string $Username, string $Email, string $UserID = '', boolean $Return = false ) : array | boolean Checks to see if $Username and $Email are already in use by another member.

Protected Methods

Method Description
getEmailWelcome ( string $registerType, object | array $user, array $data, string $password = '' ) : string Resolves the welcome email format. Maintains backwards compatibility with the 'EmailWelcome*' translations for overriding.
lookupRoleIDs ( array $Roles ) : array
mergeFinish ( integer $MergeID ) Finish merging user accounts.

Private Methods

Method Description
addEmailHeaderFooter ( string $Message, array $Data ) : string Deprecated.
addIpFilters ( string $ip, array $fields = [] ) Appends filters to the current SQL object. Filters users with a given IP Address in the UserIP table. Extends filtering to IPs in the GDN_User table for any fields passed in the $fields param.
givePointsInternal ( integer $UserID, integer $Points, string $SlotType, string $Source = 'Total', integer $CategoryID, integer | false $Timestamp = false ) Add points to a user's total in a specific time slot.
insertInternal ( array $Fields, array $Options = [] ) : integer | false A convenience method to be called when inserting users.
mergeCopy ( integer $MergeID, string $Table, string $Column, integer $OldUserID, integer $NewUserID, string $PK = '' ) Backup user before merging.
mergeStart ( integer $OldUserID, integer $NewUserID ) : integer | null Start merging user accounts.

Method Details

__construct() public method

Class constructor. Defines the related database table name.
public __construct ( )

addInsertFields() public method

Parent override.
public addInsertFields ( &$Fields )

addPasswordStrength() public method

Set password strength meter on a form.
public addPasswordStrength ( Gdn_Controller $Controller )
$Controller Gdn_Controller The controller to add the password strength information to.

approve() public method

Approve a membership applicant.
public approve ( integer $UserID, string $Email ) : boolean
$UserID integer
$Email string
return boolean

attributes() public static method

Reliably get the attributes from any user array or object.
public static attributes ( array | object $user ) : array
$user array | object The user to get the attributes for.
return array Returns an attribute array.

ban() public method

Manually ban a user.
public ban ( integer $UserID, array $Options )
$UserID integer The ID of the user to ban.
$Options array Additional options for the ban.

checkPermission() public method

Checks the specified user's for the given permission. Returns a boolean value indicating if the action is permitted.
public checkPermission ( mixed $User, mixed $Permission, array $Options = [] ) : boolean
$User mixed The user to check.
$Permission mixed The permission (or array of permissions) to check.
$Options array Not used.
return boolean

clearCache() public method

Delete cached data for user.
public clearCache ( integer | null $UserID, $CacheTypesToClear = null ) : boolean
$UserID integer | null The user to clear the cache for.
return boolean Returns **true** if the cache was cleared or **false** otherwise.

clearNavigationPreferences() public method

Clears navigation preferences for a user.
public clearNavigationPreferences ( string $userID = '' )
$userID string Optional - defaults to sessioned user

clearPermissions() public method

Clear the permission cache.
public clearPermissions ( )

clearSectionNavigationPreference() public method

Also optionally resets the section dashboard landing page, which may be desirable if a user no longer has permission to access pages in that section.
public clearSectionNavigationPreference ( string $url = '', string $userID = '', boolean $resetSectionPreference = true )
$url string The url to search the user navigation preferences for, defaults to the request
$userID string The ID of the user to clear the preferences for, defaults to the sessioned user
$resetSectionPreference boolean Whether to reset the dashboard section landing page

compilePermissions() public static method

Take raw permission definitions and create.
public static compilePermissions ( array $rawPermissions ) : array
$rawPermissions array Database rows from the permissions table.
return array Compiled permissions

confirmEmail() public method

Users respond to confirmation emails by clicking a link that takes them here.
public confirmEmail ( array | object $User, string $EmailKey ) : boolean
$User array | object The user confirming their email.
$EmailKey string The token that was emailed to the user.
return boolean Returns **true** if the email was confirmed.

connect() public method

Connect a user with a foreign authentication system.
public connect ( string $UniqueID, string $ProviderKey, array $UserData, array $Options = [] ) : integer
$UniqueID string The user's unique key in the other authentication system.
$ProviderKey string The key of the system providing the authentication.
$UserData array Data to go in the user table.
$Options array Additional connect options.
return integer The new/existing user ID.

countEstimate() public method

Approximate the number of users by checking the database table status.
public countEstimate ( ) : integer
return integer

counts() public method

User counts.
public counts ( string $Column, integer | null $UserID = null )
$Column string The name of the count column. (ex. CountDiscussions, CountComments).
$UserID integer | null The user ID to get the counts for or **null** for the current user.

decline() public method

Decline a user's application to join the forum.
public decline ( integer $UserID ) : boolean
$UserID integer
return boolean

definePermissions() public method

Load and compile user permissions
Deprecation: Use UserModel::getPermissions instead.
public definePermissions ( integer $UserID, boolean $Serialize = false ) : array
$UserID integer
$Serialize boolean
return array

delete() public method

public delete ( $where = [], $options = [] )

deleteContent() public method

Delete a user's content across many contexts.
public deleteContent ( integer $UserID, array $Options = [], array $Content = [] ) : boolean | integer
$UserID integer
$Options array
$Content array
return boolean | integer

deleteID() public method

Delete a single user.
public deleteID ( integer $userID, array $options = [] )
$userID integer The user to delete.
$options array See {@link UserModel::deleteContent()}, and {@link UserModel::getDelete()}.

filterForm() public method

Filter dangerous fields out of user-submitted data.
public filterForm ( array $data, boolean $register = false ) : array
$data array The data to filter.
$register boolean Whether or not this is a registration.
return array Returns a filtered version of {@link $data}.

fixGender() public static method

Force gender to be a verified value.
public static fixGender ( string $Value ) : string
$Value string The gender string.
return string

get() public method

Prior to 2.0.18 it incorrectly behaved like GetID. This method can be deleted entirely once it's been deprecated long enough.
public get ( $OrderFields = '', $OrderDirection = 'asc', $Limit = false, $Offset = false ) : object
return object DataSet

getActiveUsers() public method

Get the most recently active users.
public getActiveUsers ( integer $Limit = 5 ) : Gdn_DataSet
$Limit integer The number of users to return.
return Gdn_DataSet Returns a list of users.

getApplicantCount() public method

Get the current number of applicants waiting to be approved.
public getApplicantCount ( ) : integer
return integer Returns the number of applicants or 0 if the registration method isn't set to approval.

getApplicants() public method

Returns all users in the applicant role.
public getApplicants ( ) : Gdn_DataSet
return Gdn_DataSet Returns a data set of the users who are applicants.

getAttribute() public method

Get an Attribute from a single user.
public getAttribute ( integer $UserID, string $Attribute, mixed $DefaultValue = false ) : mixed
$UserID integer
$Attribute string
$DefaultValue mixed
return mixed

getAuthentication() public method

Get the a user authentication row.
public getAuthentication ( string $UniqueID, string $Provider ) : array | false
$UniqueID string The unique ID of the user in the foreign authentication scheme.
$Provider string The key of the provider.
return array | false

getByEmail() public method

Get user by email address.
public getByEmail ( string $Email ) : array | boolean | stdClass
$Email string The email address of the user.
return array | boolean | stdClass Returns the user or **false** if they don't exist.

getByRole() public method

Get users by role.
public getByRole ( integer | string $Role ) : Gdn_DataSet
$Role integer | string The ID or name of the role.
return Gdn_DataSet Returns the users with the given role.

getByUsername() public method

Get a user by their username.
public getByUsername ( string $Username ) : boolean | object
$Username string The username of the user.
return boolean | object Returns the user or **false** if they don't exist.

getCountLike() public method

public getCountLike ( array | boolean $Like = false ) : integer
$Like array | boolean
return integer

getCountWhere() public method

public getCountWhere ( array | false $Where = false ) : integer
$Where array | false
return integer

getDefaultAvatarUrl() public static method

Returns the url to the default avatar for a user.
public static getDefaultAvatarUrl ( array $user = [], string $size = 'thumbnail' ) : string
$user array The user to get the default avatar for.
$size string The size of avatar to return (only respected for dashboard-uploaded default avatars).
return string The url to the default avatar image.

getDelete() public method

Get rows from a table then delete them.
Since: 2.1
public getDelete ( string $Table, array $Where, array &$Data )
$Table string The name of the table.
$Where array The where condition for the delete.
$Data array The data to put the result.

getEmailWelcome() protected method

Resolves the welcome email format. Maintains backwards compatibility with the 'EmailWelcome*' translations for overriding.
protected getEmailWelcome ( string $registerType, object | array $user, array $data, string $password = '' ) : string
$registerType string The registration type. One of 'Connect', 'Register' or 'Add'.
$user object | array The user to send the email to.
$data array The email data.
$password string The user's password.
return string The welcome email for the registration type.

getID() public method

Get a user by ID.
public getID ( integer $ID, string | false $DatasetType = false, array $Options = [] ) : array | object | false
$ID integer The ID of the user.
$DatasetType string | false Whether to return an array or object.
$Options array Additional options to affect fetching. Currently unused.
return array | object | false Returns the user or **false** if the user wasn't found.

getIDs() public method

public getIDs ( array $IDs, boolean $SkipCacheQuery = false ) : array
$IDs array
$SkipCacheQuery boolean
return array

getIPs() public method

Retrieve IP addresses associated with a user.
public getIPs ( integer $userID ) : array
$userID integer Unique ID for a user.
return array IP addresses for the user.

getInvitationCount() public method

Get number of available invites a user has.
public getInvitationCount ( integer $UserID ) : integer
$UserID integer
return integer

getLike() public method

public getLike ( boolean $Like = false, string $OrderFields = '', string $OrderDirection = 'asc', boolean $Limit = false, boolean $Offset = false ) : Gdn_DataSet
$Like boolean
$OrderFields string
$OrderDirection string
$Limit boolean
$Offset boolean
return Gdn_DataSet

getMeta() public static method

This method takes a $UserID or array of $UserIDs, and a $Key. It converts the $Key to fully qualified format and then queries for the associated value(s). $Key can contain SQL wildcards, in which case multiple results can be returned. If $UserID is an array, the return value will be a multi dimensional array with the first axis containing UserIDs and the second containing fully qualified UserMetaKeys, associated with their values. If $UserID is a scalar, the return value will be a single dimensional array of $UserMetaKey => $Value pairs.
public static getMeta ( integer $UserID, string $Key, string $Prefix = '', string $Default = '' ) : array
$UserID integer UserID or array of UserIDs.
$Key string Relative user meta key.
$Prefix string
$Default string
return array results or $Default

getPermissions() public method

Get a user's permissions.
public getPermissions ( integer $userID ) : Vanilla\Permissions
$userID integer Unique ID of the user.
return Vanilla\Permissions

getPermissionsIncrement() public method

getRoles() public method

Get the roles for a user.
public getRoles ( integer $userID ) : Gdn_DataSet
$userID integer The user to get the roles for.
return Gdn_DataSet Returns the roles as a dataset (with array values).

getSession() public method

public getSession ( integer $UserID, boolean $Refresh = false ) : array | object | false
$UserID integer
$Refresh boolean
return array | object | false

getSummary() public method

Retrieve a summary of "safe" user information for external API calls.
public getSummary ( string $OrderFields = '', string $OrderDirection = 'asc', boolean $Limit = false, boolean $Offset = false ) : array | null
$OrderFields string
$OrderDirection string
$Limit boolean
$Offset boolean
return array | null

getSystemUserID() public method

Retrieves a "system user" id that can be used to perform non-real-person tasks.
public getSystemUserID ( ) : integer
return integer Returns a user ID.

getUserFromCache() public method

Get a user from the cache by name or ID
public getUserFromCache ( string | integer $UserToken, string $TokenType ) : array | false
$UserToken string | integer either a userid or a username
$TokenType string either 'userid' or 'name'
return array | false Returns a user array or **false** if the user isn't in the cache.

givePoints() public static method

Add points to a user's total.
Since: 2.1.0
public static givePoints ( integer $UserID, integer $Points, string $Source = 'Other', integer | false $Timestamp = false )
$UserID integer
$Points integer
$Source string
$Timestamp integer | false

increaseInviteCount() public method

Increases the user's CountInvitations value by the specified amount.
public increaseInviteCount ( integer $UserID, integer $IncreaseBy = 1 )
$UserID integer The unique id of the user being affected.
$IncreaseBy integer The number to increase CountInvitations by.

insertForApproval() public method

To be used for approval registration.
public insertForApproval ( array $FormPostValues, array $Options = [] ) : integer
$FormPostValues array
$Options array
return integer UserID.

insertForBasic() public method

To be used for basic registration, and captcha registration.
public insertForBasic ( array $FormPostValues, boolean $CheckCaptcha = true, array $Options = [] ) : boolean | integer | string
$FormPostValues array
$CheckCaptcha boolean
$Options array
return boolean | integer | string

insertForInvite() public method

To be used for invitation registration.
public insertForInvite ( array $FormPostValues, array $Options = [] ) : integer
$FormPostValues array
$Options array
return integer UserID.

joinUsers() public method

Add user data to a result set.
public joinUsers ( array | Gdn_DataSet &$Data, array $Columns, array $Options = [] )
$Data array | Gdn_DataSet Results we need to associate user data with.
$Columns array Database columns containing UserIDs to get data for.
$Options array Optionally pass list of user data to collect with key 'Join'.

lookupRoleIDs() protected method

protected lookupRoleIDs ( array $Roles ) : array
$Roles array
return array

merge() public method

Merge the old user into the new user.
public merge ( integer $OldUserID, integer $NewUserID )
$OldUserID integer The ID of the old user.
$NewUserID integer The ID of the new user.

mergeFinish() protected method

Finish merging user accounts.
protected mergeFinish ( integer $MergeID )
$MergeID integer The merge table ID.

newUserRoleIDs() public method

public newUserRoleIDs ( ) : array
return array

noEmail() public static method

Whether or not users have email addresses.
public static noEmail ( ) : boolean
return boolean

passwordRequest() public method

Send forgot password email.
public passwordRequest ( string $Email ) : boolean
$Email string
return boolean

passwordReset() public method

Do a password reset.
public passwordReset ( integer $UserID, string $Password ) : array | false
$UserID integer
$Password string
return array | false Returns the user or **false** if the user doesn't exist.

pastUserMegaThreshold() public method

Whether we're wandered into extreme database optimization territory with our user count.
public pastUserMegaThreshold ( ) : boolean
return boolean

pastUserThreshold() public method

This is a useful indication that some database operations on the User table will be painfully long.
public pastUserThreshold ( ) : boolean
return boolean

profileCount() public method

Get a user's counter.
public profileCount ( integer | string | object $User, string $Column ) : integer | false
$User integer | string | object
$Column string
return integer | false

rateLimit() public static method

Check and apply login rate limiting
public static rateLimit ( array $User, boolean $PasswordOK )
$User array
$PasswordOK boolean

reduceInviteCount() public method

Reduces the user's CountInvitations value by the specified amount.
public reduceInviteCount ( integer $UserID, integer $ReduceBy = 1 )
$UserID integer The unique id of the user being affected.
$ReduceBy integer The number to reduce CountInvitations by.

register() public method

Register a new user.
public register ( array $FormPostValues, array $Options = [] ) : boolean | integer | string
$FormPostValues array
$Options array
return boolean | integer | string

removePicture() public method

Remove the photo from a user.
public removePicture ( integer $UserID )
$UserID integer

requireConfirmEmail() public static method

Whether or not the application requires email confirmation.
public static requireConfirmEmail ( ) : boolean
return boolean

save() public method

Generic save procedure.
public save ( array $FormPostValues, array $Settings = [] )
$FormPostValues array The user to save.
$Settings array Controls certain save functionality. - SaveRoles - Save 'RoleID' field as user's roles. Default false. - HashPassword - Hash the provided password on update. Default true. - FixUnique - Try to resolve conflicts with unique constraints on Name and Email. Default false. - ValidateEmail - Make sure the provided email addresses is formatted properly. Default true. - NoConfirmEmail - Disable email confirmation. Default false.

saveAbout() public method

Saves the user's About field.
public saveAbout ( integer $UserID, string $About )
$UserID integer The UserID to save.
$About string The about message being saved.

saveAdminUser() public method

Create an admin user account.
public saveAdminUser ( array $FormPostValues )
$FormPostValues array

saveAttribute() public method

This is a convenience method that uses $this->SaveToSerializedColumn().
public saveAttribute ( integer $UserID, mixed $Attribute, mixed $Value = '' )
$UserID integer The UserID to save.
$Attribute mixed The name of the attribute being saved, or an associative array of name => value pairs to be saved. If this is an associative array, the $Value argument will be ignored.
$Value mixed The value being saved.

saveAuthentication() public method

public saveAuthentication ( array $Data ) : Gdn_DataSet | string
$Data array
return Gdn_DataSet | string

saveIP() public method

Record an IP address for a user.
public saveIP ( integer $userID, string $IP, string $dateUpdated = false ) : boolean
$userID integer Unique ID of the user.
$IP string Human-readable IP address.
$dateUpdated string Force an update timesetamp.
return boolean Was the operation successful?

savePreference() public method

This is a convenience method that uses $this->SaveToSerializedColumn().
public savePreference ( integer $UserID, mixed $Preference, mixed $Value = '' )
$UserID integer The UserID to save.
$Preference mixed The name of the preference being saved, or an associative array of name => value pairs to be saved. If this is an associative array, the $Value argument will be ignored.
$Value mixed The value being saved.

saveRoles() public method

public saveRoles ( integer $UserID, array $RoleIDs, boolean $RecordEvent )
$UserID integer
$RoleIDs array
$RecordEvent boolean

saveToSerializedColumn() public method

This method throws exceptions when errors are encountered. Use try catch blocks to capture these exceptions.
public saveToSerializedColumn ( string $Column, integer $UserID, mixed $Name, mixed $Value = '' )
$Column string The name of the serialized column to save to. At the time of this writing there are three serialized columns on the user table: Permissions, Preferences, and Attributes.
$UserID integer The UserID to save.
$Name mixed The name of the value being saved, or an associative array of name => value pairs to be saved. If this is an associative array, the $Value argument will be ignored.
$Value mixed The value being saved.

searchCount() public method

Count search results.
public searchCount ( array | string $Filter = '' ) : integer
$Filter array | string
return integer

sendEmailConfirmationEmail() public method

Send the confirmation email.
public sendEmailConfirmationEmail ( integer | string | null $User = null, boolean $Force = false )
$User integer | string | null
$Force boolean

sendPasswordEmail() public method

Send password email.
public sendPasswordEmail ( integer $UserID, string $Password )
$UserID integer
$Password string

sendWelcomeEmail() public method

Send welcome email to user.
public sendWelcomeEmail ( integer $UserID, string $Password, string $RegisterType = 'Add', array | null $AdditionalData = null )
$UserID integer
$Password string
$RegisterType string
$AdditionalData array | null

setCalculatedFields() public method

Set fields that need additional manipulation after retrieval.
public setCalculatedFields ( &$User )

setField() public method

Set a single user property.
public setField ( integer $RowID, array | string $Property, boolean $Value = false ) : boolean
$RowID integer
$Property array | string
$Value boolean
return boolean

setMeta() public static method

public static setMeta ( integer $UserID, array $Meta, string $Prefix = '' )
$UserID integer
$Meta array
$Prefix string

setTransientKey() public method

Set the TransientKey attribute on a user.
public setTransientKey ( integer $UserID, string $ExplicitKey = '' ) : string
$UserID integer
$ExplicitKey string
return string

signinLabelCode() public static method

public static signinLabelCode ( ) : string
return string

sso() public method

Initiate an SSO connection.
public sso ( string $String, boolean $ThrowError = false ) : integer | void
$String string
$ThrowError boolean
return integer | void

syncUser() public method

Sync user data.
Since: 2.1
public syncUser ( array | integer $CurrentUser, array $NewUser, boolean $Force = false )
$CurrentUser array | integer
$NewUser array Data to overwrite user with.
$Force boolean

synchUser() public method

Sync user data.
Deprecation: since 2.2.
Since: 2.1
public synchUser ( array | integer $CurrentUser, array $NewUser, boolean $Force = false )
$CurrentUser array | integer
$NewUser array Data to overwrite user with.
$Force boolean

synchronize() public method

Synchronizes the user based on a given UserKey.
public synchronize ( string $UserKey, array $Data ) : integer
$UserKey string A string that uniquely identifies this user.
$Data array Information to put in the user table.
return integer The ID of the user.

tagSearch() public method

A simple search for tag queries.
Since: 2.2
public tagSearch ( string $Search, integer $Limit = 10 )
$Search string
$Limit integer

unBan() public method

Unban a user.
Since: 2.1
public unBan ( integer $UserID, array $Options = [] )
$UserID integer The user to unban.
$Options array Options for the unban.

updateUserCache() public method

public updateUserCache ( integer $UserID, string | array $Field, mixed | null $Value = null )
$UserID integer
$Field string | array
$Value mixed | null

updateVisit() public method

Updates visit level information such as date last active and the user's ip address.
public updateVisit ( integer $UserID, string | integer | float $ClientHour = false )
$UserID integer
$ClientHour string | integer | float

userCache() public method

Cache a user.
public userCache ( array $User, $UserID = null ) : boolean
$User array The user to cache.
return boolean Returns **true** if the user was cached or **false** otherwise.

userCacheRoles() public method

Cache a user's roles.
public userCacheRoles ( integer $userID, array $roleIDs ) : boolean
$userID integer The ID of a user to cache roles for.
$roleIDs array A collection of role IDs with the specified user.
return boolean Was the caching operation successful?

userQuery() public method

Query the user table.
public userQuery ( boolean $SafeData = false )
$SafeData boolean Makes sure that the query does not return any sensitive information about the user. (password, attributes, preferences, etc).

validate() public method

Validate submitted user data.
public validate ( array $FormPostValues, boolean $Insert = false ) : boolean | array
$FormPostValues array
$Insert boolean
return boolean | array

validateCredentials() public method

Fetches a user row by email (or name) and compare the password. If the password was not stored as a blowfish hash, the password will be saved again. Return the user's id, admin status and attributes.
public validateCredentials ( string $Email = '', $ID, string $Password ) : object | false
$Email string
$Password string
return object | false Returns the user matching the credentials or **false** if the user doesn't validate.

validateSpamRegistration() public method

Since: 2.1
public validateSpamRegistration ( array $User ) : boolean | string
$User array
return boolean | string

validateUniqueFields() public method

Checks to see if $Username and $Email are already in use by another member.
public validateUniqueFields ( string $Username, string $Email, string $UserID = '', boolean $Return = false ) : array | boolean
$Username string
$Email string
$UserID string
$Return boolean
return array | boolean

Property Details

$SessionColumns public property

public $SessionColumns

$UserMegaThreshold public property

The number of users when extreme database optimizations kick in.
public $UserMegaThreshold

$UserThreshold public property

The number of users when database optimizations kick in.
public $UserThreshold