You are here

protected function UserEmailVerification::getVerificationUidsFor in User email verification 8

Return list of user IDs related to requested reason and interval pair.

Parameters

string $reason: The reason name.

int $interval: Rhe time interval in seconds.

Return value

array List of user IDs related to requested reason and interval pair.

1 call to UserEmailVerification::getVerificationUidsFor()
UserEmailVerification::cronHandler in src/UserEmailVerification.php
Handle cron related tasks.

File

src/UserEmailVerification.php, line 605

Class

UserEmailVerification
User email verification helper service.

Namespace

Drupal\user_email_verification

Code

protected function getVerificationUidsFor($reason, $interval) {
  $num_reminders = $this
    ->getNumReminders();
  $skip_roles = $this
    ->getSkipRoles();
  $query = $this->database
    ->select(UserEmailVerificationInterface::VERIFICATION_TABLE_NAME, 'uev');
  if ($skip_roles) {
    $query
      ->leftJoin('user__roles', 'ur', 'ur.entity_id = uev.uid');
    $or = $query
      ->orConditionGroup()
      ->condition('ur.roles_target_id', $skip_roles, 'NOT IN')
      ->isNull('ur.roles_target_id');
    $query
      ->condition($or);
    $query
      ->distinct();
  }
  $query
    ->fields('uev', [
    'uid',
  ])
    ->condition('uev.verified', 0, '=')
    ->condition('uev.uid', 1, '>')
    ->condition('uev.last_reminder', $this->time
    ->getRequestTime() - $interval, '<');
  switch ($reason) {
    case 'block_account':
      $query
        ->condition('uev.reminders', $num_reminders, '>=');
      break;
    case 'reminders':
      $query
        ->condition('uev.reminders', $num_reminders, '<');
      break;
    case 'delete_account':

      // Nothing to do.
      break;
  }
  return $query
    ->execute()
    ->fetchAllKeyed(0, 0);
}