Skip to content

Commit 7e59c6d

Browse files
authored
Merge pull request #114 from topcoder-platform/issues-670
Issues-670: Updated email message for Client Manager
2 parents 45abf07 + 7123413 commit 7e59c6d

File tree

1 file changed

+78
-19
lines changed

1 file changed

+78
-19
lines changed

Topcoder/class.topcoder.plugin.php

Lines changed: 78 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,27 +2397,86 @@ public function activityModel_BeforeCheckPreference_handler($sender, $args) {
23972397
$data = $activity['Data'];
23982398
$challengeID = $data['ChallengeID'];
23992399
if($challengeID) {
2400-
$resources = $this->getChallengeResources($challengeID);
2401-
$roleResources = $this->getRoleResources();
2402-
$currentProjectRoles = $this->getTopcoderProjectRoles($user, $resources, $roleResources);
2403-
if($currentProjectRoles) {
2404-
$currentProjectRoles = array_map('strtolower',$currentProjectRoles);
2405-
$isClientManager = count(array_intersect($currentProjectRoles, ["client manager"])) > 0;
2406-
if($isClientManager) {
2407-
$activity['Data']['EmailUrl'] = val('EmbedUrl',$data);
2408-
$activity['Data']['EmailTemplate'] = 'email-selfservice';
2409-
$category = CategoryModel::categories($challengeID);
2410-
$categoryName = val('Name', $category);
2411-
$headline = 'Message From a Topcoder Member on Your Work - Please See';
2412-
$activity['HeadlineFormat'] = $headline;
2413-
$activity['Headline'] = $headline;
2414-
$activity['Story']= sprintf('A new message has been posted on your work forum tied to your Topcoder Work "%s". You can read the full message below.<br/>
2415-
To answer, click "Open Discussion" below to be taken to this discussion.<br/>
2400+
$activityType = $activity['RecordType'];
2401+
if($activityType == 'Discussion' || $activityType == 'Comment') {
2402+
$resources = $this->getChallengeResources($challengeID);
2403+
$roleResources = $this->getRoleResources();
2404+
$currentProjectRoles = $this->getTopcoderProjectRoles($user, $resources, $roleResources);
2405+
if($currentProjectRoles) {
2406+
$currentProjectRoles = array_map('strtolower', $currentProjectRoles);
2407+
$isClientManager = count(array_intersect($currentProjectRoles, ["client manager"])) > 0;
2408+
if ($isClientManager) {
2409+
$recordID = $activity['RecordID'];
2410+
$category = CategoryModel::categories($challengeID);
2411+
$categoryName = val('Name', $category);
2412+
$userModel = new UserModel();
2413+
$discussionModel = new DiscussionModel();
2414+
if ($activityType == 'Discussion') {
2415+
$discussion = $discussionModel->getID($recordID);
2416+
$message = Gdn::formatService()->renderQuote(val('Body', $discussion), val('Format', $discussion));
2417+
$author = $userModel->getID(val('InsertUserID', $discussion));
2418+
$dateInserted = Gdn_Format::dateFull(val('DateInserted',$discussion));
2419+
// $categoryBreadcrumbs = array_column(array_values(CategoryModel::getAncestors(val('CategoryID',$discussion))), 'Name');
2420+
2421+
$activity['Story'] =
2422+
'<p>A new message has been posted on your work forum tied to your Topcoder Work "' . $categoryName . '" ' .
2423+
'which was updated ' . $dateInserted . ' by ' . $author->Name . ':<p/>' .
2424+
'<hr/>' .
2425+
'<div style="padding: 0; margin: 0">' .
2426+
'<p><span>Discussion: ' . val('Name', $discussion) . '</p>' .
2427+
'<p><span>Author: ' . val('Name', $author) . '</p>' .
2428+
// '<p><span>Category: ' . implode('›', $categoryBreadcrumbs) . '</p>' .
2429+
'<p><span>Message:</span> ' . $message . '</p>' .
2430+
'<hr/>'.
2431+
'<p>To answer, click "Open Discussion" below to be taken to this discussion.<br/>
2432+
Please do not reply to this email.<br/>
2433+
Thank you!
2434+
The Topcoder Team</p>' .
2435+
'</div>' .
2436+
'<hr/>';
2437+
2438+
} else { // Comment
2439+
$commentModel = new CommentModel();
2440+
$comment = $commentModel->getID($recordID);
2441+
// $discussion = $discussionModel->getID(val('DiscussionID', $comment));
2442+
// $discussionName = val('Name',$discussion);
2443+
$commentDateInserted = Gdn_Format::dateFull(val('DateInserted',$comment));
2444+
$commentAuthor = $userModel->getID(val('InsertUserID',$comment));
2445+
$commentStory = Gdn::formatService()->renderQuote(val('Body',$comment), val('Format',$comment));
2446+
$activity['Story'] =
2447+
'<p>A new message has been posted on your work forum tied to your Topcoder Work "' . $categoryName . '" ' .
2448+
'which was updated ' . $commentDateInserted . ' by ' . val('Name',$commentAuthor) . ':</p>' .
2449+
'<hr/>' .
2450+
'<p class="label"><span style="display: block">Message:</span>'.'</p>' .
2451+
$commentStory .
2452+
'<br/><hr/>';
2453+
2454+
$parentCommentID = (int)val('ParentCommentID',$comment);
2455+
if($parentCommentID > 0) {
2456+
$parentComment = $commentModel->getID($parentCommentID, DATASET_TYPE_ARRAY);
2457+
$parentCommentAuthor = $userModel->getID($parentComment['InsertUserID']);
2458+
$parentCommentStory = condense(Gdn_Format::to($parentComment['Body'], $parentComment['Format']));
2459+
$activity['Story'] .=
2460+
'<p class="label">Original Message (by '.$parentCommentAuthor->Name.' ):</p>'.
2461+
'<p>' .
2462+
$parentCommentStory.
2463+
'</p>' .
2464+
'<hr/>';
2465+
}
2466+
$activity['Story'] .= '<p>To answer, click "Open Discussion" below to be taken to this discussion.<br/>
24162467
Please do not reply to this email.<br/>
24172468
Thank you!
2418-
The Topcoder Team', $categoryName);
2419-
return;
2420-
}
2469+
The Topcoder Team</p>';
2470+
}
2471+
2472+
$headline = 'Message From a Topcoder Member on Your Work - Please See';
2473+
$activity['HeadlineFormat'] = $headline;
2474+
$activity['Headline'] = $headline;
2475+
$activity['Data']['EmailUrl'] = val('EmbedUrl', $data);
2476+
$activity['Data']['EmailTemplate'] = 'email-selfservice';
2477+
return;
2478+
}
2479+
}
24212480
}
24222481
}
24232482
$activity['Data']['EmailUrl'] = externalUrl(val('Route', $activity) == '' ? '/' : val('Route', $activity));

0 commit comments

Comments
 (0)