Skip to content

Commit 855532c

Browse files
authored
Merge pull request #73 from topcoder-platform/issues-502
Issues-502: Group owner can add new users to archived groups, Issues-505: Updated emails(discussions/comments)
2 parents 097aee4 + a5031cc commit 855532c

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

class.groups.plugin.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,13 +603,14 @@ public function discussionModel_beforeRecordAdvancedNotification_handler($sender
603603
if($groupName) {
604604
$headline = sprintf('%s: %s', $groupName, $headline);
605605
}
606-
$data["HeadlineFormat"] = $headline;
606+
$data['HeadlineFormat'] = $headline;
607+
$data['ActionText'] = 'Open Discussion';
607608
// Format to Html
608609
$message = Gdn::formatService()->renderQuote($discussion['Body'], $discussion['Format']);
609610
// We just converted it to HTML. Make sure everything downstream knows it.
610611
// Taking this HTML and feeding it into the Rich Format for example, would be invalid.
611612
$data['Format'] = 'Html';
612-
$data["Story"] =
613+
$data['Story'] =
613614
'<p>You are watching the category "' . $categoryName . '", ' .
614615
'which was updated ' . $dateInserted . ' by ' . $author->Name . ':<p/>' .
615616
'<hr/>' .
@@ -657,15 +658,16 @@ public function commentModel_beforeRecordAdvancedNotification($sender, $args){
657658
if($groupName) {
658659
$headline = sprintf('%s: %s', $groupName, $headline);
659660
}
660-
$data["HeadlineFormat"] = $headline;
661+
$data['ActionText'] = 'Open Discussion';
662+
$data['HeadlineFormat'] = $headline;
661663
// $data["HeadlineFormat"] = 'The new discussion has been posted in the category ' . $categoryName . '.';
662664
// Format to Html
663665
$discussionStory = condense(Gdn_Format::to($discussion['Body'], $discussion['Format']));
664666
$commentStory = Gdn::formatService()->renderQuote($comment['Body'],$comment['Format']);
665667
// We just converted it to HTML. Make sure everything downstream knows it.
666668
// Taking this HTML and feeding it into the required format for example, would be invalid.
667669
$data['Format'] = 'Html';
668-
$data["Story"] =
670+
$data['Story'] =
669671
'<p>You are watching the discussion "' . $discussionName . '" in the category "' .$categoryName.'" '.
670672
'which was updated ' . $commentDateInserted . ' by ' . $commentAuthor->Name . ':</p>' .
671673
'<hr/>' .
@@ -696,7 +698,8 @@ private function buildEmailGroupLink($group) {
696698
$groupName = $group->Name;
697699
$groupType = ucfirst(self::UI[$group->Type]['TypeName']);
698700
$color = c('Garden.EmailTemplate.ButtonTextColor');
699-
return sprintf('<span>%s: %s </span><br/>', $groupType, anchor($groupName, url(GroupsPlugin::GROUP_ROUTE . $group->GroupID, true), '',
701+
$url = $group->ChallengeUrl? url($group->ChallengeUrl, true) : url(GroupsPlugin::GROUP_ROUTE . $group->GroupID, true);
702+
return sprintf('<span>%s: %s </span><br/>', $groupType, anchor($groupName, $url, '',
700703
['rel' => 'noopener noreferrer', 'target' => '_blank', 'style' => 'color:' . $color]));
701704
}
702705
return '';

models/class.groupmodel.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,12 +1466,16 @@ public function canLeave($group) {
14661466
*
14671467
*/
14681468
public function canManageMembers($group) {
1469-
if((int)$group->Archived === 1) {
1469+
if(Gdn::session()->UserID == $group->OwnerID) {
1470+
return true;
1471+
}
1472+
1473+
if((int)$group->Archived == 1) {
14701474
return false;
14711475
}
1476+
14721477
$groupRole = self::getGroupRoleFor(Gdn::session()->UserID, $group->GroupID);
1473-
if($groupRole == GroupModel::ROLE_LEADER ||
1474-
Gdn::session()->UserID == $group->OwnerID) {
1478+
if($groupRole == GroupModel::ROLE_LEADER ) {
14751479
return true;
14761480
}
14771481
return false;
@@ -1486,12 +1490,15 @@ public function canInviteNewMember($group) {
14861490
$group = $this->getByGroupID($group);
14871491
}
14881492

1489-
if((int)$group->Archived === 1) {
1493+
if(Gdn::session()->UserID == $group->OwnerID) {
1494+
return true;
1495+
}
1496+
1497+
if((int)$group->Archived == 1) {
14901498
return false;
14911499
}
14921500
$groupRole = self::getGroupRoleFor(Gdn::session()->UserID, $group->GroupID);
14931501
if($groupRole === GroupModel::ROLE_LEADER ||
1494-
Gdn::session()->UserID === $group->OwnerID ||
14951502
Gdn::session()->checkPermission(GroupsPlugin::GROUPS_EMAIL_INVITATIONS_PERMISSION)) {
14961503
return true;
14971504
}

0 commit comments

Comments
 (0)