move pending queue to sidebar

This commit is contained in:
Evan Prodromou 2011-08-27 16:05:58 -04:00
parent ffd387e2dd
commit 804c343a9f
3 changed files with 59 additions and 16 deletions

View File

@ -219,6 +219,16 @@ class User_group extends Managed_DataObject
return $block->count(); return $block->count();
} }
function getQueueCount()
{
// XXX: WORM cache this
$queue = new Group_join_queue();
$queue->group_id = $this->id;
return $queue->count();
}
function getAdmins($offset=0, $limit=null) function getAdmins($offset=0, $limit=null)
{ {
$qry = $qry =

View File

@ -128,6 +128,7 @@ class GroupAction extends Action
$this->showMembers(); $this->showMembers();
$cur = common_current_user(); $cur = common_current_user();
if ($cur && $cur->isAdmin($this->group)) { if ($cur && $cur->isAdmin($this->group)) {
$this->showPending();
$this->showBlocked(); $this->showBlocked();
} }
$this->showAdmins(); $this->showAdmins();
@ -188,11 +189,56 @@ class GroupAction extends Action
$this->elementEnd('div'); $this->elementEnd('div');
} }
function showPending()
{
if ($this->group->join_policy != User_group::JOIN_POLICY_MODERATE) {
return;
}
$pending = $this->group->getQueueCount();
if (!$pending) {
return;
}
$request = $this->group->getRequests(0, MEMBERS_PER_SECTION);
if (!$request) {
return;
}
$this->elementStart('div', array('id' => 'entity_pending',
'class' => 'section'));
if (Event::handle('StartShowGroupPendingMiniList', array($this))) {
$this->elementStart('h2');
$this->element('a', array('href' => common_local_url('groupqueue', array('nickname' =>
$this->group->nickname))),
_('Pending'));
$this->text(' ');
$this->text($pending);
$this->elementEnd('h2');
$gmml = new ProfileMiniList($request, $this);
$gmml->show();
Event::handle('EndShowGroupPendingMiniList', array($this));
}
$this->elementEnd('div');
}
function showBlocked() function showBlocked()
{ {
$member = $this->group->getBlocked(0, MEMBERS_PER_SECTION); $blocked = $this->group->getBlocked(0, MEMBERS_PER_SECTION);
if (!$member) { if (!$blocked) {
return; return;
} }
@ -213,7 +259,7 @@ class GroupAction extends Action
$this->elementEnd('h2'); $this->elementEnd('h2');
$gmml = new GroupBlockedMiniList($member, $this); $gmml = new GroupBlockedMiniList($blocked, $this);
$cnt = $gmml->show(); $cnt = $gmml->show();
if ($cnt == 0) { if ($cnt == 0) {
// TRANS: Description for mini list of group members on a group page when the group has no members. // TRANS: Description for mini list of group members on a group page when the group has no members.

View File

@ -79,19 +79,6 @@ class GroupNav extends Menu
$cur = common_current_user(); $cur = common_current_user();
if ($cur && $cur->isAdmin($this->group)) { if ($cur && $cur->isAdmin($this->group)) {
$pending = $this->countPendingMembers();
if ($pending || $this->group->join_policy == User_group::JOIN_POLICY_MODERATE) {
$this->out->menuItem(common_local_url('groupqueue', array('nickname' =>
$nickname)),
// TRANS: Menu item in the group navigation page. Only shown for group administrators.
// TRANS: %d is the number of pending members.
sprintf(_m('MENU','Pending members (%d)','Pending members (%d)',$pending), $pending),
// TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators.
// TRANS: %s is the nickname of the group.
sprintf(_m('TOOLTIP','%s pending members'), $nickname),
$action_name == 'groupqueue',
'nav_group_pending');
}
} }
Event::handle('EndGroupGroupNav', array($this)); Event::handle('EndGroupGroupNav', array($this));
} }