5 * Install, update and uninstall functions for the contact module.
9 * Implements hook_schema().
11 function contact_schema() {
12 $schema['contact'] = array(
13 'description' => 'Contact form category settings.',
19 'description' => 'Primary Key: Unique category ID.',
26 'description' => 'Category name.',
27 'translatable' => TRUE,
29 'recipients' => array(
33 'description' => 'Comma-separated list of recipient e-mail addresses.',
39 'description' => 'Text of the auto-reply message.',
45 'description' => "The category's weight.",
52 'description' => 'Flag to indicate whether or not category is selected by default. (1 = Yes, 0 = No)',
55 'primary key' => array('cid'),
56 'unique keys' => array(
57 'category' => array('category'),
60 'list' => array('weight', 'category'),
68 * Implements hook_install().
70 function contact_install() {
71 // Insert a default contact category.
74 'category' => 'Website feedback',
75 'recipients' => variable_get('site_mail', ini_get('sendmail_from')),
83 * Implements hook_uninstall().
85 function contact_uninstall() {
86 variable_del('contact_default_status');
87 variable_del('contact_threshold_limit');
88 variable_del('contact_threshold_window');
92 * Implements hook_update_dependencies().
94 function contact_update_dependencies() {
95 // contact_update_7001() relies on the {role_permission} table being updated
96 // to the new format and filled with data.
97 $dependencies['contact'][7001] = array(
101 // contact_update_7002() relies on the {role_permission} table having the
102 // module field, which is created in user_update_7006().
103 $dependencies['contact'][7002] = array(
107 return $dependencies;
111 * @addtogroup updates-6.x-to-7.x
116 * Rename the threshold limit variable.
118 function contact_update_7000() {
119 variable_set('contact_threshold_limit', variable_get('contact_hourly_threshold', 5));
120 variable_del('contact_hourly_threshold');
124 * Rename the administer contact forms permission.
126 function contact_update_7001() {
127 db_update('role_permission')
128 ->fields(array('permission' => 'administer contact forms'))
129 ->condition('permission', 'administer site-wide contact form')
134 * Enable the 'access user contact forms' for registered users by default.
136 function contact_update_7002() {
137 // Do not use user_role_grant_permission() since it relies on
138 // hook_permission(), which will not run for contact module if it is
140 db_merge('role_permission')
142 'rid' => DRUPAL_AUTHENTICATED_RID,
143 'permission' => 'access user contact forms',
144 'module' => 'contact',
150 * Change the weight column to normal int.
152 function contact_update_7003() {
153 db_drop_index('contact', 'list');
154 db_change_field('contact', 'weight', 'weight', array(
158 'description' => "The category's weight.",
161 'list' => array('weight', 'category'),
167 * @} End of "addtogroup updates-6.x-to-7.x".