Streams_Avatar Class
Class representing 'Avatar' rows in the 'Streams' database You can create an object of this class either to access its non-static methods, or to actually represent a avatar row in the Streams database.
Item Index
Methods
- displayName
- fetch static
- fetchByPrefix static
- setUp
- __set_state
- updateAvatar static
- updateAvatars static
Methods
displayName
-
$options=array()
-
[$options.short]
-
[$options.show]
-
[$options.html]
-
[$options.escape]
-
[$fallback='Someone']
Calculate diplay name from avatar
Parameters:
-
$options=array()
ArrayAssociative array of options, which can include:
-
[$options.short]
Boolean optionalShow one part of the name only
-
[$options.show]
Boolean optionalThe parts of the name to show. Can have "f", "fu", "l", "lu", "flu" and "u" separated by spaces. The "fu" and "lu" represent firstname or lastname with fallback to username, while "flu" is "firstname lastname" with a fallback to username.
-
[$options.html]
Boolean optionalIf true, encloses the first name, last name, username in span tags. If an array, then it will be used as the attributes of the html.
-
[$options.escape]
Boolean optionalIf true, does HTML escaping of the retrieved fields
-
[$fallback='Someone']
String optionalHTML to return if there is no info to get displayName from.
Returns:
fetch
-
$toUserId
-
$publisherIds
-
$indexField
Retrieve avatars for one or more publishers as displayed to a particular user.
Parameters:
-
$toUserId
User_User | StringThe id of the user to which this would be displayed
-
$publisherIds
String | ArrayArray of various users whose avatars are being fetched
-
$indexField
StringOptional name of the field by which to index the resulting array. Can be "toUserId" or "publisherId"
Returns:
fetchByPrefix
-
$toUserId
-
$prefix
-
$options=array()
Retrieve avatars for one or more publishers as displayed to a particular user.
Parameters:
-
$toUserId
User_User | StringThe id of the user to which this would be displayed
-
$prefix
StringThe prefix for the firstName
-
$options=array()
Array'limit' => number of records to fetch 'fields' => defaults to array('username', 'firstName', 'lastName') 'public' => defaults to false. If true, also gets publicly accessible names.
Returns:
setUp
()
The setUp() method is called the first time an object of this class is constructed.
-
[$basename=null]
Get the url of the user icon from a Streams.Avatar
Parameters:
-
[$basename=null]
String optionalThe last part after the slash, such as "50.png"
Returns:
the url
__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
updateAvatar
-
$toUserId
-
$publisherId
Updates the publisher's avatar, as it appears to $toUserId
This function should be called during events that may cause the
publisher's avatar to change appearance for certain users viewing it.
These are usually rare events, and include things like:
adding, removing or modifying a contact
Parameters:
-
$toUserId
Integerid of the user who will be viewing this avatar
-
$publisherId
Stringid of the publisher whose avatar to update
Returns:
updateAvatars
-
$publisherId
-
$taintedAccess
-
$streamName
-
$updateToPublicValue=false
Updates the publisher's avatars, which may have changed with the taintedAccess.
This function should be called during rare events that may cause the
publisher's avatar to change appearance for certain users viewing it.
You should rarely have to call this function. It is used internally by the model, in two main situations:
1) adding, removing or modifying a Streams_Access row for Streams/user/firstName or Streams/user/lastName or Streams/user/gender In this case, the function is able to update exactly the avatars that need updating.
2) adding, removing or modifying a Stream row for Streams/user/firstName or Streams/user/lastName or Streams/user/gender In this case, there may be some avatars which this function will miss. These correspond to users which are reachable by the access array for one stream, but not the other. For example, if Streams/user/firstName is being updated, but a particular user is reachable only by the access array for Streams/user/lastName, then their avatar will not be updated and contain a stale value for firstName. To fix this, the Streams_Stream model passes true in the 4th parameter to this function.
Parameters:
-
$publisherId
Stringid of the publisher whose avatar to update
-
$taintedAccess
Arrayarray of Streams_Access objects representing access information that is either about to be saved, are about to be overwritten, or will be deleted
-
$streamName
String | Streams_Streampass the stream name here. You can also pass a Stream_Stream object here, in which case it will be used, instead of selecting that stream from the database.
-
$updateToPublicValue=false
Booleanif you want to first update all the avatars for this stream to the what the public would see, to avoid the situation described in 2).