}
}
- // Ensure the user has the rolldates capability. If not we want to lock this
- // settings so that they cannot change it.
- $hasrolldatescap = has_capability('moodle/restore:rolldates', $coursectx, $userid);
- if ($type == backup::TYPE_1COURSE && !$hasrolldatescap) {
- $datesetting = $restore_controller->get_plan()->get_setting('course_startdate');
- if ($datesetting) {
- $datesetting->set_status(base_setting::LOCKED_BY_PERMISSION);
+ if ($type == backup::TYPE_1COURSE) {
+ // Ensure the user has the rolldates capability. If not we want to lock this
+ // settings so that they cannot change it.
+ $hasrolldatescap = has_capability('moodle/restore:rolldates', $coursectx, $userid);
+ if (!$hasrolldatescap) {
+ $datesetting = $restore_controller->get_plan()->get_setting('course_startdate');
+ if ($datesetting) {
+ $datesetting->set_status(base_setting::LOCKED_BY_PERMISSION);
+ }
+ }
+
+ // Ensure the user has the changefullname capability. If not we want to lock
+ // the setting so that they cannot change it.
+ $haschangefullnamecap = has_capability('moodle/course:changefullname', $coursectx, $userid);
+ if (!$haschangefullnamecap) {
+ $fullnamesetting = $restore_controller->get_plan()->get_setting('course_fullname');
+ $fullnamesetting->set_status(base_setting::LOCKED_BY_PERMISSION);
+ }
+
+ // Ensure the user has the changeshortname capability. If not we want to lock
+ // the setting so that they cannot change it.
+ $haschangeshortnamecap = has_capability('moodle/course:changeshortname', $coursectx, $userid);
+ if (!$haschangeshortnamecap) {
+ $shortnamesetting = $restore_controller->get_plan()->get_setting('course_shortname');
+ $shortnamesetting->set_status(base_setting::LOCKED_BY_PERMISSION);
+ }
+
+ // Ensure the user has the update capability. If not we want to lock
+ // the overwrite setting so that they cannot change it.
+ $hasupdatecap = has_capability('moodle/course:update', $coursectx, $userid);
+ if (!$hasupdatecap) {
+ $overwritesetting = $restore_controller->get_plan()->get_setting('overwrite_conf');
+ $overwritesetting->set_status(base_setting::LOCKED_BY_PERMISSION);
}
}