You are here

protected function LdapProfileConfAdmin::populateFromDrupalForm in Lightweight Directory Access Protocol (LDAP) 7

2 calls to LdapProfileConfAdmin::populateFromDrupalForm()
LdapProfileConfAdmin::drupalFormSubmit in ldap_profile/LdapProfileConfAdmin.class.php
LdapProfileConfAdmin::drupalFormValidate in ldap_profile/LdapProfileConfAdmin.class.php
validate form, not object

File

ldap_profile/LdapProfileConfAdmin.class.php, line 201

Class

LdapProfileConfAdmin

Code

protected function populateFromDrupalForm($values) {
  $this->ldap_fields = array();
  $this->mapping = array();
  foreach ($values['defaultMaps'] as $field => $value) {
    if ($value != '') {

      //store value in lower case to fix a ldap searching bug
      $l_value = strtolower($value);
      $this->mapping[$field] = $l_value;

      // don't add duplicates & ignore case
      if (!in_array($l_value, array_map('strtolower', $this->ldap_fields))) {
        $this->ldap_fields[] = $l_value;
      }
    }
  }
  if (isset($values['mapping']) && is_array($values['mapping'])) {
    foreach (array_keys($values['mapping']) as $field) {
      if ($values['mapping'][$field]['ldap'] != '') {

        //store value in lower case to fix a ldap searching bug
        $l_value = strtolower($values['mapping'][$field]['ldap']);
        $this->mapping[$field] = $l_value;
        if ((bool) $values['mapping'][$field]['derive'] && $values['mapping'][$field]['derive_value'] != '') {
          $l_value = strtolower($values['mapping'][$field]['derive_value']);
          $this->derivedMapping[$field]['derive'] = TRUE;
          $this->derivedMapping[$field]['derive_value'] = $l_value;
        }
        else {
          $this->derivedMapping[$field]['derive'] = FALSE;
          $this->derivedMapping[$field]['derive_value'] = '';
        }
      }
    }
  }
}