mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-32137 Fix message preference settings.
When a messaging output is set to forced, users should not be able to change that. Regression intoroduced in bb3546f3 made possible to change checkboxes (but not avoid forced settings). This fix replace checkboxes for 'forced' settings with the corresponding message, similar to how it worked for disallowed before.
This commit is contained in:
parent
c856a1f60b
commit
de132c20f8
@ -91,7 +91,6 @@ $string['nomessages'] = 'No messages waiting';
|
||||
$string['nomessagesfound'] = 'No messages were found';
|
||||
$string['noreply'] = 'Do not reply to this message';
|
||||
$string['nosearchresults'] = 'There were no results from your search';
|
||||
$string['notpermitted'] = 'Not permitted';
|
||||
$string['offline'] = 'Offline';
|
||||
$string['offlinecontacts'] = 'Offline contacts ({$a})';
|
||||
$string['online'] = 'Online';
|
||||
|
@ -262,40 +262,33 @@ class core_message_renderer extends plugin_renderer_base {
|
||||
if (isset($defaultpreferences->{$defaultpreference})) {
|
||||
$permitted = $defaultpreferences->{$defaultpreference};
|
||||
}
|
||||
// If settings are disallowed, just display the message that
|
||||
// the setting is not permitted, if not use user settings or
|
||||
// force them.
|
||||
if ($permitted == 'disallowed') {
|
||||
// If settings are disallowed or forced, just display the
|
||||
// corresponding message, if not use user settings.
|
||||
if (in_array($permitted, array('disallowed', 'forced'))) {
|
||||
if ($state == 'loggedoff') {
|
||||
// skip if we are rendering the second line
|
||||
continue;
|
||||
}
|
||||
$cellcontent = html_writer::nonempty_tag('div', get_string('notpermitted', 'message'), array('class' => 'dimmed_text'));
|
||||
$cellcontent = html_writer::nonempty_tag('div', get_string($permitted, 'message'), array('class' => 'dimmed_text'));
|
||||
$optioncell = new html_table_cell($cellcontent);
|
||||
$optioncell->rowspan = 2;
|
||||
$optioncell->attributes['class'] = 'disallowed';
|
||||
} else {
|
||||
// determine user preferences and use then unless we force
|
||||
// the preferences.
|
||||
// determine user preferences and use them.
|
||||
$disabled = array();
|
||||
if ($permitted == 'forced') {
|
||||
$checked = true;
|
||||
$checked = false;
|
||||
if ($notificationsdisabled) {
|
||||
$disabled['disabled'] = 1;
|
||||
}
|
||||
// See if user has touched this preference
|
||||
if (isset($preferences->{$preferencebase.'_'.$state})) {
|
||||
// User have some preferneces for this state in the database, use them
|
||||
$checked = isset($preferences->{$preferencebase.'_'.$state}[$processor->name]);
|
||||
} else {
|
||||
$checked = false;
|
||||
if ($notificationsdisabled) {
|
||||
$disabled['disabled'] = 1;
|
||||
}
|
||||
// See if user has touched this preference
|
||||
if (isset($preferences->{$preferencebase.'_'.$state})) {
|
||||
// User have some preferneces for this state in the database, use them
|
||||
$checked = isset($preferences->{$preferencebase.'_'.$state}[$processor->name]);
|
||||
} else {
|
||||
// User has not set this preference yet, using site default preferences set by admin
|
||||
$defaultpreference = 'message_provider_'.$preferencebase.'_'.$state;
|
||||
if (isset($defaultpreferences->{$defaultpreference})) {
|
||||
$checked = (int)in_array($processor->name, explode(',', $defaultpreferences->{$defaultpreference}));
|
||||
}
|
||||
// User has not set this preference yet, using site default preferences set by admin
|
||||
$defaultpreference = 'message_provider_'.$preferencebase.'_'.$state;
|
||||
if (isset($defaultpreferences->{$defaultpreference})) {
|
||||
$checked = (int)in_array($processor->name, explode(',', $defaultpreferences->{$defaultpreference}));
|
||||
}
|
||||
}
|
||||
$elementname = $preferencebase.'_'.$state.'['.$processor->name.']';
|
||||
|
Loading…
x
Reference in New Issue
Block a user