You are here

function tokenauth_url_outbound_alter in Token authentication 6

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

Implementation of 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 135

Code

function tokenauth_url_outbound_alter(&$path, &$options, $original_path) {
  $key = tokenauth_get_token_key();
  if (isset($_SESSION['tokenauth_auth']) && $_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;
    }
  }
}