You are here

public function LdapUserConf::getSynchMappings in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.2 ldap_user/LdapUserConf.class.php \LdapUserConf::getSynchMappings()

Util to fetch mappings for a given direction

Parameters

string $sid: The server id

string $direction LDAP_USER_PROV_DIRECTION_* constant:

array $prov_events:

Return value

array/bool Array of mappings (may be empty array)

3 calls to LdapUserConf::getSynchMappings()
LdapUserConf::drupalUserToLdapEntry in ldap_user/LdapUserConf.class.php
populate ldap entry array for provisioning
LdapUserConf::entryToUserEdit in ldap_user/LdapUserConf.class.php
populate $user edit array (used in hook_user_save, hook_user_update, etc) ... should not assume all attribues are present in ldap entry
LdapUserConf::getLdapUserRequiredAttributes in ldap_user/LdapUserConf.class.php
Util to fetch attributes required for this user conf, not other modules.

File

ldap_user/LdapUserConf.class.php, line 265

Class

LdapUserConf

Code

public function getSynchMappings($direction = LDAP_USER_PROV_DIRECTION_ALL, $prov_events = NULL) {
  if (!$prov_events) {
    $prov_events = ldap_user_all_events();
  }
  $mappings = array();
  if ($direction == LDAP_USER_PROV_DIRECTION_ALL) {
    $directions = array(
      LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER,
      LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY,
    );
  }
  else {
    $directions = array(
      $direction,
    );
  }
  foreach ($directions as $direction) {
    if (!empty($this->ldapUserSynchMappings[$direction])) {
      foreach ($this->ldapUserSynchMappings[$direction] as $attribute => $mapping) {
        if (!empty($mapping['prov_events'])) {
          $result = count(array_intersect($prov_events, $mapping['prov_events']));
          if ($result) {
            $mappings[$attribute] = $mapping;
          }
        }
      }
    }
  }
  return $mappings;
}