Model for users.
Models don't share that much, so most implementations will be adding methods onto this class. This class simply provides helper methods for common actions.
| package | XenForo_Users |
|---|
__construct()
Use create() statically unless you know what you're doing.
| inherited_from | \XenForo_Model::__construct() |
|---|
addFetchOptionJoin(array $fetchOptions, integer $join)
Join should be one of the constants.
| inherited_from | \XenForo_Model::addFetchOptionJoin() |
|---|
array
integer
addPositionLimit(string $table, integer $limit, integer $offset, string $column) : string
It no limit value is specified, nothing will be returned.
This must be added within a WHERE clause. If a clause is required, it will begin with "AND", so ensure there is a condition before it.
| inherited_from | \XenForo_Model::addPositionLimit() |
|---|
stringName of the table alias to prefix. May be blank for no table reference.
integerNumber of records to limit to; ignored if <= 0
integerOffset from the start of the records. 0+
stringName of the column that is storing the position
stringPosition limit clause if neededaddUserGroupChange(integer $userId, string $key, string | array $addGroups) : boolean
integer
stringUnique identifier for change set
stringarrayComma delimited string or array of user groups to add
booleanTrue on change successassertValidCutOffOperator(string $operator)
| inherited_from | \XenForo_Model::assertValidCutOffOperator() |
|---|
string
ban(integer $userId, integer $endDate, $reason, $update, $errorKey, array $viewingUser) : boolean
integerID of user to ban
integerDate at which ban will be lifted. Use XenForo_Model_User::PERMANENT_BAN for a permanent ban.
booleancanBypassUserPrivacy(string $errorPhraseKey, array $viewingUser) : boolean
string
array
booleancanReportContent(string $errorPhraseKey, array $viewingUser) : boolean
string
arraynull
booleancanStartConversationWithUser(array $user, string $errorPhraseKey, array $viewingUser) : boolean
Does not check standard conversation permissions.
array
string
arraynull
booleancanStartConversations(string $errorPhraseKey, array $viewingUser) : boolean
string
arraynull
booleancanViewIps(string $errorPhraseKey, array $viewingUser) : boolean
string
arraynull
booleancanViewUserOnlineStatus(array $user, string $errorPhraseKey, array $viewingUser) : boolean
arrayUser being viewed
stringReturned by ref. Phrase key of more specific error
arraynullViewing user ref
booleancanViewWarnings(string $errorPhraseKey, array $viewingUser) : boolean
string
arraynull
booleancanWarnUser(array $user, string $errorPhraseKey, array $viewingUser) : boolean
arrayUser being viewed
stringReturned by ref. Phrase key of more specific error
arraynullViewing user ref
booleancouldBeEmail(String $email) : boolean
String
booleancouldBeSpammer(array $user, string | array $errorKey) : boolean
array
stringarrayError phrase key - may become an array if the phrase requires parameters
booleancountTotalUsers() : integer
integercountUsers(array $conditions) : array
array
arrayFormat: [user id] => user infocountUsersFollowingUserId(integer $userId) : array
integer
arrayFormat: [user id] => following user infocreate(string $class) : \XenForo_Model
The class must exist or be autoloadable or an exception will be thrown.
| inherited_from | \XenForo_Model::create() |
|---|
stringClass to load
deleteSessionActivity(integer $userId, string $ip)
integer
string
fetchAllKeyed(string $sql, string $key, mixed $bind, string $nullPrefix) : array
The 'key' parameter provides the column name with which to key the result. For example, calling fetchAllKeyed('SELECT item_id, title, date FROM table', 'item_id') would result in an array keyed by item_id: [$itemId] => array('item_id' => $itemId, 'title' => $title, 'date' => $date)
Note that the specified key must exist in the query result, or it will be ignored.
| inherited_from | \XenForo_Model::fetchAllKeyed() |
|---|
stringSQL to execute
stringColumn with which to key the results array
mixedParameters for the SQL
stringIf the key is null, prefix the counter with this
arrayfollow(array $followUsers, boolean $dupeCheck, array $user) : string
arrayUsers being followed
booleanCheck for and prevent duplicate followers
arrayUser doing the following
stringComma-separated list of all users now being followed by $userIdgetAllUsers(array $fetchOptions) : array
Can be restricted to valid users only with the validOnly fetch option.
arrayUser fetch options
arrayFormat: [user id] => user infogetConditionsForClause(array $sqlConditions) : string
This always returns a value that can be used in a clause such as WHERE.
| inherited_from | \XenForo_Model::getConditionsForClause() |
|---|
array
stringgetContentTypeField(string $contentType, string $fieldName) : string | false
| inherited_from | \XenForo_Model::getContentTypeField() |
|---|
string
string
stringfalse
getContentTypesWithField(string $fieldName) : array
| inherited_from | \XenForo_Model::getContentTypesWithField() |
|---|
string
arrayFormat: [content type] => field valuegetEarliestRegistrationDate() : integer
integergetFollowRecord(integer | array $userId, integer | array $followUserId) : array
integerarrayintegerarrayarraygetFollowedUserProfiles($userId, integer $maxResults, string $orderBy) : array
integer(0 = all)
string
arraygetFollowingDenormalizedValue($userId) : string
stringgetFullUserById(integer $userId, array $fetchOptions) : array | false
Equivalent to calling getUserById including the FETCH_USER_FULL constanct
integer
arrayUser fetch options
arrayfalse
getLatestUser() : array | false
arrayfalse
getLatestUsers(array $criteria, array $fetchOptions) : array
array
array
arrayUser recordsgetModelFromCache(string $class) : \XenForo_Model
If it does not exist, it will be instantiated.
| inherited_from | \XenForo_Model::getModelFromCache() |
|---|
stringName of the class to load
getMostActiveUsers(array $criteria, array $fetchOptions) : array
array
array
arrayUser recordsgetOrderByClause(array $choices, array $fetchOptions, string $defaultOrderSql) : string
| inherited_from | \XenForo_Model::getOrderByClause() |
|---|
array
array
string
stringOrder by clause or empty stringgetRegistrationIps(integer $userId) : array
integer
array[ register: string, account-confirmation: string ]getUnreadAlertsCount(integer $userId) : integer
integer
integergetUserAuthenticationObjectByUserId(integer $userId) : \XenForo_Authentication_Abstract | false
getUserAuthenticationRecordByUserId(integer $userId) : array | false
integer
arrayfalse
getUserByEmail(string $email, array $fetchOptions) : array | false
string
arrayUser fetch options
arrayfalse
getUserById(integer $userId, array $fetchOptions) : array | false
integer
arrayUser fetch options
arrayfalse
getUserByName(string $username, array $fetchOptions) : array | false
string
arrayUser fetch options
arrayfalse
getUserByNameOrEmail(string $input, array $fetchOptions) : array | false
string
arrayUser fetch options
arrayfalse
getUserGroupChangesForUser(integer $userId) : array
integer
array[change key] => comma list of group IDsgetUserIdFromUser($user) : integer
integerUser IDgetUserIdsInRange(integer $start, integer $limit) : array
integerFind users with user_id greater than...
integerMaximum users to return at once
arraygetUsers(array $conditions, array $fetchOptions) : array
array
array
arrayFormat: [user id] => user infogetUsersByIds(array $userIds, array $fetchOptions) : array
array
array
arrayFormat: [user id] => user infogetUsersByIp(string $ip, array $fetchOptions) : array
string
array
arrayFormat: [user id] => user infogetUsersByNames(array $usernames, array $fetchOptions, array $invalidNames) : array
array
arrayUser fetch options
arrayReturns a list of usernames that could not be found
arrayFormat: [user id] => infogetUsersFollowingUserId(integer $userId, integer $maxResults, string $orderBy) : array
integer
integer(0 = all)
string
arrayFormat: [user id] => following user infogetVisitingGuestUser() : array
arraygetVisitingUserById(integer $userId) : array
integer
arrayisFollowing(integer $userId, array $follower) : boolean
integerUser being followed
arrayUser doing the following
booleanisMemberOfUserGroup(array $user, integer | array $userGroupId, boolean $includeSecondaryGroups) : boolean
array
integerarrayeither a single user group ID or an array thereof
booleanAlso check secondary groups
booleanisUserIgnored(array $user, integer | string $ignoredUser) : array | boolean
array
integerstringUser ID or user name
arrayboolean
isUserSuperAdmin(array $user)
liftBan(integer $userId) : boolean
integer
booleanlimitQueryResults(string $query, integer $limit, integer $offset) : string
If the limit value is 0 or less, no clause is applied.
| inherited_from | \XenForo_Model::limitQueryResults() |
|---|
stringSQL query to run
integerNumber of records to limit to; ignored if <= 0
integerOffset from the start of the records. 0+
stringQuery with limit applied if necessaryloginUserByRememberCookie(string $userCookie) : false | integer
string
falseinteger
loginUserByRememberKeyFromCookie(integer $userId, string $rememberKey, array | false | null $auth) : boolean
integer
string
arrayfalsenullUser's auth record (retrieved if null)
booleanpassesPrivacyCheck(string $privacyRequirement, array $user, array $viewingUser) : \unknown_type
This must include the following status for the viewing user.
stringThe required privacy: everyone, none, members, followed
arrayUser info, including following status for viewing user
arraynullViewing user ref
\unknown_typeprepareLimitFetchOptions(array $fetchOptions) : array
Includes: limit, offset, page, and perPage.
| inherited_from | \XenForo_Model::prepareLimitFetchOptions() |
|---|
arrayUnprepared options
arrayLimit options; keys: limit, offsetprepareRememberKeyForCookie(string $rememberKey) : string
stringKey from DB
stringprepareStateLimitFromConditions(array $fetchOptions, string $table, string $stateField, string $userField) : string
Looks for keys "deleted" and "moderated".
| inherited_from | \XenForo_Model::prepareStateLimitFromConditions() |
|---|
array
stringName of the table to prefix the state and user fields with
stringName of the field that holds the state
stringName of the field that holds the user ID
stringSQL condition to limit stateprepareUser(array $user) : array
Note that this may be called on incomplete guest records.
arrayUser info
arrayPrepared user infoprepareUserCard(array $user) : array
array
arrayprepareUserCards(array $users) : array
array
arrayprepareUserConditions(array $conditions, array $fetchOptions) : string
arrayList of conditions. (TODO: make list)
arrayThe fetch options that have been provided. May be edited if criteria requires.
stringCriteria as SQL for where clauseprepareUserFetchOptions(array $fetchOptions) : array
array
arrayContaining 'selectFields' and 'joinTables' keys.prepareUserOrderOptions(array $fetchOptions, string $defaultOrderSql) : string
array(uses 'order' key)
stringDefault order SQL
stringrebuildCustomFieldCache(integer $userId)
integer
rebuildUserModerationQueueCache() : array
arrayCache, [total, lastModifiedDate]removeDuplicateFollowUserIds(integer $userId, array $newUsers, string $existingUserIds) : array
integer
array(full user arrays)
string'3,6,42,....'
arrayremoveUserGroupChange(integer $userId, string $key) : boolean
integer
stringChange set key
booleanTrue on successremoveUserGroupChangeLogByKey($key)
resetLocalCacheData($name)
This can be used if you know when some cached data has expired.
| inherited_from | \XenForo_Model::resetLocalCacheData() |
|---|
setAllowCachedRead(boolean $allowCachedRead)
This may be controllable on an individual level basis, if the implementation allows it.
| inherited_from | \XenForo_Model::setAllowCachedRead() |
|---|
boolean
setLocalCacheData(string $name, $value)
This should only be used if you know what you're doing or for testing purposes!
Note that you cannot get the existing data via the public interface. If you think you need the set data, use a new object. It defaults to empty. :)
| inherited_from | \XenForo_Model::setLocalCacheData() |
|---|
string
setPermissionsFromUserId(array $userInfo, integer $permUserId) : array
array
integer
arrayUser info with changed permissionssetPermissionsOnVisitorArray(array $userinfo, $permissionCombinationId) : array
Defaults to setting guest permissions.
arrayVisitor record
arrayVisitor record with permissionssetUserRememberCookie(integer $userId, array | false | null $auth) : boolean
integer
arrayfalsenullUser's auth record (retrieved if null)
booleanstandardizeNodePermissionsAndUserId(integer $nodeId, array | null $permissions, integer | null $userId)
If an invalid permission set or user ID is provided, the current visitor's will be used.
| inherited_from | \XenForo_Model::standardizeNodePermissionsAndUserId() |
|---|
integerNode permissions are for
arraynullPermissions for node or null to use current visitor's permissions
integernullUser permissions belong to or null to use current visitor
standardizePermissionCombinationIdAndUserId(integer | null $permissionCombinationId, integer | null $userId)
If null, users current visitor's values.
| inherited_from | \XenForo_Model::standardizePermissionCombinationIdAndUserId() |
|---|
integernullPermission combination ID or null to use current visitor
integernullUser permissions belong to or null to use current visitor
standardizePermissionsAndUserId(array | null $permissions, integer | null $userId)
If an invalid permission set or user ID is provided, the current visitor's will be used.
| inherited_from | \XenForo_Model::standardizePermissionsAndUserId() |
|---|
arraynullGlobal pPermissions or null to use current visitor's permissions
integernullUser permissions belong to or null to use current visitor
standardizeViewingUserReference(array $viewingUser)
This array must contain all basic user info (preferably all user info) and include global permissions in a "permissions" key. If not an array or missing a user_id, the visitor's values will be used.
| inherited_from | \XenForo_Model::standardizeViewingUserReference() |
|---|
arraynull
standardizeViewingUserReferenceForNode(integer $nodeId, array $viewingUser, array $nodePermissions)
| inherited_from | \XenForo_Model::standardizeViewingUserReferenceForNode() |
|---|
integer
arraynullViewing user; if null, use visitor
arraynullPermissions for this node; if null, use visitor's
unfollow(integer $followUserId, integer $userId) : string
integerUser being followed
integerUser doing the following
stringComma-separated list of all users now being followed by $userIdunserializePermissionsInList(array $items, string $serializedKey, string $targetKey) : array
| inherited_from | \XenForo_Model::unserializePermissionsInList() |
|---|
arrayList of items
stringKey where serialized permissions are
stringKey where unserialized permissions will go
arrayList of items with permissions unserializedupdate($user, array | string $field, mixed $value) : \XenForo_DataWriter_User
arraystringEither the name of a single field, or an array of field-name => field-value pairs
mixedIf the previous parameter is a string, use this as the field value
updateFollowingDenormalizedValue($userId, string $following) : string
Will query for the value if it is not provided
stringDenormalized following value
stringupdateSessionActivity(integer $userId, string $ip, string $controllerName, string $action, string $viewState, array $inputParams, integer | null $viewDate)
integer
stringIP of visiting user
stringLast controller class that was invoked
stringLast action that was invoked
stringEither "valid" or "error"
arrayList of special input params, to include to help get more info on current activity
integernullThe timestamp of the last page view; defaults to now
validateAuthentication(string $nameOrEmail, string $password, string $error) : integer | false
Exceptions are thrown on errors.
stringUser name or email address
string
stringError string (by ref)
integerfalseUser ID auth'd as; false on failure_applyUserGroupChanges(integer $userId, array $oldGroupStrings, array $newGroupStrings) : boolean
integer
arrayArray of comma-delimited strings of existing (accounted for) user group change sets
arrayArray of comma-delimited strings for new list of user group change sets
boolean_getCache(boolean $forceCachedRead) : \Zend_Cache_Core | \Zend_Cache_Frontend | false
If cache reads are disabled, this will return false.
| inherited_from | \XenForo_Model::_getCache() |
|---|
booleanIf true, the global "allow cached read" value is ignored
\Zend_Cache_Core\Zend_Cache_Frontendfalse
_getDb() : \Zend_Db_Adapter_Abstract
| inherited_from | \XenForo_Model::_getDb() |
|---|
\Zend_Db_Adapter_Abstract_getLocalCacheData(string $name) : mixed
| inherited_from | \XenForo_Model::_getLocalCacheData() |
|---|
string
mixed$defaultAdminGroupId
$defaultGuestGroupId
$defaultModeratorGroupId
$defaultRegisteredGroupId
$guestPermissionCombinationId
$_allowCachedRead : boolean
If not, it should be retrieved from the source.
| inherited_from | \XenForo_Model::$$_allowCachedRead |
|---|
$_cache : \Zend_Cache_Core | \Zend_Cache_Frontend
| inherited_from | \XenForo_Model::$$_cache |
|---|
$_db : \Zend_Db_Adapter_Abstract
| inherited_from | \XenForo_Model::$$_db |
|---|
$_ignoreCache : array
$_localCacheData : array
This data is generally treated as canonical, even if {$_allowCachedRead} is false.
| inherited_from | \XenForo_Model::$$_localCacheData |
|---|
$_modelCache : array
| inherited_from | \XenForo_Model::$$_modelCache |
|---|
FETCH_LAST_ACTIVITY
FETCH_USER_FULL : integer
FETCH_USER_OPTION
FETCH_USER_PERMISSIONS
FETCH_USER_PRIVACY
FETCH_USER_PROFILE
PERMANENT_BAN : integer