MDL-74169 core_message: Hide preferences link when permissions lacking

This commit is contained in:
Frédéric Massart
2022-03-21 18:38:05 +08:00
parent bb864ee2e1
commit 7eb557e695
4 changed files with 12 additions and 6 deletions
+1
View File
@@ -626,6 +626,7 @@ class helper {
'isdrawer' => $isdrawer,
'showemojipicker' => !empty($CFG->allowemojipicker),
'messagemaxlength' => api::MESSAGE_MAX_LENGTH,
'caneditownmessageprofile' => has_capability('moodle/user:editownmessageprofile', \context_system::instance())
];
if ($sendtouser || $conversationid) {
+3 -1
View File
@@ -47,12 +47,14 @@ function message_popup_render_navbar_output(\renderer_base $renderer) {
$enabled = \core_message\api::is_processor_enabled("popup");
if ($enabled) {
$unreadcount = \message_popup\api::count_unread_popup_notifications($USER->id);
$caneditownmessageprofile = has_capability('moodle/user:editownmessageprofile', context_system::instance());
$preferencesurl = $caneditownmessageprofile ? new moodle_url('/message/notificationpreferences.php') : null;
$context = [
'userid' => $USER->id,
'unreadcount' => $unreadcount,
'urls' => [
'seeall' => (new moodle_url('/message/output/popup/notifications.php'))->out(),
'preferences' => (new moodle_url('/message/notificationpreferences.php', ['userid' => $USER->id]))->out(),
'preferences' => $preferencesurl ? $preferencesurl->out() : null,
],
];
$output .= $renderer->render_from_template('message_popup/notification_popover', $context);
@@ -62,11 +62,12 @@
<span class="normal-icon">{{#pix}} t/markasread, core {{/pix}}</span>
{{> core/loading }}
</a>
<a href="{{{urls.preferences}}}"
title="{{#str}} notificationpreferences, message {{/str}}"
aria-label="{{#str}} notificationpreferences, message {{/str}}">
{{#pix}} i/settings, core {{/pix}}
</a>
{{# urls.preferences }}
<a href="{{{ . }}}"
title="{{#str}} notificationpreferences, message {{/str}}"
aria-label="{{#str}} notificationpreferences, message {{/str}}">
{{#pix}} i/settings, core {{/pix}}</a>
{{/ urls.preferences }}
{{/headeractions}}
{{$content}}
@@ -49,6 +49,7 @@
</span>
</div>
</div>
{{#caneditownmessageprofile}}
<div class="ml-2">
<a
href="#"
@@ -60,6 +61,7 @@
{{#pix}} t/edit, core {{/pix}}
</a>
</div>
{{/caneditownmessageprofile}}
</div>
<div class="text-right mt-sm-3">
<a href="#" data-route="view-contacts" role="button">