function cleantalk_check_comments_form in Anti Spam by CleanTalk 7.4
Same name and namespace in other branches
- 7.5 src/Form/CleantalkCheckCommentsForm.php \cleantalk_check_comments_form()
Cleantalk check comments form.
1 string reference to 'cleantalk_check_comments_form'
- cleantalk_menu in ./
cleantalk.module - Implements hook_menu().
File
- src/
Form/ CleantalkCheckCommentsForm.php, line 12 - CleanTalk module admin functions.
Code
function cleantalk_check_comments_form($form, &$form_state) {
if (module_exists('comment')) {
if (variable_get('cleantalk_authkey', '') != '') {
$rows = array();
$header = array(
'spam_comment_name' => t('Name'),
'spam_comment_email' => t('E-mail'),
'spam_comment_subject' => t('Subject'),
'spam_comment_created' => t('Created'),
'spam_comment_status' => t('Status'),
);
if (!isset($form_state['offset'])) {
$form_state['offset'] = 0;
}
if (isset($form_state['spam_comments'])) {
foreach ($form_state['spam_comments'] as $spam_comment) {
$rows[] = array(
'spam_comment_name' => $spam_comment->name,
'spam_comment_email' => '<a target="_blank" href = "https://cleantalk.org/blacklists/' . $spam_comment->mail . '">' . $spam_comment->mail . '</a>',
'spam_comment_subject' => $spam_comment->subject,
'spam_comment_created' => date("Y-m-d H:i:s", $spam_comment->created),
'spam_comment_status' => $spam_comment->status == 1 ? 'Active' : 'Inactive',
'#attributes' => array(
'comment_id' => $spam_comment->cid,
'class' => array(
'cleantalk-spam-comments-row',
),
),
);
}
}
$form['cleantalk_spam_comments']['cleantalk_spam_comments_wrapper'] = array(
'#type' => 'container',
'#tree' => TRUE,
'#prefix' => '<div id="cleantalk_spam_comments_wrapper">',
'#suffix' => '</div>',
);
$form['cleantalk_spam_comments']['cleantalk_spam_comments_wrapper']['find_spam_comments'] = array(
'#type' => 'submit',
'#value' => t('Find spam comments'),
'#submit' => array(
'find_spam_comments_btn',
),
'#ajax' => array(
'callback' => 'bulk_find_spam_comments_callback',
'wrapper' => 'cleantalk_spam_comments_wrapper',
),
);
$form['cleantalk_spam_comments']['cleantalk_spam_comments_wrapper']['cleantalk_spam_comments_table_actions'] = array(
'#type' => 'select',
'#title' => t('Actions'),
'#options' => array(
1 => t('Delete'),
),
);
$form['cleantalk_spam_comments']['cleantalk_spam_comments_wrapper']['cleantalk_spam_comments_table'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
'#empty' => t('No spam comments found'),
'#attributes' => array(
'class' => array(
'cleantalk_spam_comments_table',
),
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
else {
drupal_set_message('Access key is not valid.', 'error');
}
}
else {
drupal_set_message('Comments module is disabled.', 'error');
}
}