You are here

function oauth_common_form_authorization in OAuth 1.0 6.3

Same name and namespace in other branches
  1. 7.4 oauth_common.authorizations.inc \oauth_common_form_authorization()
  2. 7.3 oauth_common.authorizations.inc \oauth_common_form_authorization()
2 string references to 'oauth_common_form_authorization'
oauth_common_authorization_add in ./oauth_common.authorizations.inc
oauth_common_providerui_menu in ./oauth_common_providerui.module
Implementation of hook_menu().

File

./oauth_common.authorizations.inc, line 78
Functions related to a user's authorization section

Code

function oauth_common_form_authorization($form_state, $token) {
  $form = array();
  $consumer = $token->consumer;
  $context = oauth_common_context_load($consumer->context);
  drupal_set_title(t('Authorization for @app', array(
    '@app' => $consumer->name,
  )));
  $form['token_object'] = array(
    '#type' => 'value',
    '#value' => $token,
  );
  $form['authorized'] = array(
    '#type' => 'checkbox',
    '#title' => t('Authorized'),
    '#default_value' => $token->authorized,
  );
  $form['created'] = array(
    '#type' => 'item',
    '#title' => t('Created'),
    '#value' => format_date($token->created),
  );
  $form['changed'] = array(
    '#type' => 'item',
    '#title' => t('Changed'),
    '#value' => format_date($token->changed),
  );
  $form['key'] = array(
    '#type' => 'item',
    '#title' => t('Key'),
    '#value' => $token->key,
  );
  if ($token->in_database) {
    $form['secret'] = array(
      '#type' => 'item',
      '#prefix' => '<div id="token-secret-wrapper">',
      '#title' => t('Secret'),
      '#value' => substr($token->secret, 0, 6) . '...',
    );
    $ahah_path = "user/{$token->uid}/oauth/authorizations/{$token->tid}/ahah/secret";
    $form['show_secret'] = array(
      '#type' => 'button',
      '#value' => t('Show secret'),
      '#ahah' => array(
        'path' => $ahah_path,
        'wrapper' => 'token-secret-wrapper',
        'method' => 'replace',
      ),
      '#suffix' => '</div>',
    );
  }
  else {
    $form['secret'] = array(
      '#type' => 'item',
      '#title' => t('Secret'),
      '#value' => $token->secret,
    );
  }
  $form['allowed'] = array(
    '#type' => 'fieldset',
    '#title' => t('Permissions'),
  );
  oauth_common_permissions_form($user, $form['allowed'], $consumer, $context, $token->services);
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}