Show:

Users_User Class

Extends Base_Users_User
Module: Users

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.

Methods

__set_state

(
  • $array
)
Users_User

Implements the __set_state method, so it can work with with var_export and be re-imported successfully.

Parameters:

  • $array Array

Returns:

Users_User:

Class instance

_getId

(
  • $u
)
String private static

get user id

Parameters:

Returns:

String:

addContact

(
  • $contactUserId
  • $label
  • [$nickname='']
  • [$asUserId=null]
)
Array

Parameters:

  • $contactUserId String

    The id of the user who is the contact

  • $label String | Array

    The label of the contact. This can be a string or an array of strings, in which case multiple contact rows are saved.

  • [$nickname=''] String optional

    Optional nickname to assign to the contact

  • [$asUserId=null] String optional

    The user to do this operation as. Defaults to the logged-in user. Pass false to skip access checks.

Returns:

Array:

Array of contacts that are saved

addEmail

(
  • $emailAddress
  • [$activationEmailSubject=null]
  • [$activationEmailView=null]
  • [$html=true]
  • [$fields=array()]
  • [$options=array()]
  • [&$email]
)
Boolean

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 String

    The email address to add.

  • [$activationEmailSubject=null] String | Array optional

    The subject of the activation email to send. You can also pass an array($source, array($key1, $key2)) to use Q_Text.

  • [$activationEmailView=null] String optional

    The view to use for the body of the activation email to send.

  • [$html=true] Boolean optional

    Defaults to true. Whether to send as HTML email.

  • [$fields=array()] Array optional

    An array of additional fields to pass to the email view.

  • [$options=array()] Array optional

    Array of options. Can include:

    • [html=false] String optional

      Whether to send as HTML email.

    • [name] String optional

      A human-readable name in addition to the address.

    • [from] String optional

      An array of (emailAddress, human_readable_name)

    • [delay] String optional

      A delay, in milliseconds, to wait until sending email. Only works if Node server is listening.

    • [activation] String optional

      The 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 optional

    Optional reference to be filled

Returns:

Boolean:

Returns true on success. Returns false if this email address is already verified for this user.

addLabel

(
  • $label
  • [$title='']
  • [$icon='default']
  • [$asUserId=null]
)
Users_Label

Add a contact label

Parameters:

  • $label String | Array

    the label or array of ($label => array($title, $icon))

  • [$title=''] String optional

    specify the title, otherwise a default one is generated

  • [$icon='default'] String optional
  • [$asUserId=null] String optional

    The 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]
)
Boolean

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 String

    The mobile number to add.

  • [$activationMessageView=null] String optional

    The view to use for the body of the activation message to send.

  • [$fields=array()] Array optional

    An array of additional fields to pass to the mobile view.

  • [$options=array()] Array optional

    Array of options. Can include:

    • [delay] String optional

      A delay, in milliseconds, to wait until sending email. Only works if Node server is listening.

    • [activation] String optional

      The 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 optional

    Optional reference to be filled

Returns:

Boolean:

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
)
Array

Assigns 'id' and verifies 'username' fields

Parameters:

  • $modifiedFields Array

Returns:

Array:

beforeSet_emailAddress

(
  • $emailAddress
)
Array

Parameters:

  • $emailAddress String

Returns:

Array:

beforeSet_username

(
  • $username
)
Array

Parameters:

  • $username String

Returns:

Array:

clearUid

(
  • $platform
)

Parameters:

  • $platform String

    The 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]
)
Array

Returns the fields and values we can export to clients. Can also contain "messageTotals", "relatedToTotals" and "relatedFromTotals".

Parameters:

  • [$options=null] $array optional

    can include the following:

    • [asAvatar] String optional

      set to true if only the avatar fields should be exported

Returns:

Array:

fetch

(
  • $userId
  • [$throwIfMissing=false]
)
Users_User | Null | Array static

Intelligently retrieves user by id

Parameters:

  • $userId String
  • [$throwIfMissing=false] Boolean optional

    If true, throws an exception if the user can't be fetched

Returns:

Users_User | Null | Array:

If $userId is an array, returns an array of ($userId => $user) pairs. Otherwise returns a Users_User object, or null.

getAllUids

() Array

Returns:

Array:

An array of ($platform => $uid) pairs

getUid

(
  • $platform
  • $default
)
String | Null

Parameters:

  • $platform String

    The name of the platform

  • $default String | Null

    The value to return if the uid is missing

Returns:

String | Null:

The value of the uid, or the default value, or null

idFilter

(
  • $params
)
Boolean

Parameters:

  • $params String

Returns:

Boolean:

idsFromIdentifiers

(
  • $asUserId
  • $identifiers
  • $statuses
  • $identifierTypes
)
Array static

Check identifier or array of identifiers and return users - existing or future

Parameters:

  • $asUserId String

    The user id of inviting user

  • $identifiers String | Array

    Can be email addresses or mobile numbers, passed either as an array or separated by "\t"

  • $statuses Array

    Optional reference to an array to populate with $status values ('verified' or 'future') in the same order as the $identifiers.

  • $identifierTypes Array

    Optional reference to an array to populate with $identifierTypes values in the same order as $identifiers

Returns:

Array:

The array of user ids, in the same order as the $identifiers.

idsFromPlatformUids

(
  • $platform
  • $uids
  • $statuses
)
Array static

Check platform uids or array of uids and return users - existing or future

Parameters:

  • $platform String

    The name of the platform

  • $uids Array | String

    An array of facebook user ids, or a comma-delimited string

  • $statuses Array

    Optional reference to an array to populate with $status values ('verified' or 'future') in the same order as the $identifiers.

Returns:

Array:

The array of user ids

labelsToIds

(
  • $asUserId
  • $labels
)
Array static

Check label or array of labels and return existing users

Parameters:

  • $asUserId String

    The user id of inviting user

  • $labels String | Array

Returns:

Array:

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]
)
Db_Mysql

Parameters:

  • $label String | Array

    The label of the contact.

  • $contactUserId String

    The id of the user who is the contact

  • [$asUserId=null] String optional

    The id of the user who is the contact

Returns:

removeLabel

(
  • $label
  • [$userId=null]
  • [$asUserId=null]
)
Db_Query_MySql

Remove label

Parameters:

  • $label String
  • [$userId=null] String | Null optional

    The user whose label is to be removed

  • [$asUserId=null] String optional

    The user to do this operation as. Defaults to the logged-in user. Pass false to skip access checks.

Returns:

Db_Query_MySql:

removeUser

(
  • $userId
)
static

Remove users from system

Parameters:

  • $userId String | Array

    Array of id's or single id

setEmailAddress

(
  • $emailAddress
  • [$verified=false]
  • [&$email]
)

Parameters:

  • $emailAddress String
  • [$verified=false] Boolean optional

    Whether to force the email address to be marked verified for this user

  • [&$email] Users_Email optional

    Optional reference to be filled

setMobileNumber

(
  • $mobileNumber
  • [$verified=false]
  • [&$mobile]
)

Parameters:

  • $mobileNumber String
  • [$verified=false] Boolean optional

    Whether to force the mobile number to be marked verified for this user

  • [&$mobile] Users_Mobile optional

    Optional reference to be filled

setUid

(
  • $platform
  • $uid
)

Parameters:

  • $platform String | Array

    The name of the platform, or an array of $platform => $uid pairs

  • $uid String

    The 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]
)
Db_Query_Mysql static

Update a particular contact with a given userId, label, contactId.

Parameters:

  • $label String
  • $contactUserId String
  • $updates Array

    should be an array with only one key: "nickname"

  • [$asUserId=null] String optional

    The user to do this operation as. Defaults to the logged-in user. Pass false to skip access checks.

Returns:

updateLabel

(
  • $label
  • $updates
  • [$asUserId=null]
)
Db_Query_Mysql

Update labels

Parameters:

  • $label String
  • $updates Array

    Can contain one or more of "title", "icon"

  • [$asUserId=null] String optional

    The user to do this operation as. Defaults to the logged-in user. Pass false to skip access checks.

Returns:

verifyUserIds

(
  • $userIds
  • $throw=false
)
Array static

Verifies that users exist for these ids

Parameters:

  • $userIds String | Array
  • $throw=false Boolean

Returns:

Array:

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