function custom_upgrade in Spam 5.3
1 call to custom_upgrade()
- _custom_upgrade in filters/
custom/ custom.module - Upgrade from 5.x-1.x spam module. This doesn't live in the custom.install file, as there was no custom.module in the 5.x-1.x release (it was part of the core spam module). This doesn't live in spam.install because the spam_custom table…
File
- filters/
custom/ custom-upgrade.inc, line 18
Code
function custom_upgrade() {
if ($result = db_result(db_query("SHOW TABLES LIKE 'old_spam_custom'"))) {
drupal_set_message('Upgrading custom spam filter rules.');
$result = db_query('SELECT * FROM {old_spam_custom}');
while ($old = db_fetch_object($result)) {
switch ($old->style) {
case SPAM_CUSTOM_PLAIN:
case SPAM_CUSTOM_URL:
$style = SPAM_CUSTOM_STYLE_PLAIN;
break;
case SPAM_CUSTOM_REGEX:
$style = SPAM_CUSTOM_STYLE_REGEX;
break;
}
switch ($old->effect) {
case SPAM_CUSTOM_DISABLED:
default:
$status = SPAM_CUSTOM_STATUS_DISABLED;
break;
case SPAM_CUSTOM_MAYBE_SPAM:
case SPAM_CUSTOM_USUALLY_SPAM:
$status = SPAM_CUSTOM_STATUS_PROBABLY;
break;
case SPAM_CUSTOM_USUALLY_NOTSPAM:
case SPAM_CUSTOM_MAYBE_NOTSPAM:
$status = SPAM_CUSTOM_STATUS_PROBABLYNOT;
break;
case SPAM_CUSTOM_NEVER_SPAM:
$status = SPAM_CUSTOM_STATUS_NOTSPAM;
break;
case SPAM_CUSTOM_ALWAYS_SPAM:
$status = SPAM_CUSTOM_STATUS_SPAM;
break;
}
if ($old->action & SPAM_CUSTOM_ACTION_HEADER || $old->action & SPAM_CUSTOM_ACTION_BODY) {
$scan = SPAM_CUSTOM_SCAN_CONTENT;
}
else {
$scan = SPAM_CUSTOM_SCAN_CONTENT;
$status = SPAM_CUSTOM_STATUS_DISABLED;
}
db_query("INSERT INTO {spam_custom} (filter, style, status, scan, matches, last) VALUES('%s', %d, %d, %d, %d, %d)", $old->filter, $style, $status, $scan, $old->matches, $old->last);
}
// Done with upgrade, drop old table.
db_query('DROP TABLE {old_spam_custom}');
}
}