forked from GNUsocial/gnu-social
		
	Merge branch '1.0.x' into testing
This commit is contained in:
		@@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -13,4 +13,27 @@
 | 
			
		||||
    overflow-x: hidden;
 | 
			
		||||
    /* add padding to account for vertical scrollbar */
 | 
			
		||||
    padding-right: 20px;
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.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;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user