diff --git a/classes/Profile.php b/classes/Profile.php index f983225fd5..938c5357c2 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -103,41 +103,61 @@ class Profile extends Managed_DataObject return $this->_user; } - protected $_avatars; - + protected $_avatars; + function getAvatar($width, $height=null) { if (is_null($height)) { $height = $width; } - if (!isset($this->_avatars)) { - $this->_avatars = array(); + $avatar = $this->_getAvatar($width); + + if (empty($avatar)) { + + 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)); + } + + $this->_fillAvatar($width, $avatar); } - if (array_key_exists($width, $this->_avatars)) { - return $this->_avatars[$width]; - } - - $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)); - } - - $this->_avatars[$width] = $avatar; - return $avatar; } - function _fillAvatar($width, $avatar) - { - $this->_avatars[$width] = $avatar; - } - + // XXX: @Fix me gargargar + function _getAvatar($width) + { + if (empty($this->_avatars)) { + $this->_avatars = array(); + } + + // GAR! I cannot figure out where _avatars gets pre-filled with the avatar from + // the previously used profile! Please shoot me now! --Zach + if (array_key_exists($width, $this->_avatars)) { + // Don't return cached avatar unless it's really for this profile + if ($this->_avatars[$width]->profile_id == $this->id) { + return $this->_avatars[$width]; + } + } + + return null; + } + + function _fillAvatar($width, $avatar) + { + //common_debug("Storing avatar of width: {$avatar->width} and profile_id {$avatar->profile_id} in profile {$this->id}."); + $this->_avatars[$width] = $avatar; + + } + function getOriginalAvatar() { $avatar = DB_DataObject::factory('avatar'); @@ -1454,4 +1474,8 @@ class Profile extends Managed_DataObject { return $this; } + + static function pivotGet($key, $values, $otherCols=array()) { + return Memcached_DataObject::pivotGet('Profile', $key, $values, $otherCols); + } } diff --git a/lib/profileblock.php b/lib/profileblock.php index 432df0da5a..4e5539496a 100644 --- a/lib/profileblock.php +++ b/lib/profileblock.php @@ -122,6 +122,8 @@ abstract class ProfileBlock extends Widget function showHomepage() { + $homepage = $this->homepage(); + if (!empty($homepage)) { $this->out->element('a', 'profile_block_homepage', $homepage); } diff --git a/plugins/Event/event.css b/plugins/Event/event.css index 7fbb67d732..e5af5cf515 100644 --- a/plugins/Event/event.css +++ b/plugins/Event/event.css @@ -13,4 +13,27 @@ overflow-x: hidden; /* add padding to account for vertical scrollbar */ padding-right: 20px; -} \ No newline at end of file +} + +.attending-list { list-style-type: none; float: left; width: 100%; } + +#form_event_rsvp { clear: left; } + +li.rsvp-list { float: left; clear: left; } + +li.rsvp-list ul.entities { + display:inline; +} +li.rsvp-list .entities li { + list-style-type: none; + margin-right: 3px; + margin-bottom: 8px; + display: inline; +} +li.rsvp-list .entities li .photo { + margin: 0 !important; + float: none !important; +} +li.rsvp-list .entities li .fn { + display: none; +} diff --git a/plugins/Event/eventlistitem.php b/plugins/Event/eventlistitem.php index fb27704461..2f0710f01f 100644 --- a/plugins/Event/eventlistitem.php +++ b/plugins/Event/eventlistitem.php @@ -152,14 +152,39 @@ class EventListItem extends NoticeListItemAdapter $out->elementStart('div', 'event-rsvps'); // TRANS: Field label for event description. - $out->element('strong', null, _m('Attending:')); - $out->element('span', 'event-rsvps', - // TRANS: RSVP counts. - // TRANS: %1$d, %2$d and %3$d are numbers of RSVPs. - sprintf(_m('Yes: %1$d No: %2$d Maybe: %3$d'), - count($rsvps[RSVP::POSITIVE]), - count($rsvps[RSVP::NEGATIVE]), - count($rsvps[RSVP::POSSIBLE]))); + + $out->text(_('Attending:')); + $out->elementStart('ul', 'attending-list'); + + foreach ($rsvps as $verb => $responses) { + $out->elementStart('li', 'rsvp-list'); + switch ($verb) + { + case RSVP::POSITIVE: + $out->text(_('Yes:')); + break; + case RSVP::NEGATIVE: + $out->text(_('No:')); + break; + case RSVP::POSSIBLE: + $out->text(_('Maybe:')); + break; + } + $ids = array(); + foreach ($responses as $response) { + $ids[] = $response->profile_id; + } + common_debug("IDS = " . implode(',', $ids)); + $profiles = Profile::pivotGet('id', $ids); + common_debug("Profiles = " . print_r($profiles, true)); + $profile = new ArrayWrapper(array_values($profiles)); + $minilist = new ProfileMiniList($profile, $out); + $minilist->show(); + + $out->elementEnd('li'); + } + + $out->elementEnd('ul'); $out->elementEnd('div'); $user = common_current_user();