| 1 |
<?php
|
| 2 |
// $Id: account_reminder.install,v 1.6 2009/06/27 20:57:23 jaydub Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implement hook_schema().
|
| 6 |
*/
|
| 7 |
function account_reminder_schema() {
|
| 8 |
$schema['account_reminder'] = array(
|
| 9 |
'description' => 'The {account_reminder} table stores records for email reminders that have sent out to users.',
|
| 10 |
'fields' => array(
|
| 11 |
'uid' => array(
|
| 12 |
'description' => 'The user ID (corresponds to {user} table uid).',
|
| 13 |
'type' => 'int',
|
| 14 |
'not null' => TRUE,
|
| 15 |
),
|
| 16 |
'last_reminder' => array(
|
| 17 |
'description' => 'The last time a reminder was sent to a user.',
|
| 18 |
'type' => 'int',
|
| 19 |
),
|
| 20 |
'msg_cnt' => array(
|
| 21 |
'description' => 'The number of times a reminder has been sent to a user.',
|
| 22 |
'type' => 'int',
|
| 23 |
'default' => 0,
|
| 24 |
),
|
| 25 |
),
|
| 26 |
'primary key' => array('uid'),
|
| 27 |
);
|
| 28 |
return $schema;
|
| 29 |
}
|
| 30 |
|
| 31 |
/**
|
| 32 |
* Implement hook_install().
|
| 33 |
*/
|
| 34 |
function account_reminder_install() {
|
| 35 |
drupal_install_schema('account_reminder');
|
| 36 |
}
|
| 37 |
|
| 38 |
/**
|
| 39 |
* Implement hook_update_N().
|
| 40 |
*/
|
| 41 |
function account_reminder_update_1() {
|
| 42 |
return _system_update_utf8(array('account_reminder'));
|
| 43 |
}
|
| 44 |
|
| 45 |
/**
|
| 46 |
* Implement hook_update_N().
|
| 47 |
*
|
| 48 |
* In order to improve compatibility with other database, the account_reminder
|
| 49 |
* column is changed from TIMESTAMP to INT. Also, unneeded indexes are removed.
|
| 50 |
*/
|
| 51 |
function account_reminder_update_2() {
|
| 52 |
$ret = array();
|
| 53 |
switch ($GLOBALS['db_type']) {
|
| 54 |
case 'mysql':
|
| 55 |
case 'mysqli':
|
| 56 |
$ret[] = update_sql("ALTER TABLE {account_reminder} ADD COLUMN temp_last_reminder INT(11)");
|
| 57 |
$ret[] = update_sql("UPDATE {account_reminder} SET temp_last_reminder = UNIX_TIMESTAMP(last_reminder)");
|
| 58 |
$ret[] = update_sql("ALTER TABLE {account_reminder} DROP COLUMN last_reminder");
|
| 59 |
$ret[] = update_sql("ALTER TABLE {account_reminder} CHANGE temp_last_reminder last_reminder INT(11)");
|
| 60 |
$ret[] = update_sql("ALTER TABLE {account_reminder} DROP INDEX msg_cnt");
|
| 61 |
break;
|
| 62 |
}
|
| 63 |
return $ret;
|
| 64 |
}
|
| 65 |
|
| 66 |
/**
|
| 67 |
* Implement hook_update_N().
|
| 68 |
*
|
| 69 |
* Check the account reminder email subject and body and make sure any % placeholders are
|
| 70 |
* changed to ! placeholders.
|
| 71 |
*/
|
| 72 |
function account_reminder_update_6100() {
|
| 73 |
$ret = array();
|
| 74 |
if ($subject = variable_get('account_reminder_subject', FALSE)) {
|
| 75 |
variable_set('account_reminder_subject', str_replace('%', '!', $subject));
|
| 76 |
}
|
| 77 |
if ($msg = variable_get('account_reminder_msg', FALSE)) {
|
| 78 |
variable_set('account_reminder_msg', str_replace('%', '!', $msg));
|
| 79 |
}
|
| 80 |
return $ret;
|
| 81 |
}
|
| 82 |
|
| 83 |
/**
|
| 84 |
* Implement hook_uninstall().
|
| 85 |
*/
|
| 86 |
function account_reminder_uninstall() {
|
| 87 |
drupal_uninstall_schema('account_reminder');
|
| 88 |
variable_del('account_reminder_cronlimit');
|
| 89 |
variable_del('account_reminder_frequency');
|
| 90 |
variable_del('account_reminder_initial');
|
| 91 |
variable_del('account_reminder_total');
|
| 92 |
variable_del('account_reminder_subject');
|
| 93 |
variable_del('account_reminder_msg');
|
| 94 |
}
|