From e4da62b5f11d34e423690e6cd7a0af8c13f59ec0 Mon Sep 17 00:00:00 2001 From: Stevani Andolo Date: Wed, 23 Nov 2022 10:29:55 +0800 Subject: [PATCH] MDL-73964 core: Update support site/email usage to use supportemail This ensures the correct link is provided (and not email address itself), and honours the supportavailability setting. --- .../policy/classes/output/page_nopermission.php | 5 ++--- admin/tool/policy/lang/en/tool_policy.php | 2 +- .../policy/templates/page_nopermission.mustache | 13 +++++-------- lib/moodlelib.php | 13 +++++++------ user/edit.php | 4 +--- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/admin/tool/policy/classes/output/page_nopermission.php b/admin/tool/policy/classes/output/page_nopermission.php index 2191f81b7bc..87de44fdb93 100644 --- a/admin/tool/policy/classes/output/page_nopermission.php +++ b/admin/tool/policy/classes/output/page_nopermission.php @@ -126,13 +126,12 @@ class page_nopermission implements renderable, templatable { * @return \stdClass */ public function export_for_template(renderer_base $output) { - global $CFG; + global $OUTPUT; $data = (object) [ 'pluginbaseurl' => (new moodle_url('/admin/tool/policy'))->out(false), 'haspermissionagreedocs' => $this->haspermissionagreedocs, - 'supportname' => $CFG->supportname, - 'supportemail' => $CFG->supportemail ?? null, + 'supportemail' => $OUTPUT->supportemail(['class' => 'font-weight-bold']) ]; // Get the messages to display. diff --git a/admin/tool/policy/lang/en/tool_policy.php b/admin/tool/policy/lang/en/tool_policy.php index a465a8621d9..07d81a79c82 100644 --- a/admin/tool/policy/lang/en/tool_policy.php +++ b/admin/tool/policy/lang/en/tool_policy.php @@ -98,7 +98,7 @@ $string['nopermissiontoagreedocs'] = 'No permission to agree to the policies'; $string['nopermissiontoagreedocs_desc'] = 'Sorry, you do not have the required permissions to agree to the policies.
You will not be able to use this site until the following policies are agreed:'; $string['nopermissiontoagreedocsbehalf'] = 'No permission to agree to the policies on behalf of this user'; $string['nopermissiontoagreedocsbehalf_desc'] = 'Sorry, you do not have the required permission to agree to the following policies on behalf of {$a}:'; -$string['nopermissiontoagreedocscontact'] = 'For further assistance, please contact'; +$string['nopermissiontoagreedocscontact'] = 'For further assistance:'; $string['nopermissiontoviewpolicyversion'] = 'You do not have permissions to view this policy version.'; $string['nopolicies'] = 'There are no policies for registered users with an active version.'; $string['selectpolicyandversion'] = 'Use the filter above to select policy and/or version'; diff --git a/admin/tool/policy/templates/page_nopermission.mustache b/admin/tool/policy/templates/page_nopermission.mustache index 81f66f0dff9..b1013ef2403 100644 --- a/admin/tool/policy/templates/page_nopermission.mustache +++ b/admin/tool/policy/templates/page_nopermission.mustache @@ -45,7 +45,7 @@ "Policy 2" ], "supportname": "Admin", - "supportemail": "admin@yoursite.com" + "supportemail": "moodlesite/user/contactsitesupport.php" } }} @@ -61,13 +61,10 @@ -

{{#str}}nopermissiontoagreedocscontact, tool_policy{{/str}}

-
-
-

{{{supportname}}}

-

{{supportemail}}

-
-
+ {{#supportemail}} +

{{#str}}nopermissiontoagreedocscontact, tool_policy{{/str}}

+

{{{supportemail}}}

+ {{/supportemail}} {{/haspermissionagreedocs}} {{#js}} diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 6d0cc74c325..216b95c3517 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -6391,18 +6391,19 @@ function can_send_from_real_email_address($from, $user, $unused = null) { * @return string */ function generate_email_signoff() { - global $CFG; + global $CFG, $OUTPUT; $signoff = "\n"; if (!empty($CFG->supportname)) { $signoff .= $CFG->supportname."\n"; } - if (!empty($CFG->supportemail)) { - $signoff .= $CFG->supportemail."\n"; - } - if (!empty($CFG->supportpage)) { - $signoff .= $CFG->supportpage."\n"; + + $supportemail = $OUTPUT->supportemail(['class' => 'font-weight-bold']); + + if ($supportemail) { + $signoff .= "\n" . $supportemail . "\n"; } + return $signoff; } diff --git a/user/edit.php b/user/edit.php index 2a827d65006..0524632a7c9 100644 --- a/user/edit.php +++ b/user/edit.php @@ -260,13 +260,11 @@ if ($userform->is_cancelled()) { $tempuser = $DB->get_record('user', array('id' => $user->id), '*', MUST_EXIST); $tempuser->email = $emailchanged; - $supportuser = core_user::get_support_user(); - $a = new stdClass(); $a->url = $CFG->wwwroot . '/user/emailupdate.php?key=' . $emailchangedkey . '&id=' . $user->id; $a->site = format_string($SITE->fullname, true, array('context' => context_course::instance(SITEID))); $a->fullname = fullname($tempuser, true); - $a->supportemail = $supportuser->email; + $a->supportemail = $OUTPUT->supportemail(); $emailupdatemessage = get_string('emailupdatemessage', 'auth', $a); $emailupdatetitle = get_string('emailupdatetitle', 'auth', $a);