mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
(MDL-8250) install/upgrade autopilot
This commit is contained in:
parent
9f741612e5
commit
371a32e308
@ -27,7 +27,9 @@
|
||||
|
||||
$id = optional_param('id', '', PARAM_ALPHANUM);
|
||||
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
|
||||
$agreelicence = optional_param('agreelicence',0, PARAM_BOOL);
|
||||
$confirmrelease = optional_param('confirmrelease', 0, PARAM_BOOL);
|
||||
$agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
|
||||
$autopilot = optional_param('autopilot', 0, PARAM_BOOL);
|
||||
$ignoreupgradewarning = optional_param('ignoreupgradewarning', 0, PARAM_BOOL);
|
||||
|
||||
/// check upgrade status first
|
||||
@ -36,6 +38,11 @@
|
||||
}
|
||||
upgrade_check_running("Upgrade already running in this session, please wait!<br />Click on the exclamation marks to ignore this warning (<a href=\"index.php?ignoreupgradewarning=1\">!!!</a>).", 10);
|
||||
|
||||
/// set install/upgrade autocontinue session flag
|
||||
if ($autopilot) {
|
||||
$_SESSION['installautopilot'] = $autopilot;
|
||||
}
|
||||
|
||||
/// Check some PHP server settings
|
||||
|
||||
$documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
|
||||
@ -107,29 +114,42 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$linktoscrolltoerrors = '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>';
|
||||
if (! $maintables) {
|
||||
/// hide errors from headers in case debug enabled in config.php
|
||||
$origdebug = $CFG->debug;
|
||||
$CFG->debug = DEBUG_MINIMAL;
|
||||
error_reporting($CFG->debug);
|
||||
if (empty($agreelicence)) {
|
||||
if (empty($agreelicense)) {
|
||||
$strlicense = get_string('license');
|
||||
print_header($strlicense, $strlicense, $strlicense, "", "", false, " ", " ");
|
||||
print_heading("<a href=\"http://moodle.org\">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment");
|
||||
print_heading(get_string('copyrightnotice'));
|
||||
print_box(text_to_html(get_string('gpl')), 'copyrightnotice');
|
||||
echo "<br />";
|
||||
notice_yesno(get_string('doyouagree'), "index.php?agreelicence=true",
|
||||
notice_yesno(get_string('doyouagree'), "index.php?agreelicense=1",
|
||||
"http://docs.moodle.org/en/License");
|
||||
exit;
|
||||
}
|
||||
if (empty($confirmrelease)) {
|
||||
$strcurrentrelease = get_string("currentrelease");
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, " ", " ");
|
||||
print_heading("Moodle $release");
|
||||
print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'));
|
||||
echo '<form action="index.php"><fieldset class="invisiblefieldset">';
|
||||
echo '<input type="hidden" name="agreelicense" value="1" />';
|
||||
echo '<input type="hidden" name="confirmrelease" value="1" />';
|
||||
echo '</fieldset>';
|
||||
echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="1" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
|
||||
echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
|
||||
echo '</form>';
|
||||
print_footer('none');
|
||||
die;
|
||||
}
|
||||
|
||||
$strdatabasesetup = get_string("databasesetup");
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup,
|
||||
"", $linktoscrolltoerrors, false, " ", " ");
|
||||
"", upgrade_get_javascript(), false, " ", " ");
|
||||
/// return to original debugging level
|
||||
$CFG->debug = $origdebug;
|
||||
error_reporting($CFG->debug);
|
||||
@ -238,18 +258,30 @@
|
||||
}
|
||||
|
||||
if (empty($confirmupgrade)) {
|
||||
|
||||
|
||||
print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
|
||||
"", "", false, " ", " ");
|
||||
|
||||
notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=yes', 'index.php');
|
||||
notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=1', 'index.php');
|
||||
exit;
|
||||
|
||||
} else if (empty($confirmrelease)){
|
||||
$strcurrentrelease = get_string("currentrelease");
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, " ", " ");
|
||||
print_heading("Moodle $release");
|
||||
print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'));
|
||||
echo '<form action="index.php"><fieldset class="invisiblefieldset">';
|
||||
echo '<input type="hidden" name="confirmupgrade" value="1" />';
|
||||
echo '<input type="hidden" name="confirmrelease" value="1" />';
|
||||
echo '</fieldset>';
|
||||
echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="0" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
|
||||
echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
|
||||
echo '</form>';
|
||||
print_footer('none');
|
||||
die;
|
||||
} else {
|
||||
$strdatabasesuccess = get_string("databasesuccess");
|
||||
print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
|
||||
"", $linktoscrolltoerrors, false, " ", " ");
|
||||
"", upgrade_get_javascript(), false, " ", " ");
|
||||
|
||||
/// return to original debugging level
|
||||
$CFG->debug = $origdebug;
|
||||
@ -313,13 +345,9 @@
|
||||
/// Updated human-readable release version if necessary
|
||||
|
||||
if ($release <> $CFG->release) { // Update the release version
|
||||
$strcurrentrelease = get_string("currentrelease");
|
||||
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, " ", " ");
|
||||
print_heading("Moodle $release");
|
||||
if (!set_config("release", $release)) {
|
||||
notify("ERROR: Could not update release version in database!!");
|
||||
}
|
||||
notice(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'), 'index.php', 'none');
|
||||
}
|
||||
|
||||
/// Find and check all main modules and load them up or upgrade them if necessary
|
||||
@ -369,6 +397,8 @@
|
||||
/// just make sure upgrade logging is properly terminated
|
||||
upgrade_log_finish();
|
||||
|
||||
unset($_SESSION['installautopilot']);
|
||||
|
||||
/// Set up the blank site - to be customized later at the end of install.
|
||||
if (! $site = get_site()) {
|
||||
// We are about to create the site "course"
|
||||
|
@ -326,8 +326,7 @@
|
||||
if (empty($CFG->backup_version)) { // Backup has never been installed.
|
||||
$strdatabaseupgrades = get_string("databaseupgrades");
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, "",
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
|
||||
false, " ", " ");
|
||||
upgrade_get_javascript(), false, " ", " ");
|
||||
|
||||
upgrade_log_start();
|
||||
print_heading('backup');
|
||||
@ -375,8 +374,7 @@
|
||||
|
||||
if ($backup_version > $CFG->backup_version) { // Upgrade tables
|
||||
$strdatabaseupgrades = get_string("databaseupgrades");
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>');
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', upgrade_get_javascript());
|
||||
|
||||
upgrade_log_start();
|
||||
print_heading('backup');
|
||||
|
@ -31,8 +31,7 @@ function upgrade_group_db($continueto) {
|
||||
|
||||
$strdatabaseupgrades = get_string('databaseupgrades');
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
|
||||
false, " ", " ");
|
||||
upgrade_get_javascript(), false, " ", " ");
|
||||
|
||||
upgrade_log_start();
|
||||
print_heading('group');
|
||||
@ -90,8 +89,7 @@ function upgrade_group_db($continueto) {
|
||||
|
||||
if ($group_version > $CFG->group_version) { // Upgrade tables
|
||||
$strdatabaseupgrades = get_string('databaseupgrades');
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>');
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', upgrade_get_javascript());
|
||||
|
||||
upgrade_log_start();
|
||||
print_heading('group');
|
||||
|
@ -517,6 +517,7 @@ $string['timezoneforced'] = 'This is forced by the site administrator';
|
||||
$string['timezoneisforcedto'] = 'Force all users to use';
|
||||
$string['timezonenotforced'] = 'Users can choose their own timezone';
|
||||
$string['tokenizerrecommended'] = 'Installing the optional PHP Tokenizer extension is recommended -- it improves Moodle Networking functionality.';
|
||||
$string['unattendedoperation'] = 'Unattended operation';
|
||||
$string['unbookmarkthispage'] = 'unbookmark this page';
|
||||
$string['unicodeupgradenotice'] = 'In Moodle 1.6 we have migrated all languages to Unicode. To complete the upgrade for this site, you need to convert all the data in your database to Unicode (UTF-8) using our migration script. <a href=\"utfdbmigrate.php\">Click here to run the migration script now</a>!';
|
||||
$string['unicoderecommended'] = 'Storing all your data in Unicode (UTF-8) is recommended. New installations should be performed into databases that have their default character set as Unicode. If you are upgrading, you should perform the UTF-8 migration process (see the Admin page).';
|
||||
|
@ -64,8 +64,7 @@ function upgrade_plugins($type, $dir, $return) {
|
||||
$info->requiremoodle = $plugin->requires;
|
||||
if (!$updated_plugins) {
|
||||
print_header($strpluginsetup, $strpluginsetup, $strpluginsetup, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
|
||||
false, ' ', ' ');
|
||||
upgrade_get_javascript(), false, ' ', ' ');
|
||||
}
|
||||
upgrade_log_start();
|
||||
notify(get_string('pluginrequirementsnotmet', 'error', $info));
|
||||
@ -87,8 +86,7 @@ function upgrade_plugins($type, $dir, $return) {
|
||||
} else if ($CFG->$pluginversion < $plugin->version) {
|
||||
if (!$updated_plugins) {
|
||||
print_header($strpluginsetup, $strpluginsetup, $strpluginsetup, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
|
||||
false, ' ', ' ');
|
||||
upgrade_get_javascript(), false, ' ', ' ');
|
||||
}
|
||||
$updated_plugins = true;
|
||||
upgrade_log_start();
|
||||
@ -234,8 +232,7 @@ function upgrade_activity_modules($return) {
|
||||
$info->requiremoodle = $module->requires;
|
||||
if (!$updated_modules) {
|
||||
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
|
||||
false, ' ', ' ');
|
||||
upgrade_get_javascript(), false, ' ', ' ');
|
||||
}
|
||||
upgrade_log_start();
|
||||
notify(get_string('modulerequirementsnotmet', 'error', $info));
|
||||
@ -258,8 +255,7 @@ function upgrade_activity_modules($return) {
|
||||
}
|
||||
if (!$updated_modules) {
|
||||
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
|
||||
false, ' ', ' ');
|
||||
upgrade_get_javascript(), false, ' ', ' ');
|
||||
}
|
||||
upgrade_log_start();
|
||||
print_heading($module->name .' module needs upgrading');
|
||||
@ -318,8 +314,7 @@ function upgrade_activity_modules($return) {
|
||||
} else { // module not installed yet, so install it
|
||||
if (!$updated_modules) {
|
||||
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
|
||||
false, ' ', ' ');
|
||||
upgrade_get_javascript(), false, ' ', ' ');
|
||||
}
|
||||
upgrade_log_start();
|
||||
print_heading($module->name);
|
||||
@ -474,6 +469,18 @@ function print_progress($done, $total, $updatetime=5, $sleeptime=1, $donetext=''
|
||||
}
|
||||
}
|
||||
|
||||
function upgrade_get_javascript() {
|
||||
global $CFG;
|
||||
|
||||
if (!empty($_SESSION['installautopilot'])) {
|
||||
$linktoscrolltoerrors = '<script type="text/javascript">var installautopilot = true;</script>'."\n";
|
||||
} else {
|
||||
$linktoscrolltoerrors = '<script type="text/javascript">var installautopilot = false;</script>'."\n";
|
||||
}
|
||||
$linktoscrolltoerrors .= '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>';
|
||||
|
||||
return $linktoscrolltoerrors;
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
/// upgrade logging functions
|
||||
////////////////////////////////////////////////
|
||||
|
@ -1017,8 +1017,7 @@ function upgrade_blocks_db($continueto) {
|
||||
if (empty($CFG->blocks_version)) { // Blocks have never been installed.
|
||||
$strdatabaseupgrades = get_string('databaseupgrades');
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
|
||||
false, ' ', ' ');
|
||||
upgrade_get_javascript(), false, ' ', ' ');
|
||||
|
||||
upgrade_log_start();
|
||||
print_heading('blocks');
|
||||
@ -1063,8 +1062,7 @@ function upgrade_blocks_db($continueto) {
|
||||
|
||||
if ($blocks_version > $CFG->blocks_version) { // Upgrade tables
|
||||
$strdatabaseupgrades = get_string('databaseupgrades');
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>');
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', upgrade_get_javascript());
|
||||
|
||||
upgrade_log_start();
|
||||
print_heading('blocks');
|
||||
@ -1230,8 +1228,7 @@ function upgrade_blocks_plugins($continueto) {
|
||||
if (empty($updated_blocks)) {
|
||||
$strblocksetup = get_string('blocksetup');
|
||||
print_header($strblocksetup, $strblocksetup, $strblocksetup, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
|
||||
false, ' ', ' ');
|
||||
upgrade_get_javascript(), false, ' ', ' ');
|
||||
}
|
||||
$updated_blocks = true;
|
||||
upgrade_log_start();
|
||||
@ -1303,8 +1300,7 @@ function upgrade_blocks_plugins($continueto) {
|
||||
if (empty($updated_blocks)) {
|
||||
$strblocksetup = get_string('blocksetup');
|
||||
print_header($strblocksetup, $strblocksetup, $strblocksetup, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
|
||||
false, ' ', ' ');
|
||||
upgrade_get_javascript(), false, ' ', ' ');
|
||||
}
|
||||
$updated_blocks = true;
|
||||
upgrade_log_start();
|
||||
|
@ -90,8 +90,7 @@ function upgrade_local_db($continueto) {
|
||||
|
||||
if ($local_version > $CFG->local_version) { // upgrade!
|
||||
$strdatabaseupgrades = get_string('databaseupgrades');
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '',
|
||||
'<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>');
|
||||
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', upgrade_get_javascript());
|
||||
|
||||
upgrade_log_start();
|
||||
require_once ($CFG->dirroot .'/local/db/upgrade.php');
|
||||
|
@ -105,6 +105,7 @@
|
||||
warnings[warnings.length] = continueBtn; // then add the continue button to the array
|
||||
|
||||
var link;
|
||||
var statusOk = false;
|
||||
for (var i = 0; i < n; ++i) {
|
||||
// add a "next" link to all warnings except the last one on the page
|
||||
if (i < n - 1) {
|
||||
@ -136,6 +137,7 @@
|
||||
link = createWarningSkipLink('Scroll to the continue button', 0);
|
||||
p.appendChild(document.createTextNode('No warnings - '));
|
||||
p.className = 'notifysuccess';
|
||||
statusOk = true;
|
||||
}
|
||||
p.appendChild(link);
|
||||
contentDiv.insertBefore(p, contentDiv.firstChild);
|
||||
@ -143,6 +145,9 @@
|
||||
|
||||
// automatically scroll to the first warning or continue button
|
||||
initScroll(warnings[0]);
|
||||
if (statusOk && installautopilot) {//global JS variable
|
||||
document.forms[0].submit();//auto submit
|
||||
}
|
||||
};
|
||||
|
||||
// load should be a document event, but most browsers use window
|
||||
|
Loading…
x
Reference in New Issue
Block a user