Users_User Class
Class representing 'User' rows in the 'Users' database You can create an object of this class either to access its non-static methods, or to actually represent a user row in the Users database.
Item Index
Methods
- __set_state
- _getId static
- addContact
- addEmail
- addLabel
- addMobile
- addPreloaded
- addPreloaded
- beforeSave
- beforeSet_emailAddress
- beforeSet_username
- clearAllUids
- clearUid
- exportArray
- fetch static
- getAllUids
- getUid
- idFilter
- idsFromIdentifiers static
- idsFromPlatformUids static
- labelsToIds static
- mobile
- removeContact
- removeLabel
- removeUser static
- setEmailAddress
- setMobileNumber
- setUid
- setUp
- updateContact static
- updateLabel
- verifyUserIds static
Properties
- $cache static
- $fetch_cache
- $preloaded static
Methods
__set_state
-
$array
Implements the __set_state method, so it can work with with var_export and be re-imported successfully.
Parameters:
-
$arrayArray
Returns:
Class instance
addContact
-
$contactUserId -
$label -
[$nickname=''] -
[$asUserId=null]
Parameters:
-
$contactUserIdStringThe id of the user who is the contact
-
$labelString | ArrayThe label of the contact. This can be a string or an array of strings, in which case multiple contact rows are saved.
-
[$nickname='']String optionalOptional nickname to assign to the contact
-
[$asUserId=null]String optionalThe user to do this operation as. Defaults to the logged-in user. Pass false to skip access checks.
Returns:
Array of contacts that are saved
addEmail
-
$emailAddress -
[$activationEmailSubject=null] -
[$activationEmailView=null] -
[$html=true] -
[$fields=array()] -
[$options=array()] -
[&$email]
Starts the process of adding an email to a saved user object. Also modifies and saves this user object back to the database.
Parameters:
-
$emailAddressStringThe email address to add.
-
[$activationEmailSubject=null]String | Array optionalThe subject of the activation email to send. You can also pass an array($source, array($key1, $key2)) to use Q_Text.
-
[$activationEmailView=null]String optionalThe view to use for the body of the activation email to send.
-
[$html=true]Boolean optionalDefaults to true. Whether to send as HTML email.
-
[$fields=array()]Array optionalAn array of additional fields to pass to the email view.
-
[$options=array()]Array optionalArray of options. Can include:
-
[html=false]String optionalWhether to send as HTML email.
-
[name]String optionalA human-readable name in addition to the address.
-
[from]String optionalAn array of (emailAddress, human_readable_name)
-
[delay]String optionalA delay, in milliseconds, to wait until sending email. Only works if Node server is listening.
-
[activation]String optionalThe key under "Users"/"transactional" config to use for getting activation messages by default. Set to false to skip sending the activation message for some reason.
-
-
[&$email]Users_Email optionalOptional reference to be filled
Returns:
Returns true on success. Returns false if this email address is already verified for this user.
addLabel
-
$label -
[$title=''] -
[$icon='default'] -
[$asUserId=null]
Add a contact label
Parameters:
-
$labelString | Arraythe label or array of ($label => array($title, $icon))
-
[$title='']String optionalspecify the title, otherwise a default one is generated
-
[$icon='default']String optional -
[$asUserId=null]String optionalThe user to do this operation as. Defaults to the logged-in user. Pass false to skip access checks.
Returns:
addMobile
-
$mobileNumber -
[$activationMessageView=null] -
[$fields=array()] -
[$options=array()] -
[&$mobile]
Starts the process of adding a mobile to a saved user object. Also modifies and saves this user object back to the database.
Parameters:
-
$mobileNumberStringThe mobile number to add.
-
[$activationMessageView=null]String optionalThe view to use for the body of the activation message to send.
-
[$fields=array()]Array optionalAn array of additional fields to pass to the mobile view.
-
[$options=array()]Array optionalArray of options. Can include:
-
[delay]String optionalA delay, in milliseconds, to wait until sending email. Only works if Node server is listening.
-
[activation]String optionalThe key under "Users"/"transactional" config to use for getting activation messages by default. Set to false to skip sending the activation message for some reason.
-
-
[&$mobile]Users_Mobile optionalOptional reference to be filled
Returns:
Returns true on success. Returns false if this mobile number is already verified for this user.
addPreloaded
()
Add this user to the list of user objects to be preloaded onto the client with the rest of the page
addPreloaded
()
Remove this user from the list of user objects to be preloaded onto the client with the rest of the page
beforeSave
-
$modifiedFields
Assigns 'id' and verifies 'username' fields
Parameters:
-
$modifiedFieldsArray
Returns:
beforeSet_emailAddress
-
$emailAddress
Parameters:
-
$emailAddressString
Returns:
beforeSet_username
-
$username
Parameters:
-
$usernameString
Returns:
clearAllUids
()
clearUid
-
$platform
Parameters:
-
$platformStringThe name of the platform
email
()
Get the Users_Email object corresponding to this user's email address, if any
Returns:
Users_Email
exportArray
-
[$options=null]
Returns the fields and values we can export to clients. Can also contain "messageTotals", "relatedToTotals" and "relatedFromTotals".
Parameters:
-
[$options=null]$array optionalcan include the following:
-
[asAvatar]String optionalset to true if only the avatar fields should be exported
-
Returns:
fetch
-
$userId -
[$throwIfMissing=false]
Intelligently retrieves user by id
Parameters:
-
$userIdString -
[$throwIfMissing=false]Boolean optionalIf true, throws an exception if the user can't be fetched
Returns:
If $userId is an array, returns an array of ($userId => $user) pairs. Otherwise returns a Users_User object, or null.
getAllUids
()
Array
Returns:
An array of ($platform => $uid) pairs
getUid
-
$platform -
$default
Parameters:
-
$platformStringThe name of the platform
-
$defaultString | NullThe value to return if the uid is missing
Returns:
The value of the uid, or the default value, or null
idFilter
-
$params
Parameters:
-
$paramsString
Returns:
idsFromIdentifiers
-
$asUserId -
$identifiers -
$statuses -
$identifierTypes
Check identifier or array of identifiers and return users - existing or future
Parameters:
-
$asUserIdStringThe user id of inviting user
-
$identifiersString | ArrayCan be email addresses or mobile numbers, passed either as an array or separated by "\t"
-
$statusesArrayOptional reference to an array to populate with $status values ('verified' or 'future') in the same order as the $identifiers.
-
$identifierTypesArrayOptional reference to an array to populate with $identifierTypes values in the same order as $identifiers
Returns:
The array of user ids, in the same order as the $identifiers.
idsFromPlatformUids
-
$platform -
$uids -
$statuses
Check platform uids or array of uids and return users - existing or future
Parameters:
-
$platformStringThe name of the platform
-
$uidsArray | StringAn array of facebook user ids, or a comma-delimited string
-
$statusesArrayOptional reference to an array to populate with $status values ('verified' or 'future') in the same order as the $identifiers.
Returns:
The array of user ids
labelsToIds
-
$asUserId -
$labels
Check label or array of labels and return existing users
Parameters:
-
$asUserIdStringThe user id of inviting user
-
$labelsString | Array
Returns:
The array of user ids
mobile
()
Get the Users_Mobile object corresponding to this user's email address, if any
Returns:
Users_Mobile
removeContact
-
$label -
$contactUserId -
[$asUserId=null]
Parameters:
-
$labelString | ArrayThe label of the contact.
-
$contactUserIdStringThe id of the user who is the contact
-
[$asUserId=null]String optionalThe id of the user who is the contact
Returns:
removeLabel
-
$label -
[$userId=null] -
[$asUserId=null]
Remove label
Parameters:
-
$labelString -
[$userId=null]String | Null optionalThe user whose label is to be removed
-
[$asUserId=null]String optionalThe user to do this operation as. Defaults to the logged-in user. Pass false to skip access checks.
Returns:
removeUser
-
$userId
Remove users from system
Parameters:
-
$userIdString | ArrayArray of id's or single id
setEmailAddress
-
$emailAddress -
[$verified=false] -
[&$email]
Parameters:
-
$emailAddressString -
[$verified=false]Boolean optionalWhether to force the email address to be marked verified for this user
-
[&$email]Users_Email optionalOptional reference to be filled
setMobileNumber
-
$mobileNumber -
[$verified=false] -
[&$mobile]
Parameters:
-
$mobileNumberString -
[$verified=false]Boolean optionalWhether to force the mobile number to be marked verified for this user
-
[&$mobile]Users_Mobile optionalOptional reference to be filled
setUid
-
$platform -
$uid
Parameters:
-
$platformString | ArrayThe name of the platform, or an array of $platform => $uid pairs
-
$uidStringThe value to set the uid to
setUp
()
The setUp() method is called the first time an object of this class is constructed.
updateContact
-
$label -
$contactUserId -
$updates -
[$asUserId=null]
Update a particular contact with a given userId, label, contactId.
Parameters:
-
$labelString -
$contactUserIdString -
$updatesArrayshould be an array with only one key: "nickname"
-
[$asUserId=null]String optionalThe user to do this operation as. Defaults to the logged-in user. Pass false to skip access checks.
Returns:
updateLabel
-
$label -
$updates -
[$asUserId=null]
Update labels
Parameters:
-
$labelString -
$updatesArrayCan contain one or more of "title", "icon"
-
[$asUserId=null]String optionalThe user to do this operation as. Defaults to the logged-in user. Pass false to skip access checks.
Returns:
verifyUserIds
-
$userIds -
$throw=false
Verifies that users exist for these ids
Parameters:
-
$userIdsString | Array -
$throw=falseBoolean
Returns:
The array of found user ids
Properties
$cache
Array
protected
static
$fetch_cache
Array
protected
$preloaded
Array
static
Events
Users/addIdentifier
Before
Event Payload:
-
userString -
emailString
Users/addIdentifier
After
Event Payload:
-
userString -
emailString
Users/addIdentifier
Before
Event Payload:
-
userString -
mobileString
Users/addIdentifier
After
Event Payload:
-
userString -
mobileString
Users/filter/id
Event Payload:
-
idString
Users/setEmailAddress
After
Event Payload:
-
userString -
emailString
Users/setMobileNumber
After
Event Payload:
-
userString -
mobileString
Users/validate/emailAddress
Event Payload:
-
emailAddress&string
Users/validate/username
Event Payload:
-
username&string