X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FProfile.php;h=b9c50905a79e6dd06a3b35d01f6f7e660204d7ff;hb=6d5b6d98b5f68d784fee736518eaaae7a26a51f6;hp=ac008877c4bcae1d18ac3656e00913a0e054b3bf;hpb=f0d762f1968fa0ac33b39d73cc9c0225c9e8a989;p=quix0rs-gnu-social.git diff --git a/classes/Profile.php b/classes/Profile.php index ac008877c4..b9c50905a7 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() @@ -1304,4 +1312,53 @@ class Profile extends Memcached_DataObject return true; } + + static function current() + { + $user = common_current_user(); + if (empty($user)) { + $profile = null; + } else { + $profile = $user->getProfile(); + } + return $profile; + } + + function getLists() + { + $ids = array(); + + $keypart = sprintf('profile:lists:%d', $this->id); + + $idstr = self::cacheGet($keypart); + + if ($idstr !== false) { + $ids = explode(',', $idstr); + } else { + $list = new Profile_list(); + $list->selectAdd(); + $list->selectAdd('id'); + $list->tagger = $this->id; + + if ($list->find()) { + while ($list->fetch()) { + $ids[] = $list->id; + } + } + + self::cacheSet($keypart, implode(',', $ids)); + } + + $lists = array(); + + foreach ($ids as $id) { + $list = Profile_list::staticGet('id', $id); + if (!empty($list) && + ($showPrivate || !$list->private)) { + $lists[] = $list; + } + } + + return new ArrayWrapper($lists); + } }