You are here

function services_admin_browse_test in Services 6

Same name and namespace in other branches
  1. 5 services_admin_browse.inc \services_admin_browse_test()
  2. 6.2 services_admin_browse.inc \services_admin_browse_test()
  3. 7 services_admin_browse.inc \services_admin_browse_test()
1 string reference to 'services_admin_browse_test'
services_admin_browse_method in ./services_admin_browse.inc

File

./services_admin_browse.inc, line 95
@author Services Dev Team

Code

function services_admin_browse_test() {
  $form = array();
  $method = services_method_get(arg(4));
  $form['arg'] = array(
    '#tree' => TRUE,
  );
  $timestamp = time();
  $nonce = user_password();
  foreach ($method['#args'] as $key => $arg) {
    $form['name'][$key] = array(
      '#value' => $arg['#name'],
    );
    $form['optional'][$key] = array(
      '#value' => $arg['#optional'] ? t('optional') : t('required'),
    );
    switch ($arg['#name']) {
      case 'hash':
        $form['arg'][$key] = array(
          '#title' => 'Hash',
          '#type' => 'textfield',
          '#default_value' => hash_hmac('sha256', $timestamp . ';' . $_SERVER['HTTP_HOST'] . ';' . $nonce . ';' . arg(4), services_admin_browse_get_first_key()),
        );
        break;
      case 'sessid':
        $form['arg'][$key] = array(
          '#title' => 'Session id',
          '#type' => 'textfield',
          '#default_value' => session_id(),
        );
        break;
      case 'domain_name':
        $form['arg'][$key] = array(
          '#title' => 'Domain name',
          '#type' => 'textfield',
          '#default_value' => $_SERVER['HTTP_HOST'],
        );
        break;
      case 'domain_time_stamp':
        $form['arg'][$key] = array(
          '#title' => 'Timestamp',
          '#type' => 'textfield',
          '#default_value' => $timestamp,
        );
        break;
      case 'nonce':
        $form['arg'][$key] = array(
          '#title' => 'Nonce',
          '#type' => 'textfield',
          '#default_value' => $nonce,
        );
        break;
      default:
        if ($arg['#size'] == 'big') {
          $form['arg'][$key] = array(
            '#type' => 'textarea',
          );
        }
        else {
          $form['arg'][$key] = array(
            '#type' => 'textfield',
          );
        }
        break;
    }
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Call method'),
  );
  $form['#redirect'] = FALSE;
  return $form;
}