You are here

function tokenauth_user_profile_form in Token authentication 5

Same name and namespace in other branches
  1. 6.2 tokenauth.pages.inc \tokenauth_user_profile_form()
  2. 6 tokenauth.pages.inc \tokenauth_user_profile_form()
  3. 7 tokenauth.pages.inc \tokenauth_user_profile_form()

Menu callback. Prints the token and instructions.

1 string reference to 'tokenauth_user_profile_form'
tokenauth_menu in ./tokenauth.module
Implementation of hook_menu().

File

./tokenauth.module, line 202

Code

function tokenauth_user_profile_form($uid) {
  if ($account = user_load(array(
    'uid' => (int) $uid,
  ))) {
    drupal_set_title($account->name);
    $token = tokenauth_get_token($account->uid);
    $output = t('To enable aggregators, feed readers and other simple clients to see restricted content on this site you may use an authentication token. The token is unique and tied to your account so keep it private. ');
    $output .= t('Simply append this querystring to any feed on this site. Some links may already have added this for you.') . '<br />';
    $output .= '<code>' . check_plain("?token={$token}") . '</code><br /><br />';
    $output .= t('Here are some example links to get you started:');
    $items = array();
    $items[] = l(t('Front page'), 'rss.xml', array(
      'title' => url('rss.xml', "token={$token}", NULL, TRUE),
    ), "token={$token}", NULL, FALSE, TRUE);
    $items[] = l(t('Blog'), 'blog/feed', array(
      'title' => url('blog/feed', "token={$token}", NULL, TRUE),
    ), "token={$token}", NULL, FALSE, TRUE);
    $output .= theme('item_list', $items);
    $form['preamble'] = array(
      '#value' => $output,
    );
    $form['uid'] = array(
      '#type' => 'value',
      '#value' => $uid,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Reset token'),
    );
    return $form;
  }
}