root / drupal7 / sites / all / modules / ldap / ldap_user / ldap_user.api.php @ a84ddea4
1 |
<?php
|
---|---|
2 |
|
3 |
/**
|
4 |
* @file
|
5 |
* Hooks and functions relevant to developers
|
6 |
*
|
7 |
*/
|
8 |
|
9 |
/**
|
10 |
* hook_ldap_user_attrs_alter().
|
11 |
*
|
12 |
* alter list of available drupal user targets (fields, properties, etc.)
|
13 |
* for ldap_user provisioning mapping form (admin/config/people/ldap/user)
|
14 |
*
|
15 |
* return array with elements of the form:
|
16 |
* [<field_type>.<field_name>] => array(
|
17 |
* 'name' => string for user friendly name for the UI,
|
18 |
* 'source' => ldap attribute (even if target of synch. this should be refactored at some point to avoid confusion)
|
19 |
* 'configurable' =>
|
20 |
* 'configurable_to_drupal' 0 | 1, is this configurable?
|
21 |
* 'configurable_to_ldap' => 0 | 1, is this configurable?
|
22 |
* 'user_tokens' => <user_tokens>
|
23 |
* 'convert' => 1 | 0 convert from binary to string for storage and comparison purposes
|
24 |
* 'direction' => LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER or LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY leave empty if configurable
|
25 |
* 'config_module' => module providing synching configuration.
|
26 |
* 'prov_module' => module providing actual synching of attributes.
|
27 |
* 'prov_events' => array( of LDAP_USER_EVENT_* constants indicating during which synch actions field should be synched)
|
28 |
* - four permutations available
|
29 |
* to ldap: LDAP_USER_EVENT_CREATE_LDAP_ENTRY, LDAP_USER_EVENT_SYNCH_TO_LDAP_ENTRY,
|
30 |
* to drupal: LDAP_USER_EVENT_CREATE_DRUPAL_USER, LDAP_USER_EVENT_SYNCH_TO_DRUPAL_USER
|
31 |
* )
|
32 |
*
|
33 |
* where
|
34 |
* 'field_type' is one of the following:
|
35 |
* 'property' (user property such as mail, picture, timezone that is not a field)
|
36 |
* 'field' (any field attached to the user such as field_user_lname)
|
37 |
* 'profile2' (profile2 fields)
|
38 |
* 'data' ($user->data array. field_name will be used as key such as $user->data[<field_name>] = mapped value
|
39 |
* 'field_name' machine name of property, field, profile2 field, or data associative array key
|
40 |
*/
|
41 |
|
42 |
function hook_ldap_user_attrs_list_alter(&$available_user_attrs, &$params) { |
43 |
|
44 |
/** search for _ldap_user_attrs_list_alter for good examples
|
45 |
* the general trick to implementing this hook is:
|
46 |
* make sure to specify config and synch module
|
47 |
* if its configurable by ldap_user module, don't specify convert, user_tokens, direction. these will be set by UI and stored values
|
48 |
* be sure to merge with existing values as ldap_user configured values will already exist in $available_user_attrs
|
49 |
*/
|
50 |
|
51 |
} |
52 |
|
53 |
|
54 |
|
55 |
/**
|
56 |
* Allow modules to alter the user object in the context of an ldap entry
|
57 |
* during synchronization
|
58 |
*
|
59 |
* @param array $edit
|
60 |
* The edit array (see hook_user_insert). Make changes to this object as
|
61 |
* required.
|
62 |
* @param array $ldap_user, for structure @see LdapServer::userUserNameToExistingLdapEntry()
|
63 |
* Array, the ldap user object relating to the drupal user
|
64 |
* @param object $ldap_server
|
65 |
* The LdapServer object from which the ldap entry was fetched
|
66 |
* @param int $prov_event
|
67 |
*
|
68 |
*
|
69 |
*/
|
70 |
function hook_ldap_user_edit_user_alter(&$edit, &$ldap_user, $ldap_server, $prov_event) { |
71 |
$edit['myfield'] = $ldap_server->getAttributeValue($ldap_user, 'myfield'); |
72 |
} |