Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/chat/db/upgrade.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file keeps track of upgrades to
00004 // the chat module
00005 //
00006 // Sometimes, changes between versions involve
00007 // alterations to database structures and other
00008 // major things that may break installations.
00009 //
00010 // The upgrade function in this file will attempt
00011 // to perform all the necessary actions to upgrade
00012 // your older installation to the current version.
00013 //
00014 // If there's something it cannot do itself, it
00015 // will tell you what you need to do.
00016 //
00017 // The commands in here will all be database-neutral,
00018 // using the methods of database_manager class
00019 //
00020 // Please do not forget to use upgrade_set_timeout()
00021 // before any action that may take longer time to finish.
00022 
00023 function xmldb_chat_upgrade($oldversion) {
00024     global $CFG, $DB;
00025 
00026     $dbman = $DB->get_manager();
00027 
00028     //===== 1.9.0 upgrade line ======//
00029 
00030     if ($oldversion < 2010050100) {
00031 
00033         $table = new xmldb_table('chat_users');
00034         $field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, 'version');
00035 
00037         $dbman->change_field_precision($table, $field);
00038 
00040         upgrade_mod_savepoint(true, 2010050100, 'chat');
00041     }
00042 
00043     if ($oldversion < 2010050101) {
00044 
00046         $table = new xmldb_table('chat');
00047         $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
00048 
00050         if (!$dbman->field_exists($table, $field)) {
00051             $dbman->add_field($table, $field);
00052         }
00053 
00054         // conditionally migrate to html format in intro
00055         if ($CFG->texteditors !== 'textarea') {
00056             $rs = $DB->get_recordset('chat', array('introformat'=>FORMAT_MOODLE), '', 'id,intro,introformat');
00057             foreach ($rs as $ch) {
00058                 $ch->intro       = text_to_html($ch->intro, false, false, true);
00059                 $ch->introformat = FORMAT_HTML;
00060                 $DB->update_record('chat', $ch);
00061                 upgrade_set_timeout();
00062             }
00063             $rs->close();
00064         }
00065 
00067         upgrade_mod_savepoint(true, 2010050101, 'chat');
00068     }
00069 
00071     if ($oldversion < 2010050102) {
00072 
00074         $table = new xmldb_table('chat_messages_current');
00075 
00077         $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
00078         $table->add_field('chatid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
00079         $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
00080         $table->add_field('groupid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
00081         $table->add_field('system', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
00082         $table->add_field('message', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null);
00083         $table->add_field('timestamp', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
00084 
00086         $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
00087         $table->add_key('chatid', XMLDB_KEY_FOREIGN, array('chatid'), 'chat', array('id'));
00088 
00090         $table->add_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
00091         $table->add_index('groupid', XMLDB_INDEX_NOTUNIQUE, array('groupid'));
00092         $table->add_index('timestamp-chatid', XMLDB_INDEX_NOTUNIQUE, array('timestamp', 'chatid'));
00093 
00095         if (!$dbman->table_exists($table)) {
00096             $dbman->create_table($table);
00097         }
00098 
00100         upgrade_mod_savepoint(true, 2010050102, 'chat');
00101     }
00102 
00103     // Moodle v2.1.0 release upgrade line
00104     // Put any upgrade step following this
00105 
00106     // Moodle v2.2.0 release upgrade line
00107     // Put any upgrade step following this
00108 
00109     return true;
00110 }
00111 
00112 
 All Data Structures Namespaces Files Functions Variables Enumerations