You are here

function tokenauth_url_outbound_alter in Token authentication 7

Same name and namespace in other branches
  1. 6.2 tokenauth.module \tokenauth_url_outbound_alter()
  2. 6 tokenauth.module \tokenauth_url_outbound_alter()

Implements hook_url_outbound_alter().

Appends the current user's token to any path run through url() that also passes tokenauth's allowed pages filter.

File

./tokenauth.module, line 148

Code

function tokenauth_url_outbound_alter(&$path, &$options, $original_path) {
  $key = tokenauth_get_token_key();
  if (isset($_SESSION['tokenauth_auth']) && isset($_REQUEST[$key]) && $_REQUEST[$key] == ($token = tokenauth_get_token()) && tokenauth_allowed_pages($original_path)) {
    if (is_array($options['query'])) {
      $options['query'][$key] = $token;
    }
    elseif (!$options['query']) {
      $options['query'] = $key . '=' . $token;
    }
    else {
      $options['query'] .= '&' . $key . '=' . $token;
    }
  }
}