Method for user groups to get a list of members

This commit is contained in:
Evan Prodromou 2009-01-21 09:51:55 -05:00
parent 9967658f42
commit 7fec4ad33b
1 changed files with 36 additions and 4 deletions

View File

@ -29,24 +29,28 @@ class User_group extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function defaultLogo($size) {
function defaultLogo($size)
{
static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile',
AVATAR_STREAM_SIZE => 'stream',
AVATAR_MINI_SIZE => 'mini');
return theme_path('default-avatar-'.$sizenames[$size].'.png');
}
function homeUrl() {
function homeUrl()
{
return common_local_url('showgroup',
array('nickname' => $this->nickname));
}
function permalink() {
function permalink()
{
return common_local_url('groupbyid',
array('id' => $this->id));
}
function getNotices($offset, $limit) {
function getNotices($offset, $limit)
{
$qry =
'SELECT notice.* ' .
'FROM notice JOIN group_inbox ON notice.id = group_inbox.notice_id ' .
@ -55,4 +59,32 @@ class User_group extends Memcached_DataObject
'group:notices:'.$this->id,
$offset, $limit);
}
function allowedNickname($nickname)
{
static $blacklist = array('new');
return !in_array($nickname, $blacklist);
}
function getMembers($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 ' .
'ORDER BY group_member.created DESC ';
if (common_config('db','type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$members = new Profile();
$cnt = $members->query(sprintf($qry, $this->id));
return $members;
}
}