You are here

function purge_users_get_users_list in Auto Purge Users 7

Same name and namespace in other branches
  1. 7.2 purge_users.module \purge_users_get_users_list()

Get users ids to cancel.

Parameters

mixed $data: Purge users setting form data.

Return value

array Users ids to be processed.

1 call to purge_users_get_users_list()
purge_users_config_form in ./purge_users.pages.inc
Menu callback function.

File

./purge_users.module, line 444
Purge users module file.

Code

function purge_users_get_users_list($data) {

  // Collect configuration values.
  $enable_blocked = $data['values']['purge_users_enabled_blocked_users'];
  $user_roles = array_filter($data['values']['purge_users_roles']);
  $enable_loggedin = $data['values']['purge_users_enabled_loggedin_users'];
  $enable_inactive = $data['values']['purge_users_enabled_inactive_users'];
  $never_enable_loggedin = $data['values']['purge_users_enabled_never_loggedin_users'];
  $param = array(
    'never_login_value' => $data['values']['purge_users_user_never_lastlogin_value'],
    'never_login_period' => $data['values']['purge_users_user_never_lastlogin_period'],
    'login_value' => $data['values']['purge_users_user_lastlogin_value'],
    'login_period' => $data['values']['purge_users_user_lastlogin_period'],
    'inactive_value' => $data['values']['purge_users_user_inactive_value'],
    'inactive_period' => $data['values']['purge_users_user_inactive_period'],
    'blocked_value' => $data['values']['purge_users_user_blocked_value'],
    'blocked_period' => $data['values']['purge_users_user_blocked_period'],
  );

  // Get users ids to process.
  $never_loggedin_users = array();
  $not_loggedin_users = array();
  $inactive_users = array();
  $blocked_users = array();

  // Get users who have never logged in at all.
  if ($never_enable_loggedin == 1) {
    $never_loggedin_users = purge_users_never_loggedin_user_ids($param, $user_roles, $never_enable_loggedin);
  }

  // Get users who have not logged in at all.
  if ($enable_loggedin == 1) {
    $not_loggedin_users = purge_users_not_loggedin_user_ids($param, $user_roles, $enable_loggedin);
  }

  // Get users who didn't activate their account.
  if ($enable_inactive == 1) {
    $inactive_users = purge_users_inactive_user_ids($param, $user_roles, $enable_inactive);
  }

  // Get the users who are blocked.
  if ($enable_blocked == 1) {
    $blocked_users = purge_users_blocked_user_ids($param, $user_roles, $enable_blocked);
  }

  // Merge results to create an array of user ids to purge.
  $users = array_merge($never_loggedin_users, $not_loggedin_users, $inactive_users, $blocked_users);
  return $users;
}