/** * 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:<br/> * adding, removing or modifying a contact * @method updateAvatar * @static * @param {integer} $toUserId * id of the user who will be viewing this avatar * @param {string} $publisherId * id of the publisher whose avatar to update * @return {boolean} */ static function updateAvatar($toUserId, $publisherId) { $user = new Users_User(); $user->id = $publisherId; if (!$user->retrieve(null, null, true)->ignoreCache()->resume()) { return false; } // Fetch some streams as the contact user $streams = Streams::fetch($toUserId, $publisherId, array('Streams/user/firstName', 'Streams/user/lastName')); $firstName = Streams::take($streams, 'Streams/user/firstName', 'content'); $lastName = Streams::take($streams, 'Streams/user/lastName', 'content'); // Update the Streams_avatar table Streams_Avatar::update()->set(array('firstName' => $firstName, 'lastName' => $lastName, 'username' => $user->username, 'icon' => $user->icon))->where(array('toUserId' => $toUserId, 'publisherId' => $publisherId))->execute(); return true; }