upgrade_main_savepoint(true, 2013021100.01);
}
- if ($oldversion < 2013021500.00) {
+ if ($oldversion < 2013021800.00) {
+ // Add the site identifier to the cache config's file.
+ $siteidentifier = $DB->get_field('config', 'value', array('name' => 'siteidentifier'));
+ cache_helper::update_site_identifier($siteidentifier);
+
+ // Main savepoint reached.
+ upgrade_main_savepoint(true, 2013021800.00);
+ }
+
+ if ($oldversion < 2013021801.00) {
+ // Fixing possible wrong MIME types for SMART Notebook files.
+ $extensions = array('%.gallery', '%.galleryitem', '%.gallerycollection', '%.nbk', '%.notebook', '%.xbk');
+ $select = $DB->sql_like('filename', '?', false);
+ foreach ($extensions as $extension) {
+ $DB->set_field_select(
+ 'files',
+ 'mimetype',
+ 'application/x-smarttech-notebook',
+ $select,
+ array($extension)
+ );
+ }
+ upgrade_main_savepoint(true, 2013021801.00);
+ }
+
+ if ($oldversion < 2013021801.01) {
+ // Retrieve the list of course_sections as a recordset to save memory
+ $coursesections = $DB->get_recordset('course_sections', null, 'course, id', 'id, course, sequence');
+ foreach ($coursesections as $coursesection) {
+ // Retrieve all of the actual modules in this course and section combination to reduce DB calls
+ $actualsectionmodules = $DB->get_records('course_modules',
+ array('course' => $coursesection->course, 'section' => $coursesection->id), '', 'id, section');
+
+ // Break out the current sequence so that we can compare it
+ $currentsequence = explode(',', $coursesection->sequence);
+ $newsequence = array();
+
+ // Check each of the modules in the current sequence
+ foreach ($currentsequence as $module) {
+ if (isset($actualsectionmodules[$module])) {
+ $newsequence[] = $module;
+ // We unset the actualsectionmodules so that we don't get duplicates and that we can add orphaned
+ // modules later
+ unset($actualsectionmodules[$module]);
+ }
+ }
+
+ // Append any modules which have somehow been orphaned
+ foreach ($actualsectionmodules as $module) {
+ $newsequence[] = $module->id;
+ }
+
+ // Piece it all back together
+ $sequence = implode(',', $newsequence);
+
+ // Only update if there have been changes
+ if ($sequence !== $coursesection->sequence) {
+ $coursesection->sequence = $sequence;
+ $DB->update_record('course_sections', $coursesection);
+
+ // And clear the sectioncache and modinfo cache - they'll be regenerated on next use
+ $course = new stdClass();
+ $course->id = $coursesection->course;
+ $course->sectioncache = null;
+ $course->modinfo = null;
+ $DB->update_record('course', $course);
+ }
+ }
+ $coursesections->close();
+
+ // Main savepoint reached.
+ upgrade_main_savepoint(true, 2013021801.01);
+ }
+
++ if ($oldversion < 2013021902.00) {
+ // ISO country change: Netherlands Antilles is split into BQ, CW & SX
+ // http://www.iso.org/iso/iso_3166-1_newsletter_vi-8_split_of_the_dutch_antilles_final-en.pdf
+ $sql = "UPDATE {user} SET country = '' WHERE country = ?";
+ $DB->execute($sql, array('AN'));
+
- upgrade_main_savepoint(true, 2013021500.00);
++ upgrade_main_savepoint(true, 2013021902.00);
+ }
+
return true;
}