Projet

Général

Profil

Révision 32700c57

Ajouté par Assos Assos il y a environ 5 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.api.php
2 2

  
3 3
/**
4 4
 * @file
5
 * Hooks provided by ldap_servers module
5
 * Hooks provided by ldap_servers module.
6 6
 */
7 7

  
8 8
/**
9 9
 * Allows other modules to periodically affect an ldap associated user
10 10
 * or its corresponding ldap entry.
11 11
 *
12
 * when cron runs a batch of ldap associated drupal accounts
12
 * When cron runs a batch of ldap associated drupal accounts
13 13
 * will be looked at and marked as tested.  over the course
14
 * of time all ldap related users will be looked at
14
 * of time all ldap related users will be looked at.
15 15
 *
16 16
 * Each module implementing this hook is responsible for
17 17
 * altering ldap entries and drupal user objects; simply
18 18
 * altering the variables will have no affect on the actual
19 19
 * ldap entry or drupal user
20 20
 */
21

  
22 21
function hook_ldap_servers_user_cron(&$users) {
23 22

  
24

  
25

  
26 23
}
27 24

  
28 25
/**
29
 * helper hook to see if a batch of ldap users
30
 * needs to be queried
26
 * Helper hook to see if a batch of ldap users
27
 * needs to be queried.
31 28
 *
32
 * if a module implements hook_ldap_servers_user_cron,
29
 * If a module implements hook_ldap_servers_user_cron,
33 30
 * but currently does not need to process user cron batches,
34
 * it should return FALSE
31
 * it should return FALSE.
35 32
 */
36

  
37 33
function hook_ldap_servers_user_cron_needed() {
38 34
  return TRUE;
39 35
}
......
41 37
/**
42 38
 * Allows other modules to alter ldap entry or perform other necessary
43 39
 *   LDAP operations before entires are provisioned.
44
 * This should be invoked before provisioning ldap entries
40
 * This should be invoked before provisioning ldap entries.
45 41
 *
46
 * @param array $ldap_entries as array keyed on lowercase dn of entry with
42
 * @param array $ldap_entries
43
 *   as array keyed on lowercase dn of entry with
47 44
 *   value of array in format used in ldap_add or ldap_modify function
48 45
 *   e.g.
49 46
 *   $ldap_entries['cn=jkool,ou=guest accounts,dc=ad,dc=myuniversity,dc=edu'] = array(
50 47
 *    "attribute1" => array("value"),
51 48
 *    "attribute2" => array("value1", "value2"),
52
 *  );
49
 *   );.
53 50
 *
54
 * @param LdapServer $ldap_server as ldap server configuration object that is
55
 *   performing provisioning
51
 * @param LdapServer $ldap_server
52
 *   as ldap server configuration object that is
53
 *   performing provisioning.
56 54
 *
57
 * @param array $context with the following key/values:
55
 * @param array $context
56
 *   with the following key/values:
58 57
 *   'action' => add|modify|delete
59 58
 *
60 59
 *   'corresponding_drupal_data' => if ldap entries have corresponding drupal objects, such
61 60
 *     as ldap user entries and drupal user objects; ldap groups and drupal roles; etc
62
 *     this will be array keyed on lowercase dn with values of objects
63
 *     e.g.
64
 *     $context['corresponding_drupal_data'] = array(
61
 *     this will be array keyed on lowercase dn with values of objects, e.g. :
62
 *     [
65 63
 *      'cn=jkool,ou=guest accounts,dc=ad,dc=myuniversity,dc=edu' => drupal user object1,
66
 *      'cn=jfun,ou=guest accounts,dc=ad,dc=myuniversity,dc=edu'  => drupal user object2,
67
 *     )
68
 *
64
 *      'cn=jfun,ou=guest accounts,dc=ad,dc=myuniversity,dc=edu  => drupal user object2,
65
 *     ]
69 66
 *    'corresponding_drupal_data_type' => 'user', 'role', etc.
70
 *
71
 *  );
72 67
 */
73

  
74 68
function hook_ldap_entry_pre_provision_alter(&$ldap_entries, $ldap_server, $context) {
75 69

  
76

  
77

  
78 70
}
79 71

  
80 72
/**
81 73
 * Allows modules to react to provisioning of ldap entries.
82 74
 *
83
 * This should be invoked after provisioning ldap entries
75
 * This should be invoked after provisioning ldap entries.
84 76
 *
85 77
 * -- same signature as hook_ldap_entry_pre_provision_alter with ldap entries not passed by reference
86 78
 * -- ldap entries are not queried after provisioning, so $ldap_entries are in form
......
89 81
 *    $context['provisioned_ldap_entries][<dn>] => ldap entry array in format of an ldap query
90 82
 *    returned from ldap_get_entries() with 'count' keys
91 83
 */
92

  
93 84
function hook_ldap_entry_post_provision(&$ldap_entries, $ldap_server, $context) {
94 85

  
95

  
96

  
97 86
}
98 87

  
99

  
100

  
101 88
/**
102 89
 * Perform alterations of ldap attributes before query is made.
103 90
 *
104 91
 * To avoid excessive attributes in an ldap query, modules should
105
 * alter attributes needed based on $op parameter
92
 * alter attributes needed based on $op parameter.
106 93
 *
107 94
 * @param array $attributes
108 95
 *   array of attributes to be returned from ldap queries where:
......
111 98
 *       - 'conversion' => NULL,
112 99
 *       - 'values' => array(0 => 'john', 1 => 'johnny'))
113 100
 *
114
 * @param array $params context array with some or all of the following key/values
101
 * @param array $params
102
 *   context array with some or all of the following key/values
115 103
 *   'sid' => drupal account object,
116 104
 *   'ldap_context' => ,
117
 *   'direction' =>
118
 *
105
 *   'direction' =>.
119 106
 */
120 107
function hook_ldap_attributes_needed_alter(&$attributes, $params) {
121 108

  
122
  $attributes['dn'] = ldap_servers_set_attribute_map(@$attributes['dn'], 'ldap_dn') ;
123
  if ($params['sid']) { // puid attributes are server specific
109
  $attributes['dn'] = ldap_servers_set_attribute_map(@$attributes['dn'], 'ldap_dn');
110
  // Puid attributes are server specific.
111
  if ($params['sid']) {
124 112
    $ldap_server = (is_object($params['sid'])) ? $params['sid'] : ldap_servers_get_servers($params['sid'], 'enabled', TRUE);
125 113

  
126 114
    switch ($op) {
......
132 120
          $attributes[$ldap_server->user_attr] = ldap_servers_set_attribute_map();
133 121
        }
134 122
        if (!isset($attributes[$ldap_server->mail_attr])) {
135
          $attributes[$ldap_server->mail_attr] = ldap_servers_set_attribute_map(); // set default values for an attribute, force data_type
123
          // Set default values for an attribute, force data_type.
124
          $attributes[$ldap_server->mail_attr] = ldap_servers_set_attribute_map();
136 125
        }
137 126

  
138 127
        ldap_servers_token_extract_attributes($attributes, $ldap_server_obj->mail_template);
139 128
        $attributes[$ldap_server->unique_persistent_attr] = ldap_servers_set_attribute_map(@$attributes[$ldap_server->unique_persistent_attr]);
140 129

  
141
      break;
130
        break;
142 131
    }
143 132
  }
144 133
}
145 134

  
146

  
147 135
/**
148 136
 * Perform alterations of $ldap_user variable.
149 137
 *
150
 *
151
 * @param array $ldap_user see README.developers.txt for structure
152
 * @param array $params context array with some or all of the following key/values
138
 * @param array $ldap_user
139
 *   see README.developers.txt for structure.
140
 * @param array $params
141
 *   context array with some or all of the following key/values
153 142
 *   'account' => drupal account object,
154 143
 *   'ldap_context' => ,
155 144
 *   'module' =>  module calling alter, e.g. 'ldap_user',
156
 *   'function' => function calling alter, e.g. 'provisionLdapEntry'
157
 *
145
 *   'function' => function calling alter, e.g. 'provisionLdapEntry'.
158 146
 */
159

  
160 147
function hook_ldap_user_alter(&$ldap_entry, $params) {
161 148

  
162

  
163 149
}
164 150

  
165 151
/**
166 152
 * Allow the results from the ldap search answer to be modified
167 153
 * The query parameters are provided as context infomation
168 154
 * (readonly)
169
 *
170 155
 */
171 156
function hook_ldap_server_search_results_alter(&$entries, $ldap_query_params) {
172
  // look for a specific part of the $results array
173
  // and maybe change it
157
  // Look for a specific part of the $results array
158
  // and maybe change it.
174 159
}
175 160

  
176 161
/**
......
187 172
 *   - ldap_server: The LDAP server that is invoking the hook
188 173
 */
189 174
function hook_user_ldap_servers_username_to_ldapname_alter(&$ldap_username, $drupal_username, $context) {
190
  // Alter the name only if it has not been altered already, ie php eval code
175
  // Alter the name only if it has not been altered already, ie php eval code.
191 176
  if ($ldap_username == $drupal_username) {
192 177
    $authname = ldap_user_get_authname($ldap_username);
193 178
    if (!empty($authname)) {

Formats disponibles : Unified diff