function services_edit_form_endpoint_authentication in Services 6.3
Same name and namespace in other branches
- 7.3 plugins/export_ui/services_ctools_export_ui.class.php \services_edit_form_endpoint_authentication()
Endpoint authentication configuration form.
1 string reference to 'services_edit_form_endpoint_authentication'
- services_ctools_export_ui::authentication_page in plugins/
export_ui/ services_ctools_export_ui.class.php - Page callback for the authentication page.
File
- plugins/
export_ui/ services_ctools_export_ui.class.php, line 61 - Export-ui handler for the Services module.
Code
function services_edit_form_endpoint_authentication($form_state) {
$endpoint = services_endpoint_load(arg(4));
// Loading runtime include as needed by services_authentication_info().
module_load_include('runtime.inc', 'services');
$form = array();
$auth_modules = module_implements('services_authentication_info');
$form['endpoint_object'] = array(
'#type' => 'value',
'#value' => $endpoint,
);
if (empty($auth_modules)) {
$form['message'] = array(
'#type' => 'item',
'#title' => t('Authentication'),
'#description' => t('No authentication modules are installed, all requests will be anonymous.'),
);
return $form;
}
if (empty($endpoint->authentication)) {
$form['message'] = array(
'#type' => 'item',
'#title' => t('Authentication'),
'#description' => t('No authentication modules are enabled, all requests will be anonymous.'),
);
return $form;
}
// Add configuration fieldsets for the authentication modules
foreach ($endpoint->authentication as $module => $settings) {
$info = services_authentication_info($module);
if (empty($info)) {
continue;
}
$form[$module] = array(
'#type' => 'fieldset',
'#title' => isset($info['title']) ? $info['title'] : $module,
'#tree' => TRUE,
);
// Append the default settings for the authentication module.
$default_security_settings = services_auth_invoke($module, 'default_security_settings');
if ($settings == $module && is_array($default_security_settings)) {
$settings += $default_security_settings;
}
// Ask the authentication module for a settings form.
$module_settings_form = services_auth_invoke($module, 'security_settings', $settings, $form_state);
if (is_array($module_settings_form)) {
$form[$module] += $module_settings_form;
}
else {
$form[$module]['message'] = array(
'#type' => 'item',
'#value' => t('@module has no settings available.', array(
'@module' => drupal_ucfirst($module),
)),
);
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Save',
);
return $form;
}