| 1 |
<?php
|
| 2 |
// $Id: akismet.install,v 1.4 2008/03/24 23:31:16 drewish Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_schema().
|
| 6 |
*/
|
| 7 |
function akismet_schema() {
|
| 8 |
$schema['akismet_spam_marks'] = array(
|
| 9 |
'fields' => array(
|
| 10 |
'content_type' => array(
|
| 11 |
'type' => 'varchar',
|
| 12 |
'length' => 20,
|
| 13 |
'not null' => TRUE,
|
| 14 |
'default' => '',
|
| 15 |
),
|
| 16 |
'content_id' => array(
|
| 17 |
'type' => 'int',
|
| 18 |
'unsigned' => TRUE,
|
| 19 |
'not null' => TRUE,
|
| 20 |
'default' => 0,
|
| 21 |
),
|
| 22 |
'spam_created' => array(
|
| 23 |
'type' => 'int',
|
| 24 |
'unsigned' => TRUE,
|
| 25 |
'not null' => TRUE,
|
| 26 |
'default' => 0,
|
| 27 |
),
|
| 28 |
'hostname' => array(
|
| 29 |
'type' => 'varchar',
|
| 30 |
'length' => 128,
|
| 31 |
'not null' => TRUE,
|
| 32 |
'default' => '',
|
| 33 |
),
|
| 34 |
'mail' => array(
|
| 35 |
'type' => 'varchar',
|
| 36 |
'length' => 128,
|
| 37 |
'not null' => TRUE,
|
| 38 |
'default' => '',
|
| 39 |
),
|
| 40 |
),
|
| 41 |
'unique key' => array(
|
| 42 |
'content' => array('content_type', 'content_id'),
|
| 43 |
),
|
| 44 |
'indexes' => array(
|
| 45 |
'spam_created' => array('spam_created'),
|
| 46 |
'hostname' => array('hostname'),
|
| 47 |
'mail' => array('mail'),
|
| 48 |
),
|
| 49 |
);
|
| 50 |
$schema['akismet_moderator'] = array(
|
| 51 |
'fields' => array(
|
| 52 |
'uid' => array(
|
| 53 |
'type' => 'int',
|
| 54 |
'unsigned' => TRUE,
|
| 55 |
'not null' => TRUE,
|
| 56 |
'default' => 0,
|
| 57 |
),
|
| 58 |
'email_for' => array(
|
| 59 |
'type' => 'varchar',
|
| 60 |
'length' => 20,
|
| 61 |
'not null' => TRUE,
|
| 62 |
'default' => '',
|
| 63 |
),
|
| 64 |
),
|
| 65 |
'primary key' => array('uid'),
|
| 66 |
'indexes' => array(
|
| 67 |
'email_for' => array('email_for'),
|
| 68 |
),
|
| 69 |
);
|
| 70 |
return $schema;
|
| 71 |
}
|
| 72 |
|
| 73 |
/**
|
| 74 |
* Implementation of hook_install().
|
| 75 |
*/
|
| 76 |
function akismet_install() {
|
| 77 |
drupal_install_schema('akismet');
|
| 78 |
}
|
| 79 |
|
| 80 |
/**
|
| 81 |
* Implementation of hook_uninstall().
|
| 82 |
*/
|
| 83 |
function akismet_uninstall() {
|
| 84 |
drupal_uninstall_schema('akismet');
|
| 85 |
variable_del('akismet_wpapikey');
|
| 86 |
variable_del('akismet_connection_enabled');
|
| 87 |
variable_del('akismet_connection_timeout');
|
| 88 |
variable_del('akismet_remove_spam_age');
|
| 89 |
variable_del('akismet_records_per_page');
|
| 90 |
variable_del('akismet_blocks_counter');
|
| 91 |
variable_del('akismet_email_enabled');
|
| 92 |
variable_del('akismet_check_nodetypes');
|
| 93 |
variable_del('akismet_node_publish_links');
|
| 94 |
variable_del('akismet_node_spam_links');
|
| 95 |
variable_del('akismet_check_comments');
|
| 96 |
variable_del('akismet_comment_publish_links');
|
| 97 |
variable_del('akismet_comment_spam_links');
|
| 98 |
variable_del('akismet_counter_since');
|
| 99 |
variable_del('akismet_counter_date_format');
|
| 100 |
variable_del('akismet_antispambot_delay');
|
| 101 |
variable_del('akismet_antispambot_rules');
|
| 102 |
variable_del('akismet_antispambot_action');
|
| 103 |
}
|
| 104 |
|
| 105 |
/**
|
| 106 |
* Update 1: Add table for moderator extensions.
|
| 107 |
*/
|
| 108 |
function akismet_update_1() {
|
| 109 |
$schema['akismet_moderator'] = array(
|
| 110 |
'field' => array(
|
| 111 |
'uid' => array(
|
| 112 |
'type' => 'int',
|
| 113 |
'unsigned' => TRUE,
|
| 114 |
'not null' => TRUE,
|
| 115 |
'default' => 0,
|
| 116 |
),
|
| 117 |
'email_for' => array(
|
| 118 |
'type' => 'varchar',
|
| 119 |
'length' => 20,
|
| 120 |
'not null' => TRUE,
|
| 121 |
'default' => '',
|
| 122 |
),
|
| 123 |
),
|
| 124 |
'primary key' => array('uid'),
|
| 125 |
'indexes' => array(
|
| 126 |
'email_for' => array('email_for'),
|
| 127 |
),
|
| 128 |
);
|
| 129 |
|
| 130 |
$ret = array();
|
| 131 |
db_create_table($ret, 'akismet_moderator', $schema['akismet_moderator']);
|
| 132 |
return $ret;
|
| 133 |
}
|
| 134 |
|
| 135 |
/**
|
| 136 |
* Update 2: Add columns hostname and mail to {akismet_spam_marks} table.
|
| 137 |
*/
|
| 138 |
function akismet_update_2() {
|
| 139 |
$ret = array();
|
| 140 |
|
| 141 |
db_add_field($ret, 'akismet_spam_marks', 'hostname', array(
|
| 142 |
'type' => 'varchar',
|
| 143 |
'length' => 128,
|
| 144 |
'not null' => TRUE,
|
| 145 |
'default' => '',
|
| 146 |
));
|
| 147 |
db_add_index($ret, 'akismet_spam_marks', 'hostname', array('hostname'));
|
| 148 |
|
| 149 |
db_add_field($ret, 'akismet_spam_marks', 'mail', array(
|
| 150 |
'type' => 'varchar',
|
| 151 |
'length' => 128,
|
| 152 |
'not null' => TRUE,
|
| 153 |
'default' => '',
|
| 154 |
));
|
| 155 |
db_add_index($ret, 'akismet_spam_marks', 'mail', array('mail'));
|
| 156 |
|
| 157 |
return $ret;
|
| 158 |
}
|