You are here

function find_spam_comments_btn in Anti Spam by CleanTalk 7.4

Same name and namespace in other branches
  1. 7.5 src/Form/CleantalkCheckCommentsForm.php \find_spam_comments_btn()
1 string reference to 'find_spam_comments_btn'
cleantalk_check_comments_form in src/Form/CleantalkCheckCommentsForm.php
Cleantalk check comments form.

File

src/Form/CleantalkCheckCommentsForm.php, line 82
CleanTalk module admin functions.

Code

function find_spam_comments_btn($form, &$form_state) {
  $check_finished = false;
  while (!$check_finished) {

    // Get all comments
    $comments = db_query("SELECT c.cid, c.uid, u.mail, c.name, c.subject, c.created, c.status FROM {comment} c INNER JOIN {users} u on c.uid = u.uid LIMIT " . $form_state['offset'] . ", 20")
      ->fetchAll();
    if (count($comments) > 0) {
      $spam_comments = cleantalk_find_spam_comments($comments);
      if (count($spam_comments) > 0) {
        $form_state['spam_comments'] = $spam_comments;
        if (isset($form_state['spam_comments'])) {
          array_unshift($spam_comments, $form_state['spam_comments'][0]);
        }
      }
      $form_state['offset'] += 20;
    }
    else {
      $check_finished = true;
    }
  }

  // rebuild whole form with new values
  $form_state['rebuild'] = true;
}