mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
Merge branch 'MDL-76974' of https://github.com/paulholden/moodle
This commit is contained in:
commit
be35034f1c
26 changed files with 213 additions and 59 deletions
|
@ -141,10 +141,6 @@ class block_settings extends block_base {
|
||||||
} else {
|
} else {
|
||||||
$this->content->footer = '';
|
$this->content->footer = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->config->enabledock) && $this->config->enabledock == 'yes') {
|
|
||||||
user_preference_allow_ajax_update('nav_in_tab_panel_settingsnav'.block_settings::$navcount, PARAM_INT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->contentgenerated = true;
|
$this->contentgenerated = true;
|
||||||
|
|
|
@ -32,10 +32,14 @@
|
||||||
* @param string $name the name of the user_perference we should allow to be updated by remote calls.
|
* @param string $name the name of the user_perference we should allow to be updated by remote calls.
|
||||||
* @param integer $paramtype one of the PARAM_{TYPE} constants, user to clean submitted values before set_user_preference is called.
|
* @param integer $paramtype one of the PARAM_{TYPE} constants, user to clean submitted values before set_user_preference is called.
|
||||||
* @return null
|
* @return null
|
||||||
|
*
|
||||||
|
* @deprecated since Moodle 4.3
|
||||||
*/
|
*/
|
||||||
function user_preference_allow_ajax_update($name, $paramtype) {
|
function user_preference_allow_ajax_update($name, $paramtype) {
|
||||||
global $USER, $PAGE;
|
global $USER, $PAGE;
|
||||||
|
|
||||||
|
debugging(__FUNCTION__ . '() is deprecated. Please use the "core_user/repository" module instead.', DEBUG_DEVELOPER);
|
||||||
|
|
||||||
// Record in the session that this user_preference is allowed to updated remotely.
|
// Record in the session that this user_preference is allowed to updated remotely.
|
||||||
$USER->ajax_updatable_user_prefs[$name] = $paramtype;
|
$USER->ajax_updatable_user_prefs[$name] = $paramtype;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
* @category preference
|
* @category preference
|
||||||
* @copyright 2008 Tim Hunt
|
* @copyright 2008 Tim Hunt
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
* @deprecated since Moodle 4.3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(__DIR__ . '/../../config.php');
|
require_once(__DIR__ . '/../../config.php');
|
||||||
|
@ -39,6 +40,8 @@ if (!isset($USER->ajax_updatable_user_prefs[$name])) {
|
||||||
throw new \moodle_exception('notallowedtoupdateprefremotely');
|
throw new \moodle_exception('notallowedtoupdateprefremotely');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugging('Use of setuserpref.php is deprecated. Please use the "core_user/repository" module instead.', DEBUG_DEVELOPER);
|
||||||
|
|
||||||
// Get and the value.
|
// Get and the value.
|
||||||
$value = required_param('value', $USER->ajax_updatable_user_prefs[$name]);
|
$value = required_param('value', $USER->ajax_updatable_user_prefs[$name]);
|
||||||
|
|
||||||
|
|
|
@ -979,6 +979,60 @@ class core_user {
|
||||||
'permissioncallback' => function($user, $preferencename) {
|
'permissioncallback' => function($user, $preferencename) {
|
||||||
return self::is_current_user($user) && has_capability('moodle/blog:view', context_system::instance());
|
return self::is_current_user($user) && has_capability('moodle/blog:view', context_system::instance());
|
||||||
});
|
});
|
||||||
|
$preferences['filemanager_recentviewmode'] = [
|
||||||
|
'type' => PARAM_INT,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'default' => 1,
|
||||||
|
'choices' => [1, 2, 3],
|
||||||
|
'permissioncallback' => [static::class, 'is_current_user'],
|
||||||
|
];
|
||||||
|
$preferences['filepicker_recentrepository'] = [
|
||||||
|
'type' => PARAM_INT,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'permissioncallback' => [static::class, 'is_current_user'],
|
||||||
|
];
|
||||||
|
$preferences['filepicker_recentlicense'] = [
|
||||||
|
'type' => PARAM_SAFEDIR,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'permissioncallback' => [static::class, 'is_current_user'],
|
||||||
|
];
|
||||||
|
$preferences['filepicker_recentviewmode'] = [
|
||||||
|
'type' => PARAM_INT,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'default' => 1,
|
||||||
|
'choices' => [1, 2, 3],
|
||||||
|
'permissioncallback' => [static::class, 'is_current_user'],
|
||||||
|
];
|
||||||
|
$preferences['userselector_optionscollapsed'] = [
|
||||||
|
'type' => PARAM_BOOL,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'default' => true,
|
||||||
|
'permissioncallback' => [static::class, 'is_current_user'],
|
||||||
|
];
|
||||||
|
$preferences['userselector_autoselectunique'] = [
|
||||||
|
'type' => PARAM_BOOL,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'default' => false,
|
||||||
|
'permissioncallback' => [static::class, 'is_current_user'],
|
||||||
|
];
|
||||||
|
$preferences['userselector_preserveselected'] = [
|
||||||
|
'type' => PARAM_BOOL,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'default' => false,
|
||||||
|
'permissioncallback' => [static::class, 'is_current_user'],
|
||||||
|
];
|
||||||
|
$preferences['userselector_searchanywhere'] = [
|
||||||
|
'type' => PARAM_BOOL,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'default' => false,
|
||||||
|
'permissioncallback' => [static::class, 'is_current_user'],
|
||||||
|
];
|
||||||
|
$preferences['question_bank_advanced_search'] = [
|
||||||
|
'type' => PARAM_BOOL,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'default' => false,
|
||||||
|
'permissioncallback' => [static::class, 'is_current_user'],
|
||||||
|
];
|
||||||
|
|
||||||
$choices = [HOMEPAGE_SITE];
|
$choices = [HOMEPAGE_SITE];
|
||||||
if (!empty($CFG->enabledashboard)) {
|
if (!empty($CFG->enabledashboard)) {
|
||||||
|
|
|
@ -1912,6 +1912,7 @@ $functions = array(
|
||||||
'type' => 'write',
|
'type' => 'write',
|
||||||
'capabilities' => 'moodle/site:config',
|
'capabilities' => 'moodle/site:config',
|
||||||
'ajax' => true,
|
'ajax' => true,
|
||||||
|
'loginrequired' => false,
|
||||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
|
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
|
||||||
),
|
),
|
||||||
'core_user_agree_site_policy' => array(
|
'core_user_agree_site_policy' => array(
|
||||||
|
|
|
@ -1218,8 +1218,10 @@ M.form_filemanager.init = function(Y, options) {
|
||||||
},
|
},
|
||||||
set_preference: function(name, value) {
|
set_preference: function(name, value) {
|
||||||
if (this.userprefs[name] != value) {
|
if (this.userprefs[name] != value) {
|
||||||
M.util.set_user_preference('filemanager_' + name, value);
|
require(['core_user/repository'], function(UserRepository) {
|
||||||
this.userprefs[name] = value;
|
UserRepository.setUserPreference('filemanager_' + name, value);
|
||||||
|
this.userprefs[name] = value;
|
||||||
|
}.bind(this));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -453,7 +453,6 @@ class form_filemanager implements renderable {
|
||||||
|
|
||||||
$this->options->userprefs = array();
|
$this->options->userprefs = array();
|
||||||
$this->options->userprefs['recentviewmode'] = get_user_preferences('filemanager_recentviewmode', '');
|
$this->options->userprefs['recentviewmode'] = get_user_preferences('filemanager_recentviewmode', '');
|
||||||
user_preference_allow_ajax_update('filemanager_recentviewmode', PARAM_INT);
|
|
||||||
|
|
||||||
// building file picker options
|
// building file picker options
|
||||||
$params = new stdClass();
|
$params = new stdClass();
|
||||||
|
|
|
@ -160,7 +160,9 @@ M.util.CollapsibleRegion = function(Y, id, userpref, strtooltip) {
|
||||||
animation.set('reverse', this.div.hasClass('collapsed'));
|
animation.set('reverse', this.div.hasClass('collapsed'));
|
||||||
// Update the user preference.
|
// Update the user preference.
|
||||||
if (this.userpref) {
|
if (this.userpref) {
|
||||||
M.util.set_user_preference(this.userpref, !this.div.hasClass('collapsed'));
|
require(['core_user/repository'], function(UserRepository) {
|
||||||
|
UserRepository.setUserPreference(this.userpref, !this.div.hasClass('collapsed'));
|
||||||
|
}.bind(this));
|
||||||
}
|
}
|
||||||
animation.run();
|
animation.run();
|
||||||
}, this, animation);
|
}, this, animation);
|
||||||
|
@ -195,27 +197,16 @@ M.util.CollapsibleRegion.prototype.icon = null;
|
||||||
* user_preference_allow_ajax_update from moodlelib.php to tell Moodle that
|
* user_preference_allow_ajax_update from moodlelib.php to tell Moodle that
|
||||||
* the udpate is allowed, and how to safely clean and submitted values.
|
* the udpate is allowed, and how to safely clean and submitted values.
|
||||||
*
|
*
|
||||||
* @param String name the name of the setting to udpate.
|
* @param {String} name the name of the setting to update.
|
||||||
* @param String the value to set it to.
|
* @param {String} value the value to set it to.
|
||||||
|
*
|
||||||
|
* @deprecated since Moodle 4.3.
|
||||||
*/
|
*/
|
||||||
M.util.set_user_preference = function(name, value) {
|
M.util.set_user_preference = function(name, value) {
|
||||||
YUI().use('io', function(Y) {
|
Y.log('M.util.set_user_preference is deprecated. Please use the "core_user/repository" module instead.', 'warn');
|
||||||
var url = M.cfg.wwwroot + '/lib/ajax/setuserpref.php?sesskey=' +
|
|
||||||
M.cfg.sesskey + '&pref=' + encodeURI(name) + '&value=' + encodeURI(value);
|
|
||||||
|
|
||||||
// If we are a developer, ensure that failures are reported.
|
require(['core_user/repository'], function(UserRepository) {
|
||||||
var cfg = {
|
UserRepository.setUserPreference(name, value);
|
||||||
method: 'get',
|
|
||||||
on: {}
|
|
||||||
};
|
|
||||||
if (M.cfg.developerdebug) {
|
|
||||||
cfg.on.failure = function(id, o, args) {
|
|
||||||
alert("Error updating user preference '" + name + "' using ajax. Clicking this link will repeat the Ajax call that failed so you can see the error: ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make the request.
|
|
||||||
Y.io(url, cfg);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -588,7 +579,9 @@ M.util.init_block_hider = function(Y, config) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateState : function(e, hide) {
|
updateState : function(e, hide) {
|
||||||
M.util.set_user_preference(this.get('preference'), hide);
|
require(['core_user/repository'], function(UserRepository) {
|
||||||
|
UserRepository.setUserPreference(this.get('preference'), hide);
|
||||||
|
}.bind(this));
|
||||||
if (hide) {
|
if (hide) {
|
||||||
this.get('block').addClass('hidden');
|
this.get('block').addClass('hidden');
|
||||||
this.get('block').one('.block-hider-show').focus();
|
this.get('block').one('.block-hider-show').focus();
|
||||||
|
|
|
@ -2560,7 +2560,6 @@ function print_collapsible_region_start($classes, $id, $caption, $userpref = '',
|
||||||
|
|
||||||
// Work out the initial state.
|
// Work out the initial state.
|
||||||
if (!empty($userpref) and is_string($userpref)) {
|
if (!empty($userpref) and is_string($userpref)) {
|
||||||
user_preference_allow_ajax_update($userpref, PARAM_BOOL);
|
|
||||||
$collapsed = get_user_preferences($userpref, $default);
|
$collapsed = get_user_preferences($userpref, $default);
|
||||||
} else {
|
} else {
|
||||||
$collapsed = $default;
|
$collapsed = $default;
|
||||||
|
|
|
@ -72,9 +72,6 @@ class grading_app implements templatable, renderable {
|
||||||
$this->userid = $userid;
|
$this->userid = $userid;
|
||||||
$this->groupid = $groupid;
|
$this->groupid = $groupid;
|
||||||
$this->assignment = $assignment;
|
$this->assignment = $assignment;
|
||||||
user_preference_allow_ajax_update('assign_filter', PARAM_ALPHA);
|
|
||||||
user_preference_allow_ajax_update('assign_workflowfilter', PARAM_ALPHA);
|
|
||||||
user_preference_allow_ajax_update('assign_markerfilter', PARAM_ALPHANUMEXT);
|
|
||||||
$this->participants = $assignment->list_participants_with_filter_status_and_group($groupid);
|
$this->participants = $assignment->list_participants_with_filter_status_and_group($groupid);
|
||||||
if (!$this->userid && count($this->participants)) {
|
if (!$this->userid && count($this->participants)) {
|
||||||
$this->userid = reset($this->participants)->id;
|
$this->userid = reset($this->participants)->id;
|
||||||
|
|
|
@ -2252,6 +2252,38 @@ function workshop_get_coursemodule_info($coursemodule) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current user preferences that are available
|
||||||
|
*
|
||||||
|
* @return array[]
|
||||||
|
*/
|
||||||
|
function mod_workshop_user_preferences(): array {
|
||||||
|
$preferencedefinition = [
|
||||||
|
'type' => PARAM_BOOL,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'default' => false,
|
||||||
|
'permissioncallback' => [core_user::class, 'is_current_user'],
|
||||||
|
];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'workshop-viewlet-allexamples-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-allsubmissions-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-assessmentform-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-assignedassessments-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-cleargrades-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-conclusion-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-examples-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-examplesfail-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-gradereport-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-instructauthors-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-instructreviewers-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-intro-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-ownsubmission-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-publicsubmissions-collapsed' => $preferencedefinition,
|
||||||
|
'workshop-viewlet-yourgrades-collapsed' => $preferencedefinition,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback to fetch the activity event type lang string.
|
* Callback to fetch the activity event type lang string.
|
||||||
*
|
*
|
||||||
|
|
41
question/bank/previewquestion/lib.php
Normal file
41
question/bank/previewquestion/lib.php
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
// This file is part of Moodle - http://moodle.org/
|
||||||
|
//
|
||||||
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Moodle is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback methods for preview question component
|
||||||
|
*
|
||||||
|
* @package qbank_previewquestion
|
||||||
|
* @copyright 2023 Paul Holden <paulh@moodle.com>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current user preferences that are available
|
||||||
|
*
|
||||||
|
* @return array[]
|
||||||
|
*/
|
||||||
|
function qbank_previewquestion_user_preferences(): array {
|
||||||
|
return [
|
||||||
|
'core_question_preview_techinfo_collapsed' => [
|
||||||
|
'type' => PARAM_BOOL,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'default' => true,
|
||||||
|
'permissioncallback' => [core_user::class, 'is_current_user'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
|
@ -2125,8 +2125,10 @@ M.core_filepicker.init = function(Y, options) {
|
||||||
},
|
},
|
||||||
set_preference: function(name, value) {
|
set_preference: function(name, value) {
|
||||||
if (this.options.userprefs[name] != value) {
|
if (this.options.userprefs[name] != value) {
|
||||||
M.util.set_user_preference('filepicker_' + name, value);
|
require(['core_user/repository'], function(UserRepository) {
|
||||||
this.options.userprefs[name] = value;
|
UserRepository.setUserPreference('filepicker_' + name, value);
|
||||||
|
this.options.userprefs[name] = value;
|
||||||
|
}.bind(this));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
in_iframe: function () {
|
in_iframe: function () {
|
||||||
|
|
|
@ -3190,11 +3190,6 @@ function initialise_filepicker($args) {
|
||||||
$return->userprefs['recentlicense'] = get_user_preferences('filepicker_recentlicense', '');
|
$return->userprefs['recentlicense'] = get_user_preferences('filepicker_recentlicense', '');
|
||||||
$return->userprefs['recentviewmode'] = get_user_preferences('filepicker_recentviewmode', '');
|
$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
|
// provided by form element
|
||||||
$return->accepted_types = file_get_typegroup('extension', $args->accepted_types);
|
$return->accepted_types = file_get_typegroup('extension', $args->accepted_types);
|
||||||
$return->return_types = $args->return_types;
|
$return->return_types = $args->return_types;
|
||||||
|
|
2
theme/boost/amd/build/drawer.min.js
vendored
2
theme/boost/amd/build/drawer.min.js
vendored
|
@ -5,6 +5,6 @@
|
||||||
* @copyright 2016 Damyon Wiese
|
* @copyright 2016 Damyon Wiese
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
define("theme_boost/drawer",["jquery","core/custom_interaction_events","core/log","core/pubsub","core/aria"],(function($,CustomEvents,Log,PubSub,Aria){var SELECTORS_TOGGLE_REGION='[data-region="drawer-toggle"]',SELECTORS_TOGGLE_ACTION='[data-action="toggle-drawer"]',SELECTORS_BODY="body",SELECTORS_SECTION='.list-group-item[href*="#section-"]',SELECTORS_DRAWER="#nav-drawer",small=$(document).width()<768,Drawer=function(){$(SELECTORS_TOGGLE_REGION).length||Log.debug("Page is missing a drawer region"),$(SELECTORS_TOGGLE_ACTION).length||Log.debug("Page is missing a drawer toggle link"),$(SELECTORS_TOGGLE_REGION).each(function(index,ele){var trigger=$(ele).find(SELECTORS_TOGGLE_ACTION),drawerid=trigger.attr("aria-controls"),drawer=$(document.getElementById(drawerid)),hidden="false"==trigger.attr("aria-expanded"),side=trigger.attr("data-side"),body=$(SELECTORS_BODY),preference=trigger.attr("data-preference");small&&M.util.set_user_preference(preference,"false"),drawer.on("mousewheel DOMMouseScroll",this.preventPageScroll),hidden?trigger.attr("aria-expanded","false"):(body.addClass("drawer-open-"+side),trigger.attr("aria-expanded","true"))}.bind(this)),this.registerEventListeners(),small&&this.closeAll()};return Drawer.prototype.closeAll=function(){$(SELECTORS_TOGGLE_REGION).each((function(index,ele){var trigger=$(ele).find(SELECTORS_TOGGLE_ACTION),side=trigger.attr("data-side"),body=$(SELECTORS_BODY),drawerid=trigger.attr("aria-controls"),drawer=$(document.getElementById(drawerid)),preference=trigger.attr("data-preference");trigger.attr("aria-expanded","false"),body.removeClass("drawer-open-"+side),Aria.hide(drawer.get()),drawer.addClass("closed"),small||M.util.set_user_preference(preference,"false")}))},Drawer.prototype.toggleDrawer=function(e){var trigger=$(e.target).closest("[data-action=toggle-drawer]"),drawerid=trigger.attr("aria-controls"),drawer=$(document.getElementById(drawerid)),body=$(SELECTORS_BODY),side=trigger.attr("data-side"),preference=trigger.attr("data-preference");small&&M.util.set_user_preference(preference,"false"),body.addClass("drawer-ease");var open="true"==trigger.attr("aria-expanded");open?(body.removeClass("drawer-open-"+side),trigger.attr("aria-expanded","false"),drawer.addClass("closed").delay(500).queue((function(){$(this).hasClass("closed")&&Aria.hide(this),$(this).dequeue()})),small||M.util.set_user_preference(preference,"false")):(trigger.attr("aria-expanded","true"),Aria.unhide(drawer.get()),drawer.focus(),body.addClass("drawer-open-"+side),drawer.removeClass("closed"),small||M.util.set_user_preference(preference,"true")),PubSub.publish("nav-drawer-toggle-start",open)},Drawer.prototype.preventPageScroll=function(e){var delta=e.wheelDelta||e.originalEvent&&e.originalEvent.wheelDelta||-e.originalEvent.detail,bottomOverflow=this.scrollTop+$(this).outerHeight()-this.scrollHeight>=0,topOverflow=this.scrollTop<=0;(delta<0&&bottomOverflow||delta>0&&topOverflow)&&e.preventDefault()},Drawer.prototype.registerEventListeners=function(){$(SELECTORS_TOGGLE_ACTION).each(function(index,element){CustomEvents.define($(element),[CustomEvents.events.activate]),$(element).on(CustomEvents.events.activate,function(e,data){this.toggleDrawer(data.originalEvent),data.originalEvent.preventDefault()}.bind(this))}.bind(this)),$(SELECTORS_SECTION).click(function(){small&&this.closeAll()}.bind(this)),$(SELECTORS_DRAWER).on("webkitTransitionEnd msTransitionEnd transitionend",(function(e){var open=!!$(e.target).closest(SELECTORS_DRAWER).attr("aria-hidden");PubSub.publish("nav-drawer-toggle-end",open)}))},{init:function(){return new Drawer}}}));
|
define("theme_boost/drawer",["jquery","core/custom_interaction_events","core/log","core/pubsub","core/aria","core_user/repository"],(function($,CustomEvents,Log,PubSub,Aria,UserRepository){var SELECTORS_TOGGLE_REGION='[data-region="drawer-toggle"]',SELECTORS_TOGGLE_ACTION='[data-action="toggle-drawer"]',SELECTORS_BODY="body",SELECTORS_SECTION='.list-group-item[href*="#section-"]',SELECTORS_DRAWER="#nav-drawer",small=$(document).width()<768,Drawer=function(){$(SELECTORS_TOGGLE_REGION).length||Log.debug("Page is missing a drawer region"),$(SELECTORS_TOGGLE_ACTION).length||Log.debug("Page is missing a drawer toggle link"),$(SELECTORS_TOGGLE_REGION).each(function(index,ele){var trigger=$(ele).find(SELECTORS_TOGGLE_ACTION),drawerid=trigger.attr("aria-controls"),drawer=$(document.getElementById(drawerid)),hidden="false"==trigger.attr("aria-expanded"),side=trigger.attr("data-side"),body=$(SELECTORS_BODY),preference=trigger.attr("data-preference");small&&UserRepository.setUserPreference(preference,!1),drawer.on("mousewheel DOMMouseScroll",this.preventPageScroll),hidden?trigger.attr("aria-expanded","false"):(body.addClass("drawer-open-"+side),trigger.attr("aria-expanded","true"))}.bind(this)),this.registerEventListeners(),small&&this.closeAll()};return Drawer.prototype.closeAll=function(){$(SELECTORS_TOGGLE_REGION).each((function(index,ele){var trigger=$(ele).find(SELECTORS_TOGGLE_ACTION),side=trigger.attr("data-side"),body=$(SELECTORS_BODY),drawerid=trigger.attr("aria-controls"),drawer=$(document.getElementById(drawerid)),preference=trigger.attr("data-preference");trigger.attr("aria-expanded","false"),body.removeClass("drawer-open-"+side),Aria.hide(drawer.get()),drawer.addClass("closed"),small||UserRepository.setUserPreference(preference,!1)}))},Drawer.prototype.toggleDrawer=function(e){var trigger=$(e.target).closest("[data-action=toggle-drawer]"),drawerid=trigger.attr("aria-controls"),drawer=$(document.getElementById(drawerid)),body=$(SELECTORS_BODY),side=trigger.attr("data-side"),preference=trigger.attr("data-preference");small&&UserRepository.setUserPreference(preference,!1),body.addClass("drawer-ease");var open="true"==trigger.attr("aria-expanded");open?(body.removeClass("drawer-open-"+side),trigger.attr("aria-expanded","false"),drawer.addClass("closed").delay(500).queue((function(){$(this).hasClass("closed")&&Aria.hide(this),$(this).dequeue()})),small||UserRepository.setUserPreference(preference,!1)):(trigger.attr("aria-expanded","true"),Aria.unhide(drawer.get()),drawer.focus(),body.addClass("drawer-open-"+side),drawer.removeClass("closed"),small||UserRepository.setUserPreference(preference,!0)),PubSub.publish("nav-drawer-toggle-start",open)},Drawer.prototype.preventPageScroll=function(e){var delta=e.wheelDelta||e.originalEvent&&e.originalEvent.wheelDelta||-e.originalEvent.detail,bottomOverflow=this.scrollTop+$(this).outerHeight()-this.scrollHeight>=0,topOverflow=this.scrollTop<=0;(delta<0&&bottomOverflow||delta>0&&topOverflow)&&e.preventDefault()},Drawer.prototype.registerEventListeners=function(){$(SELECTORS_TOGGLE_ACTION).each(function(index,element){CustomEvents.define($(element),[CustomEvents.events.activate]),$(element).on(CustomEvents.events.activate,function(e,data){this.toggleDrawer(data.originalEvent),data.originalEvent.preventDefault()}.bind(this))}.bind(this)),$(SELECTORS_SECTION).click(function(){small&&this.closeAll()}.bind(this)),$(SELECTORS_DRAWER).on("webkitTransitionEnd msTransitionEnd transitionend",(function(e){var open=!!$(e.target).closest(SELECTORS_DRAWER).attr("aria-hidden");PubSub.publish("nav-drawer-toggle-end",open)}))},{init:function(){return new Drawer}}}));
|
||||||
|
|
||||||
//# sourceMappingURL=drawer.min.js.map
|
//# sourceMappingURL=drawer.min.js.map
|
File diff suppressed because one or more lines are too long
2
theme/boost/amd/build/drawers.min.js
vendored
2
theme/boost/amd/build/drawers.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -20,8 +20,8 @@
|
||||||
* @copyright 2016 Damyon Wiese
|
* @copyright 2016 Damyon Wiese
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub', 'core/aria'],
|
define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub', 'core/aria', 'core_user/repository'],
|
||||||
function($, CustomEvents, Log, PubSub, Aria) {
|
function($, CustomEvents, Log, PubSub, Aria, UserRepository) {
|
||||||
|
|
||||||
var SELECTORS = {
|
var SELECTORS = {
|
||||||
TOGGLE_REGION: '[data-region="drawer-toggle"]',
|
TOGGLE_REGION: '[data-region="drawer-toggle"]',
|
||||||
|
@ -55,7 +55,7 @@ define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub', '
|
||||||
var body = $(SELECTORS.BODY);
|
var body = $(SELECTORS.BODY);
|
||||||
var preference = trigger.attr('data-preference');
|
var preference = trigger.attr('data-preference');
|
||||||
if (small) {
|
if (small) {
|
||||||
M.util.set_user_preference(preference, 'false');
|
UserRepository.setUserPreference(preference, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawer.on('mousewheel DOMMouseScroll', this.preventPageScroll);
|
drawer.on('mousewheel DOMMouseScroll', this.preventPageScroll);
|
||||||
|
@ -88,7 +88,7 @@ define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub', '
|
||||||
Aria.hide(drawer.get());
|
Aria.hide(drawer.get());
|
||||||
drawer.addClass('closed');
|
drawer.addClass('closed');
|
||||||
if (!small) {
|
if (!small) {
|
||||||
M.util.set_user_preference(preference, 'false');
|
UserRepository.setUserPreference(preference, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -107,7 +107,7 @@ define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub', '
|
||||||
var side = trigger.attr('data-side');
|
var side = trigger.attr('data-side');
|
||||||
var preference = trigger.attr('data-preference');
|
var preference = trigger.attr('data-preference');
|
||||||
if (small) {
|
if (small) {
|
||||||
M.util.set_user_preference(preference, 'false');
|
UserRepository.setUserPreference(preference, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
body.addClass('drawer-ease');
|
body.addClass('drawer-ease');
|
||||||
|
@ -120,7 +120,7 @@ define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub', '
|
||||||
body.addClass('drawer-open-' + side);
|
body.addClass('drawer-open-' + side);
|
||||||
drawer.removeClass('closed');
|
drawer.removeClass('closed');
|
||||||
if (!small) {
|
if (!small) {
|
||||||
M.util.set_user_preference(preference, 'true');
|
UserRepository.setUserPreference(preference, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Close.
|
// Close.
|
||||||
|
@ -134,7 +134,7 @@ define(['jquery', 'core/custom_interaction_events', 'core/log', 'core/pubsub', '
|
||||||
$(this).dequeue();
|
$(this).dequeue();
|
||||||
});
|
});
|
||||||
if (!small) {
|
if (!small) {
|
||||||
M.util.set_user_preference(preference, 'false');
|
UserRepository.setUserPreference(preference, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import {dispatchEvent} from 'core/event_dispatcher';
|
||||||
import {debounce} from 'core/utils';
|
import {debounce} from 'core/utils';
|
||||||
import {isSmall, isLarge} from 'core/pagehelpers';
|
import {isSmall, isLarge} from 'core/pagehelpers';
|
||||||
import Pending from 'core/pending';
|
import Pending from 'core/pending';
|
||||||
|
import {setUserPreference} from 'core_user/repository';
|
||||||
// The jQuery module is only used for interacting with Boostrap 4. It can we removed when MDL-71979 is integrated.
|
// The jQuery module is only used for interacting with Boostrap 4. It can we removed when MDL-71979 is integrated.
|
||||||
import jQuery from 'jquery';
|
import jQuery from 'jquery';
|
||||||
|
|
||||||
|
@ -439,7 +440,7 @@ export default class Drawers {
|
||||||
|
|
||||||
const preference = this.drawerNode.dataset.preference;
|
const preference = this.drawerNode.dataset.preference;
|
||||||
if (preference && !isSmall() && (this.drawerNode.dataset.forceopen != 1)) {
|
if (preference && !isSmall() && (this.drawerNode.dataset.forceopen != 1)) {
|
||||||
M.util.set_user_preference(preference, true);
|
setUserPreference(preference, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const state = this.drawerNode.dataset.state;
|
const state = this.drawerNode.dataset.state;
|
||||||
|
@ -508,7 +509,7 @@ export default class Drawers {
|
||||||
|
|
||||||
const preference = this.drawerNode.dataset.preference;
|
const preference = this.drawerNode.dataset.preference;
|
||||||
if (preference && updatePreferences && !isSmall()) {
|
if (preference && updatePreferences && !isSmall()) {
|
||||||
M.util.set_user_preference(preference, false);
|
setUserPreference(preference, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const state = this.drawerNode.dataset.state;
|
const state = this.drawerNode.dataset.state;
|
||||||
|
|
|
@ -30,9 +30,6 @@ require_once($CFG->dirroot . '/course/lib.php');
|
||||||
// Add block button in editing mode.
|
// Add block button in editing mode.
|
||||||
$addblockbutton = $OUTPUT->addblockbutton();
|
$addblockbutton = $OUTPUT->addblockbutton();
|
||||||
|
|
||||||
user_preference_allow_ajax_update('drawer-open-index', PARAM_BOOL);
|
|
||||||
user_preference_allow_ajax_update('drawer-open-block', PARAM_BOOL);
|
|
||||||
|
|
||||||
if (isloggedin()) {
|
if (isloggedin()) {
|
||||||
$courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
|
$courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
|
||||||
$blockdraweropen = (get_user_preferences('drawer-open-block') == true);
|
$blockdraweropen = (get_user_preferences('drawer-open-block') == true);
|
||||||
|
|
|
@ -93,6 +93,28 @@ function theme_boost_pluginfile($course, $cm, $context, $filearea, $args, $force
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current user preferences that are available
|
||||||
|
*
|
||||||
|
* @return array[]
|
||||||
|
*/
|
||||||
|
function theme_boost_user_preferences(): array {
|
||||||
|
return [
|
||||||
|
'drawer-open-block' => [
|
||||||
|
'type' => PARAM_BOOL,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'default' => false,
|
||||||
|
'permissioncallback' => [core_user::class, 'is_current_user'],
|
||||||
|
],
|
||||||
|
'drawer-open-index' => [
|
||||||
|
'type' => PARAM_BOOL,
|
||||||
|
'null' => NULL_NOT_ALLOWED,
|
||||||
|
'default' => true,
|
||||||
|
'permissioncallback' => [core_user::class, 'is_current_user'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the main SCSS content.
|
* Returns the main SCSS content.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1822,14 +1822,14 @@ class core_user_external extends \core_external\external_api {
|
||||||
* @throws moodle_exception
|
* @throws moodle_exception
|
||||||
*/
|
*/
|
||||||
public static function set_user_preferences($preferences) {
|
public static function set_user_preferences($preferences) {
|
||||||
global $USER;
|
global $PAGE, $USER;
|
||||||
|
|
||||||
$params = self::validate_parameters(self::set_user_preferences_parameters(), array('preferences' => $preferences));
|
$params = self::validate_parameters(self::set_user_preferences_parameters(), array('preferences' => $preferences));
|
||||||
$warnings = array();
|
$warnings = array();
|
||||||
$saved = array();
|
$saved = array();
|
||||||
|
|
||||||
$context = context_system::instance();
|
$context = context_system::instance();
|
||||||
self::validate_context($context);
|
$PAGE->set_context($context);
|
||||||
|
|
||||||
$userscache = array();
|
$userscache = array();
|
||||||
foreach ($params['preferences'] as $pref) {
|
foreach ($params['preferences'] as $pref) {
|
||||||
|
@ -1855,7 +1855,18 @@ class core_user_external extends \core_external\external_api {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (core_user::can_edit_preference($pref['name'], $user)) {
|
|
||||||
|
// Support legacy preferences from the old M.util.set_user_preference API (always using the current user).
|
||||||
|
if (isset($USER->ajax_updatable_user_prefs[$pref['name']])) {
|
||||||
|
debugging('Updating preferences via ajax_updatable_user_prefs is deprecated. ' .
|
||||||
|
'Please use the "core_user/repository" module instead.', DEBUG_DEVELOPER);
|
||||||
|
|
||||||
|
set_user_preference($pref['name'], $pref['value']);
|
||||||
|
$saved[] = array(
|
||||||
|
'name' => $pref['name'],
|
||||||
|
'userid' => $USER->id,
|
||||||
|
);
|
||||||
|
} else if (core_user::can_edit_preference($pref['name'], $user)) {
|
||||||
$value = core_user::clean_preference($pref['value'], $pref['name']);
|
$value = core_user::clean_preference($pref['value'], $pref['name']);
|
||||||
set_user_preference($pref['name'], $value, $user->id);
|
set_user_preference($pref['name'], $value, $user->id);
|
||||||
$saved[] = array(
|
$saved[] = array(
|
||||||
|
|
|
@ -679,7 +679,6 @@ abstract class user_selector_base {
|
||||||
'" value="1"' . $checked . ' /> ' . $label .
|
'" value="1"' . $checked . ' /> ' . $label .
|
||||||
"</label>
|
"</label>
|
||||||
</div>\n";
|
</div>\n";
|
||||||
user_preference_allow_ajax_update($name, PARAM_BOOL);
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -368,7 +368,9 @@ M.core_user.init_user_selector_options_tracker = function(Y) {
|
||||||
* @param {string} name The name of the preference to set
|
* @param {string} name The name of the preference to set
|
||||||
*/
|
*/
|
||||||
set_user_preference : function(e, name) {
|
set_user_preference : function(e, name) {
|
||||||
M.util.set_user_preference(name, Y.one('#' + name + 'id').get('checked'));
|
require(['core_user/repository'], function(UserRepository) {
|
||||||
|
UserRepository.setUserPreference(name, Y.one('#' + name + 'id').get('checked'));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Initialise the options tracker
|
// Initialise the options tracker
|
||||||
|
|
|
@ -9,6 +9,10 @@ This files describes API changes for code that uses the user API.
|
||||||
* The `core_user/repository` Javascript module now exports new methods for manipulating user preferences:
|
* The `core_user/repository` Javascript module now exports new methods for manipulating user preferences:
|
||||||
- `[get|set]UserPreference`
|
- `[get|set]UserPreference`
|
||||||
- `[get|set]UserPreferences`
|
- `[get|set]UserPreferences`
|
||||||
|
* The following user preference helpers have been deprecated, please use the `core_user/repository` module instead:
|
||||||
|
- `user_preference_allow_ajax_update`
|
||||||
|
- `M.util.set_user_preference`
|
||||||
|
- `lib/ajax/setuserpref.php`
|
||||||
* The external `core_user_set_user_preferences` method will now default the `userid` property of each preference to
|
* The external `core_user_set_user_preferences` method will now default the `userid` property of each preference to
|
||||||
that of the current user, if omitted
|
that of the current user, if omitted
|
||||||
* The following previously deprecated methods have been removed and can no longer be used:
|
* The following previously deprecated methods have been removed and can no longer be used:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue