Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403] [Versions 39 and 310]

   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   * This file keeps track of upgrades to the paypal enrolment plugin
  19   *
  20   * @package    enrol_paypal
  21   * @copyright  2010 Eugene Venter
  22   * @author     Eugene Venter
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  // Sometimes, changes between versions involve
  27  // alterations to database structures and other
  28  // major things that may break installations.
  29  //
  30  // The upgrade function in this file will attempt
  31  // to perform all the necessary actions to upgrade
  32  // your older installation to the current version.
  33  //
  34  // If there's something it cannot do itself, it
  35  // will tell you what you need to do.
  36  //
  37  // The commands in here will all be database-neutral,
  38  // using the methods of database_manager class
  39  //
  40  // Please do not forget to use upgrade_set_timeout()
  41  // before any action that may take longer time to finish.
  42  
  43  defined('MOODLE_INTERNAL') || die();
  44  
  45  function xmldb_enrol_paypal_upgrade($oldversion) {
  46      global $DB;
  47  
  48      $dbman = $DB->get_manager();
  49  
  50      // Automatically generated Moodle v3.5.0 release upgrade line.
  51      // Put any upgrade step following this.
  52  
  53      if ($oldversion < 2018053000) {
  54  
  55          // Define field instanceid to be added to enrol_paypal.
  56          // For some reason, some Moodle instances that are upgraded from old versions do not have this field.
  57          $table = new xmldb_table('enrol_paypal');
  58          $field = new xmldb_field('instanceid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'userid');
  59  
  60          // Conditionally launch add field instanceid.
  61          if (!$dbman->field_exists($table, $field)) {
  62              $dbman->add_field($table, $field);
  63          }
  64  
  65          // Paypal savepoint reached.
  66          upgrade_plugin_savepoint(true, 2018053000, 'enrol', 'paypal');
  67      }
  68  
  69      if ($oldversion < 2018062500) {
  70  
  71          // Define key courseid (foreign) to be added to enrol_paypal.
  72          $table = new xmldb_table('enrol_paypal');
  73          $key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
  74  
  75          // Launch add key courseid.
  76          $dbman->add_key($table, $key);
  77  
  78          // Paypal savepoint reached.
  79          upgrade_plugin_savepoint(true, 2018062500, 'enrol', 'paypal');
  80      }
  81  
  82      if ($oldversion < 2018062501) {
  83  
  84          // Define key userid (foreign) to be added to enrol_paypal.
  85          $table = new xmldb_table('enrol_paypal');
  86          $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
  87  
  88          // Launch add key userid.
  89          $dbman->add_key($table, $key);
  90  
  91          // Paypal savepoint reached.
  92          upgrade_plugin_savepoint(true, 2018062501, 'enrol', 'paypal');
  93      }
  94  
  95      if ($oldversion < 2018062502) {
  96  
  97          // Define key instanceid (foreign) to be added to enrol_paypal.
  98          $table = new xmldb_table('enrol_paypal');
  99          $key = new xmldb_key('instanceid', XMLDB_KEY_FOREIGN, array('instanceid'), 'enrol', array('id'));
 100  
 101          // Launch add key instanceid.
 102          $dbman->add_key($table, $key);
 103  
 104          // Paypal savepoint reached.
 105          upgrade_plugin_savepoint(true, 2018062502, 'enrol', 'paypal');
 106      }
 107  
 108      if ($oldversion < 2018062503) {
 109  
 110          $table = new xmldb_table('enrol_paypal');
 111  
 112          // Define index business (not unique) to be added to enrol_paypal.
 113          $index = new xmldb_index('business', XMLDB_INDEX_NOTUNIQUE, array('business'));
 114  
 115          // Conditionally launch add index business.
 116          if (!$dbman->index_exists($table, $index)) {
 117              $dbman->add_index($table, $index);
 118          }
 119  
 120          // Define index receiver_email (not unique) to be added to enrol_paypal.
 121          $index = new xmldb_index('receiver_email', XMLDB_INDEX_NOTUNIQUE, array('receiver_email'));
 122  
 123          // Conditionally launch add index receiver_email.
 124          if (!$dbman->index_exists($table, $index)) {
 125              $dbman->add_index($table, $index);
 126          }
 127  
 128          // Paypal savepoint reached.
 129          upgrade_plugin_savepoint(true, 2018062503, 'enrol', 'paypal');
 130      }
 131  
 132      // Automatically generated Moodle v3.6.0 release upgrade line.
 133      // Put any upgrade step following this.
 134  
 135      // Automatically generated Moodle v3.7.0 release upgrade line.
 136      // Put any upgrade step following this.
 137  
 138      // Automatically generated Moodle v3.8.0 release upgrade line.
 139      // Put any upgrade step following this.
 140  
 141      // Automatically generated Moodle v3.9.0 release upgrade line.
 142      // Put any upgrade step following this.
 143  
 144      // Automatically generated Moodle v3.10.0 release upgrade line.
 145      // Put any upgrade step following this.
 146  
 147      return true;
 148  }