From 371a32e3089b9099e38713fe0fe534280fb629f7 Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 22 Jan 2007 20:15:12 +0000 Subject: [PATCH] (MDL-8250) install/upgrade autopilot --- admin/index.php | 58 +++++++++++++++++++++++++++++++---------- backup/lib.php | 6 ++--- group/db/upgrade.php | 6 ++--- lang/en_utf8/admin.php | 1 + lib/adminlib.php | 27 ++++++++++++------- lib/blocklib.php | 12 +++------ lib/locallib.php | 3 +-- lib/scroll_to_errors.js | 5 ++++ 8 files changed, 76 insertions(+), 42 deletions(-) diff --git a/admin/index.php b/admin/index.php index a7473bf662c..aa03332ecf7 100644 --- a/admin/index.php +++ b/admin/index.php @@ -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!
Click on the exclamation marks to ignore this warning (!!!).", 10); +/// set install/upgrade autocontinue session flag + if ($autopilot) { + $_SESSION['installautopilot'] = $autopilot; + } + /// Check some PHP server settings $documentationlink = 'Installation docs'; @@ -107,29 +114,42 @@ } } } - - $linktoscrolltoerrors = ''; 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("Moodle - Modular Object-Oriented Dynamic Learning Environment"); print_heading(get_string('copyrightnotice')); print_box(text_to_html(get_string('gpl')), 'copyrightnotice'); echo "
"; - 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 '
'; + echo ''; + echo ''; + echo '
'; + echo '
'; + echo '

'; + echo '
'; + 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 '
'; + echo ''; + echo ''; + echo '
'; + echo '
'; + echo '

'; + echo '
'; + 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" diff --git a/backup/lib.php b/backup/lib.php index 402e7ce6e74..23b9d316642 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -326,8 +326,7 @@ if (empty($CFG->backup_version)) { // Backup has never been installed. $strdatabaseupgrades = get_string("databaseupgrades"); print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, "", - '', - 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, '', - ''); + print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', upgrade_get_javascript()); upgrade_log_start(); print_heading('backup'); diff --git a/group/db/upgrade.php b/group/db/upgrade.php index 6702e06b886..30bf84092df 100644 --- a/group/db/upgrade.php +++ b/group/db/upgrade.php @@ -31,8 +31,7 @@ function upgrade_group_db($continueto) { $strdatabaseupgrades = get_string('databaseupgrades'); print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', - '', - 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, '', - ''); + print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', upgrade_get_javascript()); upgrade_log_start(); print_heading('group'); diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 893e7178939..5d89d63f380 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -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. Click here to run the migration script now!'; $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).'; diff --git a/lib/adminlib.php b/lib/adminlib.php index e8c4966b231..44a458cd847 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -64,8 +64,7 @@ function upgrade_plugins($type, $dir, $return) { $info->requiremoodle = $plugin->requires; if (!$updated_plugins) { print_header($strpluginsetup, $strpluginsetup, $strpluginsetup, '', - '', - 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, '', - '', - 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, '', - '', - 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, '', - '', - 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, '', - '', - 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 = ''."\n"; + } else { + $linktoscrolltoerrors = ''."\n"; + } + $linktoscrolltoerrors .= ''; + + return $linktoscrolltoerrors; +} //////////////////////////////////////////////// /// upgrade logging functions //////////////////////////////////////////////// diff --git a/lib/blocklib.php b/lib/blocklib.php index ea05f0a634d..729a86fb9d0 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -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, '', - '', - 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, '', - ''); + 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, '', - '', - 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, '', - '', - false, ' ', ' '); + upgrade_get_javascript(), false, ' ', ' '); } $updated_blocks = true; upgrade_log_start(); diff --git a/lib/locallib.php b/lib/locallib.php index 82a94f83af4..85aa28f9143 100644 --- a/lib/locallib.php +++ b/lib/locallib.php @@ -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, '', - ''); + print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', upgrade_get_javascript()); upgrade_log_start(); require_once ($CFG->dirroot .'/local/db/upgrade.php'); diff --git a/lib/scroll_to_errors.js b/lib/scroll_to_errors.js index 741f1815ff7..928f9487ea2 100644 --- a/lib/scroll_to_errors.js +++ b/lib/scroll_to_errors.js @@ -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