Show:

Users_Label Class

Extends Base_Users_Label
Module: Users

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

Item Index

Methods

Methods

__set_state

(
  • $array
)
Users_Label

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

Parameters:

  • $array Array

Returns:

Users_Label:

Class instance

addLabel

(
  • $label
  • [$userId=null]
  • [$title='']
  • [$icon='labels/default']
  • [$asUserId=null]
  • boolean
)
Users_Label static

Add a contact label

Parameters:

  • $label String | Array

    A label or array of ($label => $title) or ($label => array($title, $icon)) pairs.

  • [$userId=null] String optional

    The logged-in user if not provided

  • [$title=''] String optional

    specify the title, otherwise a default one is generated

  • [$icon='labels/default'] String optional
  • [$asUserId=null] String | False 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 label if it already exists in the database.

Returns:

fetch

(
  • [$userId=null]
  • [$filter='']
  • [$options=array()]
)
Array

Fetch an array of labels. By default, returns all the labels.

Parameters:

  • [$userId=null] String optional

    The id of the user whose contact labels should be fetched

  • [$filter=''] String | Array | Db_Expression optional

    Pass a string prefix such as "Users/", or some array or db expression, to get only a particular subset of labels.

  • [$options=array()] Array optional
    • [skipAccess] Boolean optional

      whether to skip access checks

    • [asUserId] String optional

      the user to do access checks as

    • [checkContacts=false] Boolean optional

      Whether to also look in the Users_Contact table and only return labels that have at least one contact.

Returns:

Array:

An array of array(label => Users_Label) pairs

removeLabel

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

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:

setUp

()

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

updateLabel

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

Update labels

Parameters:

  • $label String
  • $updates Array

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

  • [$userId=null] String optional

    User that owns the label, current user if not provided

  • [$asUserId=null] String optional

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

Returns: