function system_get_user_whitelist

6.x system.module system_get_user_whitelist()

Returns the "whitelist" or "allow list" (from system settings) as an array. If empty, it will return FALSE

1 call to system_get_user_whitelist()
system_login_form_validate in modules/system/system.module
Validate function for the login form. This is where we will do all of the lookups to verify username and password. If you want to write your own login handler (like for LDAP) this is the function you would duplicate in a custom module, then use…

File

modules/system/system.module, line 2067

Code

function system_get_user_whitelist() {
  $rtn = array();

  $list = trim(variable_get('user_whitelist', ''));
  if (!$list) {
    return FALSE;
  }

  $lines = explode("\n", $list);
  foreach ($lines as $line) {
    $line = trim($line);
    if ($line == "") {
      continue;
    }
    // If the first char is a # then its a comment, skip it.
    if (substr($line, 0, 1) == '#') {
      continue;
    }

    // Otherwise, we can add to our rtn array.
    $rtn [] = $line;

    // To make sure we catch all occurances, also force lower-case (for emails)
    $rtn [] = strtolower($line);

  } // foreach 

  if (count($rtn) == 0) {
    return FALSE;
  }

  return $rtn;

}