View source
<?php
function messaging_template_schema() {
$schema['messaging_message_parts'] = array(
'description' => 'Templates for message composition.',
'fields' => array(
'tpid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Unique template part id.',
),
'type' => array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
'description' => 'Message group key.',
),
'method' => array(
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => '',
'description' => 'Messaging send method.',
),
'msgkey' => array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
'description' => 'Message part key, should be unique within a group (header, footer,..).',
),
'module' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Module that owns this template.',
),
'message' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => 'Message template, multiline text with tokens for replacement.',
),
'language' => array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'description' => 'Language code.',
),
'format' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The input format used by this text.',
),
'data' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'Additional serialized parameters.',
),
),
'primary key' => array(
'tpid',
),
'indexes' => array(
'type' => array(
'type',
),
'method' => array(
'method',
),
'msgkey' => array(
'msgkey',
),
'language' => array(
'language',
),
),
);
return $schema;
}
function messaging_template_install() {
if (!db_table_exists('messaging_message_parts')) {
drupal_install_schema('messaging_template');
}
}
function messaging_template_uninstall() {
drupal_uninstall_schema('messaging_template');
}
function messaging_template_update_6001() {
$ret = array();
db_add_field($ret, 'messaging_message_parts', 'tpid', array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
), array(
'primary key' => array(
'tpid',
),
));
db_add_field($ret, 'messaging_message_parts', 'language', array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
), array(
'indexes' => array(
'language' => array(
'language',
),
),
));
$lang = language_default('language');
$ret[] = update_sql("UPDATE {messaging_message_parts} SET language = '{$lang}'");
return $ret;
}
function messaging_template_update_6002() {
$ret = array();
db_add_field($ret, 'messaging_message_parts', 'format', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
));
db_add_field($ret, 'messaging_message_parts', 'data', array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'default' => '',
'serialize' => TRUE,
));
return $ret;
}