Show:

Streams_Avatar Class

Extends Base_Streams_Avatar
Module: Streams

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

(
  • $options=array()
  • [$options.short]
  • [$options.show]
  • [$options.html]
  • [$options.escape]
  • [$fallback='Someone']
)
String | Null

Calculate diplay name from avatar

Parameters:

  • $options=array() Array

    Associative array of options, which can include:

  • [$options.short] Boolean optional

    Show one part of the name only

  • [$options.show] Boolean optional

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

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

    If true, does HTML escaping of the retrieved fields

  • [$fallback='Someone'] String optional

    HTML to return if there is no info to get displayName from.

Returns:

String | Null:

fetch

(
  • $toUserId
  • $publisherIds
  • $indexField
)
Streams_Avatar | Array static

Retrieve avatars for one or more publishers as displayed to a particular user.

Parameters:

  • $toUserId User_User | String

    The id of the user to which this would be displayed

  • $publisherIds String | Array

    Array of various users whose avatars are being fetched

  • $indexField String

    Optional name of the field by which to index the resulting array. Can be "toUserId" or "publisherId"

Returns:

Streams_Avatar | Array:

fetchByPrefix

(
  • $toUserId
  • $prefix
  • $options=array()
)
Array static

Retrieve avatars for one or more publishers as displayed to a particular user.

Parameters:

  • $toUserId User_User | String

    The id of the user to which this would be displayed

  • $prefix String

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

Array:

setUp

()

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

(
  • [$basename=null]
)
String

Get the url of the user icon from a Streams.Avatar

Parameters:

  • [$basename=null] String optional

    The last part after the slash, such as "50.png"

Returns:

String:

the url

__set_state

(
  • $array
)
Streams_Avatar

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

Parameters:

  • $array Array

Returns:

Streams_Avatar:

Class instance

updateAvatar

(
  • $toUserId
  • $publisherId
)
Boolean static

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 Integer

    id of the user who will be viewing this avatar

  • $publisherId String

    id of the publisher whose avatar to update

Returns:

Boolean:

updateAvatars

(
  • $publisherId
  • $taintedAccess
  • $streamName
  • $updateToPublicValue=false
)
static

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 String

    id of the publisher whose avatar to update

  • $taintedAccess Array

    array 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_Stream

    pass 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 Boolean

    if 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).