You are here

function oauthconnector_devel in OAuth Connector 7

1 string reference to 'oauthconnector_devel'
oauthconnector_menu in ./oauthconnector.module
Implements hook_menu().

File

./oauthconnector.admin.inc, line 957
Administrative functions for the OAuth Connector module.

Code

function oauthconnector_devel($form, &$form_state) {

  // devel page.
  $values = array();
  if (isset($form_state['values'])) {
    $values = $form_state['values'];
  }
  if (empty($values['account'])) {
    global $user;
    $values['account'] = $user->name;
  }
  $form['endpoint'] = array(
    '#type' => 'textfield',
    '#title' => t('Endpoint'),
    '#size' => 64,
    '#maxlength' => 255,
    '#required' => TRUE,
    '#default_value' => isset($values['endpoint']) ? $values['endpoint'] : '',
  );
  $form['account'] = array(
    '#type' => 'textfield',
    '#title' => t('User'),
    '#size' => 32,
    '#maxlength' => 60,
    '#autocomplete_path' => 'user/autocomplete',
    '#required' => TRUE,
    '#default_value' => $values['account'],
  );
  $providers = oauthconnector_provider_load_all();
  $options = array();
  foreach ($providers as $provider) {
    $options[$provider->name] = $provider->title;
  }
  $form['provider'] = array(
    '#type' => 'radios',
    '#title' => 'Provider',
    '#options' => $options,
    '#default_value' => isset($values['provider']) ? $values['provider'] : '',
  );
  $options = array(
    'json' => 'JSON',
    'xml' => 'XML',
    'raw' => 'RAW',
  );
  $form['format'] = array(
    '#type' => 'select',
    '#title' => 'Format',
    '#options' => $options,
    '#default_value' => isset($values['format']) ? $values['format'] : '',
  );
  $options = array(
    'get' => 'GET',
    'post' => 'POST',
  );
  $form['method'] = array(
    '#type' => 'select',
    '#title' => 'Method',
    '#options' => $options,
    '#default_value' => isset($values['method']) ? $values['method'] : '',
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Run call'),
  );
  if (!empty($values['endpoint'])) {

    // get results
    $results = oauthconnector_endpoint_call_for_user($values['endpoint'], array(), $values['provider'], $values['account'], $values['method'], $values['format']);
    $form['results'] = array(
      '#type' => 'markup',
      '#markup' => dvr($results, TRUE),
      '#weight' => 255,
    );
  }
  return $form;
}