X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FUser_group.php;h=8f736de6d09a5728b194f37487405ee5f2905fee;hb=cb8bf360c42ca8fce44fac62316d6d71d66d912e;hp=01437ace39a6b2aa88506990fc5171c5107d9ab7;hpb=c950f1854623f0df2a50c193f624f0a0bf1fcbb3;p=quix0rs-gnu-social.git diff --git a/classes/User_group.php b/classes/User_group.php index 01437ace39..8f736de6d0 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -14,6 +14,7 @@ class User_group extends Managed_DataObject 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 @@ -33,6 +34,12 @@ class User_group extends Managed_DataObject /* 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( @@ -98,6 +105,11 @@ class User_group extends Managed_DataObject return $this->getProfile()->getNickname(); } + public function getFullname() + { + return $this->getProfile()->getFullname(); + } + public static function defaultLogo($size) { static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile', @@ -108,18 +120,7 @@ class User_group extends Managed_DataObject 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() @@ -152,7 +153,9 @@ class User_group extends Managed_DataObject 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); } @@ -214,24 +217,19 @@ class User_group extends Managed_DataObject */ 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; }