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:
-
$array
Array
Returns:
Class instance
addContact
-
$contactUserId
-
$label
-
[$nickname='']
-
[$asUserId=null]
Parameters:
-
$contactUserId
StringThe id of the user who is the contact
-
$label
String | 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:
-
$emailAddress
StringThe 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:
-
$label
String | 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:
-
$mobileNumber
StringThe 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:
-
$modifiedFields
Array
Returns:
beforeSet_emailAddress
-
$emailAddress
Parameters:
-
$emailAddress
String
Returns:
beforeSet_username
-
$username
Parameters:
-
$username
String
Returns:
clearAllUids
()
clearUid
-
$platform
Parameters:
-
$platform
StringThe 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:
-
$userId
String -
[$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:
-
$platform
StringThe name of the platform
-
$default
String | NullThe value to return if the uid is missing
Returns:
The value of the uid, or the default value, or null
idFilter
-
$params
Parameters:
-
$params
String
Returns:
idsFromIdentifiers
-
$asUserId
-
$identifiers
-
$statuses
-
$identifierTypes
Check identifier or array of identifiers and return users - existing or future
Parameters:
-
$asUserId
StringThe user id of inviting user
-
$identifiers
String | ArrayCan be email addresses or mobile numbers, passed either as an array or separated by "\t"
-
$statuses
ArrayOptional reference to an array to populate with $status values ('verified' or 'future') in the same order as the $identifiers.
-
$identifierTypes
ArrayOptional 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:
-
$platform
StringThe name of the platform
-
$uids
Array | StringAn array of facebook user ids, or a comma-delimited string
-
$statuses
ArrayOptional 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:
-
$asUserId
StringThe user id of inviting user
-
$labels
String | 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:
-
$label
String | ArrayThe label of the contact.
-
$contactUserId
StringThe 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:
-
$label
String -
[$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:
-
$userId
String | ArrayArray of id's or single id
setEmailAddress
-
$emailAddress
-
[$verified=false]
-
[&$email]
Parameters:
-
$emailAddress
String -
[$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:
-
$mobileNumber
String -
[$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:
-
$platform
String | ArrayThe name of the platform, or an array of $platform => $uid pairs
-
$uid
StringThe 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:
-
$label
String -
$contactUserId
String -
$updates
Arrayshould 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:
-
$label
String -
$updates
ArrayCan 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:
-
$userIds
String | Array -
$throw=false
Boolean
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:
-
user
String -
email
String
Users/addIdentifier
After
Event Payload:
-
user
String -
email
String
Users/addIdentifier
Before
Event Payload:
-
user
String -
mobile
String
Users/addIdentifier
After
Event Payload:
-
user
String -
mobile
String
Users/filter/id
Event Payload:
-
id
String
Users/setEmailAddress
After
Event Payload:
-
user
String -
email
String
Users/setMobileNumber
After
Event Payload:
-
user
String -
mobile
String
Users/validate/emailAddress
Event Payload:
-
emailAddress
&string
Users/validate/username
Event Payload:
-
username
&string