From a0b4282cbf1d36c80a27121dded1e9fa718fa19d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 14 Apr 2011 11:33:10 -0400 Subject: [PATCH] hook for getting profile avatars --- EVENTS.txt | 9 +++++++++ classes/Profile.php | 14 +++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index d1e36ad906..7819d9042b 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -1366,3 +1366,12 @@ EndLocalURL: before resolving a local url for an action - &$addSession: whether to add session variable - &$url: resulting URL to local resource +StartProfileGetAvatar: When getting an avatar for a profile +- $profile: profile +- $size: size of the avatar +- &$avatar: avatar + +EndProfileGetAvatar: After getting an avatar for a profile +- $profile: profile +- $size: size of the avatar +- &$avatar: avatar diff --git a/classes/Profile.php b/classes/Profile.php index a47744a124..6c7c182345 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -68,9 +68,17 @@ class Profile extends Memcached_DataObject if (is_null($height)) { $height = $width; } - return Avatar::pkeyGet(array('profile_id' => $this->id, - 'width' => $width, - 'height' => $height)); + + $avatar = null; + + if (Event::handle('StartProfileGetAvatar', array($this, $width, &$avatar))) { + $avatar = Avatar::pkeyGet(array('profile_id' => $this->id, + 'width' => $width, + 'height' => $height)); + Event::handle('EndProfileGetAvatar', array($this, $width, &$avatar)); + } + + return $avatar; } function getOriginalAvatar() -- 2.39.5