| 1 |
<?php
|
| 2 |
// $Id: contact.install,v 1.20 2009/10/12 15:17:51 dries Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Install, update and uninstall functions for the contact module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implement hook_schema().
|
| 11 |
*/
|
| 12 |
function contact_schema() {
|
| 13 |
$schema['contact'] = array(
|
| 14 |
'description' => 'Contact form category settings.',
|
| 15 |
'fields' => array(
|
| 16 |
'cid' => array(
|
| 17 |
'type' => 'serial',
|
| 18 |
'unsigned' => TRUE,
|
| 19 |
'not null' => TRUE,
|
| 20 |
'description' => 'Primary Key: Unique category ID.',
|
| 21 |
),
|
| 22 |
'category' => array(
|
| 23 |
'type' => 'varchar',
|
| 24 |
'length' => 255,
|
| 25 |
'not null' => TRUE,
|
| 26 |
'default' => '',
|
| 27 |
'description' => 'Category name.',
|
| 28 |
'translatable' => TRUE,
|
| 29 |
),
|
| 30 |
'recipients' => array(
|
| 31 |
'type' => 'text',
|
| 32 |
'not null' => TRUE,
|
| 33 |
'size' => 'big',
|
| 34 |
'description' => 'Comma-separated list of recipient e-mail addresses.',
|
| 35 |
),
|
| 36 |
'reply' => array(
|
| 37 |
'type' => 'text',
|
| 38 |
'not null' => TRUE,
|
| 39 |
'size' => 'big',
|
| 40 |
'description' => 'Text of the auto-reply message.',
|
| 41 |
),
|
| 42 |
'weight' => array(
|
| 43 |
'type' => 'int',
|
| 44 |
'not null' => TRUE,
|
| 45 |
'default' => 0,
|
| 46 |
'size' => 'tiny',
|
| 47 |
'description' => "The category's weight.",
|
| 48 |
),
|
| 49 |
'selected' => array(
|
| 50 |
'type' => 'int',
|
| 51 |
'not null' => TRUE,
|
| 52 |
'default' => 0,
|
| 53 |
'size' => 'tiny',
|
| 54 |
'description' => 'Flag to indicate whether or not category is selected by default. (1 = Yes, 0 = No)',
|
| 55 |
),
|
| 56 |
),
|
| 57 |
'primary key' => array('cid'),
|
| 58 |
'unique keys' => array(
|
| 59 |
'category' => array('category'),
|
| 60 |
),
|
| 61 |
'indexes' => array(
|
| 62 |
'list' => array('weight', 'category'),
|
| 63 |
),
|
| 64 |
);
|
| 65 |
|
| 66 |
return $schema;
|
| 67 |
}
|
| 68 |
|
| 69 |
/**
|
| 70 |
* Implement hook_install().
|
| 71 |
*/
|
| 72 |
function contact_install() {
|
| 73 |
// Insert a default contact category.
|
| 74 |
db_insert('contact')
|
| 75 |
->fields(array(
|
| 76 |
'category' => 'Website feedback',
|
| 77 |
'recipients' => variable_get('site_mail', ini_get('sendmail_from')),
|
| 78 |
'selected' => 1,
|
| 79 |
'reply' => '',
|
| 80 |
))
|
| 81 |
->execute();
|
| 82 |
}
|
| 83 |
|
| 84 |
/**
|
| 85 |
* Implement hook_uninstall().
|
| 86 |
*/
|
| 87 |
function contact_uninstall() {
|
| 88 |
variable_del('contact_default_status');
|
| 89 |
variable_del('contact_threshold_limit');
|
| 90 |
variable_del('contact_threshold_window');
|
| 91 |
}
|
| 92 |
|
| 93 |
/**
|
| 94 |
* @defgroup updates-6.x-to-7.x Contact updates from 6.x to 7.x
|
| 95 |
* @{
|
| 96 |
*/
|
| 97 |
|
| 98 |
/**
|
| 99 |
* Rename the threshold limit variable.
|
| 100 |
*/
|
| 101 |
function contact_update_7000() {
|
| 102 |
variable_set('contact_threshold_limit', variable_get('contact_hourly_threshold', 5));
|
| 103 |
variable_del('contact_hourly_threshold');
|
| 104 |
}
|
| 105 |
|
| 106 |
/**
|
| 107 |
* Rename the administer contact forms permission.
|
| 108 |
*/
|
| 109 |
function contact_update_7001() {
|
| 110 |
db_update('role_permission')
|
| 111 |
->fields(array('permission' => 'administer contact forms'))
|
| 112 |
->condition('permission', 'administer site-wide contact form')
|
| 113 |
->execute();
|
| 114 |
}
|
| 115 |
|
| 116 |
/**
|
| 117 |
* Enable the 'access user contact forms' for registered users by default.
|
| 118 |
*/
|
| 119 |
function contact_update_7002() {
|
| 120 |
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access user contact forms'));
|
| 121 |
}
|
| 122 |
|
| 123 |
/**
|
| 124 |
* @} End of "defgroup updates-6.x-to-7.x"
|
| 125 |
* The next series of updates should start at 8000.
|
| 126 |
*/
|