You are here

public function ForcePasswordChangeMapper::getPendingUserIds 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::getPendingUserIds()

*

Overrides ForcePasswordChangeMapperInterface::getPendingUserIds

File

src/Mapper/ForcePasswordChangeMapper.php, line 133

Class

ForcePasswordChangeMapper

Namespace

Drupal\force_password_change\Mapper

Code

public function getPendingUserIds($rid = FALSE) {
  $query = $this->connection
    ->select('users_data', 'ud')
    ->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender');
  $query
    ->join('users_field_data', 'ufd', 'ufd.uid = ud.uid AND ufd.status = :one', [
    ':one' => 1,
  ]);
  $query
    ->addField('ud', 'uid');
  $query
    ->addTag('force_password_change_pending_users')
    ->limit(20)
    ->condition('ud.module', 'force_password_change')
    ->condition('ud.name', 'pending_force')
    ->condition('ud.value', 1);

  // If the role is anything other than the authenticated users role, we need to
  // limit the users to the members of that role
  if ($rid) {
    $alias = $query
      ->join('user__roles', 'ur', 'ur.entity_id = ud.uid');
    $query
      ->condition($alias . '.roles_target_id', $rid);
  }
  return $query
    ->execute()
    ->fetchCol();
}