You are here

function tokenauth_url_outbound_alter in Token authentication 6.2

Same name and namespace in other branches
  1. 6 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 130

Code

function tokenauth_url_outbound_alter(&$path, &$options, $original_path) {
  $key = tokenauth_get_token_key();
  if (tokenauth_is_token_authenticated() && $_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;
    }
  }
}