2006-07-13 13:14:25 +00:00
|
|
|
<?php
|
|
|
|
|
2009-05-13 19:42:18 +00:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Install, update and uninstall functions for the contact module.
|
|
|
|
*/
|
|
|
|
|
2007-10-05 14:43:26 +00:00
|
|
|
/**
|
2009-12-04 16:49:48 +00:00
|
|
|
* Implements hook_schema().
|
2007-10-05 14:43:26 +00:00
|
|
|
*/
|
|
|
|
function contact_schema() {
|
|
|
|
$schema['contact'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Contact form category settings.',
|
2007-10-05 14:43:26 +00:00
|
|
|
'fields' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'cid' => array(
|
|
|
|
'type' => 'serial',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Primary Key: Unique category ID.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'category' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 255,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => '',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Category name.',
|
2009-10-16 19:06:25 +00:00
|
|
|
'translatable' => TRUE,
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'recipients' => array(
|
|
|
|
'type' => 'text',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'size' => 'big',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Comma-separated list of recipient e-mail addresses.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'reply' => array(
|
|
|
|
'type' => 'text',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'size' => 'big',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Text of the auto-reply message.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'weight' => array(
|
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => "The category's weight.",
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
|
|
|
'selected' => array(
|
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
|
|
|
'size' => 'tiny',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Flag to indicate whether or not category is selected by default. (1 = Yes, 0 = No)',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
2007-10-05 14:43:26 +00:00
|
|
|
),
|
|
|
|
'primary key' => array('cid'),
|
2007-12-18 12:59:22 +00:00
|
|
|
'unique keys' => array(
|
|
|
|
'category' => array('category'),
|
|
|
|
),
|
|
|
|
'indexes' => array(
|
|
|
|
'list' => array('weight', 'category'),
|
|
|
|
),
|
2007-10-05 14:43:26 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
return $schema;
|
|
|
|
}
|
2009-09-26 00:13:19 +00:00
|
|
|
|
2009-10-09 02:54:10 +00:00
|
|
|
/**
|
2009-12-04 16:49:48 +00:00
|
|
|
* Implements hook_install().
|
2009-10-09 02:54:10 +00:00
|
|
|
*/
|
|
|
|
function contact_install() {
|
2012-07-02 17:20:33 +00:00
|
|
|
$site_mail = config('system.site')->get('mail');
|
|
|
|
if (empty($site_mail)) {
|
|
|
|
$site_mail = ini_get('sendmail_from');
|
|
|
|
}
|
2009-10-09 02:54:10 +00:00
|
|
|
// Insert a default contact category.
|
|
|
|
db_insert('contact')
|
|
|
|
->fields(array(
|
|
|
|
'category' => 'Website feedback',
|
2012-07-02 17:20:33 +00:00
|
|
|
'recipients' => $site_mail,
|
2009-10-09 02:54:10 +00:00
|
|
|
'selected' => 1,
|
|
|
|
'reply' => '',
|
|
|
|
))
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
|
2009-10-09 02:34:07 +00:00
|
|
|
/**
|
2009-12-04 16:49:48 +00:00
|
|
|
* Implements hook_uninstall().
|
2009-10-09 02:34:07 +00:00
|
|
|
*/
|
|
|
|
function contact_uninstall() {
|
|
|
|
variable_del('contact_default_status');
|
|
|
|
variable_del('contact_threshold_limit');
|
|
|
|
variable_del('contact_threshold_window');
|
|
|
|
}
|