MDL-74169 core_message: Hide preferences link when permissions lacking
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user