You are here

function fb_admin_replace_token_form in Drupal for Facebook 7.4

1 call to fb_admin_replace_token_form()
fb_admin_default_token_form in ./fb.admin.inc

File

./fb.admin.inc, line 178

Code

function fb_admin_replace_token_form($form, &$form_state, $variable, $options = array()) {

  // defaults
  $options = $options + array(
    'title' => t('Configure Access Token'),
    'save' => TRUE,
    'replace' => TRUE,
    'scope' => array(),
  );
  drupal_set_title($options['title']);

  // Save values needed in submit handler.
  $form_state['fb_vars']['variable'] = $variable;
  $form_state['fb_vars']['options'] = $options;

  // Show details about the current token.
  if ($variable) {
    $current = variable_get($variable, FALSE);
    if ($current) {
      $form['current_token'] = array(
        '#type' => 'fieldset',
        '#title' => t('Current Token'),
        'info' => fb_admin_token_info($current),
        '#attributes' => array(
          'class' => array(
            'fb_new_token_hide',
          ),
        ),
        '#weight' => -10,
      );
    }
  }

  // Allow selection of previously saved tokens.
  $form['fb_admin_token_select'] = array(
    '#type' => 'fb_admin_token_select',
    '#title' => t('Select from previously saved tokens'),
    '#description' => t('Select a token from the <a href=!url>token management</a> page.', array(
      '!url' => url(FB_PATH_ADMIN_CONFIG . '/token'),
    )),
    '#default_value' => $variable ? variable_get($variable, NULL) : NULL,
  );

  // Allow generation of new token.
  $form['fb_admin_token_generate'] = array(
    '#type' => 'fb_admin_token_generate',
    '#title' => t('Generate a new token'),
    '#description' => t('Click a link to create a token for your Facebook account.'),
    '#scope' => $options['scope'],
  );
  $form[FB_VAR_PREFER_LONG_TOKEN] = array(
    '#type' => 'checkbox',
    '#title' => t('Prefer longer-lived tokens.'),
    '#description' => t('Some Facebook access tokens expire in minutes, or when user logs out of facebook.com. Longer lived tokens can last weeks before expiring.  Facebook no longer offers access that never expire.'),
    '#default_value' => variable_get(FB_VAR_PREFER_LONG_TOKEN, TRUE),
  );
  $form['#validate'] = array(
    'fb_admin_replace_token_form_validate',
  );
  $form['#submit'] = array(
    'fb_admin_replace_token_form_submit',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save token'),
  );
  return $form;
}