]> git.mjollnir.org Git - moodle.git/commitdiff
(MDL-8250) install/upgrade autopilot
authorskodak <skodak>
Mon, 22 Jan 2007 20:15:12 +0000 (20:15 +0000)
committerskodak <skodak>
Mon, 22 Jan 2007 20:15:12 +0000 (20:15 +0000)
admin/index.php
backup/lib.php
group/db/upgrade.php
lang/en_utf8/admin.php
lib/adminlib.php
lib/blocklib.php
lib/locallib.php
lib/scroll_to_errors.js

index a7473bf662c77845eeff32ece97b008d1c787af3..aa03332ecf7ae73aff9dd5a64ab392065997f1c2 100644 (file)
@@ -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
     }
     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>';
             }
         }
     }
-
-    $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, "&nbsp;", "&nbsp;");
             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, "&nbsp;", "&nbsp;");
+            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, "&nbsp;", "&nbsp;");
+                        "", upgrade_get_javascript(), false, "&nbsp;", "&nbsp;");
     /// return to original debugging level
         $CFG->debug = $origdebug;
         error_reporting($CFG->debug);
             }
 
             if (empty($confirmupgrade)) {
-
-
                 print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
                         "", "", false, "&nbsp;", "&nbsp;");
 
-                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, "&nbsp;", "&nbsp;");
+                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, "&nbsp;", "&nbsp;");
+                        "", upgrade_get_javascript(), false, "&nbsp;", "&nbsp;");
 
             /// return to original debugging level
                 $CFG->debug = $origdebug;
 /// 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, "&nbsp;", "&nbsp;");
-        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
 /// 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"
index 402e7ce6e7452024656e8c0494d17b72b082bbf8..23b9d316642a2ce4bc87c1a3d317464b79c57d56 100644 (file)
         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, "&nbsp;", "&nbsp;");
+                    upgrade_get_javascript(), false, "&nbsp;", "&nbsp;");
 
             upgrade_log_start();
             print_heading('backup');
 
         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');
index 6702e06b886dc52974dc24faf73d293bb4719563..30bf84092dfdfc2c716837f9ff440e90fa751810 100644 (file)
@@ -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, "&nbsp;", "&nbsp;");
+                upgrade_get_javascript(), false, "&nbsp;", "&nbsp;");
 
         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');
index 893e7178939e3060ac4ae91c1bba3540f5f711e7..5d89d63f380dca77dcdad012b3357827c5d52d45 100644 (file)
@@ -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).';
index e8c4966b23119fce18e054e78c16a236dbba8128..44a458cd847746084265425274d9dac509f708b6 100644 (file)
@@ -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, '&nbsp;', '&nbsp;');
+                        upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
                 }
                 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, '&nbsp;', '&nbsp;');
+                        upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
             }
             $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, '&nbsp;', '&nbsp;');
+                            upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
                 }
                 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, '&nbsp;', '&nbsp;');
+                            upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
                 }
                 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, '&nbsp;', '&nbsp;');
+                        upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
             }
             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
 ////////////////////////////////////////////////
index ea05f0a634d5836cfb40c32dd00990cf70025e7e..729a86fb9d0ccde442765f4488981c2e527c19d2 100644 (file)
@@ -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, '&nbsp;', '&nbsp;');
+                upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
 
         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, '&nbsp;', '&nbsp;');
+                            upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
                 }
                 $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, '&nbsp;', '&nbsp;');
+                        upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
             }
             $updated_blocks = true;
             upgrade_log_start();
index 82a94f83af4f8f8e16939e43b31736c9773329dd..85aa28f91437487ef2aaee98f37f3b39a3fec817 100644 (file)
@@ -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');
index 741f1815ff7b596195bcaa143e582a0552035f49..928f9487ea2335e3dd9f938ea8209aa107e0f79e 100644 (file)
         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) {
                 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);
         
         // 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