function services_ctools_export_ui_form in Services 7.3
Same name and namespace in other branches
- 6.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 71
Code
function services_ctools_export_ui_form(&$form, &$form_state) {
// Loading runtime include as needed by services_auth_info().
module_load_include('inc', 'services', 'includes/services.runtime');
$endpoint = $form_state['item'];
$form['info']['name'] = array_merge($form['info']['name'], array(
'#title' => t('Machine-readable name of the endpoint'),
'#type' => 'machine_name',
'#description' => t('The endpoint name can only consist of lowercase letters, underscores, and numbers.'),
'#machine_name' => array(
'exists' => 'services_ctools_export_ui_form_machine_name_exists',
),
));
$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 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,
);
$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 anonymous.'),
);
}
return $form;
}