You are here

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

Same name and namespace in other branches
  1. 8.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

arraybool 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 295

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 = [];
  if ($direction == LDAP_USER_PROV_DIRECTION_ALL) {
    $directions = [
      LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER,
      LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY,
    ];
  }
  else {
    $directions = [
      $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;
}