You are here

function ldap_servers_token_extract_attributes in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_servers/ldap_servers.tokens.inc \ldap_servers_token_extract_attributes()

Parameters

array $attributes: array of attributes passed by reference.

string $text: with tokens in it

by reference return add ldap attribute triplet $attribute_maps[<attr_name>] = (<attr_name>, <ordinal>, <data_type>) to $attributes.

7 calls to ldap_servers_token_extract_attributes()
hook_ldap_attributes_needed_alter in ldap_servers/ldap_servers.api.php
Perform alterations of ldap attributes before query is made.
LdapUserConf::getLdapUserRequiredAttributes in ldap_user/LdapUserConf.class.php
Util to fetch attributes required for this user conf, not other modules.
LdapUserConfAdmin::validate in ldap_user/LdapUserConfAdmin.class.php
Validate object, not form.
LdapUserUnitTests::testProvisionToDrupal in ldap_user/tests/ldap_user.test
ldap_servers_ldap_attributes_needed_alter in ldap_servers/ldap_servers.module
Implements hook_ldap_attributes_needed_alter().

... See full list

File

ldap_servers/ldap_servers.tokens.inc, line 128
Collection of functions related to ldap tokens.

Code

function ldap_servers_token_extract_attributes(&$attribute_maps, $text) {
  $tokens = ldap_servers_token_tokens_needed_for_template($text);
  foreach ($tokens as $token) {
    $token = str_replace([
      LDAP_SERVERS_TOKEN_PRE,
      LDAP_SERVERS_TOKEN_POST,
    ], [
      '',
      '',
    ], $token);
    $parts = explode(LDAP_SERVERS_TOKEN_DEL, $token);
    $ordinal = isset($parts[1]) && $parts[1] ? $parts[1] : 0;
    $attr_name = $parts[0];
    $source_data_type = NULL;
    $parts2 = explode(LDAP_SERVERS_TOKEN_MODIFIER_DEL, $attr_name);
    if (count($parts2) > 1) {
      $attr_name = $parts2[0];
      $conversion = $parts2[1];
    }
    else {
      $conversion = NULL;
    }
    $attribute_maps[$attr_name] = ldap_servers_set_attribute_map(@$attribute_maps[$attr_name], $conversion, [
      $ordinal => NULL,
    ]);
  }
}