]> git.mjollnir.org Git - moodle.git/commitdiff
merged fix for MDL-9064, use $CFG->creatornewroleid setting
authortoyomoyo <toyomoyo>
Wed, 28 Mar 2007 02:31:24 +0000 (02:31 +0000)
committertoyomoyo <toyomoyo>
Wed, 28 Mar 2007 02:31:24 +0000 (02:31 +0000)
backup/restorelib.php

index 6e51e4a2678b23437cccc29838fa7bede4efd69a..bf0f95aeb0007b4921a18c0c6a5fb9ed60e97937 100644 (file)
             // 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')) {