Show:

Users_Contact Class

Extends Base_Users_Contact
Module: Users

Class representing 'Contact' 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 contact row in the Users database.

Item Index

Methods

Methods

__set_state

(
  • $array
)
Users_Contact

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

Parameters:

  • $array Array

Returns:

Users_Contact:

Class instance

addContact

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

Add contact with one or more labels

Parameters:

  • $userId String

    The id of the user whose contact will be added

  • $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.

  • $contactUserId String

    The id of the user who is the contact

  • [$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.

  • boolean Object

    [$unlessExists=false] If true, skips adding contact if it already exists in the database.

Returns:

Array:

Array of contacts that are saved

checkLabel

(
  • $userId
  • $label
  • $contactId
)
Db_Row | False static

Check if a contact with this label exists

Parameters:

  • $userId String
  • $label String
  • $contactId String

Returns:

Db_Row | False:

fetch

(
  • $userId
  • $label
  • [$options=array()]
)
Array static

Retrieve contacts belonging to label

Parameters:

  • $userId String
  • $label String | Array | Db_Range | Db_Expression
  • [$options=array()] Array optional
    • [limit=false] Integer optional
    • [offset=0] Integer optional
    • [skipAccess] Boolean optional

      whether to skip access checks

    • [asUserId] String optional

      the user to do access checks as

    • [contactUserId=null] String | Array optional

Returns:

Array:

removeContact

(
  • $userId
  • $label
  • $contactUserId
  • [$asUserId=null]
)
Db_Query_Mysql static

Remove contact from label

Parameters:

  • $userId String
  • $label String
  • $contactUserId String
  • [$asUserId=null] String optional

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

Returns:

setUp

()

The setUp() method is called the first time an object of this class is constructed.

updateContact

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

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

Parameters:

  • $userId String
  • $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:

Events

Users/Contact/addContact

After

Event Payload:

  • contactUserId String
  • label String
  • contacts Array