You are here

function services_ctools_export_ui_form_submit 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_submit()

Submit handler for endpoint.

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

File

plugins/export_ui/services_ctools_export_ui.inc, line 191

Code

function services_ctools_export_ui_form_submit(&$form, &$form_state) {
  variable_set('services_use_content_permissions', $form_state['values']['services_use_content_permissions']);
  $endpoint = $form_state['values']['endpoint_object'];
  $endpoint->name = $form_state['values']['name'];
  $endpoint->server = $form_state['values']['server'];
  $endpoint->path = $form_state['values']['path'];
  $endpoint->debug = $form_state['values']['debug'];

  // Set the authentication modules, and preserve the settings for modules
  // that already exist.
  $auth = array();
  if (isset($form_state['values']['authentication'])) {
    foreach (array_keys($form_state['values']['authentication']) as $module) {

      //if module's checkbox is checked, add to empty
      $auth_module = $form_state['values']['authentication'][$module];
      if ($module === $auth_module) {

        //If existing settings are set, preserve them
        if (isset($endpoint->authentication[$module]) && !empty($endpoint->authentication[$module])) {
          $auth[$module] = $endpoint->authentication[$module];
        }
        else {
          if (isset($endpoint->authentication[$module]) && empty($endpoint->authentication[$module])) {
            $auth[$module] = $module;
          }
          else {
            $auth[$module] = array();
          }
        }
      }
      elseif ($auth_module == 0) {
        unset($auth[$module]);
      }
    }
  }
  $endpoint->authentication = $auth;
  services_endpoint_save($endpoint);
}