Merge branch 'MDL-69079-master-1' of git://github.com/mihailges/moodle

This commit is contained in:
Adrian Greeve 2020-07-27 08:48:58 +08:00
commit 0f70cf0497
7 changed files with 89 additions and 4 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -133,7 +133,18 @@ const registerListenerEvents = (courseId, chooserConfig) => {
const sectionModal = buildModal(bodyPromise, footerData);
// Now we have a modal we should start fetching data.
const data = await fetchModuleData();
// If an error occurs while fetching the data, display the error within the modal.
const data = await fetchModuleData().catch(async(e) => {
const errorTemplateData = {
'errormessage': e.message
};
bodyPromiseResolver(await Templates.render('core_course/local/activitychooser/error', errorTemplateData));
});
// Early return if there is no module data.
if (!data) {
return;
}
// Apply the section id to all the module instance links.
const builtModuleData = sectionIdMapper(data, caller.dataset.sectionid, caller.dataset.sectionreturnid);

View File

@ -105,6 +105,11 @@ class content_item_service {
return $favmods;
}
// Make sure the guest user exists in the database.
if (!\core_user::get_user($CFG->siteguest)) {
throw new \coding_exception('The guest user does not exist in the database.');
}
$favourites = $this->get_content_favourites(self::RECOMMENDATION_PREFIX, \context_user::instance($CFG->siteguest));
$recommendationcache->set($CFG->siteguest, $favourites);

View File

@ -0,0 +1,39 @@
{{!
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/>.
}}
{{!
@template core_course/local/activitychooser/error
Chooser error template.
Variables required for this template:
* errormessage - The error message
Example context (json):
{
"errormessage": "Error"
}
}}
<div class="p-2 px-sm-5 py-sm-4">
<div class="alert alert-danger" role="alert">
<h5 class="alert-heading">
<i class="fa fa-exclamation-circle fa-fw text-danger"></i>
{{#str}} error, error {{/str}}
</h5>
<hr>
<p class="text-break">{{{errormessage}}}</p>
</div>
</div>

View File

@ -2509,5 +2509,35 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2020071100.01);
}
if ($oldversion < 2020072300.01) {
// Restore and set the guest user if it has been previously removed via GDPR, or set to an nonexistent
// user account.
$currentguestuser = $DB->get_record('user', array('id' => $CFG->siteguest));
if (!$currentguestuser) {
if (!$guest = $DB->get_record('user', array('username' => 'guest', 'mnethostid' => $CFG->mnet_localhost_id))) {
// Create a guest user account.
$guest = new stdClass();
$guest->auth = 'manual';
$guest->username = 'guest';
$guest->password = hash_internal_user_password('guest');
$guest->firstname = get_string('guestuser');
$guest->lastname = ' ';
$guest->email = 'root@localhost';
$guest->description = get_string('guestuserinfo');
$guest->mnethostid = $CFG->mnet_localhost_id;
$guest->confirmed = 1;
$guest->lang = $CFG->lang;
$guest->timemodified= time();
$guest->id = $DB->insert_record('user', $guest);
}
// Set the guest user.
set_config('siteguest', $guest->id);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2020072300.01);
}
return true;
}

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2020072300.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2020072300.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.0dev (Build: 20200723)'; // Human-friendly version name