You are here

function anonymous_login_paths in Anonymous login 7

Fetch the paths that should be used when determining when to force anonymous users to login.

Return value

An array of paths, keyed by "include", paths that should force a login, and "exclude", paths that should be ignored.

1 call to anonymous_login_paths()
anonymous_login_redirect in ./anonymous_login.module
Perform the anonymous user redirection, if needed.
2 string references to 'anonymous_login_paths'
anonymous_login_admin_settings in ./anonymous_login.admin.inc
Admin settings form
anonymous_login_uninstall in ./anonymous_login.install
Implements hook_uninstall().

File

./anonymous_login.module, line 113

Code

function anonymous_login_paths() {
  $paths = array(
    'include' => array(),
    'exclude' => array(),
  );

  // Fetch the stored paths set in the admin settings.
  if ($setting = variable_get('anonymous_login_paths', NULL)) {

    // Split by each newline.
    $setting = explode("\n", $setting);

    // Iterate each path and determine if the path should be included
    // or excluded.
    foreach ($setting as $path) {
      if (substr($path, 0, 1) == '~') {
        $paths['exclude'][] = substr($path, 1);
      }
      else {
        $paths['include'][] = $path;
      }
    }
  }

  // Always exclude certain paths.
  $paths['exclude'][] = variable_get('anonymous_login_page_path', 'user/login');
  $paths['exclude'][] = 'user/reset/*';

  // Allow other modules to alter the paths.
  drupal_alter('anonymous_login_paths', $paths);
  return $paths;
}