From: Evan Prodromou Date: Wed, 21 Jan 2009 14:51:55 +0000 (-0500) Subject: Method for user groups to get a list of members X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7fec4ad33bcf0eebe1a59d2231a691cddbeb9f65;p=quix0rs-gnu-social.git Method for user groups to get a list of members --- diff --git a/classes/User_group.php b/classes/User_group.php index e0b6f28859..06c0316101 100755 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -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; + } }