function antispam_confirm_multiple_operation_submit in AntiSpam 6
Same name and namespace in other branches
- 7 antispam.admin.inc \antispam_confirm_multiple_operation_submit()
confirm_form callback; perform the actual operation against selected content.
File
- ./
antispam.admin.inc, line 905
Code
function antispam_confirm_multiple_operation_submit($form, &$form_state) {
$mode = $form_state['values']['mode'];
$submode = $form_state['values']['submode'];
$operation = $form_state['values']['operation'];
$valid_operations = antispam_moderator_operations($mode, $submode);
// Make sure we deal with a valid combination of mode, submode and operation.
if (!isset($valid_operations[$operation])) {
$form_state['redirect'] = 'admin/content/antispam';
return;
}
if ($form_state['values']['confirm']) {
$content_type = $mode == 'nodes' ? 'node' : 'comment';
foreach ($form_state['values']['items'] as $content_id => $value) {
if ($operation == 'delete') {
antispam_content_delete($content_type, $content_id);
$message = $mode == 'nodes' ? t('The nodes have been deleted.') : t('The comments have been deleted.');
}
else {
if ($content = antispam_content_load($content_type, $content_id)) {
if ($content_type == 'node') {
$is_published = $content->status ? TRUE : FALSE;
}
else {
// comment
$is_published = $content->status == COMMENT_PUBLISHED ? TRUE : FALSE;
}
$is_spam = antispam_content_is_spam($content_type, $content_id);
if ($operation == 'submit-spam' && !$is_spam) {
antispam_content_spam_operation($content_type, $content, 'submit-spam', TRUE);
antispam_increase_counter(ANTISPAM_COUNT_FALSE_NEGATIVE);
}
else {
if ($operation == 'submit-ham' && $is_spam) {
antispam_content_spam_operation($content_type, $content, 'submit-ham', TRUE);
antispam_increase_counter(ANTISPAM_COUNT_FALSE_POSITIVE);
}
}
if (in_array($operation, array(
'unpublish',
'submit-spam',
)) && $is_published) {
antispam_content_publish_operation($content_type, $content, 'unpublish');
}
else {
if (in_array($operation, array(
'publish',
'submit-ham',
)) && !$is_published) {
antispam_content_publish_operation($content_type, $content, 'publish');
}
}
$message = $mode == 'nodes' ? t('The nodes have been updated.') : t('The comments have been updated.');
}
}
}
drupal_set_message($message);
}
$form_state['redirect'] = 'admin/content/antispam/' . $mode;
if ($submode != 'spam') {
$form_state['redirect'] .= '/' . $submode;
}
return;
}