From 3d0c2607530c70175669af44dc65e203b7f88605 Mon Sep 17 00:00:00 2001 From: Tim Schroeder <t.schroeder@itc.rwth-aachen.de> Date: Thu, 8 Oct 2020 13:07:20 +0200 Subject: [PATCH] fix multilang titles in notifications and other places --- controller.php | 9 +++++---- lib.php | 4 +--- locallib.php | 12 +++++++----- model/comment.class.php | 9 +++++---- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/controller.php b/controller.php index 9f76319..19f4af4 100644 --- a/controller.php +++ b/controller.php @@ -97,7 +97,7 @@ if ($action === 'forwardquestion') { $data = new stdClass(); $data->course = $cm->course; $data->pdfannotatorid = $cm->instance; - $data->pdfname = $cm->name; + $data->pdfname = format_string($cm->name, true); $data->commentid = $commentid; $data->id = $cm->id; // Course module id. $data->action = 'forwardquestion'; @@ -474,7 +474,7 @@ if ($action === 'report') { $data = new stdClass(); $data->course = $cm->course; $data->pdfannotatorid = $cm->instance; - $data->pdfname = $cm->name; + $data->pdfname = format_string($cm->name, true); $data->commentid = $commentid; $data->id = $id; // Course module id. $data->action = 'report'; @@ -498,11 +498,12 @@ if ($action === 'report') { $report->reportinguser = fullname($USER); $report->url = $CFG->wwwroot . '/mod/pdfannotator/view.php?id=' . $cm->id . '&action=overviewreports'; $messagetext = new stdClass(); - $messagetext->text = pdfannotator_format_notification_message_text($course, $cm, $context, get_string('modulename', 'pdfannotator'), $cm->name, $report, 'reportadded'); + $modulename = format_string($cm->name, true); + $messagetext->text = pdfannotator_format_notification_message_text($course, $cm, $context, get_string('modulename', 'pdfannotator'), $modulename, $report, 'reportadded'); $messagetext->url = $report->url; try { foreach ($recipients as $recipient) { - $messagetext->html = pdfannotator_format_notification_message_html($course, $cm, $context, get_string('modulename', 'pdfannotator'), $cm->name, $report, 'reportadded', $recipient->id); + $messagetext->html = pdfannotator_format_notification_message_html($course, $cm, $context, get_string('modulename', 'pdfannotator'), $modulename, $report, 'reportadded', $recipient->id); $messageid = pdfannotator_notify_manager($recipient, $course, $cm, $name, $messagetext); } // 2. Notify the reporting user that their report has been sent off (display blue toast box at top of page). diff --git a/lib.php b/lib.php index a1dcaae..17e8a16 100644 --- a/lib.php +++ b/lib.php @@ -605,14 +605,12 @@ function pdfannotator_get_recent_mod_activity(&$activities, &$index, $timestart, return; } - $aname = format_string($cm->name, true); - foreach ($printposts as $post) { $tmpactivity = new stdClass(); $tmpactivity->type = 'pdfannotator'; $tmpactivity->cmid = $cm->id; - $tmpactivity->name = $aname; + $tmpactivity->name = format_string($cm->name, true); $tmpactivity->sectionnum = $cm->sectionnum; $tmpactivity->timestamp = $post->timecreated; diff --git a/locallib.php b/locallib.php index b1d8635..bdf20c9 100644 --- a/locallib.php +++ b/locallib.php @@ -259,11 +259,12 @@ function pdfannotator_send_forward_message($recipients, $messageparams, $course, $name = 'forwardedquestion'; $text = new stdClass(); $module = get_string('modulename', 'pdfannotator'); - $text->text = pdfannotator_format_notification_message_text($course, $cm, $context, $module, $cm->name, $messageparams, $name); + $modulename = format_string($cm->name, true); + $text->text = pdfannotator_format_notification_message_text($course, $cm, $context, $module, $modulename, $messageparams, $name); $text->url = $messageparams->urltoquestion; foreach ($recipients as $recipient) { - $text->html = pdfannotator_format_notification_message_html($course, $cm, $context, $module, $cm->name, $messageparams, $name, $recipient); + $text->html = pdfannotator_format_notification_message_html($course, $cm, $context, $module, $modulename, $messageparams, $name, $recipient); pdfannotator_notify_manager($recipient, $course, $cm, $name, $text); } } @@ -272,10 +273,11 @@ function pdfannotator_notify_manager($recipient, $course, $cm, $name, $messagete global $USER; $userfrom = $USER; + $modulename = format_string($cm->name, true); if ($anonymous) { $userfrom = clone($USER); $userfrom->firstname = get_string('pdfannotatorname', 'pdfannotator') . ':'; - $userfrom->lastname = $cm->name; + $userfrom->lastname = $modulename; } $message = new \core\message\message(); $message->component = 'mod_pdfannotator'; @@ -283,11 +285,11 @@ function pdfannotator_notify_manager($recipient, $course, $cm, $name, $messagete $message->courseid = $course->id; $message->userfrom = $userfrom; $message->userto = $recipient; - $message->subject = get_string('notificationsubject:' . $name, 'pdfannotator', $cm->name); + $message->subject = get_string('notificationsubject:' . $name, 'pdfannotator', $modulename); $message->fullmessage = $messagetext->text; $message->fullmessageformat = FORMAT_PLAIN; $message->fullmessagehtml = $messagetext->html; - $message->smallmessage = get_string('notificationsubject:' . $name, 'pdfannotator', $cm->name); + $message->smallmessage = get_string('notificationsubject:' . $name, 'pdfannotator', $modulename); $message->notification = 1; // For personal messages '0'. Important: the 1 without '' and 0 with ''. $message->contexturl = $messagetext->url; $message->contexturlname = 'Context name'; diff --git a/model/comment.class.php b/model/comment.class.php index ac4e407..428d751 100644 --- a/model/comment.class.php +++ b/model/comment.class.php @@ -76,6 +76,7 @@ class pdfannotator_comment { $datarecord->solved = false; $anonymous = $visibility == 'anonymous' ? true : false; + $modulename = format_string($cm->name, true); if ($isquestion == 0) { // Notify subscribed users. $comment = new stdClass(); @@ -88,12 +89,12 @@ class pdfannotator_comment { $messagetext = new stdClass(); $module = get_string('modulename', 'pdfannotator'); - $messagetext->text = pdfannotator_format_notification_message_text($course, $cm, $context, $module, $cm->name, $comment, 'newanswer'); + $messagetext->text = pdfannotator_format_notification_message_text($course, $cm, $context, $module, $modulename, $comment, 'newanswer'); $messagetext->url = $comment->urltoanswer; $recipients = self::get_subscribed_users($annotationid); foreach ($recipients as $recipient) { if ($recipient != $USER->id) { - $messagetext->html = pdfannotator_format_notification_message_html($course, $cm, $context, $module, $cm->name, $comment, 'newanswer', $recipient); + $messagetext->html = pdfannotator_format_notification_message_html($course, $cm, $context, $module, $modulename, $comment, 'newanswer', $recipient); $messageid = pdfannotator_notify_manager($recipient, $course, $cm, 'newanswer', $messagetext, $anonymous); } } @@ -111,13 +112,13 @@ class pdfannotator_comment { $question->urltoanswer = $CFG->wwwroot . '/mod/pdfannotator/view.php?id=' . $cm->id . '&page=' . $page . '&annoid=' . $annotationid . '&commid=' . $commentuuid; $messagetext = new stdClass(); - $messagetext->text = pdfannotator_format_notification_message_text($course, $cm, $context, get_string('modulename', 'pdfannotator'), $cm->name, $question, 'newquestion'); + $messagetext->text = pdfannotator_format_notification_message_text($course, $cm, $context, get_string('modulename', 'pdfannotator'), $modulename, $question, 'newquestion'); $messagetext->url = $question->urltoanswer; foreach ($recipients as $recipient) { if ($recipient->id == $USER->id) { continue; } - $messagetext->html = pdfannotator_format_notification_message_html($course, $cm, $context, get_string('modulename', 'pdfannotator'), $cm->name, $question, 'newquestion', $recipient->id); + $messagetext->html = pdfannotator_format_notification_message_html($course, $cm, $context, get_string('modulename', 'pdfannotator'), $modulename, $question, 'newquestion', $recipient->id); $messageid = pdfannotator_notify_manager($recipient, $course, $cm, 'newquestion', $messagetext, $anonymous); } -- GitLab