Commit d5cc8db4 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow html in feedback emails, shorten internal feedback notifications


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent b908eb90
......@@ -68,4 +68,36 @@ $string['thiscommentisprivate'] = 'This comment is private';
$string['typefeedback'] = 'Feedback';
$string['youhaverequestedpublic'] = 'You have requested that this comment be made public.';
$string['feedbacknotificationhtml'] = "<div style=\"padding: 0.5em 0; border-bottom: 1px solid #999;\"><strong>%s commented on %s</strong><br>%s</div>
<div style=\"margin: 1em 0;\">%s</div>
<div style=\"font-size: smaller; border-top: 1px solid #999;\">
<p><a href=\"%s\">Reply to this comment online</a></p>
</div>";
$string['feedbacknotificationtext'] = "%s commented on %s
%s
------------------------------------------------------------------------
%s
------------------------------------------------------------------------
To see and reply to the comment online, follow this link:
%s";
$string['feedbackdeletedhtml'] = "<div style=\"padding: 0.5em 0; border-bottom: 1px solid #999;\"><strong>A comment on %s was removed</strong><br>%s</div>
<div style=\"margin: 1em 0;\">%s</div>
<div style=\"font-size: smaller; border-top: 1px solid #999;\">
<p><a href=\"%s\">%s</a></p>
</div>";
$string['feedbackdeletedtext'] = "A comment on %s was removed
%s
------------------------------------------------------------------------
%s
------------------------------------------------------------------------
To see %s online, follow this link:
%s";
?>
......@@ -883,6 +883,8 @@ class ActivityTypeArtefactCommentFeedback extends ActivityTypePlugin {
$comment = new ArtefactTypeComment($this->commentid);
$this->overridemessagecontents = true;
if ($onartefact = $comment->get('onartefact')) { // feedback on artefact
$userid = null;
require_once(get_config('docroot') . 'artefact/lib.php');
......@@ -910,36 +912,63 @@ class ActivityTypeArtefactCommentFeedback extends ActivityTypePlugin {
}
$this->users = activity_get_users($this->get_id(), array($userid));
$deletedby = $comment->get('deletedby');
$subjectkey = $deletedby ? 'commentdeletednotificationsubject' : 'newfeedbacknotificationsubject';
$title = $onartefact ? $artefactinstance->get('title') : $viewrecord->title;
$this->urltext = $title;
$body = $comment->get('description');
$posttime = strftime(get_string('strftimedaydatetime'), $comment->get('ctime'));
$user = $this->users[0];
$lang = (empty($user->lang) || $user->lang == 'default') ? get_config('lang') : $user->lang;
// Internal
$this->message = strip_tags(str_shorten_html($body, 200, true));
// Comment deleted notification
if ($deletedby = $comment->get('deletedby')) {
$this->strings = (object) array(
'subject' => (object) array(
'key' => 'commentdeletednotificationsubject',
'section' => 'artefact.comment',
'args' => array($title),
),
);
$deletedmessage = ArtefactTypeComment::deleted_messages();
$removedbyline = get_string_from_language($lang, $deletedmessage[$deletedby], 'artefact.comment');
$this->message = $removedbyline . ":\n" . $this->message;
// Email
$this->users[0]->htmlmessage = get_string_from_language(
$lang, 'feedbackdeletedhtml', 'artefact.comment',
$title, $removedbyline, $body, $this->url, $title
);
$this->users[0]->emailmessage = get_string_from_language(
$lang, 'feedbackdeletedtext', 'artefact.comment',
$title, $removedbyline, trim(html2text($body)), $title, $this->url
);
return;
}
$this->strings = (object) array(
'subject' => (object) array(
'key' => $subjectkey,
'key' => 'newfeedbacknotificationsubject',
'section' => 'artefact.comment',
'args' => array($title),
),
);
$this->urltext = $title;
if ($deletedby) {
$deletedmessage = ArtefactTypeComment::deleted_messages();
$this->strings->deletedmessage = (object) array(
'key' => $deletedmessage[$deletedby],
'section' => 'artefact.comment',
'args' => array(),
);
}
$this->message = html2text($comment->get('description'));
}
$this->url .= '&showcomment=' . $comment->get('id');
public function get_message($user) {
if (!empty($this->strings->deletedmessage)) {
return $this->get_string_for_user($user, 'deletedmessage') . ":\n" . $this->message;
}
return $this->message;
// Email
$author = $comment->get('author');
$authorname = empty($author) ? $comment->get('authorname') : display_name($author, $user);
$this->users[0]->htmlmessage = get_string_from_language(
$lang, 'feedbacknotificationhtml', 'artefact.comment',
$authorname, $title, $posttime, $body, $this->url
);
$this->users[0]->emailmessage = get_string_from_language(
$lang, 'feedbacknotificationhtml', 'artefact.comment',
$authorname, $title, $posttime, trim(html2text($body)), $this->url
);
}
public function get_plugintype(){
......@@ -954,5 +983,3 @@ class ActivityTypeArtefactCommentFeedback extends ActivityTypePlugin {
return array('commentid', 'viewid');
}
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment