drupal/core/modules/contact/contact.install

98 lines
2.4 KiB
Plaintext

<?php
/**
* @file
* Install, update and uninstall functions for the contact module.
*/
/**
* Implements hook_schema().
*/
function contact_schema() {
$schema['contact'] = array(
'description' => 'Contact form category settings.',
'fields' => array(
'cid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique category ID.',
),
'category' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Category name.',
'translatable' => TRUE,
),
'recipients' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => 'Comma-separated list of recipient e-mail addresses.',
),
'reply' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => 'Text of the auto-reply message.',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => "The category's weight.",
),
'selected' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Flag to indicate whether or not category is selected by default. (1 = Yes, 0 = No)',
),
),
'primary key' => array('cid'),
'unique keys' => array(
'category' => array('category'),
),
'indexes' => array(
'list' => array('weight', 'category'),
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function contact_install() {
$site_mail = config('system.site')->get('mail');
if (empty($site_mail)) {
$site_mail = ini_get('sendmail_from');
}
// Insert a default contact category.
db_insert('contact')
->fields(array(
'category' => 'Website feedback',
'recipients' => $site_mail,
'selected' => 1,
'reply' => '',
))
->execute();
}
/**
* Moves contact setting from variable to config.
*
* @ingroup config_upgrade
*/
function contact_update_8000() {
update_variables_to_config('contact.settings', array(
'contact_default_status' => 'user_default_enabled',
'contact_threshold_limit' => 'flood.limit',
'contact_threshold_window' => 'flood.interval',
));
}