MDL-76974 javascript: convert remaining uses of old preferences API.

Implement component preference definition callbacks, update JS code
to use the `core_user/repository` module instead of the now deprecated
API.
This commit is contained in:
Paul Holden 2023-06-18 19:11:36 +01:00
parent d096c60e0c
commit b30245b3e2
No known key found for this signature in database
GPG key ID: A81A96D6045F6164
21 changed files with 180 additions and 38 deletions

View file

@ -2125,8 +2125,10 @@ M.core_filepicker.init = function(Y, options) {
},
set_preference: function(name, value) {
if (this.options.userprefs[name] != value) {
M.util.set_user_preference('filepicker_' + name, value);
this.options.userprefs[name] = value;
require(['core_user/repository'], function(UserRepository) {
UserRepository.setUserPreference('filepicker_' + name, value);
this.options.userprefs[name] = value;
}.bind(this));
}
},
in_iframe: function () {

View file

@ -3190,11 +3190,6 @@ function initialise_filepicker($args) {
$return->userprefs['recentlicense'] = get_user_preferences('filepicker_recentlicense', '');
$return->userprefs['recentviewmode'] = get_user_preferences('filepicker_recentviewmode', '');
user_preference_allow_ajax_update('filepicker_recentrepository', PARAM_INT);
user_preference_allow_ajax_update('filepicker_recentlicense', PARAM_SAFEDIR);
user_preference_allow_ajax_update('filepicker_recentviewmode', PARAM_INT);
// provided by form element
$return->accepted_types = file_get_typegroup('extension', $args->accepted_types);
$return->return_types = $args->return_types;