You are here

function user_email_verification_install in User email verification 8

Same name and namespace in other branches
  1. 7 user_email_verification.install \user_email_verification_install()

Implements hook_install().

File

./user_email_verification.install, line 11
The module installation functions.

Code

function user_email_verification_install() {

  // TODO: ReDo it with batch (if many users - timeout on install).
  $database = \Drupal::database();
  $uids = $database
    ->select('users', 'u')
    ->fields('u', [
    'uid',
  ])
    ->condition('uid', 0, '>')
    ->execute()
    ->fetchAllKeyed(0, 0);
  if ($uids) {
    $verified = \Drupal::time()
      ->getRequestTime();
    $query = $database
      ->insert('user_email_verification')
      ->fields([
      'uid',
      'verified',
    ]);
    foreach ($uids as $uid) {
      $query
        ->values([
        'uid' => $uid,
        'verified' => $verified,
      ]);
    }
    $query
      ->execute();
  }
}