| 1 |
<?php
|
| 2 |
// $Id: signup_status.install,v 1.6 2009/09/18 23:38:23 dww Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* signup_status module installation and upgrade code.
|
| 7 |
*/
|
| 8 |
|
| 9 |
//////////////////////////////////////////////////////////////////////////////
|
| 10 |
// Core API hooks
|
| 11 |
|
| 12 |
/**
|
| 13 |
* Implementation of hook_enable().
|
| 14 |
*/
|
| 15 |
function signup_status_enable() {
|
| 16 |
drupal_set_message(t('signup_status module successfully installed. Please review the available <a href="@settings">configuration settings</a>.', array('@settings' => url('admin/settings/signup_status'))));
|
| 17 |
}
|
| 18 |
|
| 19 |
/**
|
| 20 |
* Implementation of hook_install().
|
| 21 |
*/
|
| 22 |
function signup_status_install() {
|
| 23 |
drupal_install_schema('signup_status');
|
| 24 |
|
| 25 |
$ret = array();
|
| 26 |
db_add_field($ret, 'signup_log', 'status', array(
|
| 27 |
'type' => 'int',
|
| 28 |
'not null' => TRUE,
|
| 29 |
'default' => '0',
|
| 30 |
'description' => t('The status status.'),
|
| 31 |
));
|
| 32 |
|
| 33 |
return $ret;
|
| 34 |
}
|
| 35 |
|
| 36 |
/**
|
| 37 |
* Implementation of hook_uninstall().
|
| 38 |
*/
|
| 39 |
function signup_status_uninstall() {
|
| 40 |
drupal_uninstall_schema('signup_status');
|
| 41 |
|
| 42 |
$ret = array();
|
| 43 |
db_drop_field($ret, 'signup_log', 'status');
|
| 44 |
|
| 45 |
return $ret;
|
| 46 |
}
|
| 47 |
|
| 48 |
//////////////////////////////////////////////////////////////////////////////
|
| 49 |
// Schema API hooks
|
| 50 |
|
| 51 |
/**
|
| 52 |
* Implementation of hook_schema().
|
| 53 |
*/
|
| 54 |
function signup_status_schema() {
|
| 55 |
return array(
|
| 56 |
'signup_status_codes' => array(
|
| 57 |
'description' => t('Stores signup statuses.'),
|
| 58 |
'fields' => array(
|
| 59 |
'cid' => array(
|
| 60 |
'type' => 'serial',
|
| 61 |
'unsigned' => TRUE,
|
| 62 |
'not null' => TRUE,
|
| 63 |
'description' => t('The signup status code ID.'),
|
| 64 |
),
|
| 65 |
'name' => array(
|
| 66 |
'type' => 'varchar',
|
| 67 |
'length' => 128,
|
| 68 |
'not null' => TRUE,
|
| 69 |
'description' => t('The name of the signup status.'),
|
| 70 |
),
|
| 71 |
'description' => array(
|
| 72 |
'type' => 'text',
|
| 73 |
'size' => 'big',
|
| 74 |
'not null' => TRUE,
|
| 75 |
'description' => t('The description of the signup status.'),
|
| 76 |
),
|
| 77 |
'mod_signup_count' => array(
|
| 78 |
'type' => 'int',
|
| 79 |
'not null' => TRUE,
|
| 80 |
'default' => 0,
|
| 81 |
'size' => 'tiny',
|
| 82 |
'description' => t('A flag showing if users with this signup status should be added to the total count of signed up users.'),
|
| 83 |
),
|
| 84 |
'show_on_form' => array(
|
| 85 |
'type' => 'int',
|
| 86 |
'not null' => TRUE,
|
| 87 |
'default' => 0,
|
| 88 |
'size' => 'tiny',
|
| 89 |
'description' => t('A flag showing if this signup status should be shown on the signup form.'),
|
| 90 |
),
|
| 91 |
'weight' => array(
|
| 92 |
'type' => 'int',
|
| 93 |
'not null' => TRUE,
|
| 94 |
'default' => 0,
|
| 95 |
'description' => t('The weight of this signup status in the UI'),
|
| 96 |
),
|
| 97 |
),
|
| 98 |
'primary key' => array('cid'),
|
| 99 |
'unique key' => array('name'),
|
| 100 |
),
|
| 101 |
);
|
| 102 |
}
|
| 103 |
|
| 104 |
/**
|
| 105 |
* Implementation of hook_schema_alter().
|
| 106 |
*/
|
| 107 |
function signup_status_schema_alter(&$schema) {
|
| 108 |
$schema['signup_log']['fields']['status'] = array(
|
| 109 |
'type' => 'int',
|
| 110 |
'not null' => TRUE,
|
| 111 |
'default' => '0',
|
| 112 |
'description' => t('The status status.'),
|
| 113 |
);
|
| 114 |
}
|
| 115 |
|
| 116 |
//////////////////////////////////////////////////////////////////////////////
|
| 117 |
// Schema update functions
|
| 118 |
|
| 119 |
/**
|
| 120 |
* Add the {signup_status_codes}.weight column.
|
| 121 |
*/
|
| 122 |
function signup_status_update_6000() {
|
| 123 |
$ret = array();
|
| 124 |
$field = array(
|
| 125 |
'type' => 'int',
|
| 126 |
'not null' => TRUE,
|
| 127 |
'default' => 0,
|
| 128 |
);
|
| 129 |
db_add_field($ret, 'signup_status_codes', 'weight', $field);
|
| 130 |
// As an initial default, weight the status codes by the cid. This
|
| 131 |
// replicates the previous cronological order of status codes.
|
| 132 |
$ret[] = update_sql("UPDATE {signup_status_codes} SET weight = cid");
|
| 133 |
return $ret;
|
| 134 |
}
|
| 135 |
|