From 3ed699287e19e29cc5f26b5260e83f1f2f4b4ec4 Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Wed, 28 Mar 2007 02:31:24 +0000 Subject: [PATCH] merged fix for MDL-9064, use $CFG->creatornewroleid setting --- backup/restorelib.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/backup/restorelib.php b/backup/restorelib.php index 6e51e4a267..bf0f95aeb0 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -6296,12 +6296,17 @@ // fix for MDL-6831 $newcontext = get_context_instance(CONTEXT_COURSE, $restore->course_id); if (!has_capability('moodle/course:manageactivities', $newcontext)) { - if ($legacyteachers = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM, SITEID))) { - if ($legacyteacher = array_shift($legacyteachers)) { - role_assign($legacyteacher->id, $USER->id, 0, $newcontext->id); - } + // fix for MDL-9065, use the new config setting if exists + if ($CFG->creatornewroleid) { + role_assign($CFG->creatornewroleid, $USER->id, 0, $newcontext->id); } else { - notify('Could not find a legacy teacher role. You might need your moodle admin to assign a role with editing privilages to this course.'); + if ($legacyteachers = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if ($legacyteacher = array_shift($legacyteachers)) { + role_assign($legacyteacher->id, $USER->id, 0, $newcontext->id); + } + } else { + notify('Could not find a legacy teacher role. You might need your moodle admin to assign a role with editing privilages to this course.'); + } } } if (!defined('RESTORE_SILENTLY')) { -- 2.39.5