[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/choice/db/ -> upgrade.php (source)

   1  <?php
   2  // This file keeps track of upgrades to
   3  // the choice module
   4  //
   5  // Sometimes, changes between versions involve
   6  // alterations to database structures and other
   7  // major things that may break installations.
   8  //
   9  // The upgrade function in this file will attempt
  10  // to perform all the necessary actions to upgrade
  11  // your older installation to the current version.
  12  //
  13  // If there's something it cannot do itself, it
  14  // will tell you what you need to do.
  15  //
  16  // The commands in here will all be database-neutral,
  17  // using the methods of database_manager class
  18  //
  19  // Please do not forget to use upgrade_set_timeout()
  20  // before any action that may take longer time to finish.
  21  
  22  defined('MOODLE_INTERNAL') || die();
  23  
  24  function xmldb_choice_upgrade($oldversion) {
  25      global $CFG, $DB;
  26  
  27      $dbman = $DB->get_manager();
  28  
  29      if ($oldversion < 2014051201) {
  30  
  31          // Define field allowmultiple to be added to choice.
  32          $table = new xmldb_table('choice');
  33          $field = new xmldb_field('allowmultiple', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'allowupdate');
  34  
  35          // Conditionally launch add field allowmultiple.
  36          if (!$dbman->field_exists($table, $field)) {
  37              $dbman->add_field($table, $field);
  38          }
  39  
  40          // Choice savepoint reached.
  41          upgrade_mod_savepoint(true, 2014051201, 'choice');
  42      }
  43  
  44      // Moodle v2.8.0 release upgrade line.
  45      // Put any upgrade step following this.
  46  
  47      if ($oldversion < 2014111001) {
  48  
  49          // Define field showpreview to be added to choice.
  50          $table = new xmldb_table('choice');
  51          $field = new xmldb_field('showpreview', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'timeclose');
  52  
  53          // Conditionally launch add field showpreview.
  54          if (!$dbman->field_exists($table, $field)) {
  55              $dbman->add_field($table, $field);
  56          }
  57  
  58          // Choice savepoint reached.
  59          upgrade_mod_savepoint(true, 2014111001, 'choice');
  60      }
  61  
  62      if ($oldversion < 2014111002) {
  63  
  64          // Define field includeinactive to be added to choice.
  65          $table = new xmldb_table('choice');
  66          $field = new xmldb_field('includeinactive', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '1', 'showunanswered');
  67  
  68          // Conditionally launch add field includeactive.
  69          if (!$dbman->field_exists($table, $field)) {
  70              $dbman->add_field($table, $field);
  71          }
  72  
  73          // Choice savepoint reached.
  74          upgrade_mod_savepoint(true, 2014111002, 'choice');
  75      }
  76  
  77      // Moodle v2.9.0 release upgrade line.
  78      // Put any upgrade step following this.
  79  
  80      // Moodle v3.0.0 release upgrade line.
  81      // Put any upgrade step following this.
  82  
  83      // Moodle v3.1.0 release upgrade line.
  84      // Put any upgrade step following this.
  85  
  86      return true;
  87  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1