diff --git a/class.groups.plugin.php b/class.groups.plugin.php index 5aa24ba..3033320 100644 --- a/class.groups.plugin.php +++ b/class.groups.plugin.php @@ -781,15 +781,16 @@ public function base_userAnchor_handler($sender, $args){ if($sender instanceof DiscussionController || $sender instanceof GroupController || $sender instanceof PostController) { $user = $args['User']; $isTopcoderAdmin = $args['IsTopcoderAdmin']; + $hideRoles = isset($args['HideRoles'])? $args['HideRoles']: false; $anchorText = &$args['Text']; $resources = $sender->data('ChallengeResources'); $roleResources = $sender->data('ChallengeRoleResources'); $anchorText = ''.$anchorText.''; // Don't show Topcoder Challenge roles for admin roles - if(!$isTopcoderAdmin){ - $roles = $this->topcoderProjectRolesText($user, $resources, $roleResources); - if($roles) { - $anchorText = $anchorText . ' ('.$roles. ')'; + if(!$isTopcoderAdmin && !$hideRoles) { + $roles = $this->topcoderProjectRolesText($user, $resources, $roleResources); + if ($roles) { + $anchorText = $anchorText . ' (' . $roles . ')'; } } } diff --git a/controllers/class.groupcontroller.php b/controllers/class.groupcontroller.php index b7a5193..d2cab92 100644 --- a/controllers/class.groupcontroller.php +++ b/controllers/class.groupcontroller.php @@ -88,11 +88,10 @@ public function index($GroupID = '') { $this->title($Group->Name); $this->setData('Breadcrumbs', $this->buildBreadcrumb($Group)); - // $this->setData('CurrentUserGroups', GroupModel::memberOf(Gdn::session()->UserID)); - $this->setData('TotalMembers', $this->GroupModel->countOfMembers($GroupID)); - $this->setData('Leaders', $this->GroupModel->getLeaders($GroupID)); - $this->setData('Members', $this->GroupModel->getMembers($GroupID,[],'',30,0)); - + $roleResources = $this->data('ChallengeRoleResources'); + $resources = $this->data('ChallengeResources'); + $copilots = $this->getCopilots($resources, $roleResources); + $this->setData('Copilots', $copilots); $groupDiscussions = $this->GroupModel->getGroupDiscussionCategories($Group); $defaultDiscussionUrl = '/post/discussion/'; if($Group->Type == GroupModel::TYPE_REGULAR) { @@ -128,6 +127,25 @@ public function index($GroupID = '') { $this->render(); } + private function getCopilots($resources = null, $roleResources = null) { + $copilots = []; + $roleName = 'copilot'; + if (isset($resources) && isset($roleResources)) { + $copilotRoleResources = array_filter($roleResources, function ($k) use ($roleName) { + return $roleName == strtolower($k->name); + }); + + $copilotRoleResource = reset($copilotRoleResources); + $memberResources = array_filter($resources, function ($k) use ($copilotRoleResource) { + return $k->roleId == $copilotRoleResource->id; + }); + foreach ($memberResources as $memberResourceId => $memberResource) { + array_push($copilots, $memberResource->memberHandle); + } + } + return array_unique($copilots); + } + /** * Create new group. * @@ -252,11 +270,12 @@ public function edit($groupID = false) { /** - * Create new group. + * The list of members * - * @since 2.0.0 - * @access public */ + // FIX: https://github.com/topcoder-platform/forums/issues/561 + // Hide members endpoint and view + /* public function members($GroupID = '',$Page = false) { $this->allowJSONP(true); @@ -317,6 +336,7 @@ public function members($GroupID = '',$Page = false) { $this->render(); } + */ /** * Remove a member from a group diff --git a/views/group/helper_functions.php b/views/group/helper_functions.php index abfe2b3..62f5d59 100644 --- a/views/group/helper_functions.php +++ b/views/group/helper_functions.php @@ -1,4 +1,7 @@ - - +
-
Description; ?>
-
- ChallengeUrl) { ?> -
-
Challenge
-
Name, $group->ChallengeUrl);?>
-
- -
-
Owner
-
-
-
-
Leaders
-
- -
-
-
-
Member(s)
-
-
+
Description, MarkdownFormat::FORMAT_KEY): + $group->Description; + echo $text ; + ?>
+
+ +
-
-
Created on
-
DateInserted; ?>
+ +
+
+
+
+
+ Author + +
+
+ Copilot + + getByUsername($copilot); + array_push($copilotAnchors, userAnchor($user, null, ['HideRoles'=> true])); + } + echo implode(', ', $copilotAnchors); + ?> +
-
-
Privacy
-
Privacy; ?>
+
+
+
+ Privacy + Privacy; ?>
-
-
Archived
-
Archived == 1? 'yes': 'no'; ?>
+
+ Date Created + get(DateTimeFormatter::class)->formatDate($group->DateInserted, false, '%d %B %Y'); + $timeFormatted = Gdn::getContainer()->get(DateTimeFormatter::class)->formatDate($group->DateInserted, false, '%I:%M %p'); + echo $dateFormatted.', '.$timeFormatted; + ?>
-
- +
+ diff --git a/views/group/index.php b/views/group/index.php index a076ae9..4c0d1dd 100644 --- a/views/group/index.php +++ b/views/group/index.php @@ -9,18 +9,19 @@ $Session = Gdn::session(); $Group = $this->data('Group'); $Owner = Gdn::userModel()->getID($Group->OwnerID); -$Leaders = $this->data('Leaders'); -$Members = $this->data('Members'); +// $Leaders = $this->data('Leaders'); +// $Members = $this->data('Members'); +$Copilots = $this->data('Copilots'); $Discussions = $this->data('Discussions'); $Announcements = $this->data('Announcements'); -$TotalMembers = $this->data('TotalMembers'); +// $TotalMembers = $this->data('TotalMembers'); $bannerCssClass = $Group->Banner ? 'HasBanner':'NoBanner'; $groupModel = new GroupModel(); $currentTopcoderProjectRoles = Gdn::controller()->data('ChallengeCurrentUserProjectRoles'); //$groupModel->setCurrentUserTopcoderProjectRoles($currentTopcoderProjectRoles); ?> - +
@@ -73,20 +74,19 @@
-
-
-
-

Members

-
- 0 ) { ?> -
- - data('Group')), 'MoreWrap');?> -
- There are no members.
'; - }?> -
-
+
'. + // '

Members

'; + // if(count($Members) > 0 ) { + // echo '
' + // echo writeGroupMembersWithPhoto($Members); + // echo anchor('All Members',allMembersUrl($this->data('Group')), 'MoreWrap'); + // echo '
' + // } else { + // echo '
There are no members.
'; + // } + // echo '
'; + ?>
+