You are here

function tokenauth_text_load in Token authentication 7

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

Helper function to pull tokenauth UI text from the variables table, and optionally render.

Parameters

$account: User object for which the text will be pulled. Only useful in render mode.

$render: Whether to pass along the raw text or render using specific input format. (And token replacement, if enabled.)

2 calls to tokenauth_text_load()
tokenauth_admin_settings in ./tokenauth.pages.inc
Menu callback for Tokenauth administration interface.
tokenauth_user_profile_form in ./tokenauth.pages.inc
Menu callback. Prints the token and instructions.

File

./tokenauth.inc, line 165
Provides tokenauth API for Token Authentication module.

Code

function tokenauth_text_load($account = NULL, $render = FALSE) {
  $tokenauth_text = variable_get('tokenauth_text', array());
  if (empty($tokenauth_text)) {
    $tokenauth_text['value'] = <<<EOT
You may use an alphanumeric token to see restricted content using RSS Feed Readers or other simple content viewers. This token authenticates your user account, and as unique to you. If you have reason to believe someone else is misusing your token, please press the <em>Reset token</em> button to get a new one, and update your RSS readers.

Append the string below to the end of URLs approved for use with Token Authentication for temporary authentication.
EOT;
    if (module_exists('token')) {
      $key = tokenauth_get_token_key();
      $tokenauth_text['value'] .= "\n\n<strong>Your token:</strong> ?{$key}=<code>[user:tokenauth-token]</code>";
    }
    $tokenauth_text['format'] = filter_format_exists('filtered_html') ? 'filtered_html' : filter_fallback_format();
  }
  if (!$render) {
    return $tokenauth_text;
  }
  if (module_exists('token')) {
    if (empty($account)) {
      $account = $GLOBALS['user'];
    }
    $tokenauth_text['value'] = token_replace($tokenauth_text['value'], array(
      'user' => $account,
    ));
  }
  return check_markup($tokenauth_text['value'], $tokenauth_text['format']);
}