You are here

function clients_connection_base::connectionSettingsForm_submit in Web Service Clients 7.3

Same name and namespace in other branches
  1. 6.2 clients.inc \clients_connection_base::connectionSettingsForm_submit()
  2. 7 clients.inc \clients_connection_base::connectionSettingsForm_submit()
  3. 7.2 clients.inc \clients_connection_base::connectionSettingsForm_submit()

Submit handler for saving/updating connections of this class.

This base class method handles preserving the password when the connection form is submitted on edit. Connection classes with a password configuration option may make use of it.

See also

clients_connection_form_submit().

2 calls to clients_connection_base::connectionSettingsForm_submit()
clients_connection_drupal_services::connectionSettingsForm_submit in connections/clients_drupal/clients_drupal.inc
Submit handler for saving/updating connections of this class.
clients_connection_drupal_services_rest_7::connectionSettingsForm_submit in connections/clients_drupal_rest/clients_drupal_rest.inc
Submit handler for saving/updating connections of this class.
2 methods override clients_connection_base::connectionSettingsForm_submit()
clients_connection_drupal_services::connectionSettingsForm_submit in connections/clients_drupal/clients_drupal.inc
Submit handler for saving/updating connections of this class.
clients_connection_drupal_services_rest_7::connectionSettingsForm_submit in connections/clients_drupal_rest/clients_drupal_rest.inc
Submit handler for saving/updating connections of this class.

File

includes/clients.entity.inc, line 152
Provides base classes for clients handler entities.

Class

clients_connection_base
Base class for client connections.

Code

function connectionSettingsForm_submit($form, &$form_state) {

  // Check there is a password form element.
  if (isset($form['credentials']['password'])) {
    $old_connection = $form['#connection'];

    // Check whether we're editing or adding a new connection.
    if (isset($old_connection->is_new)) {

      // Encryption disabled for now. TODO.

      //$form_state['values']['configuration']['password'] = clients_drupal_encrypt($form_state['values']['configuration']['password']);
    }
    else {

      // Set password to original if blank.
      if (empty($form_state['values']['credentials']['password'])) {

        // Load the old credentials into the old connection, then copy the
        // password into the new one.
        $old_connection
          ->credentialsLoad();
        $this->credentials['password'] = $old_connection->credentials['password'];
      }

      // Encryption disabled for now. TODO

      //$form_state['values']['configuration']['password'] = clients_drupal_encrypt($form_state['values']['configuration']['password']);
    }
  }

  // Base class doesn't save: saving of the connection is handled by the
  // 'real' FormAPI submit handler.
}