]> git.mjollnir.org Git - moodle.git/commitdiff
fixed logic of moodle_install_roles() - it now calls update_capabilities() after...
authorskodak <skodak>
Wed, 27 Sep 2006 22:59:37 +0000 (22:59 +0000)
committerskodak <skodak>
Wed, 27 Sep 2006 22:59:37 +0000 (22:59 +0000)
admin/index.php
lib/accesslib.php

index aeed1b7ec5f3b49233508af4dc8f7010c4d6e240..2075457c0798d68064b5ceba7461141e48fb431f 100644 (file)
         if ($status) {
             // Install the roles system.
             moodle_install_roles();
-            if (!update_capabilities()) {
-                error('Had trouble installing the core capabilities for the Roles System');
-            }
             set_config('statsrolesupgraded',time());
 
             // Write default settings unconditionally (i.e. even if a setting is already set, overwrite it)
                     if (empty($CFG->rolesactive)) {
                         // Upgrade to the roles system.
                         moodle_install_roles();
-                    }
-                    if (!update_capabilities()) {
-                        error('Had trouble upgrading the core capabilities for the Roles System');
-                    } else {
                         set_config('rolesactive', 1);
+                    } else if (!update_capabilities()) {
+                        error('Had trouble upgrading the core capabilities for the Roles System');
                     }
                     require_once($CFG->libdir.'/statslib.php');
                     if (!stats_upgrade_for_roles_wrapper()) {
index 16e625d589c450bea88e2bfc374459a5f582d843..4f6fb518f96e36d90df4007c30bf00b43f1d8d95 100755 (executable)
@@ -932,6 +932,10 @@ function moodle_install_roles() {
     $studentrole = create_role(get_string('defaultcoursestudent'), 'student', get_string('defaultcoursestudentdescription'), 'moodle/legacy:student');
     $guestrole = create_role(get_string('guest'), 'guest', get_string('guestdescription'), 'moodle/legacy:guest');
 
+    // now is the correct moment to install capabilitites - after creation of legacy roles, but before assigning of roles
+    if (!update_capabilities()) {
+        error('Had trouble upgrading the core capabilities for the Roles System');
+    }
 
     // Look inside user_admin, user_creator, user_teachers, user_students and
     // assign above new roles. If a user has both teacher and student role,