Commit 90f78b39 authored by Nigel McNie's avatar Nigel McNie
Browse files

Clean up of the display of e-mail notifications.

Now the subject line is a lot shorter, and the boilerplate within the e-mail is simpler.

I filed a feature request for other, more invasive improvements that can be done past 1.0: #1987.
parent cd35a722
......@@ -26,10 +26,9 @@
defined('INTERNAL') || die();
$string['emailsubject'] = 'Message from %s: %s';
$string['emailbodynoreply'] = "This is an auto generated notification from %s. Please do not reply to this message. Following is the content of your notification\n\n--------------------------------------------------\n\n";
$string['emailbody'] = "This is an auto generated notification from %s. Following is the content of your notification\n\n--------------------------------------------------\n\n";
$string['emailbodyending'] = 'To update your notification preferences, visit %s';
$string['emailsubject'] = '%s';
$string['emailheader'] = 'You have been sent a notification from %s. Message follows:';
$string['emailfooter'] = 'This is an auto generated notification from %s. To update your notification preferences, visit %s';
$string['referurl'] = 'See %s';
$string['name'] = 'Email';
......
......@@ -33,32 +33,29 @@ class PluginNotificationEmail extends PluginNotification {
public static function notify_user($user, $data) {
$lang = (empty($user->lang) || $user->lang == 'default') ? get_config('lang') : $user->lang;
$separator = str_repeat('-', 72);
$sitename = get_config('sitename');
$fulltype = get_string_from_language($lang, 'type' . $data->activityname, 'activity');
$subject = get_string_from_language($lang, 'emailsubject', 'notification.email', $sitename, $fulltype);
$subject = get_string_from_language($lang, 'emailsubject', 'notification.email', $sitename);
if (!empty($data->subject)) {
$subject .= ': ' . $data->subject;
}
if (!empty($data->userfrom)) {
$userfrom = get_record('usr', 'id', $data->userfrom);
$messagebody = get_string_from_language($lang, 'emailbody', 'notification.email', $sitename)
. get_string_from_language($lang, 'subject') . ': ' . $data->subject . "\n\n"
. $data->message;
}
else {
$userfrom = null;
$messagebody = get_string_from_language($lang, 'emailbodynoreply', 'notification.email', $sitename)
. get_string_from_language($lang, 'subject') . ': ' . $data->subject . "\n\n"
. $data->message;
}
$messagebody = get_string_from_language($lang, 'emailheader', 'notification.email', $sitename) . "\n";
$messagebody .= $separator . "\n\n";
$messagebody .= get_string_from_language($lang, 'subject') . ': ' . $data->subject . "\n\n";
$messagebody .= $data->message;
if (!empty($data->url)) {
$messagebody .= "\n\n" . get_string_from_language($lang, 'referurl', 'notification.email', $data->url);
}
$messagebody .= "\n\n$separator";
$prefurl = get_config('wwwroot') . 'account/activity/preferences/';
$messagebody .= "\n\n" . get_string_from_language($lang, 'emailbodyending', 'notification.email', $prefurl);
email_user($user, $userfrom, $subject, $messagebody);
$messagebody .= "\n\n" . get_string_from_language($lang, 'emailfooter', 'notification.email', $sitename, $prefurl);
email_user($user, null, $subject, $messagebody);
}
}
......
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