2006-10-26 17:33:40 +00:00
|
|
|
<?php //$Id$
|
|
|
|
|
2008-07-24 03:15:03 +00:00
|
|
|
// This file keeps track of upgrades to
|
2006-10-26 17:33:40 +00:00
|
|
|
// the chat module
|
|
|
|
//
|
|
|
|
// Sometimes, changes between versions involve
|
|
|
|
// alterations to database structures and other
|
|
|
|
// major things that may break installations.
|
|
|
|
//
|
|
|
|
// The upgrade function in this file will attempt
|
|
|
|
// to perform all the necessary actions to upgrade
|
|
|
|
// your older installtion to the current version.
|
|
|
|
//
|
|
|
|
// If there's something it cannot do itself, it
|
|
|
|
// will tell you what you need to do.
|
|
|
|
//
|
|
|
|
// The commands in here will all be database-neutral,
|
2008-06-15 10:32:50 +00:00
|
|
|
// using the methods of database_manager class
|
2006-10-26 17:33:40 +00:00
|
|
|
|
|
|
|
function xmldb_chat_upgrade($oldversion=0) {
|
|
|
|
|
2008-05-31 18:05:42 +00:00
|
|
|
global $CFG, $THEME, $DB;
|
2006-10-26 17:33:40 +00:00
|
|
|
|
2008-07-24 03:15:03 +00:00
|
|
|
$dbman = $DB->get_manager();
|
|
|
|
|
2006-10-26 17:33:40 +00:00
|
|
|
$result = true;
|
|
|
|
|
2008-07-24 05:28:56 +00:00
|
|
|
if ($result && $oldversion < 2008072400) {
|
2008-07-24 03:15:03 +00:00
|
|
|
|
2008-07-24 05:28:56 +00:00
|
|
|
/// Define table chat_messages_current to be created
|
2008-07-24 03:15:03 +00:00
|
|
|
$table = new xmldb_table('chat_messages_current');
|
|
|
|
|
2008-07-24 05:28:56 +00:00
|
|
|
/// Adding fields to table chat_messages_current
|
|
|
|
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
|
|
|
$table->add_field('chatid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
|
|
|
|
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
|
|
|
|
$table->add_field('groupid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
|
|
|
|
$table->add_field('system', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
|
|
|
$table->add_field('message', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
|
|
|
|
$table->add_field('timestamp', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
|
|
|
|
|
|
|
/// Adding keys to table chat_messages_current
|
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
|
|
$table->add_key('chatid', XMLDB_KEY_FOREIGN, array('chatid'), 'chat', array('id'));
|
|
|
|
|
|
|
|
/// Adding indexes to table chat_messages_current
|
|
|
|
$table->add_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
|
|
|
|
$table->add_index('groupid', XMLDB_INDEX_NOTUNIQUE, array('groupid'));
|
|
|
|
$table->add_index('timestamp-chatid', XMLDB_INDEX_NOTUNIQUE, array('timestamp', 'chatid'));
|
|
|
|
|
|
|
|
/// Conditionally launch create table for chat_messages_current
|
|
|
|
if (!$dbman->table_exists($table)) {
|
|
|
|
$dbman->create_table($table);
|
2008-07-24 03:15:03 +00:00
|
|
|
}
|
|
|
|
|
2008-07-24 05:28:56 +00:00
|
|
|
/// chat savepoint reached
|
|
|
|
upgrade_mod_savepoint($result, 2008072400, 'chat');
|
2008-07-24 03:15:03 +00:00
|
|
|
}
|
2006-10-26 17:33:40 +00:00
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|