We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 90e6eab6 authored by Evan Prodromou's avatar Evan Prodromou

show user's lists in sidebar

parent 14308c21
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment