MDL-73284 messages: Final deprecation MESSAGE_DEFAULT_LOGGED(OFF|IN)

Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
This commit is contained in:
Daniel Ziegenberg 2024-03-27 20:49:09 +01:00
parent 7d7a871edd
commit cbac1d5e32
No known key found for this signature in database
GPG Key ID: 7E6F98FFADBEFD39
5 changed files with 6 additions and 71 deletions

View File

@ -0,0 +1,5 @@
issueNumber: MDL-73284
notes:
core_message:
- message: Final deprecation MESSAGE_DEFAULT_LOGGEDOFF / MESSAGE_DEFAULT_LOGGEDIN.
type: removed

View File

@ -107,7 +107,6 @@ class notification_list_processor implements templatable, renderable {
/**
* Export this data so it can be used as the context for a mustache template.
* @todo Remove loggedin and loggedoff from context on MDL-73284.
*
* @param renderer_base $output
* @return stdClass
@ -129,18 +128,6 @@ class notification_list_processor implements templatable, renderable {
'name' => $processor->name,
'locked' => false,
'userconfigured' => $processor->object->is_user_configured(),
// Backward compatibility, deprecated attribute.
'loggedin' => [
'name' => 'loggedin',
'displayname' => 'loggedin',
'checked' => false,
],
// Backward compatibility, deprecated attribute.
'loggedoff' => [
'name' => 'loggedoff',
'displayname' => 'loggedoff',
'checked' => false,
],
'enabled' => false,
'enabledlabel' => get_string('sendingviaenabled', 'message', $labelparams),
];
@ -151,8 +138,6 @@ class notification_list_processor implements templatable, renderable {
}
$context['enabled'] = $this->is_preference_enabled($preferencebase.'_enabled', $context['locked']);
$context['loggedoff']['checked'] = $context['enabled']; // Backward compatibility, deprecated attribute.
$context['loggedin']['checked'] = $context['enabled']; // Backward compatibility, deprecated attribute.
// If settings are disallowed or forced, just display the corresponding message, if not use user settings.
if ($context['locked']) {

View File

@ -3028,7 +3028,6 @@ class core_message_external extends external_api {
*
* @return external_single_structure the structure
* @since Moodle 3.2
* @todo Remove loggedin and loggedoff from processors structure on MDL-73284.
*/
protected static function get_preferences_structure() {
return new external_single_structure(
@ -3065,24 +3064,6 @@ class core_message_external extends external_api {
'lockedmessage' => new external_value(PARAM_TEXT,
'Text to display if locked', VALUE_OPTIONAL),
'userconfigured' => new external_value(PARAM_INT, 'Is configured?'),
'loggedin' => new external_single_structure(
array(
'name' => new external_value(PARAM_NOTAGS, 'Name'),
'displayname' => new external_value(PARAM_TEXT, 'Display name'),
'checked' => new external_value(PARAM_BOOL, 'Is checked?'),
),
'DEPRECATED ATTRIBUTE -
Kept for backward compatibility, use enabled instead.',
),
'loggedoff' => new external_single_structure(
array(
'name' => new external_value(PARAM_NOTAGS, 'Name'),
'displayname' => new external_value(PARAM_TEXT, 'Display name'),
'checked' => new external_value(PARAM_BOOL, 'Is checked?'),
),
'DEPRECATED ATTRIBUTE -
Kept for backward compatibility, use enabled instead.',
),
'enabled' => new external_value(PARAM_BOOL, 'Is enabled?'),
)
),

View File

@ -35,24 +35,12 @@ define('MESSAGE_TYPE_MESSAGE', 'message');
* Define contants for messaging default settings population. For unambiguity of
* plugin developer intentions we use 4-bit value (LSB numbering):
* bit 0 - whether to send message (MESSAGE_DEFAULT_ENABLED)
* bit 1 - Deprecated: whether to send message (MESSAGE_DEFAULT_LOGGEDOFF). Used to mean only when the user is logged off.
* bit 1 - not used
* bit 2..3 - messaging permission (MESSAGE_DISALLOWED|MESSAGE_PERMITTED|MESSAGE_FORCED)
*
* MESSAGE_PERMITTED_MASK contains the mask we use to distinguish permission setting.
*/
/**
* @deprecated since Moodle 4.0. Use MESSAGE_DEFAULT_ENABLED instead.
* @todo Remove on MDL-73284.
*/
define('MESSAGE_DEFAULT_LOGGEDIN', 0x01); // 0001
/**
* @deprecated since Moodle 4.0 MDL-73284. Use MESSAGE_DEFAULT_ENABLED instead.
* @todo Remove on MDL-73284.
*/
define('MESSAGE_DEFAULT_LOGGEDOFF', 0x02); // 0010
define('MESSAGE_DEFAULT_ENABLED', 0x01); // 0001.
define('MESSAGE_DISALLOWED', 0x04); // 0100.
@ -61,13 +49,6 @@ define('MESSAGE_FORCED', 0x0c); // 1100.
define('MESSAGE_PERMITTED_MASK', 0x0c); // 1100.
/**
* Set default value for default outputs permitted setting
* @deprecated since Moodle 4.0 MDL-73284.
* @todo Remove on MDL-73284.
*/
define('MESSAGE_DEFAULT_PERMITTED', 'permitted');
/**
* Set default values for polling.
*/
@ -464,7 +445,6 @@ function get_message_output_default_preferences() {
* Translate message default settings from binary value to the array of string
* representing the settings to be stored. Also validate the provided value and
* use default if it is malformed.
* @todo Remove usage of MESSAGE_DEFAULT_LOGGEDOFF on MDL-73284.
*
* @param int $plugindefault Default setting suggested by plugin
* @param string $processorname The name of processor
@ -503,10 +483,6 @@ function translate_message_default_setting($plugindefault, $processorname) {
$locked = false;
// It's equivalent to logged in.
$enabled = $plugindefault & MESSAGE_DEFAULT_ENABLED == MESSAGE_DEFAULT_ENABLED;
// MESSAGE_DEFAULT_LOGGEDOFF is deprecated but we're checking it just in case.
$loggedoff = $plugindefault & MESSAGE_DEFAULT_LOGGEDOFF == MESSAGE_DEFAULT_LOGGEDOFF;
$enabled = $enabled || $loggedoff;
break;
}

View File

@ -410,18 +410,6 @@ class core_user_external extends \core_external\external_api {
if (!empty($preferences)) {
$userpref = ['id' => $userid];
foreach ($preferences as $preference) {
/*
* Rename user message provider preferences to avoid orphan settings on old app versions.
* @todo Remove this "translation" block on MDL-73284.
*/
if (preg_match('/message_provider_.*_loggedin/', $preference['type']) ||
preg_match('/message_provider_.*_loggedoff/', $preference['type'])) {
$nameparts = explode('_', $preference['type']);
array_pop($nameparts);
$preference['type'] = implode('_', $nameparts).'_enabled';
}
$userpref['preference_' . $preference['type']] = $preference['value'];
}
useredit_update_user_preference($userpref);