You are here

function _email_verify_batch_display_get_max in Email Verify 8.2

Same name and namespace in other branches
  1. 7.2 email_verify.check.inc \_email_verify_batch_display_get_max()

Retrieves the number of users to verify.

Parameters

int $user_count: The number of user email addresses to verify.

int $user_offset: The number of users to skip before beginning verification.

bool $disabled_users: Indicates whether to include disabled users or not. A value of TRUE (or 1) includes them, where a value of FALSE (or 0) does not.

int $current_uid: The user ID of the user to start the verification on.

Return value

int The value that goes in the batch sandbox's 'max' variable, which is the maximum number of records to process.

1 call to _email_verify_batch_display_get_max()
email_verify_user_check_form_submit in ./email_verify.check.inc
Submit handler for the user check form.

File

./email_verify.check.inc, line 237
User email check menu callback file for email_verify module.

Code

function _email_verify_batch_display_get_max($user_count, $user_offset, $disabled_users, $current_uid) {

  // Default to not running the batch.
  $max = 0;
  if (empty($user_count)) {

    // Set 'max' to the total number of users in the database.
    $query = 'SELECT COUNT(uid) FROM users';

    // Check for whether to include blocked users.
    if (empty($disabled_users)) {
      $query .= ' WHERE status = 1';
    }
    $max = db_query($query)
      ->fetchField();

    // If the offset value is not empty, use it to modify $max.
    if (!empty($user_offset)) {
      $max = $max - $user_offset;
    }
  }
  else {
    if (empty($user_offset)) {

      // Set 'max' to number of users specified in the form.
      $max = $user_count;
    }
    else {

      // Set 'max' to number of users specified in the form, using the offset.
      $query = 'SELECT uid FROM users WHERE uid >= :start_uid';

      // Check for whether to include blocked users.
      if (empty($disabled_users)) {
        $query .= ' AND status = 1';
      }
      $query .= ' ORDER BY uid ASC LIMIT ' . $user_count;
      $results = db_query($query, array(
        ':start_uid' => $current_uid,
      ))
        ->fetchAll();
      $max = count($results);
    }
  }
  return $max;
}