You are here

function services_admin_settings in Services 7

Same name and namespace in other branches
  1. 5 services.module \services_admin_settings()
  2. 6 services_admin_browse.inc \services_admin_settings()
  3. 6.2 services_admin_browse.inc \services_admin_settings()
1 string reference to 'services_admin_settings'
services_menu in ./services.module
Implements hook_menu().

File

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

Code

function services_admin_settings() {
  $auth_modules = module_implements('authentication_info');

  // Add security options.
  if (!empty($auth_modules)) {
    $auth_options = array(
      '' => t('-- Select a authorization module'),
    );
    foreach ($auth_modules as $module) {
      $info = services_auth_info(NULL, $module);
      $auth_options[$info['#description']][$module] = $info['#title'];
    }
    $form['security'] = array(
      '#title' => t('Security'),
      '#type' => 'fieldset',
      '#description' => t('Changing security settings will require you to adjust all method calls. This will affect all applications using site services.'),
    );
    $form['security']['auth_module'] = array(
      '#type' => 'select',
      '#title' => t('Authorization module'),
      '#options' => $auth_options,
      '#required' => FALSE,
      '#default_value' => variable_get('services_auth_module', ''),
      '#ajax' => array(
        'callback' => '_services_ahah_security_options',
        'path' => 'admin/services/ahah/security-options',
        'wrapper' => 'security-module-options',
      ),
    );

    // Placeholder for the auth module options
    // also used as wrapper for ahah.
    $form['security']['options'] = array(
      '#prefix' => '<div id="security-module-options">',
      '#suffix' => '</div>',
    );

    // Get the configuration form for the authorization module
    $settings = services_auth_invoke('security_settings');
    if (is_array($settings)) {
      $form['security']['options']['settings'] = $settings;
    }
  }
  else {

    // Warn if no authorization module has been installed.
    drupal_set_message(t('No authorization modules have been installed'), 'warning');
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save settings'),
  );
  return $form;
}