You are here

public function ForcePasswordChangeMapper::getNonPendingUserIds in Force Password Change 8

Same name and namespace in other branches
  1. 2.0.x src/Mapper/ForcePasswordChangeMapper.php \Drupal\force_password_change\Mapper\ForcePasswordChangeMapper::getNonPendingUserIds()

*

Overrides ForcePasswordChangeMapperInterface::getNonPendingUserIds

File

src/Mapper/ForcePasswordChangeMapper.php, line 158

Class

ForcePasswordChangeMapper

Namespace

Drupal\force_password_change\Mapper

Code

public function getNonPendingUserIds($rid = FALSE) {
  $query = $this->connection
    ->select('users', 'u')
    ->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender');
  $query
    ->join('users_field_data', 'ufd', 'ufd.uid = u.uid AND ufd.status = :one', [
    ':one' => 1,
  ]);
  $alias = $query
    ->leftJoin('users_data', 'ud', 'ud.uid = u.uid AND ud.module = :force_password_change AND ud.name = :pending_force AND ud.value = :one', [
    ':force_password_change' => 'force_password_change',
    ':pending_force' => 'pending_force',
    ':one' => 1,
  ]);
  $query
    ->addField('u', 'uid');
  $query
    ->addTag('force_password_change_pending_users')
    ->limit(100)
    ->condition('u.uid', 0, '!=')
    ->isNull('ud.uid');
  if ($rid) {
    $alias2 = $query
      ->join('user__roles', 'ur', 'ur.entity_id = ud.uid');
    $query
      ->condition($alias2 . '.roles_target_id', $rid);
  }
  return $query
    ->execute()
    ->fetchCol();
}