You are here

function saml_sp__configure_idp_form_submit in SAML Service Provider 7.8

Same name and namespace in other branches
  1. 7 saml_sp.admin.inc \saml_sp__configure_idp_form_submit()
  2. 7.2 saml_sp.admin.inc \saml_sp__configure_idp_form_submit()
  3. 7.3 saml_sp.admin.inc \saml_sp__configure_idp_form_submit()

Submit handler for the SAML IDP configuration form.

File

./saml_sp.admin.inc, line 168
Admin pages for the SAML Service Provider module.

Code

function saml_sp__configure_idp_form_submit($form, &$form_state) {

  // Redirect to the admin overview page.
  if (!empty($form['#destination'])) {
    $form_state['redirect'] = $form['#destination'];
  }
  $idp = (object) array(
    'name' => $form_state['values']['name'],
    'machine_name' => $form_state['values']['machine_name'],
    'app_name' => $form_state['values']['app_name'],
    'entity_id' => $form_state['values']['entity_id'],
    'nameid_field' => $form_state['values']['nameid_field'],
    'login_url' => $form_state['values']['idp_login_url'],
    'logout_url' => $form_state['values']['idp_logout_url'],
    'x509_cert' => $form_state['values']['idp_x509_cert'],
    'authn_context_class_ref' => $form_state['values']['authn_context_class_ref'],
    'export_type' => $form_state['values']['export_type'],
  );

  // Machine names can be changed.
  if (isset($form_state['values']['orig_machine_name']) && $form_state['values']['orig_machine_name'] != $form_state['values']['machine_name']) {
    $idp->orig_machine_name = $form_state['values']['orig_machine_name'];
  }
  $result = saml_sp_idp_save($idp);
  switch ($result) {
    case SAVED_NEW:
      drupal_set_message(t('IdP %idp_name has been created.', array(
        '%idp_name' => $form_state['values']['name'],
      )));
      break;
    case SAVED_UPDATED:
      drupal_set_message(t('IdP %idp_name has been updated.', array(
        '%idp_name' => $form_state['values']['name'],
      )));
      break;
    default:
      drupal_set_message(t('An error occurred, IdP %idp_name has not been saved.', array(
        '%idp_name' => $form_state['values']['name'],
      )), 'error');
      break;
  }
}