[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/admin/tool/log/store/standard/db/ -> upgrade.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Standard log store upgrade.
  19   *
  20   * @package    logstore_standard
  21   * @copyright  2014 Petr Skoda
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  function xmldb_logstore_standard_upgrade($oldversion) {
  26      global $CFG, $DB;
  27  
  28      $dbman = $DB->get_manager();
  29  
  30      if ($oldversion < 2014032000) {
  31  
  32          // Define field anonymous to be added to logstore_standard_log.
  33          $table = new xmldb_table('logstore_standard_log');
  34          $field = new xmldb_field('anonymous', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'relateduserid');
  35  
  36          // Conditionally launch add field anonymous.
  37          if (!$dbman->field_exists($table, $field)) {
  38              $dbman->add_field($table, $field);
  39          }
  40  
  41          // Standard savepoint reached.
  42          upgrade_plugin_savepoint(true, 2014032000, 'logstore', 'standard');
  43      }
  44  
  45      if ($oldversion < 2014041500) {
  46  
  47          // Define index contextid-component (not unique) to be dropped form logstore_standard_log.
  48          $table = new xmldb_table('logstore_standard_log');
  49          $index = new xmldb_index('contextid-component', XMLDB_INDEX_NOTUNIQUE, array('contextid', 'component'));
  50  
  51          // Conditionally launch drop index contextid-component.
  52          if ($dbman->index_exists($table, $index)) {
  53              $dbman->drop_index($table, $index);
  54          }
  55  
  56          // Define index courseid (not unique) to be dropped form logstore_standard_log.
  57          $table = new xmldb_table('logstore_standard_log');
  58          $index = new xmldb_index('courseid', XMLDB_INDEX_NOTUNIQUE, array('courseid'));
  59  
  60          // Conditionally launch drop index courseid.
  61          if ($dbman->index_exists($table, $index)) {
  62              $dbman->drop_index($table, $index);
  63          }
  64  
  65          // Define index eventname (not unique) to be dropped form logstore_standard_log.
  66          $table = new xmldb_table('logstore_standard_log');
  67          $index = new xmldb_index('eventname', XMLDB_INDEX_NOTUNIQUE, array('eventname'));
  68  
  69          // Conditionally launch drop index eventname.
  70          if ($dbman->index_exists($table, $index)) {
  71              $dbman->drop_index($table, $index);
  72          }
  73  
  74          // Define index crud (not unique) to be dropped form logstore_standard_log.
  75          $table = new xmldb_table('logstore_standard_log');
  76          $index = new xmldb_index('crud', XMLDB_INDEX_NOTUNIQUE, array('crud'));
  77  
  78          // Conditionally launch drop index crud.
  79          if ($dbman->index_exists($table, $index)) {
  80              $dbman->drop_index($table, $index);
  81          }
  82  
  83          // Define index edulevel (not unique) to be dropped form logstore_standard_log.
  84          $table = new xmldb_table('logstore_standard_log');
  85          $index = new xmldb_index('edulevel', XMLDB_INDEX_NOTUNIQUE, array('edulevel'));
  86  
  87          // Conditionally launch drop index edulevel.
  88          if ($dbman->index_exists($table, $index)) {
  89              $dbman->drop_index($table, $index);
  90          }
  91  
  92          // Define index course-time (not unique) to be added to logstore_standard_log.
  93          $table = new xmldb_table('logstore_standard_log');
  94          $index = new xmldb_index('course-time', XMLDB_INDEX_NOTUNIQUE, array('courseid', 'anonymous', 'timecreated'));
  95  
  96          // Conditionally launch add index course-time.
  97          if (!$dbman->index_exists($table, $index)) {
  98              $dbman->add_index($table, $index);
  99          }
 100  
 101          // Define index user-module (not unique) to be added to logstore_standard_log.
 102          $table = new xmldb_table('logstore_standard_log');
 103          $index = new xmldb_index('user-module', XMLDB_INDEX_NOTUNIQUE, array('userid', 'contextlevel', 'contextinstanceid', 'crud', 'edulevel', 'timecreated'));
 104  
 105          // Conditionally launch add index user-module.
 106          if (!$dbman->index_exists($table, $index)) {
 107              $dbman->add_index($table, $index);
 108          }
 109  
 110          // Standard savepoint reached.
 111          upgrade_plugin_savepoint(true, 2014041500, 'logstore', 'standard');
 112      }
 113  
 114      // Moodle v2.7.0 release upgrade line.
 115      // Put any upgrade step following this.
 116  
 117      // Moodle v2.8.0 release upgrade line.
 118      // Put any upgrade step following this.
 119  
 120      return true;
 121  }


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