Skip to content

Issues-502: Group owner can add new users to archived groups, Issues-505: Updated emails(discussions/comments) #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions class.groups.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,14 @@ public function discussionModel_beforeRecordAdvancedNotification_handler($sender
if($groupName) {
$headline = sprintf('%s: %s', $groupName, $headline);
}
$data["HeadlineFormat"] = $headline;
$data['HeadlineFormat'] = $headline;
$data['ActionText'] = 'Open Discussion';
// Format to Html
$message = Gdn::formatService()->renderQuote($discussion['Body'], $discussion['Format']);
// We just converted it to HTML. Make sure everything downstream knows it.
// Taking this HTML and feeding it into the Rich Format for example, would be invalid.
$data['Format'] = 'Html';
$data["Story"] =
$data['Story'] =
'<p>You are watching the category "' . $categoryName . '", ' .
'which was updated ' . $dateInserted . ' by ' . $author->Name . ':<p/>' .
'<hr/>' .
Expand Down Expand Up @@ -657,15 +658,16 @@ public function commentModel_beforeRecordAdvancedNotification($sender, $args){
if($groupName) {
$headline = sprintf('%s: %s', $groupName, $headline);
}
$data["HeadlineFormat"] = $headline;
$data['ActionText'] = 'Open Discussion';
$data['HeadlineFormat'] = $headline;
// $data["HeadlineFormat"] = 'The new discussion has been posted in the category ' . $categoryName . '.';
// Format to Html
$discussionStory = condense(Gdn_Format::to($discussion['Body'], $discussion['Format']));
$commentStory = Gdn::formatService()->renderQuote($comment['Body'],$comment['Format']);
// We just converted it to HTML. Make sure everything downstream knows it.
// Taking this HTML and feeding it into the required format for example, would be invalid.
$data['Format'] = 'Html';
$data["Story"] =
$data['Story'] =
'<p>You are watching the discussion "' . $discussionName . '" in the category "' .$categoryName.'" '.
'which was updated ' . $commentDateInserted . ' by ' . $commentAuthor->Name . ':</p>' .
'<hr/>' .
Expand Down Expand Up @@ -696,7 +698,8 @@ private function buildEmailGroupLink($group) {
$groupName = $group->Name;
$groupType = ucfirst(self::UI[$group->Type]['TypeName']);
$color = c('Garden.EmailTemplate.ButtonTextColor');
return sprintf('<span>%s: %s </span><br/>', $groupType, anchor($groupName, url(GroupsPlugin::GROUP_ROUTE . $group->GroupID, true), '',
$url = $group->ChallengeUrl? url($group->ChallengeUrl, true) : url(GroupsPlugin::GROUP_ROUTE . $group->GroupID, true);
return sprintf('<span>%s: %s </span><br/>', $groupType, anchor($groupName, $url, '',
['rel' => 'noopener noreferrer', 'target' => '_blank', 'style' => 'color:' . $color]));
}
return '';
Expand Down
17 changes: 12 additions & 5 deletions models/class.groupmodel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1466,12 +1466,16 @@ public function canLeave($group) {
*
*/
public function canManageMembers($group) {
if((int)$group->Archived === 1) {
if(Gdn::session()->UserID == $group->OwnerID) {
return true;
}

if((int)$group->Archived == 1) {
return false;
}

$groupRole = self::getGroupRoleFor(Gdn::session()->UserID, $group->GroupID);
if($groupRole == GroupModel::ROLE_LEADER ||
Gdn::session()->UserID == $group->OwnerID) {
if($groupRole == GroupModel::ROLE_LEADER ) {
return true;
}
return false;
Expand All @@ -1486,12 +1490,15 @@ public function canInviteNewMember($group) {
$group = $this->getByGroupID($group);
}

if((int)$group->Archived === 1) {
if(Gdn::session()->UserID == $group->OwnerID) {
return true;
}

if((int)$group->Archived == 1) {
return false;
}
$groupRole = self::getGroupRoleFor(Gdn::session()->UserID, $group->GroupID);
if($groupRole === GroupModel::ROLE_LEADER ||
Gdn::session()->UserID === $group->OwnerID ||
Gdn::session()->checkPermission(GroupsPlugin::GROUPS_EMAIL_INVITATIONS_PERMISSION)) {
return true;
}
Expand Down