getRequestTime() - 24 * 60 * 60; $ids = \Drupal::entityQuery('user') ->condition('status', 0) ->condition('created', $time_limit, '<') ->accessCheck(TRUE) ->execute(); // Delete rows from the wisski_cloud_account_manager table. $connection = \Drupal::database(); $wisskiCloudUsers = $connection->select('wisski_cloud_account_manager', 'wcam') ->fields('wcam', ['uid']) ->condition('uid', $ids, 'IN') ->execute() ->fetchAll(); $ids = array_map(function($wisskiCloudUser) { return $wisskiCloudUser->uid; }, $wisskiCloudUsers); if (empty($ids)) { return; } \Drupal::logger('wisski_cloud_account_manager')->notice('Deleting users, who missed the validation: @ids', ['@ids' => implode(', ', $ids)]); $connection->delete('wisski_cloud_account_manager') ->condition('uid', $ids, 'IN') ->execute(); $storage_handler = \Drupal::entityTypeManager()->getStorage('user'); $entities = $storage_handler->loadMultiple($ids); $storage_handler->delete($entities); } /** * Implements hook_help(). */ function wisski_cloud_account_manager_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match) { $output = ''; switch ($route_name) { case 'help.page.wisski_cloud_account_manager': $output .= '

' . t('About') . '

'; $output .= '

' . t('This module provides the functionality to create, validate and manage WissKI Cloud accounts.') . '

'; $output .= '

' . t('Configuration') . '

'; $output .= '

' . t('Configuration is done on the settings page.', ['@settingsPage' => '/admin/config/wisski-cloud-account-manager/settings']) . '

'; $output .= '

' . t('Create WissKI Cloud Account') . '

'; $output .= '

' . t('This page allows you to create a WissKI Cloud account.', ['@createPage' => '/wisski-cloud-account-manager/create']) . '

'; $output .= '

' . t('Validate WissKI Cloud Account') . '

'; $output .= '

' . t('This page allows you to validate your account and check the status of the provision.', ['@validationPage' => '/wisski-cloud-account-manager/validate/GsyMv5DdFhPCixL1wTLZhzFg7sVDOiHq']) . '

'; break; } return $output; } /** * Implements hook_mail(). */ function wisski_cloud_account_manager_mail($key, &$message, $params) { $options = [ 'langcode' => $message['langcode'], ]; switch ($key) { case 'wisski_cloud_account_validation': $message['from'] = \Drupal::config('system.site')->get('mail'); $message['subject'] = t('@subject', ['@subject' => $params['subject']], $options); $message['body'][] = $params['message']; $headers = [ 'Content-Type' => 'text/html; charset=UTF-8; format=flowed', 'MIME-Version' => '1.0', 'Content-Transfer-Encoding' => '8Bit', 'X-Mailer' => 'Drupal', ]; $message['headers'] = $headers; break; } } /** * Implements hook_theme(). */ function wisski_cloud_account_manager_theme($existing, $type, $theme, $path) { return [ 'wisski_cloud_account_manager_terms_and_conditions_page' => [ 'variables' => ['date' => NULL], ], 'wisski_cloud_account_manager_account_managing_page' => [ 'variables' => [ 'accounts' => NULL, 'healthCheck' => NULL,], ], 'wisski_cloud_account_manager_validation_page' => [ 'variables' => ['account' => NULL], ], 'wisski_cloud_account_manager_health_check_page' => [ 'variables' => ['healthCheck' => NULL], ], 'wisski_cloud_account_manager_validation_email' => [ 'variables' => [ 'personName' => NULL, 'validationLink' => NULL, ], ], ]; }