Users_Label Class
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
- __set_state
- addLabel static
- fetch
- removeLabel static
- setUp
- updateLabel 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
addLabel
-
$label
-
[$userId=null]
-
[$title='']
-
[$icon='labels/default']
-
[$asUserId=null]
-
boolean
Add a contact label
Parameters:
-
$label
String | ArrayA label or array of ($label => $title) or ($label => array($title, $icon)) pairs.
-
[$userId=null]
String optionalThe logged-in user if not provided
-
[$title='']
String optionalspecify the title, otherwise a default one is generated
-
[$icon='labels/default']
String optional -
[$asUserId=null]
String | False optionalThe 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()]
Fetch an array of labels. By default, returns all the labels.
Parameters:
-
[$userId=null]
String optionalThe id of the user whose contact labels should be fetched
-
[$filter='']
String | Array | Db_Expression optionalPass 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 optionalwhether to skip access checks
-
[asUserId]
String optionalthe user to do access checks as
-
[checkContacts=false]
Boolean optionalWhether to also look in the Users_Contact table and only return labels that have at least one contact.
-
Returns:
An array of array(label => Users_Label) pairs
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:
setUp
()
The setUp() method is called the first time an object of this class is constructed.
updateLabel
-
$label
-
$updates
-
[$userId=null]
-
[$asUserId=null]
Update labels
Parameters:
-
$label
String -
$updates
ArrayCan contain one or more of "title", "icon"
-
[$userId=null]
String optionalUser that owns the label, current user if not provided
-
[$asUserId=null]
String optionalThe user to do this operation as. Defaults to the logged-in user. Pass false to skip access checks.