show section with admins in sidebar of group

This commit is contained in:
Evan Prodromou 2009-06-29 10:22:17 -04:00
parent ffa40a84ba
commit d03b8c4276
2 changed files with 68 additions and 0 deletions

View File

@ -331,6 +331,7 @@ class ShowgroupAction extends GroupDesignAction
{
$this->showMembers();
$this->showStatistics();
$this->showAdmins();
$cloud = new GroupTagCloudSection($this, $this->group);
$cloud->show();
}
@ -369,6 +370,18 @@ class ShowgroupAction extends GroupDesignAction
$this->elementEnd('div');
}
/**
* Show list of admins
*
* @return void
*/
function showAdmins()
{
$adminSection = new GroupAdminSection($this, $this->group);
$adminSection->show();
}
/**
* Show some statistics
*
@ -423,3 +436,34 @@ class ShowgroupAction extends GroupDesignAction
$this->elementEnd('div');
}
}
class GroupAdminSection extends ProfileSection
{
var $group;
function __construct($out, $group)
{
parent::__construct($out);
$this->group = $group;
}
function getProfiles()
{
return $this->group->getAdmins();
}
function title()
{
return _('Admins');
}
function divId()
{
return 'group_admins';
}
function moreUrl()
{
return null;
}
}

View File

@ -126,6 +126,30 @@ class User_group extends Memcached_DataObject
return $members;
}
function getAdmins($offset=0, $limit=null)
{
$qry =
'SELECT profile.* ' .
'FROM profile JOIN group_member '.
'ON profile.id = group_member.profile_id ' .
'WHERE group_member.group_id = %d ' .
'AND group_member.is_admin = 1 ' .
'ORDER BY group_member.modified ASC ';
if ($limit != null) {
if (common_config('db','type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
}
$admins = new Profile();
$admins->query(sprintf($qry, $this->id));
return $admins;
}
function getBlocked($offset=0, $limit=null)
{
$qry =