mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-47686 assign: Fix restoring from a mod_assignment backup.
This was only working for admins.
This commit is contained in:
parent
ec72585d64
commit
127b3915df
1 changed files with 8 additions and 5 deletions
|
@ -56,11 +56,6 @@ class assign_upgrade_manager {
|
||||||
global $DB, $CFG, $USER;
|
global $DB, $CFG, $USER;
|
||||||
// Steps to upgrade an assignment.
|
// Steps to upgrade an assignment.
|
||||||
|
|
||||||
// Is the user the admin? admin check goes here.
|
|
||||||
if (!is_siteadmin($USER->id)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
core_php_time_limit::raise(ASSIGN_MAX_UPGRADE_TIME_SECS);
|
core_php_time_limit::raise(ASSIGN_MAX_UPGRADE_TIME_SECS);
|
||||||
|
|
||||||
// Get the module details.
|
// Get the module details.
|
||||||
|
@ -71,6 +66,14 @@ class assign_upgrade_manager {
|
||||||
'*',
|
'*',
|
||||||
MUST_EXIST);
|
MUST_EXIST);
|
||||||
$oldcontext = context_module::instance($oldcoursemodule->id);
|
$oldcontext = context_module::instance($oldcoursemodule->id);
|
||||||
|
// We used to check for admin capability, but since Moodle 2.7 this is called
|
||||||
|
// during restore of a mod_assignment module.
|
||||||
|
// Also note that we do not check for any mod_assignment capabilities, because they can
|
||||||
|
// be removed so that users don't add new instances of the broken old thing.
|
||||||
|
if (!has_capability('mod/assign:addinstance', $oldcontext)) {
|
||||||
|
$log = get_string('couldnotcreatenewassignmentinstance', 'mod_assign');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// First insert an assign instance to get the id.
|
// First insert an assign instance to get the id.
|
||||||
$oldassignment = $DB->get_record('assignment', array('id'=>$oldassignmentid), '*', MUST_EXIST);
|
$oldassignment = $DB->get_record('assignment', array('id'=>$oldassignmentid), '*', MUST_EXIST);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue