Vanilla 2  2.0.18.8
 All Data Structures Namespaces Files Functions Variables Pages
UserModel Class Reference
Inheritance diagram for UserModel:
Collaboration diagram for UserModel:

Public Member Functions

 __construct ()
 
 ConfirmEmail ($User, $EmailKey)
 
 Connect ($UniqueID, $ProviderKey, $UserData)
 
 FilterForm ($Data)
 
 JoinUsers (&$Data, $Columns, $Options=array())
 
 UserQuery ($SafeData=FALSE)
 
 DefinePermissions ($UserID, $Serialize=TRUE)
 
 Get ($OrderFields= '', $OrderDirection= 'asc', $Limit=FALSE, $Offset=FALSE)
 
 GetByUsername ($Username)
 
 GetByEmail ($Email)
 
 GetByRole ($Role)
 
 GetActiveUsers ($Limit=5)
 
 GetApplicantCount ()
 
 GetApplicants ()
 
 GetAuthentication ($UniqueID, $Provider)
 
 GetCountLike ($Like=FALSE)
 
 GetCountWhere ($Where=FALSE)
 
 GetID ($ID, $DatasetType=DATASET_TYPE_OBJECT)
 
 GetIDs ($IDs, $SkipCacheQuery=FALSE)
 
 GetLike ($Like=FALSE, $OrderFields= '', $OrderDirection= 'asc', $Limit=FALSE, $Offset=FALSE)
 
 GetRoles ($UserID)
 
 GetSession ($UserID, $Refresh=FALSE)
 
 GetSummary ($OrderFields= '', $OrderDirection= 'asc', $Limit=FALSE, $Offset=FALSE)
 
 GetSystemUserID ()
 
 Register ($FormPostValues, $Options=array())
 
 RemovePicture ($UserID)
 
 ProfileCount ($User, $Column)
 
 Save ($FormPostValues, $Settings=FALSE)
 
 SaveAdminUser ($FormPostValues)
 
 SaveRoles ($UserID, $RoleIDs, $RecordActivity=TRUE)
 
 Search ($Keywords, $OrderFields= '', $OrderDirection= 'asc', $Limit=FALSE, $Offset=FALSE)
 
 SearchCount ($Keywords=FALSE)
 
 InsertForInvite ($FormPostValues, $Options=array())
 
 InsertForApproval ($FormPostValues, $Options=array())
 
 InsertForBasic ($FormPostValues, $CheckCaptcha=TRUE, $Options=array())
 
 AddInsertFields (&$Fields)
 
 UpdateLastVisit ($UserID, $Attributes, $ClientHour='')
 
 ValidateCredentials ($Email= '', $ID=0, $Password)
 
 ValidateUniqueFields ($Username, $Email, $UserID= '')
 
 Approve ($UserID, $Email)
 
 Delete ($UserID, $Options=array())
 
 Decline ($UserID)
 
 GetInvitationCount ($UserID)
 
 ReduceInviteCount ($UserID, $ReduceBy=1)
 
 IncreaseInviteCount ($UserID, $IncreaseBy=1)
 
 SaveAbout ($UserID, $About)
 
 SaveToSerializedColumn ($Column, $UserID, $Name, $Value= '')
 
 SavePreference ($UserID, $Preference, $Value= '')
 
 SaveAttribute ($UserID, $Attribute, $Value= '')
 
 SaveAuthentication ($Data)
 
 SetCalculatedFields (&$User)
 
 SetTransientKey ($UserID, $ExplicitKey= '')
 
 GetAttribute ($UserID, $Attribute, $DefaultValue=FALSE)
 
 SendEmailConfirmationEmail ($User=NULL)
 
 SendWelcomeEmail ($UserID, $Password, $RegisterType= 'Add', $AdditionalData=NULL)
 
 SendPasswordEmail ($UserID, $Password)
 
 Synchronize ($UserKey, $Data)
 
 NewUserRoleIDs ()
 
 PasswordRequest ($Email)
 
 PasswordReset ($UserID, $Password)
 
 SetField ($RowID, $Property, $Value=FALSE)
 
 GetUserFromCache ($UserToken, $TokenType)
 
 UpdateUserCache ($UserID, $Field, $Value=NULL)
 
 UserCache ($User)
 
 UserCacheRoles ($UserID, $RoleIDs)
 
 ClearCache ($UserID, $CacheTypesToClear=NULL)
 
 ClearPermissions ()
 
 GetPermissionsIncrement ()
 
- Public Member Functions inherited from Gdn_Model
 __construct ($Name= '')
 
 DefineSchema ()
 
 Save ($FormPostValues, $Settings=FALSE)
 
 Insert ($Fields)
 
 Update ($Fields, $Where=FALSE, $Limit=FALSE)
 
 Delete ($Where= '', $Limit=FALSE, $ResetData=FALSE)
 
 FilterForm ($Data)
 
 FilterSchema ($Data)
 
 Get ($OrderFields= '', $OrderDirection= 'asc', $Limit=FALSE, $Offset=FALSE)
 
 GetCount ($Wheres= '')
 
 GetID ($ID, $DatasetType=FALSE)
 
 GetWhere ($Where=FALSE, $OrderFields= '', $OrderDirection= 'asc', $Limit=FALSE, $Offset=FALSE)
 
 ValidationResults ()
 
 Validate ($FormPostValues, $Insert=FALSE)
 
 SaveToSerializedColumn ($Column, $RowID, $Name, $Value= '')
 
 SetProperty ($RowID, $Property, $ForceValue=FALSE)
 
- Public Member Functions inherited from Gdn_Pluggable
 __construct ()
 
 GetReturn ($PluginName, $HandlerName)
 
 FireEvent ($EventName)
 
 __call ($MethodName, $Arguments)
 
- Public Member Functions inherited from Gdn_SliceProvider
 EnableSlicing (&$Sender)
 
 Slice ($SliceName, $Arguments=array())
 
 AddSliceAsset ($Asset)
 
 RenderSliceConfig ()
 

Static Public Member Functions

static GetMeta ($UserID, $Key, $Prefix= '')
 
static SetMeta ($UserID, $Meta, $Prefix= '')
 

Data Fields

const DEFAULT_CONFIRM_EMAIL = 'You need to confirm your email address before you can continue. Please confirm your email address by clicking on the following link: {/entry/emailconfirm,url,domain}/{User.UserID,rawurlencode}/{EmailKey,rawurlencode}'
 
const USERID_KEY = 'user.{UserID}'
 
const USERNAME_KEY = 'user.{Name}.name'
 
const USERROLES_KEY = 'user.{UserID}.roles'
 
const USERPERMISSIONS_KEY = 'user.{UserID}.permissions.{PermissionsIncrement}'
 
const INC_PERMISSIONS_KEY = 'permissions.increment'
 
 $SessionColumns
 
- Data Fields inherited from Gdn_Model
 $Data
 
 $Database
 
 $DateInserted = 'DateInserted'
 
 $DateUpdated = 'DateUpdated'
 
 $InsertUserID = 'InsertUserID'
 
 $Name
 
 $PrimaryKey = 'id'
 
 $Schema
 
 $SQL
 
 $UpdateUserID = 'UpdateUserID'
 
 $Validation
 
- Data Fields inherited from Gdn_Pluggable
 $EventArguments
 
 $Returns = array()
 
 $HandlerType
 

Static Public Attributes

static $UserCache = array()
 

Protected Member Functions

 _AddEmailHeaderFooter ($Message, $Data)
 
 _Insert ($Fields, $Options=array())
 
- Protected Member Functions inherited from Gdn_Model
 _BeforeGet ()
 
 AddInsertFields (&$Fields)
 
 AddUpdateFields (&$Fields)
 

Additional Inherited Members

- Protected Attributes inherited from Gdn_Pluggable
 $ClassName
 
- Protected Attributes inherited from Gdn_SliceProvider
 $SliceHandler
 
 $SliceConfig
 

Constructor & Destructor Documentation

__construct ( )

Class constructor. Defines the related database table name.

Member Function Documentation

_AddEmailHeaderFooter (   $Message,
  $Data 
)
protected

Here is the call graph for this function:

Here is the caller graph for this function:

_Insert (   $Fields,
  $Options = array() 
)
protected

A convenience method to be called when inserting users (because users are inserted in various methods depending on registration setups).

Here is the call graph for this function:

Here is the caller graph for this function:

AddInsertFields ( $Fields)

Here is the call graph for this function:

Here is the caller graph for this function:

Approve (   $UserID,
  $Email 
)

Approve a membership applicant.

Here is the call graph for this function:

ClearCache (   $UserID,
  $CacheTypesToClear = NULL 
)

Delete cached data for user

Parameters
type$UserID
Returns
type

Here is the call graph for this function:

Here is the caller graph for this function:

ClearPermissions ( )

Here is the call graph for this function:

ConfirmEmail (   $User,
  $EmailKey 
)

Here is the call graph for this function:

Here is the caller graph for this function:

Connect (   $UniqueID,
  $ProviderKey,
  $UserData 
)

Connect a user with a foreign authentication system.

Parameters
string$UniqueIDThe user's unique key in the other authentication system.
string$ProviderKeyThe key of the system providing the authentication.
array$UserDataData to go in the user table.
Returns
int The new/existing user ID.

Here is the call graph for this function:

Decline (   $UserID)

Here is the call graph for this function:

DefinePermissions (   $UserID,
  $Serialize = TRUE 
)

Here is the call graph for this function:

Here is the caller graph for this function:

Delete (   $UserID,
  $Options = array() 
)

Here is the call graph for this function:

Here is the caller graph for this function:

FilterForm (   $Data)

Here is the call graph for this function:

Get (   $OrderFields = '',
  $OrderDirection = 'asc',
  $Limit = FALSE,
  $Offset = FALSE 
)

Default Gdn_Model::Get() behavior.

Prior to 2.0.18 it incorrectly behaved like GetID. This method can be deleted entirely once it's been deprecated long enough.

Since
2.0.0
Returns
object DataSet

Here is the call graph for this function:

Here is the caller graph for this function:

GetActiveUsers (   $Limit = 5)

Here is the call graph for this function:

GetApplicantCount ( )

Here is the call graph for this function:

GetApplicants ( )

Returns all users in the applicant role

Here is the call graph for this function:

GetAttribute (   $UserID,
  $Attribute,
  $DefaultValue = FALSE 
)

Here is the call graph for this function:

Here is the caller graph for this function:

GetAuthentication (   $UniqueID,
  $Provider 
)

Get the a user authentication row.

Parameters
string$UniqueIDThe unique ID of the user in the foreign authentication scheme.
string$ProviderThe key of the provider.
Returns
array|false

Here is the call graph for this function:

Here is the caller graph for this function:

GetByEmail (   $Email)

Here is the call graph for this function:

Here is the caller graph for this function:

GetByRole (   $Role)

Here is the call graph for this function:

GetByUsername (   $Username)

Here is the call graph for this function:

Here is the caller graph for this function:

GetCountLike (   $Like = FALSE)

Here is the call graph for this function:

GetCountWhere (   $Where = FALSE)

Here is the call graph for this function:

GetID (   $ID,
  $DatasetType = DATASET_TYPE_OBJECT 
)

Here is the call graph for this function:

Here is the caller graph for this function:

GetIDs (   $IDs,
  $SkipCacheQuery = FALSE 
)

Here is the call graph for this function:

Here is the caller graph for this function:

GetInvitationCount (   $UserID)

Here is the call graph for this function:

Here is the caller graph for this function:

GetLike (   $Like = FALSE,
  $OrderFields = '',
  $OrderDirection = 'asc',
  $Limit = FALSE,
  $Offset = FALSE 
)

Here is the call graph for this function:

static GetMeta (   $UserID,
  $Key,
  $Prefix = '' 
)
static

Retries UserMeta information for a UserID / Key pair

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.

Parameters
$UserIDinteger UserID or array of UserIDs.
$Keystring relative user meta key.
Returns
array results or $Default

Here is the call graph for this function:

Here is the caller graph for this function:

GetPermissionsIncrement ( )

Here is the call graph for this function:

Here is the caller graph for this function:

GetRoles (   $UserID)

Here is the call graph for this function:

Here is the caller graph for this function:

GetSession (   $UserID,
  $Refresh = FALSE 
)

Here is the call graph for this function:

GetSummary (   $OrderFields = '',
  $OrderDirection = 'asc',
  $Limit = FALSE,
  $Offset = FALSE 
)

Retrieve a summary of "safe" user information for external API calls.

Here is the call graph for this function:

GetSystemUserID ( )

Retrieves a "system user" id that can be used to perform non-real-person tasks.

Here is the call graph for this function:

GetUserFromCache (   $UserToken,
  $TokenType 
)

Get a user from the cache by name or ID

Parameters
type$UserTokeneither a userid or a username
string$TokenTypeeither 'userid' or 'name'
Returns
type user array or FALSE

Here is the call graph for this function:

Here is the caller graph for this function:

IncreaseInviteCount (   $UserID,
  $IncreaseBy = 1 
)

Increases the user's CountInvitations value by the specified amount.

Parameters
intThe unique id of the user being affected.
intThe number to increase CountInvitations by.

Here is the call graph for this function:

InsertForApproval (   $FormPostValues,
  $Options = array() 
)

To be used for approval registration

Here is the call graph for this function:

Here is the caller graph for this function:

InsertForBasic (   $FormPostValues,
  $CheckCaptcha = TRUE,
  $Options = array() 
)

To be used for basic registration, and captcha registration

Here is the call graph for this function:

Here is the caller graph for this function:

InsertForInvite (   $FormPostValues,
  $Options = array() 
)

To be used for invitation registration

Here is the call graph for this function:

Here is the caller graph for this function:

JoinUsers ( $Data,
  $Columns,
  $Options = array() 
)

Add user data to a result set.

Parameters
object$DataResults we need to associate user data with.
array$ColumnsDatabase columns containing UserIDs to get data for.
array$OptionsOptionally pass list of user data to collect with key 'Join'.

Here is the call graph for this function:

NewUserRoleIDs ( )

Here is the caller graph for this function:

PasswordRequest (   $Email)

Here is the call graph for this function:

Here is the caller graph for this function:

PasswordReset (   $UserID,
  $Password 
)

Here is the call graph for this function:

Here is the caller graph for this function:

ProfileCount (   $User,
  $Column 
)

Here is the call graph for this function:

Here is the caller graph for this function:

ReduceInviteCount (   $UserID,
  $ReduceBy = 1 
)

Reduces the user's CountInvitations value by the specified amount.

Parameters
intThe unique id of the user being affected.
intThe number to reduce CountInvitations by.

Here is the call graph for this function:

Register (   $FormPostValues,
  $Options = array() 
)

Here is the call graph for this function:

RemovePicture (   $UserID)

Here is the call graph for this function:

Save (   $FormPostValues,
  $Settings = FALSE 
)

Generic save procedure.

Here is the call graph for this function:

Here is the caller graph for this function:

SaveAbout (   $UserID,
  $About 
)

Saves the user's About field.

Parameters
intThe UserID to save.
stringThe about message being saved.

Here is the call graph for this function:

Here is the caller graph for this function:

SaveAdminUser (   $FormPostValues)

Force the admin user into UserID 1.

Here is the call graph for this function:

SaveAttribute (   $UserID,
  $Attribute,
  $Value = '' 
)

Saves a user attribute to the database.

This is a convenience method that uses $this->SaveToSerializedColumn().

Parameters
intThe UserID to save.
mixedThe 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.
mixedThe value being saved.

Here is the call graph for this function:

Here is the caller graph for this function:

SaveAuthentication (   $Data)

Here is the caller graph for this function:

SavePreference (   $UserID,
  $Preference,
  $Value = '' 
)

Saves a user preference to the database.

This is a convenience method that uses $this->SaveToSerializedColumn().

Parameters
intThe UserID to save.
mixedThe 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.
mixedThe value being saved.

Here is the call graph for this function:

Here is the caller graph for this function:

SaveRoles (   $UserID,
  $RoleIDs,
  $RecordActivity = TRUE 
)

Here is the call graph for this function:

Here is the caller graph for this function:

SaveToSerializedColumn (   $Column,
  $UserID,
  $Name,
  $Value = '' 
)

Saves a name/value to the user's specified $Column.

This method throws exceptions when errors are encountered. Use try ... catch blocks to capture these exceptions.

Parameters
stringThe 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.
intThe UserID to save.
mixedThe 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.
mixedThe value being saved.

Here is the call graph for this function:

Here is the caller graph for this function:

Search (   $Keywords,
  $OrderFields = '',
  $OrderDirection = 'asc',
  $Limit = FALSE,
  $Offset = FALSE 
)

Here is the call graph for this function:

SearchCount (   $Keywords = FALSE)

Here is the call graph for this function:

SendEmailConfirmationEmail (   $User = NULL)

Here is the call graph for this function:

Here is the caller graph for this function:

SendPasswordEmail (   $UserID,
  $Password 
)

Here is the call graph for this function:

SendWelcomeEmail (   $UserID,
  $Password,
  $RegisterType = 'Add',
  $AdditionalData = NULL 
)

Here is the call graph for this function:

SetCalculatedFields ( $User)

Here is the call graph for this function:

Here is the caller graph for this function:

SetField (   $RowID,
  $Property,
  $Value = FALSE 
)

Here is the call graph for this function:

Here is the caller graph for this function:

static SetMeta (   $UserID,
  $Meta,
  $Prefix = '' 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

SetTransientKey (   $UserID,
  $ExplicitKey = '' 
)

Here is the call graph for this function:

Here is the caller graph for this function:

Synchronize (   $UserKey,
  $Data 
)

Synchronizes the user based on a given UserKey.

Parameters
string$UserKeyA string that uniquely identifies this user.
array$DataInformation to put in the user table.
Returns
int The ID of the user.

Here is the call graph for this function:

Here is the caller graph for this function:

UpdateLastVisit (   $UserID,
  $Attributes,
  $ClientHour = '' 
)

Update last visit.

Regenerates other related user properties.

Parameters
int$UserID
array$Attributes
string | int | float$ClientHour

Here is the call graph for this function:

UpdateUserCache (   $UserID,
  $Field,
  $Value = NULL 
)

Here is the call graph for this function:

Here is the caller graph for this function:

UserCache (   $User)

Cache user object

Parameters
type$User
Returns
type

Here is the call graph for this function:

Here is the caller graph for this function:

UserCacheRoles (   $UserID,
  $RoleIDs 
)

Cache user's roles

Parameters
type$UserID
type$RoleIDs
Returns
type

Here is the call graph for this function:

UserQuery (   $SafeData = FALSE)

$SafeData makes sure that the query does not return any sensitive information about the user (password, attributes, preferences, etc).

Here is the caller graph for this function:

ValidateCredentials (   $Email = '',
  $ID = 0,
  $Password 
)

Validate User Credential

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.

Parameters
string$Email
string$Password
Returns
object

Here is the call graph for this function:

ValidateUniqueFields (   $Username,
  $Email,
  $UserID = '' 
)

Checks to see if $Username and $Email are already in use by another member.

Here is the call graph for this function:

Here is the caller graph for this function:

Field Documentation

$SessionColumns
$UserCache = array()
static
const DEFAULT_CONFIRM_EMAIL = 'You need to confirm your email address before you can continue. Please confirm your email address by clicking on the following link: {/entry/emailconfirm,url,domain}/{User.UserID,rawurlencode}/{EmailKey,rawurlencode}'
const INC_PERMISSIONS_KEY = 'permissions.increment'
const USERID_KEY = 'user.{UserID}'
const USERNAME_KEY = 'user.{Name}.name'
const USERPERMISSIONS_KEY = 'user.{UserID}.permissions.{PermissionsIncrement}'
const USERROLES_KEY = 'user.{UserID}.roles'

The documentation for this class was generated from the following file: