mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
install: MDL-19610 encapsulate empty($CFG->rolesactive) checks in a during_initial_install() function.
This commit is contained in:
parent
6847d4d824
commit
31a9987770
@ -244,9 +244,10 @@ if ($release <> $CFG->release) { // Update the release version
|
|||||||
// upgrade all plugins and other parts
|
// upgrade all plugins and other parts
|
||||||
upgrade_noncore(true);
|
upgrade_noncore(true);
|
||||||
|
|
||||||
// indicate that this site is fully configured except the admin password
|
// If this is the first install, indicate that this site is fully configured
|
||||||
if (empty($CFG->rolesactive)) {
|
// except the admin password
|
||||||
set_config('rolesactive', 1);
|
if (during_initial_install()) {
|
||||||
|
set_config('rolesactive', 1); // after this, during_initial_install will return false.
|
||||||
set_config('adminsetuppending', 1);
|
set_config('adminsetuppending', 1);
|
||||||
// we neeed this redirect to setup proper session
|
// we neeed this redirect to setup proper session
|
||||||
upgrade_finished("index.php?sessionstarted=1&lang=$CFG->lang");
|
upgrade_finished("index.php?sessionstarted=1&lang=$CFG->lang");
|
||||||
|
@ -82,7 +82,7 @@ if ($hassiteconfig
|
|||||||
// "userpolicies" settingpage
|
// "userpolicies" settingpage
|
||||||
$temp = new admin_settingpage('userpolicies', get_string('userpolicies', 'admin'));
|
$temp = new admin_settingpage('userpolicies', get_string('userpolicies', 'admin'));
|
||||||
if ($ADMIN->fulltree) {
|
if ($ADMIN->fulltree) {
|
||||||
if (!empty($CFG->rolesactive)) {
|
if (!during_initial_install()) {
|
||||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||||
if (!$guestrole = get_guest_role()) {
|
if (!$guestrole = get_guest_role()) {
|
||||||
$guestrole->id = 0;
|
$guestrole->id = 0;
|
||||||
@ -138,7 +138,7 @@ if ($hassiteconfig
|
|||||||
|
|
||||||
$temp->add(new admin_setting_configcheckbox('nodefaultuserrolelists', get_string('nodefaultuserrolelists', 'admin'), get_string('confignodefaultuserrolelists', 'admin'), 0));
|
$temp->add(new admin_setting_configcheckbox('nodefaultuserrolelists', get_string('nodefaultuserrolelists', 'admin'), get_string('confignodefaultuserrolelists', 'admin'), 0));
|
||||||
|
|
||||||
if (!empty($CFG->rolesactive)) {
|
if (!during_initial_install()) {
|
||||||
$temp->add(new admin_setting_configselect('defaultcourseroleid', get_string('defaultcourseroleid', 'admin'),
|
$temp->add(new admin_setting_configselect('defaultcourseroleid', get_string('defaultcourseroleid', 'admin'),
|
||||||
get_string('configdefaultcourseroleid', 'admin'), $studentrole->id, $allroles));
|
get_string('configdefaultcourseroleid', 'admin'), $studentrole->id, $allroles));
|
||||||
$temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'),
|
$temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'),
|
||||||
@ -147,7 +147,7 @@ if ($hassiteconfig
|
|||||||
|
|
||||||
$temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
|
$temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
|
||||||
|
|
||||||
if (!empty($CFG->rolesactive)) {
|
if (!during_initial_install()) {
|
||||||
$temp->add(new admin_setting_configmultiselect('nonmetacoursesyncroleids', get_string('nonmetacoursesyncroleids', 'admin'),
|
$temp->add(new admin_setting_configmultiselect('nonmetacoursesyncroleids', get_string('nonmetacoursesyncroleids', 'admin'),
|
||||||
get_string('confignonmetacoursesyncroleids', 'admin'), array(), $allroles));
|
get_string('confignonmetacoursesyncroleids', 'admin'), array(), $allroles));
|
||||||
}
|
}
|
||||||
|
@ -453,7 +453,7 @@ function get_guest_role() {
|
|||||||
function has_capability($capability, $context, $userid=NULL, $doanything=true) {
|
function has_capability($capability, $context, $userid=NULL, $doanything=true) {
|
||||||
global $USER, $CFG, $DB, $SCRIPT, $ACCESSLIB_PRIVATE;
|
global $USER, $CFG, $DB, $SCRIPT, $ACCESSLIB_PRIVATE;
|
||||||
|
|
||||||
if (empty($CFG->rolesactive)) {
|
if (during_initial_install()) {
|
||||||
if ($SCRIPT === "/$CFG->admin/index.php" or $SCRIPT === "/$CFG->admin/cliupgrade.php") {
|
if ($SCRIPT === "/$CFG->admin/index.php" or $SCRIPT === "/$CFG->admin/cliupgrade.php") {
|
||||||
// we are in an installer - roles can not work yet
|
// we are in an installer - roles can not work yet
|
||||||
return true;
|
return true;
|
||||||
@ -1768,7 +1768,7 @@ function load_all_capabilities() {
|
|||||||
global $USER, $CFG, $ACCESSLIB_PRIVATE;
|
global $USER, $CFG, $ACCESSLIB_PRIVATE;
|
||||||
|
|
||||||
// roles not installed yet - we are in the middle of installation
|
// roles not installed yet - we are in the middle of installation
|
||||||
if (empty($CFG->rolesactive)) {
|
if (during_initial_install()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6207,7 +6207,7 @@ function get_dirty_contexts($time) {
|
|||||||
function mark_context_dirty($path) {
|
function mark_context_dirty($path) {
|
||||||
global $CFG, $ACCESSLIB_PRIVATE;
|
global $CFG, $ACCESSLIB_PRIVATE;
|
||||||
|
|
||||||
if (empty($CFG->rolesactive)) {
|
if (during_initial_install()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1260,7 +1260,7 @@ abstract class admin_setting {
|
|||||||
|
|
||||||
// log change
|
// log change
|
||||||
$log = new object();
|
$log = new object();
|
||||||
$log->userid = empty($CFG->rolesactive) ? 0 :$USER->id; // 0 as user id during install
|
$log->userid = during_initial_install() ? 0 :$USER->id; // 0 as user id during install
|
||||||
$log->timemodified = time();
|
$log->timemodified = time();
|
||||||
$log->plugin = $this->plugin;
|
$log->plugin = $this->plugin;
|
||||||
$log->name = $name;
|
$log->name = $name;
|
||||||
@ -3713,7 +3713,7 @@ class admin_setting_pickroles extends admin_setting_configmulticheckbox {
|
|||||||
*/
|
*/
|
||||||
public function load_choices() {
|
public function load_choices() {
|
||||||
global $CFG, $DB;
|
global $CFG, $DB;
|
||||||
if (empty($CFG->rolesactive)) {
|
if (during_initial_install()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (is_array($this->choices)) {
|
if (is_array($this->choices)) {
|
||||||
@ -3738,7 +3738,7 @@ class admin_setting_pickroles extends admin_setting_configmulticheckbox {
|
|||||||
public function get_defaultsetting() {
|
public function get_defaultsetting() {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
if (empty($CFG->rolesactive)) {
|
if (during_initial_install()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$result = array();
|
$result = array();
|
||||||
|
@ -608,7 +608,7 @@ class moodle_page {
|
|||||||
protected function starting_output() {
|
protected function starting_output() {
|
||||||
global $SITE, $CFG;
|
global $SITE, $CFG;
|
||||||
|
|
||||||
if (empty($CFG->rolesactive)) {
|
if (during_initial_install()) {
|
||||||
$this->_course = new stdClass;
|
$this->_course = new stdClass;
|
||||||
$this->_course->id = 1;
|
$this->_course->id = 1;
|
||||||
moodle_setlocale();
|
moodle_setlocale();
|
||||||
|
@ -352,6 +352,21 @@ function init_performance_info() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether we are in the middle of the initial Moodle install.
|
||||||
|
*
|
||||||
|
* Very occasionally it is necessary avoid running certain bits of code before the
|
||||||
|
* Moodle installation has completed. The installed flag is set in admin/index.php
|
||||||
|
* after Moodle core and all the plugins have been installed, but just before
|
||||||
|
* the person doing the initial install is asked to choose the admin password.
|
||||||
|
*
|
||||||
|
* @return boolean true if the initial install is not complete.
|
||||||
|
*/
|
||||||
|
function during_initial_install() {
|
||||||
|
global $CFG;
|
||||||
|
return empty($CFG->rolesactive);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to raise the memory limit to a new value.
|
* Function to raise the memory limit to a new value.
|
||||||
* Will respect the memory limit if it is higher, thus allowing
|
* Will respect the memory limit if it is higher, thus allowing
|
||||||
|
@ -3688,13 +3688,13 @@ function build_navigation($extranavlinks, $cm = null) {
|
|||||||
// Work out whether we should be showing the activity (e.g. Forums) link.
|
// Work out whether we should be showing the activity (e.g. Forums) link.
|
||||||
// Note: build_navigation() is called from many places --
|
// Note: build_navigation() is called from many places --
|
||||||
// install & upgrade for example -- where we cannot count on the
|
// install & upgrade for example -- where we cannot count on the
|
||||||
// roles infrastructure to be defined. Hence the $CFG->rolesactive check.
|
// roles infrastructure to be defined. Hence the during_initial_install() check.
|
||||||
if (!isset($CFG->hideactivitytypenavlink)) {
|
if (!isset($CFG->hideactivitytypenavlink)) {
|
||||||
$CFG->hideactivitytypenavlink = 0;
|
$CFG->hideactivitytypenavlink = 0;
|
||||||
}
|
}
|
||||||
if ($CFG->hideactivitytypenavlink == 2) {
|
if ($CFG->hideactivitytypenavlink == 2) {
|
||||||
$hideactivitylink = true;
|
$hideactivitylink = true;
|
||||||
} else if ($CFG->hideactivitytypenavlink == 1 && $CFG->rolesactive &&
|
} else if ($CFG->hideactivitytypenavlink == 1 && !during_initial_install() &&
|
||||||
!empty($COURSE->id) && $COURSE->id != SITEID) {
|
!empty($COURSE->id) && $COURSE->id != SITEID) {
|
||||||
if (!isset($COURSE->context)) {
|
if (!isset($COURSE->context)) {
|
||||||
$COURSE->context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
|
$COURSE->context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
|
||||||
@ -6931,7 +6931,7 @@ function convert_tabrows_to_tree($tabrows, $selected, $inactive, $activated) {
|
|||||||
function page_doc_link($text='', $iconpath='') {
|
function page_doc_link($text='', $iconpath='') {
|
||||||
global $CFG, $PAGE;
|
global $CFG, $PAGE;
|
||||||
|
|
||||||
if (empty($CFG->docroot) || empty($CFG->rolesactive)) {
|
if (empty($CFG->docroot) || during_initial_install()) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if (!has_capability('moodle/site:doclinks', $PAGE->context)) {
|
if (!has_capability('moodle/site:doclinks', $PAGE->context)) {
|
||||||
|
@ -64,7 +64,7 @@ class mnet_environment {
|
|||||||
|
|
||||||
// We don't generate keys on install/upgrade because we want the USER
|
// We don't generate keys on install/upgrade because we want the USER
|
||||||
// record to have an email address, city and country already.
|
// record to have an email address, city and country already.
|
||||||
if (empty($CFG->rolesactive)) return true;
|
if (during_initial_install()) return true;
|
||||||
if ($CFG->mnet_dispatcher_mode == 'off') return true;
|
if ($CFG->mnet_dispatcher_mode == 'off') return true;
|
||||||
if (!extension_loaded("openssl")) return true;
|
if (!extension_loaded("openssl")) return true;
|
||||||
if (!empty($this->keypair)) return true;
|
if (!empty($this->keypair)) return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user