forked from GNUsocial/gnu-social
show user's lists in sidebar
This commit is contained in:
parent
14308c21db
commit
90e6eab68e
@ -1323,4 +1323,38 @@ class Profile extends Memcached_DataObject
|
||||
}
|
||||
return $profile;
|
||||
}
|
||||
|
||||
function getLists($offset, $limit)
|
||||
{
|
||||
$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) {
|
||||
$lists[] = Profile_list::staticGet('id', $id);
|
||||
}
|
||||
|
||||
return new ArrayWrapper($lists);
|
||||
}
|
||||
}
|
||||
|
@ -326,6 +326,8 @@ class Profile_list extends Memcached_DataObject
|
||||
Profile_tag::cleanup($this);
|
||||
Profile_tag_subscription::cleanup($this);
|
||||
|
||||
self::blow('profile:lists:%d', $this->tagger);
|
||||
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
@ -910,4 +912,13 @@ class Profile_list extends Memcached_DataObject
|
||||
return new ArrayWrapper($wrapped);
|
||||
}
|
||||
}
|
||||
|
||||
function insert()
|
||||
{
|
||||
$result = parent::insert();
|
||||
if ($result) {
|
||||
self::blow('profile:lists:%d', $this->tagger);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@ -97,8 +97,7 @@ class ProfileAction extends OwnerDesignAction
|
||||
$this->showSubscriptions();
|
||||
$this->showSubscribers();
|
||||
$this->showGroups();
|
||||
$this->showListsFor();
|
||||
$this->showListSubscriptions();
|
||||
$this->showLists();
|
||||
$this->showStatistics();
|
||||
}
|
||||
|
||||
@ -180,28 +179,6 @@ class ProfileAction extends OwnerDesignAction
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
function showListsFor()
|
||||
{
|
||||
if (Event::handle('StartShowListsForSection', array($this))) {
|
||||
|
||||
$section = new PeopletagsForUserSection($this, $this->profile);
|
||||
$section->show();
|
||||
|
||||
Event::handle('EndShowListsForSection', array($this));
|
||||
}
|
||||
}
|
||||
|
||||
function showListSubscriptions()
|
||||
{
|
||||
if (Event::handle('StartShowListSubscriptionsSection', array($this))) {
|
||||
|
||||
$section = new PeopletagSubscriptionsSection($this, $this->profile);
|
||||
$section->show();
|
||||
|
||||
Event::handle('EndShowListSubscriptionsSection', array($this));
|
||||
}
|
||||
}
|
||||
|
||||
function showStatistics()
|
||||
{
|
||||
$notice_count = $this->profile->noticeCount();
|
||||
@ -305,6 +282,52 @@ class ProfileAction extends OwnerDesignAction
|
||||
}
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
function showLists()
|
||||
{
|
||||
$lists = $this->profile->getLists();
|
||||
|
||||
if ($lists->N > 0) {
|
||||
$this->elementStart('div', array('id' => 'entity_lists',
|
||||
'class' => 'section'));
|
||||
|
||||
if (Event::handle('StartShowListsMiniList', array($this))) {
|
||||
|
||||
$this->elementStart('h2');
|
||||
// TRANS: H2 text for user list membership statistics.
|
||||
$this->statsSectionLink('userlists', _('Lists'));
|
||||
$this->text(' ');
|
||||
$this->text($lists->N);
|
||||
$this->elementEnd('h2');
|
||||
|
||||
$this->elementStart('ul');
|
||||
|
||||
$cur = common_current_user();
|
||||
|
||||
while ($lists->fetch()) {
|
||||
if (!$lists->private ||
|
||||
($lists->private && !empty($cur) && $cur->id == $profile->id)) {
|
||||
if (!empty($lists->mainpage)) {
|
||||
$url = $lists->mainpage;
|
||||
} else {
|
||||
$url = common_local_url('showprofiletag',
|
||||
array('tagger' => $this->profile->nickname,
|
||||
'tag' => $lists->tag));
|
||||
}
|
||||
$this->elementStart('li');
|
||||
$this->element('a', array('href' => $url),
|
||||
$lists->tag);
|
||||
$this->elementEnd('li');
|
||||
}
|
||||
}
|
||||
|
||||
$this->elementEnd('ul');
|
||||
|
||||
Event::handle('EndShowListsMiniList', array($this));
|
||||
}
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SubscribersMiniList extends ProfileMiniList
|
||||
|
Loading…
Reference in New Issue
Block a user