You are here

function services_ctools_export_ui_form in Services 6.3

Same name and namespace in other branches
  1. 7.3 plugins/export_ui/services_ctools_export_ui.inc \services_ctools_export_ui_form()

Form to edit the settings of an endpoint.

1 string reference to 'services_ctools_export_ui_form'
services_ctools_export_ui.inc in plugins/export_ui/services_ctools_export_ui.inc

File

plugins/export_ui/services_ctools_export_ui.inc, line 73

Code

function services_ctools_export_ui_form(&$form, &$form_state) {

  // Loading runtime include as needed by services_auth_info().
  module_load_include('runtime.inc', 'services');
  $endpoint = $form_state['item'];
  $form['info']['name'] = array_merge($form['info']['name'], array(
    '#title' => t('Machine-readable name of the endpoint'),
    '#description' => t('The endpoint name can only consist of lowercase letters, underscores, and numbers.'),
  ));
  $form['eid'] = array(
    '#type' => 'value',
    '#value' => isset($endpoint->eid) ? $endpoint->eid : '',
  );
  $form['endpoint_object'] = array(
    '#type' => 'value',
    '#value' => $endpoint,
  );
  $servers = services_get_servers();
  $server_opts = array(
    '' => t('-- Select a server'),
  );
  foreach ($servers as $server => $info) {
    $server_opts[$server] = $info['name'];
  }
  $form['server'] = array(
    '#type' => 'select',
    '#options' => $server_opts,
    '#default_value' => $endpoint->server,
    '#title' => t('Server'),
    '#description' => t('Select a the server that should be used to handle requests to this endpoint.'),
    '#required' => TRUE,
  );
  $form['path'] = array(
    '#type' => 'textfield',
    '#size' => 24,
    '#maxlength' => 255,
    '#default_value' => $endpoint->path,
    '#title' => t('Path to endpoint'),
    '#required' => TRUE,
  );
  $form['debug'] = array(
    '#type' => 'checkbox',
    '#default_value' => $endpoint->debug,
    '#title' => t('Debug mode enabled'),
    '#description' => t('Useful for developers. Do not enable on production environments'),
    '#required' => FALSE,
  );
  $form['services_use_content_permissions'] = array(
    '#type' => 'checkbox',
    '#title' => t('Apply content permissions'),
    '#default_value' => variable_get('services_use_content_permissions', TRUE),
    '#description' => t('CCK includes the optional Content Permissions module, which allows administrators to restrict access to content at the field level. By default, node services do NOT apply these permissions, causing all fields to be returned in all cases. Checking this box causes content permissions to be applied to node services.'),
  );
  $auth_modules = module_implements('services_authentication_info');
  if (!empty($auth_modules)) {
    $auth_options = array();
    foreach ($auth_modules as $module) {
      $info = services_authentication_info($module);
      $auth_options[$module] = $info['title'];
    }
    $default_values = array();
    foreach ($endpoint->authentication as $auth_module => $settings) {
      if (!empty($settings)) {
        $default_values[] = $auth_module;
      }
    }
    $form['authentication'] = array(
      '#type' => 'checkboxes',
      '#options' => $auth_options,
      '#default_value' => $default_values,
      '#title' => t('Authentication'),
      '#description' => t('Choose which authentication schemes that should be used with your endpoint. If no authentication method is selected all requests will be done by an anonymous user.'),
    );
  }
  else {
    $form['authentication'] = array(
      '#type' => 'item',
      '#title' => t('Authentication'),
      '#description' => t('No authentication modules are installed, all requests will be done by an anonymous user.'),
    );
  }
  return $form;
}