You are here

function _shib_auth_rule_clone_confirm_form_submit in Shibboleth Authentication 6.4

Same name and namespace in other branches
  1. 7.4 shib_auth_roles_forms.inc \_shib_auth_rule_clone_confirm_form_submit()

This function enables the administrator to clone an existing rule, this is useful, when we want to create a rule, which is simiral to another one

File

./shib_auth_roles_forms.inc, line 115
Roles manager forms.

Code

function _shib_auth_rule_clone_confirm_form_submit(&$form_state, $id) {
  $id = $form_state['#parameters'][2];
  if ($id = intval($id)) {
    $rule = db_query("SELECT * FROM {shib_auth} WHERE id = %d", array(
      $id,
    ));
    $db_entry = db_fetch_array($rule);
    $db_entry['id'] = NULL;
    $update = array();
    $ret = drupal_write_record('shib_auth', $db_entry, $update);
    if ($ret == SAVED_NEW) {
      drupal_set_message(t('The rule has been successfully cloned.'));
    }
    else {
      drupal_set_message(t('Unexpected error has been detected.'), 'error');
    }
  }
  else {
    drupal_set_message(t("Invalid rule id."), 'error');
  }
  drupal_goto('admin/user/shib_auth/rules');
}