|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00027 defined('MOODLE_INTERNAL') || die(); 00028 00029 function xmldb_enrol_flatfile_upgrade($oldversion) { 00030 global $CFG, $DB; 00031 00032 $result = TRUE; 00033 $dbman = $DB->get_manager(); 00034 00035 if ($oldversion < 2010091400) { 00036 00037 // Define table enrol_flatfile to be created 00038 $table = new xmldb_table('enrol_flatfile'); 00039 00040 // Adding fields to table enrol_flatfile 00041 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); 00042 $table->add_field('action', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null); 00043 $table->add_field('roleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); 00044 $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); 00045 $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); 00046 $table->add_field('timestart', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); 00047 $table->add_field('timeend', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); 00048 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); 00049 00050 // Adding keys to table enrol_flatfile 00051 $table->add_key('id', XMLDB_KEY_PRIMARY, array('id')); 00052 $table->add_key('courseid-id', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id')); 00053 $table->add_key('userid-id', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); 00054 $table->add_key('roleid-id', XMLDB_KEY_FOREIGN, array('roleid'), 'role', array('id')); 00055 00056 // Conditionally launch create table for enrol_flatfile 00057 if (!$dbman->table_exists($table)) { 00058 $dbman->create_table($table); 00059 } 00060 00061 // flatfile savepoint reached 00062 upgrade_plugin_savepoint(true, 2010091400, 'enrol', 'flatfile'); 00063 } 00064 00065 // Moodle v2.2.0 release upgrade line 00066 // Put any upgrade step following this 00067 00068 return $result; 00069 }