public $__table = 'user_group'; // table name
public $id; // int(4) primary_key not_null
+ public $profile_id; // int(4) primary_key not_null
public $nickname; // varchar(64)
public $fullname; // varchar(191) not 255 because utf8mb4 takes more space
public $homepage; // varchar(191) not 255 because utf8mb4 takes more space
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+ public function getObjectType()
+ {
+ return ActivityObject::GROUP;
+ }
+
+
public static function schemaDef()
{
return array(
return $this->getProfile()->getNickname();
}
+ public function getFullname()
+ {
+ return $this->getProfile()->getFullname();
+ }
+
public static function defaultLogo($size)
{
static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile',
function homeUrl()
{
- $url = null;
- if (Event::handle('StartUserGroupHomeUrl', array($this, &$url))) {
- // normally stored in mainpage, but older ones may be null
- if (!empty($this->mainpage)) {
- $url = $this->mainpage;
- } elseif ($this->isLocal()) {
- $url = common_local_url('showgroup',
- array('nickname' => $this->nickname));
- }
- }
- Event::handle('EndUserGroupHomeUrl', array($this, &$url));
- return $url;
+ return $this->getProfile()->getUrl();
}
function getUri()
function getNotices($offset, $limit, $since_id=null, $max_id=null)
{
- $stream = new GroupNoticeStream($this);
+ // FIXME: Get the Profile::current() some other way, to avoid
+ // possible confusion between current session and queue process.
+ $stream = new GroupNoticeStream($this, Profile::current());
return $stream->getNotices($offset, $limit, $since_id, $max_id);
}
*/
function getRequests($offset=0, $limit=null)
{
- $qry =
- 'SELECT profile.* ' .
- 'FROM profile JOIN group_join_queue '.
- 'ON profile.id = group_join_queue.profile_id ' .
- 'WHERE group_join_queue.group_id = %d ' .
- 'ORDER BY group_join_queue.created DESC ';
+ $rq = new Group_join_queue();
+ $rq->group_id = $this->id;
+
+ $members = new Profile();
+
+ $members->joinAdd(['id', $rq, 'profile_id']);
if ($limit != null) {
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
+ $members->limit($offset, $limit);
}
- $members = new Profile();
+ $members->find();
- $members->query(sprintf($qry, $this->id));
return $members;
}