Permalink
Browse files

MDL-29591 Check for permission before overwriting course idnumber whe…

…n restoring
  • Loading branch information...
1 parent 50f0c58 commit f7aef5c6481676d8a0f472adf904987c4e08476e @andrewnicols andrewnicols committed with stronk7 Sep 30, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 backup/moodle2/restore_stepslib.php
@@ -1096,7 +1096,6 @@ public function process_course($data) {
global $CFG, $DB;
$data = (object)$data;
- $oldid = $data->id; // We'll need this later
$fullname = $this->get_setting_value('course_fullname');
$shortname = $this->get_setting_value('course_shortname');
@@ -1109,7 +1108,13 @@ public function process_course($data) {
$data->id = $this->get_courseid();
$data->fullname = $fullname;
$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
$data->restrictmodules = $data->restrictmodules && !empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor == 'all';

0 comments on commit f7aef5c

Please sign in to comment.