drupalchat.install in DrupalChat 7.2
Same filename and directory in other branches
Installation file for the DrupalChat module.
File
drupalchat.installView source
<?php
/**
* @file
* Installation file for the DrupalChat module.
*/
/**
* Implements hook_install().
*/
function drupalchat_install() {
// TODO The drupal_(un)install_schema functions are called automatically in D7.
$success = array();
if ($success) {
drupal_set_message(st('The DrupalChat module installed tables successfully.'));
}
else {
//drupal_set_message(st('The installation of the DrupalChat module failed.'), 'error');
}
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function drupalchat_uninstall() {
// TODO The drupal_(un)install_schema functions are called automatically in D7.
// drupal_uninstall_schema('drupalchat')
variable_del('drupalchat_polling_method');
variable_del('drupalchat_refresh_rate');
variable_del('drupalchat_send_rate');
variable_del('drupalchat_ur_name');
variable_del('drupalchat_ur_activate');
variable_del('drupalchat_theme');
variable_del('drupalchat_yui_path');
}
/**
* Implements hook_schema().
*/
function drupalchat_schema() {
$schema = array();
$schema['drupalchat_msg'] = array(
'fields' => array(
'message_id' => array(
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'description' => 'ID of chat message.',
),
'uid1' => array(
'description' => 'Uid of the sender.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'uid2' => array(
'description' => 'Uid of the receiver.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'message' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'description' => 'Chat message.',
),
'timestamp' => array(
'description' => 'The Unix timestamp when the XMPP account was created.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
),
'indexes' => array(
'uid1' => array(
'uid1',
),
'uid2' => array(
'uid2',
),
),
);
$schema['drupalchat_users'] = array(
'fields' => array(
'uid' => array(
'description' => 'The user uid.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'session' => array(
'description' => 'Current session id.',
'type' => 'varchar',
'length' => 60,
'not null' => TRUE,
),
'name' => array(
'description' => 'Name of the user.',
'type' => 'varchar',
'length' => 60,
'not null' => TRUE,
),
'status' => array(
'description' => 'Unix timestamp of last activity.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'timestamp' => array(
'description' => 'Unix timestamp of last activity.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
),
'primary key' => array(
'uid',
'session',
),
'indexes' => array(
'uid' => array(
'uid',
),
'session' => array(
'session',
),
'timestamp' => array(
'timestamp',
),
),
);
return $schema;
}
function drupalchat_update_7000() {
db_drop_index('drupalchat_msg', 'uid1');
db_drop_index('drupalchat_msg', 'uid2');
db_drop_primary_key('drupalchat_users');
db_change_field('drupalchat_msg', 'uid1', 'uid1', array(
'description' => 'Uid of the sender.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
));
db_change_field('drupalchat_msg', 'uid2', 'uid2', array(
'description' => 'Uid of the receiver.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
));
if (!db_index_exists('drupalchat_msg', 'uid1')) {
db_add_index('drupalchat_msg', 'uid1', array(
'uid1',
));
}
if (!db_index_exists('drupalchat_msg', 'uid2')) {
db_add_index('drupalchat_msg', 'uid2', array(
'uid2',
));
}
if (!db_index_exists('drupalchat_users', 'uid')) {
db_add_index('drupalchat_users', 'uid', array(
'uid',
));
}
if (!db_index_exists('drupalchat_users', 'session')) {
db_add_index('drupalchat_users', 'session', array(
'session',
));
}
}
function drupalchat_update_7001() {
if (!db_field_exists('drupalchat_msg', 'message_id')) {
db_add_field('drupalchat_msg', 'message_id', array(
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'description' => 'ID of chat message.',
));
}
}
Functions
Name | Description |
---|---|
drupalchat_install | Implements hook_install(). |
drupalchat_schema | Implements hook_schema(). |
drupalchat_uninstall | @todo Please document this function. |
drupalchat_update_7000 | |
drupalchat_update_7001 |