From 250934b8e07a66182ed78e14177ee4c93904f98a Mon Sep 17 00:00:00 2001 From: skodak Date: Wed, 27 Sep 2006 22:59:37 +0000 Subject: [PATCH] fixed logic of moodle_install_roles() - it now calls update_capabilities() after creation of default roles, but before first role_assign(). The problem was that role_assign calls code from forum lib which already uses capabilities, this might cause even bigger problems later. --- admin/index.php | 9 ++------- lib/accesslib.php | 4 ++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/admin/index.php b/admin/index.php index aeed1b7ec5..2075457c07 100644 --- a/admin/index.php +++ b/admin/index.php @@ -147,9 +147,6 @@ 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) @@ -247,11 +244,9 @@ 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()) { diff --git a/lib/accesslib.php b/lib/accesslib.php index 16e625d589..4f6fb518f9 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -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, -- 2.39.5