Skip to content

Commit bbae73a

Browse files
committed
Revert "Merge pull request #58 from topcoder-platform/issue-381"
This reverts commit 8c60597, reversing changes made to 44709a1.
1 parent 8c60597 commit bbae73a

File tree

8 files changed

+100
-80
lines changed

8 files changed

+100
-80
lines changed

class.groups.plugin.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ public function base_render_before($sender) {
211211

212212
public function base_groupOptionsDropdown_handler($sender, $args){
213213
$group = $args['Group'];
214-
// $currentTopcoderProjectRoles = $sender->Data['ChallengeCurrentUserProjectRoles'];
214+
$currentTopcoderProjectRoles = $sender->Data['ChallengeCurrentUserProjectRoles'];
215215
$groupModel = new GroupModel();
216-
// $groupModel->setCurrentUserTopcoderProjectRoles($currentTopcoderProjectRoles);
216+
$groupModel->setCurrentUserTopcoderProjectRoles($currentTopcoderProjectRoles);
217217
$groupID = $group->GroupID;
218218
$canEdit = $groupModel->canEdit($group) ;
219219
$canDelete = $groupModel->canDelete($group) ;
@@ -293,9 +293,9 @@ public function base_discussionOptionsDropdown_handler($sender, $args){
293293
// The list of Topcoder Project Roles are added to a sender by Topcoder plugin before each request
294294
// for DiscussionController/GroupController
295295
$data = $sender->Data;
296-
// $currentTopcoderProjectRoles = val('ChallengeCurrentUserProjectRoles', $data, []);
296+
$currentTopcoderProjectRoles = val('ChallengeCurrentUserProjectRoles', $data, []);
297297
$groupModel = new GroupModel();
298-
// $groupModel->setCurrentUserTopcoderProjectRoles($currentTopcoderProjectRoles);
298+
$groupModel->setCurrentUserTopcoderProjectRoles($currentTopcoderProjectRoles);
299299
$canView = $groupModel->canViewDiscussion($Discussion);
300300
$canEdit = $groupModel->canEditDiscussion($Discussion);
301301
$canDelete = $groupModel->canDeleteDiscussion($Discussion);
@@ -468,7 +468,7 @@ private function watchCategory($sender, $categoryID = null, $watched = null, $t
468468
throw notFoundException('Category');
469469
}
470470

471-
$hasPermission = CategoryModel::checkPermission($categoryID, 'Vanilla.Discussions.View');
471+
$hasPermission = $categoryModel::checkPermission($categoryID, 'Vanilla.Discussions.View');
472472
if (!$hasPermission) {
473473
throw permissionException('Vanilla.Discussion.View');
474474
}
@@ -803,13 +803,11 @@ private function getTopcoderProjectRoles($user, $resources = null, $roleResource
803803
$allResourcesByMember = array_filter($resources, function ($k) use ($topcoderUsername) {
804804
return $k->memberHandle == $topcoderUsername;
805805
});
806-
if($allResourcesByMember) {
807-
foreach ($allResourcesByMember as $resource) {
808-
$roleResource = array_filter($roleResources, function ($k) use ($resource) {
809-
return $k->id == $resource->roleId;
810-
});
811-
array_push($roles, reset($roleResource)->name);
812-
}
806+
foreach ($allResourcesByMember as $resource) {
807+
$roleResource = array_filter($roleResources, function ($k) use ($resource) {
808+
return $k->id == $resource->roleId;
809+
});
810+
array_push($roles, reset($roleResource)->name);
813811
}
814812
}
815813
return $roles;

controllers/api/GroupsApiController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ public function patch_member($id, $userid, array $body) {
319319
throw new NotFoundException('Group');
320320
}
321321

322-
$isMember = GroupModel::isMemberOfGroup($user->UserID, $group->GroupID);
322+
$isMember = $this->groupModel->isMemberOfGroup($user->UserID, $group->GroupID);
323323
if(!$isMember) {
324324
throw new ClientException('User is not a member of this group');
325325
}
@@ -354,7 +354,7 @@ public function get_member($id, $userid) {
354354
throw new NotFoundException('Group');
355355
}
356356

357-
$isMember = GroupModel::isMemberOfGroup($user->UserID, $group->GroupID);
357+
$isMember = $this->groupModel->isMemberOfGroup($user->UserID, $group->GroupID);
358358
if(!$isMember) {
359359
throw new ClientException('User is not a member of this group');
360360
}

controllers/class.groupcontroller.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function index($GroupID = '') {
8484
$this->title($Group->Name);
8585

8686
$this->setData('Breadcrumbs', $this->buildBreadcrumb($Group));
87-
// $this->setData('CurrentUserGroups', GroupModel::memberOf(Gdn::session()->UserID));
87+
$this->setData('CurrentUserGroups', $this->GroupModel->memberOf(Gdn::session()->UserID));
8888
$this->setData('TotalMembers', $this->GroupModel->countOfMembers($GroupID));
8989
$this->setData('Leaders', $this->GroupModel->getLeaders($GroupID));
9090
$this->setData('Members', $this->GroupModel->getMembers($GroupID,[],'',30,0));
@@ -402,7 +402,7 @@ public function invite($GroupID) {
402402
$this->Form->addError('You are a member of "'.$Group->Name.'".');
403403
} else {
404404
try {
405-
if(GroupModel::isMemberOfGroup($user->UserID, $GroupID)) {
405+
if($this->GroupModel->isMemberOfGroup($user->UserID, $GroupID)) {
406406
$this->Form->addError('User is a member of "'.$Group->Name.'".');
407407
} else {
408408
$this->GroupModel->invite($GroupID, $user->UserID);
@@ -524,7 +524,8 @@ public function unwatch($GroupID) {
524524
* @throws Gdn_UserException
525525
*/
526526
public function accept($GroupID, $UserID) {
527-
if(!GroupModel::isMemberOfGroup($UserID, $GroupID) ) {
527+
$Group = $this->findGroup($GroupID);
528+
if($this->GroupModel->isMemberOfGroup($UserID, $GroupID) !== true) {
528529
$this->GroupModel->accept($GroupID, $UserID);
529530
}
530531
redirectTo(GroupsPlugin::GROUP_ROUTE.$GroupID);

controllers/class.groupscontroller.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function index($Page=false, $filter) {
102102
$countOfGroups = $GroupModel->countMyGroups($where);
103103
//$AvailableGroupData = $GroupModel->getAvailableGroups($where, $defaultSort, $Limit, $Offset);
104104

105-
// $this->setData('CurrentUserGroups', GroupModel::memberOf(Gdn::session()->UserID));
105+
$this->setData('CurrentUserGroups', $GroupModel->memberOf(Gdn::session()->UserID));
106106
$this->setData('Groups', $GroupData);
107107

108108
$this->setData('CountOfGroups', $countOfGroups);
@@ -138,7 +138,7 @@ public function mine($Page = false,$filter ='') {
138138
$countOfRegularGroups = $GroupModel->countMyGroups($regularGroupsWhere);
139139
$this->setData('RegularGroups', $regularGroupsData);
140140
$this->setData('CountOfRegularGroups', $countOfRegularGroups);
141-
// $this->setData('CurrentUserGroups', GroupModel::memberOf(Gdn::session()->UserID));
141+
$this->setData('CurrentUserGroups', $GroupModel->memberOf(Gdn::session()->UserID));
142142

143143
$this->render();
144144
}
@@ -166,7 +166,7 @@ private function mygroups($Page = false, $filter = '') {
166166
$CountGroups = $GroupModel->countMyGroups($where);
167167
$this->setData('CountGroups', $CountGroups);
168168
$this->setData('Groups', $GroupData, true);
169-
// $this->setData('CurrentUserGroups', GroupModel::memberOf(Gdn::session()->UserID));
169+
$this->setData('CurrentUserGroups', $GroupModel->memberOf(Gdn::session()->UserID));
170170

171171
// Build a pager
172172
$PagerFactory = new Gdn_PagerFactory();
@@ -234,7 +234,7 @@ public function all($Page = false, $filter = '') {
234234
$CountGroups = $GroupModel->countAvailableGroups($where);
235235
$this->setData('CountGroups', $CountGroups);
236236
$this->setData('Groups', $GroupData, true);
237-
// $this->setData('CurrentUserGroups', GroupModel::memberOf(Gdn::session()->UserID));
237+
$this->setData('CurrentUserGroups', $GroupModel->memberOf(Gdn::session()->UserID));
238238

239239
// Build a pager
240240
$PagerFactory = new Gdn_PagerFactory();

0 commit comments

Comments
 (0)