Skip to content

Commit 7763a05

Browse files
authored
Merge pull request #83 from topcoder-platform/develop
v1.6
2 parents 322934c + ae948ef commit 7763a05

9 files changed

+131
-79
lines changed

class.groups.plugin.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,15 +781,16 @@ public function base_userAnchor_handler($sender, $args){
781781
if($sender instanceof DiscussionController || $sender instanceof GroupController || $sender instanceof PostController) {
782782
$user = $args['User'];
783783
$isTopcoderAdmin = $args['IsTopcoderAdmin'];
784+
$hideRoles = isset($args['HideRoles'])? $args['HideRoles']: false;
784785
$anchorText = &$args['Text'];
785786
$resources = $sender->data('ChallengeResources');
786787
$roleResources = $sender->data('ChallengeRoleResources');
787788
$anchorText = '<span class="topcoderHandle">'.$anchorText.'</span>';
788789
// Don't show Topcoder Challenge roles for admin roles
789-
if(!$isTopcoderAdmin){
790-
$roles = $this->topcoderProjectRolesText($user, $resources, $roleResources);
791-
if($roles) {
792-
$anchorText = $anchorText . '&nbsp;<span class="challengeRoles">('.$roles. ')</span>';
790+
if(!$isTopcoderAdmin && !$hideRoles) {
791+
$roles = $this->topcoderProjectRolesText($user, $resources, $roleResources);
792+
if ($roles) {
793+
$anchorText = $anchorText . '&nbsp;<span class="challengeRoles">(' . $roles . ')</span>';
793794
}
794795
}
795796
}

controllers/class.groupcontroller.php

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,10 @@ public function index($GroupID = '') {
8888
$this->title($Group->Name);
8989

9090
$this->setData('Breadcrumbs', $this->buildBreadcrumb($Group));
91-
// $this->setData('CurrentUserGroups', GroupModel::memberOf(Gdn::session()->UserID));
92-
$this->setData('TotalMembers', $this->GroupModel->countOfMembers($GroupID));
93-
$this->setData('Leaders', $this->GroupModel->getLeaders($GroupID));
94-
$this->setData('Members', $this->GroupModel->getMembers($GroupID,[],'',30,0));
95-
91+
$roleResources = $this->data('ChallengeRoleResources');
92+
$resources = $this->data('ChallengeResources');
93+
$copilots = $this->getCopilots($resources, $roleResources);
94+
$this->setData('Copilots', $copilots);
9695
$groupDiscussions = $this->GroupModel->getGroupDiscussionCategories($Group);
9796
$defaultDiscussionUrl = '/post/discussion/';
9897
if($Group->Type == GroupModel::TYPE_REGULAR) {
@@ -128,6 +127,25 @@ public function index($GroupID = '') {
128127
$this->render();
129128
}
130129

130+
private function getCopilots($resources = null, $roleResources = null) {
131+
$copilots = [];
132+
$roleName = 'copilot';
133+
if (isset($resources) && isset($roleResources)) {
134+
$copilotRoleResources = array_filter($roleResources, function ($k) use ($roleName) {
135+
return $roleName == strtolower($k->name);
136+
});
137+
138+
$copilotRoleResource = reset($copilotRoleResources);
139+
$memberResources = array_filter($resources, function ($k) use ($copilotRoleResource) {
140+
return $k->roleId == $copilotRoleResource->id;
141+
});
142+
foreach ($memberResources as $memberResourceId => $memberResource) {
143+
array_push($copilots, $memberResource->memberHandle);
144+
}
145+
}
146+
return array_unique($copilots);
147+
}
148+
131149
/**
132150
* Create new group.
133151
*
@@ -252,11 +270,12 @@ public function edit($groupID = false) {
252270

253271

254272
/**
255-
* Create new group.
273+
* The list of members
256274
*
257-
* @since 2.0.0
258-
* @access public
259275
*/
276+
// FIX: https://github.com/topcoder-platform/forums/issues/561
277+
// Hide members endpoint and view
278+
/*
260279
public function members($GroupID = '',$Page = false) {
261280
262281
$this->allowJSONP(true);
@@ -317,6 +336,7 @@ public function members($GroupID = '',$Page = false) {
317336
318337
$this->render();
319338
}
339+
*/
320340

321341
/**
322342
* Remove a member from a group

views/group/add_category.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php if (!defined('APPLICATION')) exit(); ?>
2-
<h1><?php echo t('Add New Category'); ?></h1>
2+
<h1><?php echo t('Add'); ?></h1>
33
<?php
44
$Group = $this->data('Group');
55
echo $this->Form->open();
66
echo $this->Form->errors();
77
?>
88
<div class="Wrap">
99
<?php
10-
echo '<div class="P">Are you sure you want to add a new category to \''. $Group->Name.'\'?</div>';
10+
echo '<div class="P Message">Are you sure you want to add a new category?</div>';
1111
echo '<div class="P">';
1212
echo $this->Form->label('Category Name', 'Name');
1313
echo wrap($this->Form->textBox('Name', ['maxlength' => 255, 'class' => 'InputBox']), 'div', ['class' => 'TextBoxWrapper']);

views/group/delete.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?php
33
$Group = $this->data('Group');
44
?>
5-
<h1><?php echo 'Delete \''.$Group->Name.'\'' ?></h1>
5+
<h1><?php echo 'Delete' ?></h1>
66
<?php
77
echo $this->Form->open();
88
echo $this->Form->errors();
@@ -11,10 +11,10 @@
1111
<div class="Wrap">
1212

1313
<?php
14-
echo '<div class="P">Are you sure you want to delete \''. $Group->Name.'\'?</div>';
14+
echo '<div class="P Message">Are you sure you want to delete this item?</div>';
1515
echo '<div class="Buttons Buttons-Confirm">';
1616
echo $this->Form->button('Cancel', ['type' => 'button', 'class' => 'Button Close']);
17-
echo $this->Form->button( 'Delete', ['class' => 'Button Primary GroupButton']);
17+
echo $this->Form->button( 'Delete', ['class' => 'Button Primary Delete']);
1818
echo '</div>';
1919
?>
2020
</div>

views/group/delete_member.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php if (!defined('APPLICATION')) exit(); ?>
2-
<h1><?php echo t('Delete Member'); ?></h1>
2+
<h1><?php echo t('Delete'); ?></h1>
33
<?php
44
echo $this->Form->open();
55
echo $this->Form->errors();
66
?>
77
<div class="Wrap">
8-
<div class="P">Are you sure you want to delete this member?</div>
8+
<div class="P">Are you sure you want to delete this item?</div>
99
<?php
1010
echo '<div class="Buttons Buttons-Confirm">';
11-
echo $this->Form->button( 'Delete', ['class' => 'Button Primary GroupButton']);
1211
echo $this->Form->button('Cancel', ['type' => 'button', 'class' => 'Button Close']);
12+
echo $this->Form->button( 'Delete', ['class' => 'Button Primary Delete']);
1313
echo '</div>';
1414

1515
?>

views/group/helper_functions.php

Lines changed: 60 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<?php if (!defined('APPLICATION')) exit();
1+
<?php use Vanilla\Formatting\DateTimeFormatter;
2+
use Vanilla\Formatting\Formats\MarkdownFormat;
3+
4+
if (!defined('APPLICATION')) exit();
25

36
if (!function_exists('allMembersUrl')) {
47
/**
@@ -243,51 +246,72 @@ function writeGroupHeader($group, $showDetails = false, $owner = null, $leaders
243246
<?php echo writeGroupIcon($group, '', 'Group-Icon Group-Icon-Big');?>
244247
</div>
245248
<?php }?>
246-
<?php if($showDetails) { ?>
247249
<div class="Group-Info">
248-
<div class="Group-Description"><?php echo $group->Description; ?></div>
249-
<div class="Meta Group-Meta Table">
250-
<?php if($group->ChallengeUrl) { ?>
251-
<div class="MItem TableRow">
252-
<div class="TableCell Cell1">Challenge</div>
253-
<div class="TableCell Cell2"><?php echo anchor($group->Name, $group->ChallengeUrl);?></div>
254-
</div>
255-
<?php } ?>
256-
<div class="MItem TableRow">
257-
<div class="TableCell Cell1">Owner</div>
258-
<div class="TableCell Cell2"><?php echo userAnchor($owner, 'Username');?></div>
259-
</div>
260-
<div class="MItem TableRow">
261-
<div class="TableCell Cell1">Leaders</div>
262-
<div class="TableCell Cell2">
263-
<?php echo writeGroupMembers($leaders, ','); ?>
264-
</div>
265-
</div>
266-
<div class="MItem TableRow">
267-
<div class="TableCell Cell1">Member(s)</div>
268-
<div class="TableCell Cell2"><?php echo $totalMembers; ?></div>
269-
</div>
250+
<?php if(!$group->Archived) { ?>
251+
<div class="Group-Description"><?php
252+
$isMarkdownFormatter = strcasecmp(Gdn_Format::defaultFormat(), MarkdownFormat::FORMAT_KEY) === 0;
253+
$text = $isMarkdownFormatter? Gdn_Format::to($group->Description, MarkdownFormat::FORMAT_KEY):
254+
$group->Description;
255+
echo $text ;
256+
?></div>
257+
<?php } else {?>
258+
<div class="Group-Archived"><?php
259+
$challengeAnchor = $group->ChallengeUrl? anchor('challenge', $group->ChallengeUrl,'', ['target' => 'blank']):'challenge';
260+
echo '<span class="Archived">Archived</span><span>This '.$challengeAnchor.' forum has been archived.</span> ';
261+
?>
262+
</div>
263+
<?php } ?>
264+
</div>
265+
</div>
270266

271-
<div class="MItem TableRow">
272-
<div class="TableCell Cell1">Created on</div>
273-
<div class="TableCell Cell2"><?php echo $group->DateInserted; ?></div>
267+
<?php
268+
}
269+
}
270+
if (!function_exists('writeGroupMetaData')) {
271+
function writeGroupMetaData($group, $owner = null, $copilots=null) {
272+
?>
273+
<div class="Group-Footer">
274+
<div class="Group-Info">
275+
<div class="Meta Group-Meta Table">
276+
<div class="MItem TableRow">
277+
<div class="TableCell Cell1">
278+
<span class="MLabel">Author</span>
279+
<span class="MValue"><?php echo userAnchor($owner, 'Username');?></span>
274280
</div>
275-
<div class="MItem TableRow">
276-
<div class="TableCell Cell1">Privacy</div>
277-
<div class="TableCell Cell2"><?php echo $group->Privacy; ?></div>
281+
<div class="TableCell Cell2">
282+
<span class="MLabel">Copilot</span>
283+
<span class="MValue">
284+
<?php
285+
$copilotAnchors = [];
286+
foreach ($copilots as $copilot) {
287+
$user = Gdn::userModel()->getByUsername($copilot);
288+
array_push($copilotAnchors, userAnchor($user, null, ['HideRoles'=> true]));
289+
}
290+
echo implode(', ', $copilotAnchors);
291+
?>
292+
</span>
278293
</div>
279-
<div class="MItem TableRow Last">
280-
<div class="TableCell Cell1">Archived</div>
281-
<div class="TableCell Cell2"><?php echo $group->Archived == 1? 'yes': 'no'; ?></div>
294+
</div>
295+
<div class="MItem TableRow Last">
296+
<div class="TableCell Cell1">
297+
<span class="MLabel">Privacy</span>
298+
<span class="MValue"><?php echo $group->Privacy; ?></span>
299+
</div>
300+
<div class="TableCell Cell2">
301+
<span class="MLabel">Date Created</span>
302+
<span class="MValue"><?php
303+
$dateFormatted = Gdn::getContainer()->get(DateTimeFormatter::class)->formatDate($group->DateInserted, false, '%d %B %Y');
304+
$timeFormatted = Gdn::getContainer()->get(DateTimeFormatter::class)->formatDate($group->DateInserted, false, '%I:%M %p');
305+
echo $dateFormatted.', '.$timeFormatted;
306+
?></span>
282307
</div>
283308
</div>
284309
</div>
285-
<?php }?>
286310
</div>
287-
311+
</div>
288312
<?php
289313
}
290314
}
291-
?>
315+
292316

293317

views/group/index.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@
99
$Session = Gdn::session();
1010
$Group = $this->data('Group');
1111
$Owner = Gdn::userModel()->getID($Group->OwnerID);
12-
$Leaders = $this->data('Leaders');
13-
$Members = $this->data('Members');
12+
// $Leaders = $this->data('Leaders');
13+
// $Members = $this->data('Members');
14+
$Copilots = $this->data('Copilots');
1415
$Discussions = $this->data('Discussions');
1516
$Announcements = $this->data('Announcements');
16-
$TotalMembers = $this->data('TotalMembers');
17+
// $TotalMembers = $this->data('TotalMembers');
1718
$bannerCssClass = $Group->Banner ? 'HasBanner':'NoBanner';
1819
$groupModel = new GroupModel();
1920
$currentTopcoderProjectRoles = Gdn::controller()->data('ChallengeCurrentUserProjectRoles');
2021
//$groupModel->setCurrentUserTopcoderProjectRoles($currentTopcoderProjectRoles);
2122

2223
?>
23-
<?php echo writeGroupHeader($Group, true, $Owner, $Leaders, $TotalMembers);?>
24+
<?php echo writeGroupHeader($Group, true, $Owner);?>
2425

2526
<div class="Group-Content">
2627
<div class="Group-Box Group-Announcements Section-DiscussionList">
@@ -73,20 +74,19 @@
7374
<?php } ?>
7475

7576
</div>
76-
<div class="Group-Info ClearFix clearfix">
77-
<div class="Group-Box Group-MembersPreview">
78-
<div class="PageControls">
79-
<h1 class="Groups H">Members</h1>
80-
</div>
81-
<?php if(count($Members) > 0 ) { ?>
82-
<div class="PhotoGrid PhotoGridSmall">
83-
<?php echo writeGroupMembersWithPhoto($Members); ?>
84-
<?php echo anchor('All Members',allMembersUrl($this->data('Group')), 'MoreWrap');?>
85-
</div>
86-
<?php } else {
87-
echo '<div class="EmptyMessage">There are no members.</div>';
88-
}?>
89-
</div>
90-
</div>
77+
<?php
78+
// echo '<div class="Group-Info ClearFix clearfix"><div class="Group-Box Group-MembersPreview"> <div class="PageControls">'.
79+
// '<h1 class="Groups H">Members</h1></div>';
80+
// if(count($Members) > 0 ) {
81+
// echo '<div class="PhotoGrid PhotoGridSmall">'
82+
// echo writeGroupMembersWithPhoto($Members);
83+
// echo anchor('All Members',allMembersUrl($this->data('Group')), 'MoreWrap');
84+
// echo '</div>'
85+
// } else {
86+
// echo '<div class="EmptyMessage">There are no members.</div>';
87+
// }
88+
// echo '</div></div>';
89+
?>
9190
</div>
91+
<?php echo writeGroupMetaData($Group, $Owner, $Copilots);?>
9292

views/group/invite.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?php if (!defined('APPLICATION')) exit(); ?>
2-
<h1><?php echo t('Invite User'); ?></h1>
2+
<h1><?php echo t('Invite'); ?></h1>
33
<?php
44
$Group = $this->data('Group');
55
echo $this->Form->open();
66
echo $this->Form->errors();
77
?>
88
<div class="Wrap">
99
<?php
10-
echo '<div class="P">Are you sure you want to invite User to \''. $Group->Name.'\'?</div>';
10+
echo '<div class="P Message">Are you sure you want to invite User?</div>';
1111
echo '<div class="P">';
1212
echo $this->Form->label('Username', 'Username');
1313
echo wrap($this->Form->textBox('Username', ['maxlength' => 100, 'class' => 'InputBox BigInput']), 'div', ['class' => 'TextBoxWrapper']);
1414
echo '</div>';
1515
echo '<div class="Buttons Buttons-Confirm">';
1616
echo $this->Form->button('Cancel', ['type' => 'button', 'class' => 'Button Close']);
17-
echo $this->Form->button( 'Invite', ['class' => 'Button Primary GroupButton']);
17+
echo $this->Form->button( 'Invite User', ['class' => 'Button Primary']);
1818
echo '</div>';
1919

2020
?>

views/groups/helper_functions.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php if (!defined('APPLICATION')) exit();
1+
<?php use Vanilla\Formatting\Formats\MarkdownFormat;
2+
3+
if (!defined('APPLICATION')) exit();
24

35
if (!function_exists('getGroupUrl')) :
46
function getGroupUrl($group) {
@@ -71,7 +73,12 @@ function writeGroup($group, $sender, $session) {
7173
$cssClass = cssClass($group);
7274
$groupUrl = getGroupUrl($group);
7375
$groupName = $group->Name;
76+
$isMarkdownFormatter = strcasecmp(Gdn_Format::defaultFormat(), MarkdownFormat::FORMAT_KEY) === 0;
7477
$groupDesc = $group->Description;
78+
if($isMarkdownFormatter) {
79+
$groupDesc = Gdn_Format::to($groupDesc, MarkdownFormat::FORMAT_KEY);
80+
$groupDesc = preg_replace('/<br\\s*?\/??>/i', "", $groupDesc);
81+
}
7582
$wrapCssClass = $group->Icon ? 'hasPhotoWrap':'noPhotoWrap';
7683
?>
7784
<li id="Group_<?php echo $group->GroupID; ?>" class="<?php echo $cssClass.' '.$wrapCssClass; ?> ">

0 commit comments

Comments
 (0)