Skip to content

Commit 2362dc5

Browse files
authored
Merge pull request #30 from topcoder-platform/issues-229
Issues-229
2 parents ff6101a + c26ecbb commit 2362dc5

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

controllers/api/GroupsApiController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,14 @@ public function post_members($id, array $body) {
192192
if(!$user) {
193193
throw new NotFoundException('User');
194194
}
195+
195196
if(!$this->groupModel->canManageMembers($group)) {
196197
throw new ClientException('Don\'t have permissions to add a member to this group.');
197198
}
198199

199-
$this->groupModel->join($group->GroupID, $user->UserID);
200+
$watch = $body['watch'];
201+
$follow = $body['follow'];
202+
$this->groupModel->join($group->GroupID, $user->UserID, $watch, $follow);
200203
}
201204

202205
/**
@@ -263,6 +266,8 @@ public function groupMemberPostSchema($type) {
263266
$this->groupMemberPostSchema = $this->schema(
264267
Schema::parse([
265268
'userID:i?' => 'The userID.',
269+
'watch:b?' => 'Watch all group categories',
270+
'follow:b?' => 'Follow all group categories',
266271
]),
267272
'GroupMemberPost'
268273
);

models/class.groupmodel.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -814,17 +814,23 @@ public function checkPermission($userID,$groupID,$permissions = null, $fullMatch
814814
}
815815

816816
/**
817-
* Join a new member
817+
* Join a new member.
818818
* @param $GroupID
819819
* @param $UserID
820+
* @param bool $watched
821+
* @param bool $followed
820822
* @return bool|Gdn_DataSet|object|string
821823
*/
822-
public function join($GroupID, $UserID){
824+
public function join($GroupID, $UserID, $watched = true, $followed = true ){
823825
$Fields = ['Role' => GroupModel::ROLE_MEMBER, 'GroupID' => $GroupID,'UserID' => $UserID, 'DateInserted' => Gdn_Format::toDateTime()];
824826
if( $this->SQL->getWhere('UserGroup', ['GroupID' => $GroupID,'UserID' => $UserID])->numRows() == 0) {
825827
$this->SQL->insert('UserGroup', $Fields);
826-
$this->followGroup($GroupID, $UserID);
827-
$this->watchGroup($GroupID, $UserID);
828+
if($followed) {
829+
$this->followGroup($GroupID, $UserID);
830+
}
831+
if($watched) {
832+
$this->watchGroup($GroupID, $UserID);
833+
}
828834
$this->notifyJoinGroup($GroupID, $UserID);
829835
}
830836
}

openapi/groups.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ components:
271271
userID:
272272
description: The Vanilla user ID
273273
type: integer
274+
watch:
275+
description: Watch all group categories
276+
type: boolean
277+
follow:
278+
description: Follow all group categories
279+
type: boolean
274280
required:
275281
- userID
276282
type: object

0 commit comments

Comments
 (0)