mirror of
https://github.com/moodle/moodle.git
synced 2025-03-15 05:00:06 +01:00
MDL-29591 Check for permission before overwriting course idnumber when restoring
This commit is contained in:
parent
6be90ce05f
commit
7d7d82de03
@ -1102,7 +1102,6 @@ class restore_course_structure_step extends restore_structure_step {
|
|||||||
global $CFG, $DB;
|
global $CFG, $DB;
|
||||||
|
|
||||||
$data = (object)$data;
|
$data = (object)$data;
|
||||||
$oldid = $data->id; // We'll need this later
|
|
||||||
|
|
||||||
$fullname = $this->get_setting_value('course_fullname');
|
$fullname = $this->get_setting_value('course_fullname');
|
||||||
$shortname = $this->get_setting_value('course_shortname');
|
$shortname = $this->get_setting_value('course_shortname');
|
||||||
@ -1115,7 +1114,13 @@ class restore_course_structure_step extends restore_structure_step {
|
|||||||
$data->id = $this->get_courseid();
|
$data->id = $this->get_courseid();
|
||||||
$data->fullname = $fullname;
|
$data->fullname = $fullname;
|
||||||
$data->shortname= $shortname;
|
$data->shortname= $shortname;
|
||||||
$data->idnumber = '';
|
|
||||||
|
$context = get_context_instance_by_id($this->task->get_contextid());
|
||||||
|
if (has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
|
||||||
|
$data->idnumber = '';
|
||||||
|
} else {
|
||||||
|
unset($data->idnumber);
|
||||||
|
}
|
||||||
|
|
||||||
// Only restrict modules if original course was and target site too for new courses
|
// Only restrict modules if original course was and target site too for new courses
|
||||||
$data->restrictmodules = $data->restrictmodules && !empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor == 'all';
|
$data->restrictmodules = $data->restrictmodules && !empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor == 'all';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user