You are here

function find_spam_users_btn in Anti Spam by CleanTalk 7.5

Same name and namespace in other branches
  1. 7.4 src/Form/CleantalkCheckUsersForm.php \find_spam_users_btn()
1 string reference to 'find_spam_users_btn'
cleantalk_check_users_form in src/Form/CleantalkCheckUsersForm.php
Cleantalk check users form.

File

src/Form/CleantalkCheckUsersForm.php, line 85
CleanTalk module admin functions.

Code

function find_spam_users_btn($form, &$form_state) {
  $check_finished = false;
  while (!$check_finished) {
    $accounts = db_select('users', 'u')
      ->fields('u')
      ->range($form_state['offset'], 20)
      ->execute()
      ->fetchAll();
    if (count($accounts) > 0) {
      $spam_users = cleantalk_find_spam_users($accounts);
      if (count($spam_users) > 0) {
        $form_state['spam_users'] = $spam_users;
        if (isset($form_state['spam_users'])) {
          array_unshift($spam_users, $form_state['spam_users'][0]);
        }
      }
      $form_state['offset'] += 20;
    }
    else {
      $check_finished = true;
    }
  }

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