[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

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

   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * Folder module upgrade code
  20   *
  21   * This file keeps track of upgrades to
  22   * the resource module
  23   *
  24   * Sometimes, changes between versions involve
  25   * alterations to database structures and other
  26   * major things that may break installations.
  27   *
  28   * The upgrade function in this file will attempt
  29   * to perform all the necessary actions to upgrade
  30   * your older installation to the current version.
  31   *
  32   * If there's something it cannot do itself, it
  33   * will tell you what you need to do.
  34   *
  35   * The commands in here will all be database-neutral,
  36   * using the methods of database_manager class
  37   *
  38   * Please do not forget to use upgrade_set_timeout()
  39   * before any action that may take longer time to finish.
  40   *
  41   * @package   mod_folder
  42   * @copyright 2009 Petr Skoda  {@link http://skodak.org}
  43   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  44   */
  45  
  46  defined('MOODLE_INTERNAL') || die();
  47  
  48  function xmldb_folder_upgrade($oldversion) {
  49      global $CFG, $DB;
  50  
  51      $dbman = $DB->get_manager();
  52  
  53  
  54      // Moodle v2.2.0 release upgrade line
  55      // Put any upgrade step following this
  56  
  57      // Moodle v2.3.0 release upgrade line
  58      // Put any upgrade step following this
  59  
  60      // Moodle v2.4.0 release upgrade line
  61      // Put any upgrade step following this
  62  
  63      if ($oldversion < 2013012100) {
  64  
  65          // Define field display to be added to folder
  66          $table = new xmldb_table('folder');
  67          $field = new xmldb_field('display', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'timemodified');
  68  
  69          // Conditionally launch add field display
  70          if (!$dbman->field_exists($table, $field)) {
  71              $dbman->add_field($table, $field);
  72          }
  73  
  74          // folder savepoint reached
  75          upgrade_mod_savepoint(true, 2013012100, 'folder');
  76      }
  77  
  78      if ($oldversion < 2013031500) {
  79  
  80          // Define field showexpanded to be added to folder
  81          $table = new xmldb_table('folder');
  82          $field = new xmldb_field('showexpanded', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'revision');
  83  
  84          // Conditionally launch add field showexpanded
  85          if (!$dbman->field_exists($table, $field)) {
  86              $dbman->add_field($table, $field);
  87          }
  88  
  89          // folder savepoint reached
  90          upgrade_mod_savepoint(true, 2013031500, 'folder');
  91      }
  92  
  93      // Rename show_expanded to showexpanded (see MDL-38646).
  94      if ($oldversion < 2013040700) {
  95  
  96          // Rename site config setting.
  97          $showexpanded = get_config('folder', 'show_expanded');
  98          set_config('showexpanded', $showexpanded, 'folder');
  99          set_config('show_expanded', null, 'folder');
 100  
 101          // Rename table column.
 102          $table = new xmldb_table('folder');
 103          $field = new xmldb_field('show_expanded', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'revision');
 104          if ($dbman->field_exists($table, $field)) {
 105              $dbman->rename_field($table, $field, 'showexpanded');
 106          }
 107  
 108          // folder savepoint reached
 109          upgrade_mod_savepoint(true, 2013040700, 'folder');
 110      }
 111  
 112      // Moodle v2.5.0 release upgrade line.
 113      // Put any upgrade step following this.
 114  
 115  
 116      // Moodle v2.6.0 release upgrade line.
 117      // Put any upgrade step following this.
 118  
 119      // Moodle v2.7.0 release upgrade line.
 120      // Put any upgrade step following this.
 121  
 122      // Moodle v2.8.0 release upgrade line.
 123      // Put any upgrade step following this.
 124  
 125      return true;
 126  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1