[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/enrol/authorize/db/ -> mysql.php (source)

   1  <?php //$Id: mysql.php,v 1.29.6.1 2008/02/07 16:27:50 ethem Exp $
   2  
   3  // THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
   4  //
   5  // IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
   6  // LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
   7  
   8  // MySQL commands for upgrading this enrolment module
   9  
  10  function enrol_authorize_upgrade($oldversion=0) {
  11      global $CFG, $THEME, $db;
  12      require_once("$CFG->dirroot/enrol/authorize/const.php");
  13  
  14      $result = true;
  15  
  16      if ($oldversion < 2005071600) {
  17          // Be sure, only last 4 digit is inserted.
  18          table_column('enrol_authorize', 'cclastfour', 'cclastfour', 'integer', '4', 'unsigned', '0', 'not null');
  19          table_column('enrol_authorize', 'courseid', 'courseid', 'integer', '10', 'unsigned', '0', 'not null');
  20          table_column('enrol_authorize', 'userid', 'userid', 'integer', '10', 'unsigned', '0', 'not null');
  21          // Add some indexes for speed.
  22          execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX courseid(courseid)", false);
  23          execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX userid(userid)", false);
  24      }
  25  
  26      if ($oldversion && $oldversion < 2005071602) {
  27          notify("If you are using the authorize.net enrolment plugin for credit card
  28                  handling, please ensure that you have turned loginhttps ON in Admin >> Variables >> Security.");
  29      }
  30  
  31      if ($oldversion < 2005112100) {
  32          table_column('enrol_authorize', '', 'authcode', 'varchar', '6', '', '', '', 'avscode'); // CAPTURE_ONLY
  33          table_column('enrol_authorize', '', 'status', 'integer', '10', 'unsigned', '0', 'not null', 'transid');
  34          table_column('enrol_authorize', '', 'timecreated', 'integer', '10', 'unsigned', '0', 'not null', 'status');
  35          table_column('enrol_authorize', '', 'timeupdated', 'integer', '10', 'unsigned', '0', 'not null', 'timecreated');
  36          // status index for speed.
  37          execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX status(status)");
  38          // defaults.
  39          $status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
  40          execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET status='$status' WHERE transid<>'0'", false);
  41          $timenow = time();
  42          execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET timecreated='$timenow', timeupdated='$timenow'", false);
  43      }
  44  
  45      if ($oldversion < 2005121200) {
  46          // new fields for refund and sales reports.
  47          $defaultcurrency = empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency;
  48          table_column('enrol_authorize', '', 'amount', 'varchar', '10', '', '0', 'not null', 'timeupdated');
  49          table_column('enrol_authorize', '', 'currency', 'varchar', '3', '', $defaultcurrency, 'not null', 'amount');
  50          modify_database("","CREATE TABLE prefix_enrol_authorize_refunds (
  51            `id` int(10) unsigned NOT NULL auto_increment,
  52            `orderid` int(10) unsigned NOT NULL default 0,
  53            `refundtype` int(1) unsigned NOT NULL default 0,
  54            `amount` varchar(10) NOT NULL default '',
  55            `transid` int(10) unsigned NULL default 0,
  56            PRIMARY KEY (`id`),
  57            KEY `orderid` (`orderid`));");
  58          // defaults.
  59          if (($courses = get_records_select('course', '', '', 'id, cost, currency'))) {
  60              foreach ($courses as $course) {
  61                  execute_sql("UPDATE {$CFG->prefix}enrol_authorize
  62                               SET amount = '$course->cost', currency = '$course->currency'
  63                               WHERE courseid = '$course->id'", false);
  64              }
  65          }
  66      }
  67  
  68      if ($oldversion < 2005122200) { // settletime
  69          table_column('enrol_authorize_refunds', 'refundtype', 'status', 'integer', '1', 'unsigned', '0', 'not null');
  70          table_column('enrol_authorize_refunds', '', 'settletime', 'integer', '10', 'unsigned', '0', 'not null', 'transid');
  71          table_column('enrol_authorize', 'timeupdated', 'settletime', 'integer', '10', 'unsigned', '0', 'not null');
  72          $status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
  73          if (($settlements = get_records_select('enrol_authorize', "status='$status'", '', 'id, settletime'))) {
  74              include_once("$CFG->dirroot/enrol/authorize/authorizenetlib.php");
  75              foreach ($settlements as $settlement) {
  76                  execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET settletime = '" .
  77                  authorize_getsettletime($settlement->settletime) . "' WHERE id = '$settlement->id'", false);
  78              }
  79          }
  80      }
  81  
  82      if ($oldversion < 2005122800) { // no need anymore some fields.
  83          execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP ccexp", false);
  84          execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP cvv", false);
  85          execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP avscode", false);
  86          execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false);
  87      }
  88  
  89      if ($oldversion < 2006010200) { // rename an_review_day
  90          if (isset($CFG->an_review_day)) {
  91              set_config('an_capture_day', $CFG->an_review_day);
  92              delete_records('config', 'name', 'an_review_day');
  93          }
  94      }
  95  
  96      if ($oldversion < 2006020100) { // rename an_cutoff_hour and an_cutoff_min to an_cutoff
  97          if (isset($CFG->an_cutoff_hour) && isset($CFG->an_cutoff_min)) {
  98              $an_cutoff_hour = intval($CFG->an_cutoff_hour);
  99              $an_cutoff_min = intval($CFG->an_cutoff_min);
 100              $an_cutoff = ($an_cutoff_hour * 60) + $an_cutoff_min;
 101              if (set_config('an_cutoff', $an_cutoff)) {
 102                  delete_records('config', 'name', 'an_cutoff_hour');
 103                  delete_records('config', 'name', 'an_cutoff_min');
 104              }
 105          }
 106      }
 107  
 108      if ($oldversion < 2006021500) { // transid is int
 109          table_column('enrol_authorize', 'transid', 'transid', 'integer', '10', 'unsigned', '0', 'not null');
 110      }
 111  
 112      if ($oldversion < 2006021501) { // delete an_nextmail record from config_plugins table
 113          delete_records('config_plugins', 'name', 'an_nextmail');
 114      }
 115  
 116      if ($oldversion < 2006050400) { // Create transid indexes for backup & restore speed.
 117          execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX transid(transid)", false);
 118          execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize_refunds` ADD INDEX transid(transid)", false);
 119      }
 120  
 121      if ($oldversion < 2006060500) { // delete an_nextmail record from config_plugins table
 122          delete_records('config_plugins', 'name', 'an_nextmail'); // run twice.
 123      }
 124  
 125      if ($oldversion < 2006081401) { // no need an_teachermanagepay in 1.7
 126          if (isset($CFG->an_teachermanagepay)) {
 127              delete_records('config', 'name', 'an_teachermanagepay');
 128          }
 129      }
 130  
 131      if ($oldversion < 2006083100) {
 132          // enums are lower case
 133          if (isset($CFG->an_acceptmethods)) {
 134              set_config('an_acceptmethods', strtolower($CFG->an_acceptmethods));
 135          }
 136          // new ENUM field: paymentmethod(cc,echeck)
 137          execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD paymentmethod enum('cc', 'echeck') NOT NULL default 'cc' AFTER `id`", true);
 138      }
 139  
 140      //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
 141  
 142      return $result;
 143  }
 144  
 145  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7