MDL-16810 - amend upgrade process to preserve config values where possible. thanks...
authorpiers <piers>
Sun, 14 Dec 2008 23:45:54 +0000 (23:45 +0000)
committerpiers <piers>
Sun, 14 Dec 2008 23:45:54 +0000 (23:45 +0000)
mod/scorm/db/upgrade.php
mod/scorm/version.php

index 57462ac547be9bfc5df5b29ef98c445eb2f2b617..03705f2c0c8f97a732eaf1fdfb009d123da9f5b6 100644 (file)
@@ -259,21 +259,25 @@ function xmldb_scorm_upgrade($oldversion) {
         if (!$dbman->field_exists($table,$field)) {
             $dbman->add_field($table, $field);
         }
-        
+
     /// scorm savepoint reached
         upgrade_mod_savepoint($result, 2008090305, 'scorm');
     }
-    
+
 
     // remove redundant config values
     if ($result && $oldversion < 2008090306) {
+        /*
+         * comment this out as it is handled by the update mark 2008090310 below
+         * left for historical documentation as some early adopters may have done
+         * this already.
          $redundant_config = array(
                          'scorm_allowapidebug',
                          'scorm_allowtypeexternal',
                          'scorm_allowtypeimsrepository',
-                         'scorm_allowtypelocalsync', 
-                         'scorm_apidebugmask', 
-                         'scorm_frameheight', 
+                         'scorm_allowtypelocalsync',
+                         'scorm_apidebugmask',
+                         'scorm_frameheight',
                          'scorm_framewidth',
                          'scorm_maxattempts',
                          'scorm_updatetime');
@@ -282,30 +286,35 @@ function xmldb_scorm_upgrade($oldversion) {
                 unset_config($rcfg);
             }
         }
+         */
         /// scorm savepoint reached
         upgrade_mod_savepoint($result, 2008090306, 'scorm');
     }
-    
-    
+
+
 
     // remove redundant config values
     if ($result && $oldversion < 2008090307) {
+        /*
+         * comment this out as it is handled by the update mark 2008090310 below
+         * left for historical documentation as some early adopters may have done
+         * this already.
          $redundant_config = array(
                          'scorm_allowapidebug',
                          'scorm_allowtypeexternal',
                          'scorm_allowtypeimsrepository',
-                         'scorm_allowtypelocalsync', 
-                         'scorm_apidebugmask', 
-                         'scorm_frameheight', 
+                         'scorm_allowtypelocalsync',
+                         'scorm_apidebugmask',
+                         'scorm_frameheight',
                          'scorm_framewidth',
                          'scorm_maxattempts',
                          'scorm_updatetime',
-                         'scorm_resizable', 
-                         'scorm_scrollbars', 
-                         'scorm_directories', 
+                         'scorm_resizable',
+                         'scorm_scrollbars',
+                         'scorm_directories',
                          'scorm_location',
-                         'scorm_menubar', 
-                         'scorm_toolbar', 
+                         'scorm_menubar',
+                         'scorm_toolbar',
                          'scorm_status',
                          'scorm_grademethod',
                          'scorm_maxgrade',
@@ -323,11 +332,12 @@ function xmldb_scorm_upgrade($oldversion) {
                 unset_config($rcfg);
             }
         }
-        
+         */
+
         /// scorm savepoint reached
         upgrade_mod_savepoint($result, 2008090307, 'scorm');
     }
-    
+
     if ($result && $oldversion < 2008090308) {
         $table = new xmldb_table('scorm');
         $field = new xmldb_field('timeopen', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'height');
@@ -338,10 +348,61 @@ function xmldb_scorm_upgrade($oldversion) {
         if (!$dbman->field_exists($table,$field)) {
             $dbman->add_field($table, $field);
         }
-        
+
         /// scorm savepoint reached
         upgrade_mod_savepoint($result, 2008090308, 'scorm');
     }
+
+
+    if ($result && $oldversion < 2008090310) {
+        // take above blocks that delete config and move the values in to config_plugins
+
+        $redundant_config = array(
+                         'scorm_allowapidebug',
+                         'scorm_allowtypeexternal',
+                         'scorm_allowtypeimsrepository',
+                         'scorm_allowtypelocalsync',
+                         'scorm_apidebugmask',
+                         'scorm_frameheight',
+                         'scorm_framewidth',
+                         'scorm_maxattempts',
+                         'scorm_updatetime',
+                         'scorm_resizable',
+                         'scorm_scrollbars',
+                         'scorm_directories',
+                         'scorm_location',
+                         'scorm_menubar',
+                         'scorm_toolbar',
+                         'scorm_status',
+                         'scorm_grademethod',
+                         'scorm_maxgrade',
+                         'scorm_whatgrade',
+                         'scorm_popup',
+                         'scorm_skipview',
+                         'scorm_hidebrowse',
+                         'scorm_hidetoc',
+                         'scorm_hidenav',
+                         'scorm_auto',
+                         'scorm_updatefreq',
+                         'scorm_displayattemptstatus',
+                         'scorm_displaycoursestructure',
+                         'scorm_forcecompleted',
+                         'scorm_forcenewattempt',
+                         'scorm_lastattemptlock'
+         );
+
+        foreach ($redundant_config as $rcfg) {
+            if (isset($CFG->$rcfg)) {
+                $shortname = substr($rcfg, 6);
+                $result = $result && set_config($shortname, $CFG->$rcfg, 'scorm');
+                $result = $result && unset_config($rcfg);
+            }
+        }
+
+        /// scorm savepoint reached
+        upgrade_mod_savepoint($result, 2008090310, 'scorm');
+    }
+
     return $result;
 }
 
index fa5aed7ede130f59a33c6dc6c8bd15fcb4ec74af..21df95ec5c3f2b1b0b2b66f19aa3cce93db38591 100755 (executable)
@@ -10,7 +10,7 @@
 //       catch up now, so until 27th October please only increment in very tiny steps
 //       in HEAD, until we get past that date..
 
-$module->version  = 2008090309;   // The (date) version of this module
+$module->version  = 2008090310;   // The (date) version of this module
 $module->requires = 2008090108;   // The version of Moodle that is required
 $module->cron     = 300;            // How often should cron check this module (seconds)?