Merge branch 'MDL-43784-master' of git://github.com/FMCorz/moodle
authorSam Hemelryk <sam@moodle.com>
Tue, 25 Mar 2014 22:33:15 +0000 (11:33 +1300)
committerSam Hemelryk <sam@moodle.com>
Tue, 25 Mar 2014 22:33:47 +0000 (11:33 +1300)
Conflicts:
lib/classes/plugin_manager.php
lib/db/upgrade.php

1  2 
lib/classes/plugin_manager.php
lib/db/upgrade.php
version.php

@@@ -1111,11 -1113,7 +1113,7 @@@ class core_plugin_manager 
              ),
  
              'theme' => array(
-                 'afterburner', 'anomaly', 'arialist', 'base', 'binarius', 'bootstrapbase',
-                 'boxxie', 'brick', 'canvas', 'clean', 'formal_white', 'formfactor',
-                 'fusion', 'leatherbound', 'magazine', 'more', 'nimble',
-                 'nonzero', 'overlay', 'serenity', 'sky_high', 'splash',
-                 'standard', 'standardold'
 -                'base', 'bootstrapbase', 'canvas', 'clean'
++                'base', 'bootstrapbase', 'canvas', 'clean', 'more'
              ),
  
              'tool' => array(
@@@ -3184,101 -3184,49 +3184,145 @@@ function xmldb_main_upgrade($oldversion
      }
  
      if ($oldversion < 2014032000.01) {
 +        // Add new fields to the 'tag_instance' table.
 +        $table = new xmldb_table('tag_instance');
 +        $field = new xmldb_field('component', XMLDB_TYPE_CHAR, '100', null, false, null, null, 'tagid');
 +        if (!$dbman->field_exists($table, $field)) {
 +            $dbman->add_field($table, $field);
 +        }
 +
 +        $field = new xmldb_field('contextid', XMLDB_TYPE_INTEGER, '10', null, false, null, '0', 'itemid');
 +        if (!$dbman->field_exists($table, $field)) {
 +            $dbman->add_field($table, $field);
 +        }
 +
 +        $field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'ordering');
 +        if (!$dbman->field_exists($table, $field)) {
 +            $dbman->add_field($table, $field);
 +        }
  
 -        upgrade_main_savepoint(true, 2014032000.01);
 +        $sql = "UPDATE {tag_instance}
 +                   SET timecreated = timemodified";
 +        $DB->execute($sql);
 +
 +        // Update all the course tags.
 +        $sql = "UPDATE {tag_instance}
 +                   SET component = 'core',
 +                       contextid = (SELECT ctx.id
 +                                      FROM {context} ctx
 +                                     WHERE ctx.contextlevel = :contextlevel
 +                                       AND ctx.instanceid = {tag_instance}.itemid)
 +                 WHERE itemtype = 'course'";
 +        $DB->execute($sql, array('contextlevel' => CONTEXT_COURSE));
 +
 +        // Update all the user tags.
 +        $sql = "UPDATE {tag_instance}
 +                   SET component = 'core',
 +                       contextid = (SELECT ctx.id
 +                                      FROM {context} ctx
 +                                     WHERE ctx.contextlevel = :contextlevel
 +                                       AND ctx.instanceid = {tag_instance}.itemid)
 +                 WHERE itemtype = 'user'";
 +        $DB->execute($sql, array('contextlevel' => CONTEXT_USER));
 +
 +        // Update all the blog post tags.
 +        $sql = "UPDATE {tag_instance}
 +                   SET component = 'core',
 +                       contextid = (SELECT ctx.id
 +                                      FROM {context} ctx
 +                                      JOIN {post} p
 +                                        ON p.userid = ctx.instanceid
 +                                     WHERE ctx.contextlevel = :contextlevel
 +                                       AND p.id = {tag_instance}.itemid)
 +                 WHERE itemtype = 'post'";
 +        $DB->execute($sql, array('contextlevel' => CONTEXT_USER));
 +
 +        // Update all the wiki page tags.
 +        $sql = "UPDATE {tag_instance}
 +                   SET component = 'mod_wiki',
 +                       contextid = (SELECT ctx.id
 +                                      FROM {context} ctx
 +                                      JOIN {course_modules} cm
 +                                        ON cm.id = ctx.instanceid
 +                                      JOIN {modules} m
 +                                        ON m.id = cm.module
 +                                      JOIN {wiki} w
 +                                        ON w.id = cm.instance
 +                                      JOIN {wiki_subwikis} sw
 +                                        ON sw.wikiid = w.id
 +                                      JOIN {wiki_pages} wp
 +                                        ON wp.subwikiid = sw.id
 +                                     WHERE m.name = 'wiki'
 +                                       AND ctx.contextlevel = :contextlevel
 +                                       AND wp.id = {tag_instance}.itemid)
 +                 WHERE itemtype = 'wiki_pages'";
 +        $DB->execute($sql, array('contextlevel' => CONTEXT_MODULE));
 +
 +        // Update all the question tags.
 +        $sql = "UPDATE {tag_instance}
 +                   SET component = 'core_question',
 +                       contextid = (SELECT qc.contextid
 +                                      FROM {question} q
 +                                      JOIN {question_categories} qc
 +                                        ON q.category = qc.id
 +                                     WHERE q.id = {tag_instance}.itemid)
 +                 WHERE itemtype = 'question'";
 +        $DB->execute($sql);
 +
 +        // Update all the tag tags.
 +        $sql = "UPDATE {tag_instance}
 +                   SET component = 'core',
 +                       contextid = :systemcontext
 +                 WHERE itemtype = 'tag'";
 +        $DB->execute($sql, array('systemcontext' => context_system::instance()->id));
 +
 +        // Main savepoint reached.
 +        upgrade_main_savepoint(true, 2014032000.01);
 +    }
 +
++    if ($oldversion < 2014032600.00) {
+         // Removing the themes from core.
+         $themes = array('afterburner', 'anomaly', 'arialist', 'binarius', 'boxxie', 'brick', 'formal_white', 'formfactor',
+             'fusion', 'leatherbound', 'magazine', 'nimble', 'nonzero', 'overlay', 'serenity', 'sky_high', 'splash',
+             'standard', 'standardold');
+         foreach ($themes as $key => $theme) {
+             if (check_dir_exists($CFG->dirroot . '/theme/' . $theme, false)) {
+                 // Ignore the themes that have been re-downloaded.
+                 unset($themes[$key]);
+             }
+         }
+         list($insql, $inparams) = $DB->get_in_or_equal($themes, SQL_PARAMS_NAMED);
+         // Replace the theme usage.
+         $DB->set_field_select('course', 'theme', 'clean', "theme $insql", $inparams);
+         $DB->set_field_select('course_categories', 'theme', 'clean', "theme $insql", $inparams);
+         $DB->set_field_select('user', 'theme', 'clean', "theme $insql", $inparams);
+         $DB->set_field_select('mnet_host', 'theme', 'clean', "theme $insql", $inparams);
+         // Replace the theme configs.
+         if (in_array(get_config('core', 'theme'), $themes)) {
+             set_config('theme', 'clean');
+         }
+         if (in_array(get_config('core', 'thememobile'), $themes)) {
+             set_config('thememobile', 'clean');
+         }
+         if (in_array(get_config('core', 'themelegacy'), $themes)) {
+             set_config('themelegacy', 'clean');
+         }
+         if (in_array(get_config('core', 'themetablet'), $themes)) {
+             set_config('themetablet', 'clean');
+         }
+         // Hacky emulation of plugin uninstallation.
+         foreach ($themes as $theme) {
+             unset_all_config_for_plugin('theme_' . $theme);
+         }
+         // Main savepoint reached.
++        upgrade_main_savepoint(true, 2014032600.00);
+     }
      return true;
  }
diff --cc version.php
@@@ -29,7 -29,7 +29,7 @@@
  
  defined('MOODLE_INTERNAL') || die();
  
--$version  = 2014032000.01;              // YYYYMMDD      = weekly release date of this DEV branch.
++$version  = 2014032600.00;              // YYYYMMDD      = weekly release date of this DEV branch.
                                          //         RR    = release increments - 00 in DEV branches.
                                          //           .XX = incremental changes.