[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/workshop/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   * Keeps track of upgrades to the workshop module
  20   *
  21   * @package    mod_workshop
  22   * @category   upgrade
  23   * @copyright  2009 David Mudrak <[email protected]>
  24   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  
  27  /**
  28   * Performs upgrade of the database structure and data
  29   *
  30   * Workshop supports upgrades from version 1.9.0 and higher only. During 1.9 > 2.0 upgrade,
  31   * there are significant database changes.
  32   *
  33   * @param int $oldversion the version we are upgrading from
  34   * @return bool result
  35   */
  36  function xmldb_workshop_upgrade($oldversion) {
  37      global $CFG, $DB, $OUTPUT;
  38  
  39      $dbman = $DB->get_manager();
  40  
  41      // Moodle v2.2.0 release upgrade line
  42  
  43      if ($oldversion < 2012033100) {
  44          // add the field 'phaseswitchassessment' to the 'workshop' table
  45          $table = new xmldb_table('workshop');
  46          $field = new xmldb_field('phaseswitchassessment', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'assessmentend');
  47          if (!$dbman->field_exists($table, $field)) {
  48              $dbman->add_field($table, $field);
  49          }
  50          upgrade_mod_savepoint(true, 2012033100, 'workshop');
  51      }
  52  
  53      /**
  54       * Remove all workshop calendar events
  55       */
  56      if ($oldversion < 2012041700) {
  57          require_once($CFG->dirroot . '/calendar/lib.php');
  58          $events = $DB->get_records('event', array('modulename' => 'workshop'));
  59          foreach ($events as $event) {
  60              $event = calendar_event::load($event);
  61              $event->delete();
  62          }
  63          upgrade_mod_savepoint(true, 2012041700, 'workshop');
  64      }
  65  
  66      /**
  67       * Recreate all workshop calendar events
  68       */
  69      if ($oldversion < 2012041701) {
  70          require_once(dirname(dirname(__FILE__)) . '/lib.php');
  71  
  72          $sql = "SELECT w.id, w.course, w.name, w.intro, w.introformat, w.submissionstart,
  73                         w.submissionend, w.assessmentstart, w.assessmentend,
  74                         cm.id AS cmid
  75                    FROM {workshop} w
  76                    JOIN {modules} m ON m.name = 'workshop'
  77                    JOIN {course_modules} cm ON (cm.module = m.id AND cm.course = w.course AND cm.instance = w.id)";
  78  
  79          $rs = $DB->get_recordset_sql($sql);
  80  
  81          foreach ($rs as $workshop) {
  82              $cmid = $workshop->cmid;
  83              unset($workshop->cmid);
  84              workshop_calendar_update($workshop, $cmid);
  85          }
  86          $rs->close();
  87          upgrade_mod_savepoint(true, 2012041701, 'workshop');
  88      }
  89  
  90      // Moodle v2.3.0 release upgrade line
  91  
  92      /**
  93       * Add new fields conclusion and conclusionformat
  94       */
  95      if ($oldversion < 2012102400) {
  96          $table = new xmldb_table('workshop');
  97  
  98          $field = new xmldb_field('conclusion', XMLDB_TYPE_TEXT, null, null, null, null, null, 'phaseswitchassessment');
  99          if (!$dbman->field_exists($table, $field)) {
 100              $dbman->add_field($table, $field);
 101          }
 102  
 103          $field = new xmldb_field('conclusionformat', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '1', 'conclusion');
 104          if (!$dbman->field_exists($table, $field)) {
 105              $dbman->add_field($table, $field);
 106          }
 107  
 108          upgrade_mod_savepoint(true, 2012102400, 'workshop');
 109      }
 110  
 111  
 112      // Moodle v2.4.0 release upgrade line
 113      // Put any upgrade step following this
 114  
 115      /**
 116       * Add overall feedback related fields into the workshop table.
 117       */
 118      if ($oldversion < 2013032500) {
 119          $table = new xmldb_table('workshop');
 120  
 121          $field = new xmldb_field('overallfeedbackmode', XMLDB_TYPE_INTEGER, '3', null, null, null, '1', 'conclusionformat');
 122          if (!$dbman->field_exists($table, $field)) {
 123              $dbman->add_field($table, $field);
 124          }
 125  
 126          $field = new xmldb_field('overallfeedbackfiles', XMLDB_TYPE_INTEGER, '3', null, null, null, '0', 'overallfeedbackmode');
 127          if (!$dbman->field_exists($table, $field)) {
 128              $dbman->add_field($table, $field);
 129          }
 130  
 131          $field = new xmldb_field('overallfeedbackmaxbytes', XMLDB_TYPE_INTEGER, '10', null, null, null, '100000', 'overallfeedbackfiles');
 132          if (!$dbman->field_exists($table, $field)) {
 133              $dbman->add_field($table, $field);
 134          }
 135  
 136          upgrade_mod_savepoint(true, 2013032500, 'workshop');
 137      }
 138  
 139      /**
 140       * Add feedbackauthorattachment field into the workshop_assessments table.
 141       */
 142      if ($oldversion < 2013032501) {
 143          $table = new xmldb_table('workshop_assessments');
 144          $field = new xmldb_field('feedbackauthorattachment', XMLDB_TYPE_INTEGER, '3', null, null, null, '0', 'feedbackauthorformat');
 145          if (!$dbman->field_exists($table, $field)) {
 146              $dbman->add_field($table, $field);
 147          }
 148  
 149          upgrade_mod_savepoint(true, 2013032501, 'workshop');
 150      }
 151  
 152  
 153      // Moodle v2.5.0 release upgrade line.
 154      // Put any upgrade step following this.
 155  
 156  
 157      // Moodle v2.6.0 release upgrade line.
 158      // Put any upgrade step following this.
 159  
 160      // Moodle v2.7.0 release upgrade line.
 161      // Put any upgrade step following this.
 162  
 163      // Moodle v2.8.0 release upgrade line.
 164      // Put any upgrade step following this.
 165  
 166      return true;
 167  }


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