function spam_content_delete in Spam 6
Same name and namespace in other branches
- 5.3 spam.module \spam_content_delete()
This function is called when content on your website is deleted.
Parameters
$content: An array holding the complete content.
$type: A string naming the type of content being deleted.
3 calls to spam_content_delete()
- spam_comment in content/
spam_content_comment.inc - Drupal _comment() hook.
- spam_nodeapi in content/
spam_content_node.inc - Drupal _nodeapi() hook.
- spam_user in content/
spam_content_user.inc
File
- ./
spam.module, line 374 - Spam module, v3 Copyright(c) 2006-2008 Jeremy Andrews <jeremy@tag1consulting.com>. All rights reserved.
Code
function spam_content_delete($content, $type, $extra = array()) {
$id = spam_invoke_module($type, 'content_id', $content, $extra);
spam_log(SPAM_VERBOSE, 'spam_content_delete', t('deleting'), $type, $id);
$error = FALSE;
if ($id) {
$sid = db_result(db_query("SELECT sid FROM {spam_tracker} WHERE content_type = '%s' AND content_id = '%s'", $type, $id));
if ($sid) {
$extra['sid'] = $sid;
if (!isset($extra['host'])) {
// Content type modules can set this value, should REMOTE_ADDR not be
// the correct IP for their content type.
$extra['host'] = ip_address();
}
$fields = spam_invoke_module($type, 'filter_fields', $content, $extra);
if (!empty($fields) && is_array($fields['main'])) {
$filters = db_query('SELECT name, module, gain FROM {spam_filters} WHERE status = %d ORDER BY weight', SPAM_FILTER_ENABLED);
while ($filter = db_fetch_object($filters)) {
// Let filters act on insert action.
spam_invoke_module($filter->module, 'delete', $type, $content, $fields, $extra);
}
}
else {
watchdog('spam', 'Function spam_content_delete failed, no fields are defined for %type content type.', array(
'%type' => $type,
), WATCHDOG_ERROR);
$error = -3;
}
db_query("DELETE FROM {spam_tracker} WHERE sid = %d", $sid);
watchdog('spam', 'Removed %type (id %id) from spam_tracker table.', array(
'%type' => $type,
'%id' => $id,
), WATCHDOG_NOTICE);
}
else {
watchdog('spam', 'Attempt to remove %type (id %id) from spam_tracker failed: does not exist.', array(
'%type' => $type,
'%id' => $id,
), WATCHDOG_NOTICE);
$error = -2;
}
}
else {
watchdog('spam', 'Function spam_content_delete failed, unable to delete %type from spam_tracker table, no id found in the content array.', array(
'%type' => $type,
), WATCHDOG_ERROR);
$error = -1;
}
return $error;
}