You are here

function ldapdata_admin_edit_submit in LDAP integration 5.2

Same name and namespace in other branches
  1. 5 ldapdata.module \ldapdata_admin_edit_submit()
  2. 6 ldapdata.admin.inc \ldapdata_admin_edit_submit()

File

./ldapdata.module, line 351

Code

function ldapdata_admin_edit_submit($form_id, $form_values) {
  $config_name = $form_values['config_name'];

  // Attribute Mapping
  $attr_mapping_access = $form_values['ldap_attr_mapping'];
  $attr_mappings['access'] = $attr_mapping_access;
  if ($attr_mapping_access >= 4) {
    foreach (element_children($form_values) as $attr) {
      if (preg_match("/ldap_amap/", $attr) && $form_values[$attr]) {

        // match found
        $attr_mappings[$attr] = $form_values[$attr];
      }
    }
  }
  $serialized_data = serialize($attr_mappings);

  // Attribute Access Control
  $ro_tmp = array_filter($form_values['ldap_editable_attributes']['ro_status']);
  if (!empty($ro_tmp)) {
    foreach ($ro_tmp as $ro_attr) {
      $ro_attrs[] = $ro_attr;
    }
    $serialized_ro_attrs = serialize($ro_attrs);
  }
  $rw_tmp = array_filter($form_values['ldap_editable_attributes']['rw_status']);
  if (!empty($rw_tmp)) {
    foreach ($rw_tmp as $rw_attr) {
      $rw_attrs[] = $rw_attr;
    }
    $serialized_rw_attrs = serialize($rw_attrs);
  }
  if (!$form_values['ldapdata_bindpw_clear'] && $form_values['ldapdata_bindpw']) {
    db_query("UPDATE {ldapauth} SET ldapdata_mappings = '%s', ldapdata_roattrs = '%s', ldapdata_rwattrs = '%s', ldapdata_binddn = '%s', ldapdata_bindpw = '%s', ldapdata_bindpw_clear = '%d' WHERE name = '%s'", $serialized_data, $serialized_ro_attrs, $serialized_rw_attrs, $form_values['ldapdata_binddn'], $form_values['ldapdata_bindpw'], $form_values['ldapdata_bindpw_clear'], $config_name);
  }
  else {

    // set the clear password switch
    db_query("UPDATE {ldapauth} SET ldapdata_mappings = '%s', ldapdata_roattrs = '%s', ldapdata_rwattrs = '%s', ldapdata_binddn = '%s', ldapdata_bindpw_clear = '%d' WHERE name = '%s'", $serialized_data, $serialized_ro_attrs, $serialized_rw_attrs, $form_values['ldapdata_binddn'], $form_values['ldapdata_bindpw_clear'], $config_name);
  }
  return 'admin/settings/ldapdata/edit/' . $config_name;
}