Révision 32700c57
Ajouté par Assos Assos il y a environ 5 ans
drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php | ||
---|---|---|
17 | 17 |
public function save() { |
18 | 18 |
|
19 | 19 |
$op = $this->inDatabase ? 'edit' : 'insert'; |
20 |
// $this;. |
|
21 | 20 |
$values = new stdClass(); |
22 | 21 |
$values->sid = $this->sid; |
23 | 22 |
$values->numeric_consumer_conf_id = $this->numericConsumerConfId; |
... | ... | |
113 | 112 |
public function drupalForm($server_options, $op) { |
114 | 113 |
|
115 | 114 |
$consumer_tokens = ldap_authorization_tokens($this->consumer); |
116 |
$form['intro'] = array(
|
|
115 |
$form['intro'] = [
|
|
117 | 116 |
'#type' => 'item', |
118 | 117 |
'#markup' => t('<h1>LDAP to !consumer_name Configuration</h1>', $consumer_tokens), |
119 |
);
|
|
118 |
];
|
|
120 | 119 |
|
121 |
$form['status'] = array(
|
|
120 |
$form['status'] = [
|
|
122 | 121 |
'#type' => 'fieldset', |
123 | 122 |
'#title' => t('I. Basics', $consumer_tokens), |
124 | 123 |
'#collapsible' => TRUE, |
125 | 124 |
'#collapsed' => FALSE, |
126 |
);
|
|
125 |
];
|
|
127 | 126 |
|
128 |
$form['status']['sid'] = array(
|
|
127 |
$form['status']['sid'] = [
|
|
129 | 128 |
'#type' => 'radios', |
130 | 129 |
'#title' => t('LDAP Server used in !consumer_name configuration.', $consumer_tokens), |
131 | 130 |
'#required' => 1, |
132 | 131 |
'#default_value' => $this->sid, |
133 | 132 |
'#options' => $server_options, |
134 |
);
|
|
133 |
];
|
|
135 | 134 |
|
136 |
$form['status']['consumer_type'] = array(
|
|
135 |
$form['status']['consumer_type'] = [
|
|
137 | 136 |
'#type' => 'hidden', |
138 | 137 |
'#value' => $this->consumerType, |
139 | 138 |
'#required' => 1, |
140 |
);
|
|
139 |
];
|
|
141 | 140 |
|
142 |
$form['status']['status'] = array(
|
|
141 |
$form['status']['status'] = [
|
|
143 | 142 |
'#type' => 'checkbox', |
144 | 143 |
'#title' => t('Enable this configuration', $consumer_tokens), |
145 | 144 |
'#default_value' => $this->status, |
146 |
);
|
|
145 |
];
|
|
147 | 146 |
|
148 |
$form['status']['only_ldap_authenticated'] = array(
|
|
147 |
$form['status']['only_ldap_authenticated'] = [
|
|
149 | 148 |
'#type' => 'checkbox', |
150 | 149 |
'#title' => t('Only apply the following LDAP to !consumer_name configuration to users authenticated via LDAP. One uncommon reason for disabling this is when you are using Drupal authentication, but want to leverage LDAP for authorization; for this to work the Drupal username still has to map to an LDAP entry.', $consumer_tokens), |
151 | 150 |
'#default_value' => $this->onlyApplyToLdapAuthenticated, |
152 |
);
|
|
151 |
];
|
|
153 | 152 |
|
154 | 153 |
if (method_exists($this->consumer, 'mappingExamples')) { |
155 | 154 |
$consumer_tokens['!examples'] = '<fieldset class="collapsible collapsed form-wrapper" id="authorization-mappings"> |
... | ... | |
160 | 159 |
else { |
161 | 160 |
$consumer_tokens['!examples'] = ''; |
162 | 161 |
} |
163 |
$form['filter_and_mappings'] = array(
|
|
162 |
$form['filter_and_mappings'] = [
|
|
164 | 163 |
'#type' => 'fieldset', |
165 | 164 |
'#title' => t('II. LDAP to !consumer_name mapping and filtering', $consumer_tokens), |
166 | 165 |
'#description' => t(' |
... | ... | |
181 | 180 |
', $consumer_tokens), |
182 | 181 |
'#collapsible' => TRUE, |
183 | 182 |
'#collapsed' => !($this->mappings || $this->useMappingsAsFilter || $this->useFirstAttrAsGroupId), |
184 |
);
|
|
183 |
];
|
|
185 | 184 |
|
186 |
$form['filter_and_mappings']['use_first_attr_as_groupid'] = array(
|
|
185 |
$form['filter_and_mappings']['use_first_attr_as_groupid'] = [
|
|
187 | 186 |
'#type' => 'checkbox', |
188 | 187 |
'#title' => t('Convert full dn to value of first attribute before mapping. e.g. <code>cn=students,ou=groups,dc=hogwarts,dc=edu</code> would be converted to <code>students</code>', $consumer_tokens), |
189 | 188 |
'#default_value' => $this->useFirstAttrAsGroupId, |
190 |
);
|
|
191 |
$form['filter_and_mappings']['mappings'] = array(
|
|
189 |
];
|
|
190 |
$form['filter_and_mappings']['mappings'] = [
|
|
192 | 191 |
'#type' => 'textarea', |
193 | 192 |
'#title' => t('Mapping of LDAP to !consumer_name (one per line)', $consumer_tokens), |
194 | 193 |
'#default_value' => $this->mappingsToPipeList($this->mappings), |
195 | 194 |
'#cols' => 50, |
196 | 195 |
'#rows' => 5, |
197 |
);
|
|
198 |
$form['filter_and_mappings']['use_filter'] = array(
|
|
196 |
];
|
|
197 |
$form['filter_and_mappings']['use_filter'] = [
|
|
199 | 198 |
'#type' => 'checkbox', |
200 | 199 |
'#title' => t('Only grant !consumer_namePlural that match a filter above.', $consumer_tokens), |
201 | 200 |
'#default_value' => $this->useMappingsAsFilter, |
202 | 201 |
'#description' => t('If enabled, only above mapped !consumer_namePlural will be assigned (e.g. students and administrator). |
203 | 202 |
<strong>If not checked, !consumer_namePlural not mapped above also may be created and granted (e.g. gryffindor and probation students). In some LDAPs this can lead to hundreds of !consumer_namePlural being created if "Create !consumer_namePlural if they do not exist" is enabled below. |
204 | 203 |
</strong>', $consumer_tokens), |
205 |
);
|
|
204 |
];
|
|
206 | 205 |
|
207 |
$form['more'] = array(
|
|
206 |
$form['more'] = [
|
|
208 | 207 |
'#type' => 'fieldset', |
209 | 208 |
'#title' => t('Part III. Even More Settings.'), |
210 | 209 |
'#collapsible' => TRUE, |
211 | 210 |
'#collapsed' => FALSE, |
212 |
);
|
|
211 |
];
|
|
213 | 212 |
|
214 |
$synchronization_modes = array();
|
|
213 |
$synchronization_modes = [];
|
|
215 | 214 |
if ($this->synchOnLogon) { |
216 | 215 |
$synchronization_modes[] = 'user_logon'; |
217 | 216 |
} |
218 |
$form['more']['synchronization_modes'] = array(
|
|
217 |
$form['more']['synchronization_modes'] = [
|
|
219 | 218 |
'#type' => 'checkboxes', |
220 | 219 |
'#title' => t('When should !consumer_namePlural be granted/revoked from user?', $consumer_tokens), |
221 |
'#options' => array(
|
|
220 |
'#options' => [
|
|
222 | 221 |
'user_logon' => t('When a user logs on.'), |
223 |
),
|
|
222 |
],
|
|
224 | 223 |
'#default_value' => $synchronization_modes, |
225 | 224 |
'#description' => '', |
226 |
);
|
|
225 |
];
|
|
227 | 226 |
|
228 |
$synchronization_actions = array();
|
|
227 |
$synchronization_actions = [];
|
|
229 | 228 |
if ($this->revokeLdapProvisioned) { |
230 | 229 |
$synchronization_actions[] = 'revoke_ldap_provisioned'; |
231 | 230 |
} |
... | ... | |
236 | 235 |
$synchronization_actions[] = 'regrant_ldap_provisioned'; |
237 | 236 |
} |
238 | 237 |
|
239 |
$options = array(
|
|
238 |
$options = [
|
|
240 | 239 |
'revoke_ldap_provisioned' => t('Revoke !consumer_namePlural previously granted by LDAP Authorization but no longer valid.', $consumer_tokens), |
241 | 240 |
'regrant_ldap_provisioned' => t('Re grant !consumer_namePlural previously granted by LDAP Authorization but removed manually.', $consumer_tokens), |
242 |
);
|
|
241 |
];
|
|
243 | 242 |
if ($this->consumer->allowConsumerObjectCreation) { |
244 | 243 |
$options['create_consumers'] = t('Create !consumer_namePlural if they do not exist.', $consumer_tokens); |
245 | 244 |
} |
246 | 245 |
|
247 |
$form['more']['synchronization_actions'] = array(
|
|
246 |
$form['more']['synchronization_actions'] = [
|
|
248 | 247 |
'#type' => 'checkboxes', |
249 | 248 |
'#title' => t('What actions would you like performed when !consumer_namePlural are granted/revoked from user?', $consumer_tokens), |
250 | 249 |
'#options' => $options, |
251 | 250 |
'#default_value' => $synchronization_actions, |
252 |
);
|
|
251 |
];
|
|
253 | 252 |
/** |
254 | 253 |
* @todo some general options for an individual mapping (perhaps in an advance tab). |
255 | 254 |
* |
... | ... | |
272 | 271 |
break; |
273 | 272 |
} |
274 | 273 |
|
275 |
$form['submit'] = array(
|
|
274 |
$form['submit'] = [
|
|
276 | 275 |
'#type' => 'submit', |
277 | 276 |
'#value' => $action, |
278 |
);
|
|
277 |
];
|
|
279 | 278 |
|
280 | 279 |
return $form; |
281 | 280 |
} |
... | ... | |
291 | 290 |
* |
292 | 291 |
*/ |
293 | 292 |
public function getLdapAuthorizationConsumerActions() { |
294 |
$actions = array();
|
|
293 |
$actions = [];
|
|
295 | 294 |
$actions[] = l(t('edit'), LDAP_SERVERS_MENU_BASE_PATH . '/authorization/edit/' . $this->consumerType); |
296 | 295 |
if (property_exists($this, 'type')) { |
297 | 296 |
if ($this->type == 'Overridden') { |
... | ... | |
312 | 311 |
* |
313 | 312 |
*/ |
314 | 313 |
public function drupalFormValidate($op, $values) { |
315 |
$errors = array();
|
|
314 |
$errors = [];
|
|
316 | 315 |
|
317 | 316 |
if ($op == 'delete') { |
318 | 317 |
if (!$this->consumerType) { |
... | ... | |
334 | 333 |
/** |
335 | 334 |
* |
336 | 335 |
*/ |
337 |
public function validate($form_values = array()) {
|
|
338 |
$errors = array();
|
|
336 |
public function validate($form_values = []) {
|
|
337 |
$errors = [];
|
|
339 | 338 |
|
340 | 339 |
if (!$this->consumerType) { |
341 | 340 |
$errors['consumer_type'] = t('Consumer type is missing.'); |
... | ... | |
418 | 417 |
* consumer_type is tag (unique alphanumeric id) of consuming authorization such as |
419 | 418 |
* drupal_roles, og_groups, civicrm_memberships |
420 | 419 |
*/ |
421 |
$fields = array(
|
|
422 |
'numeric_consumer_conf_id' => array(
|
|
423 |
'schema' => array(
|
|
420 |
$fields = [
|
|
421 |
'numeric_consumer_conf_id' => [
|
|
422 |
'schema' => [
|
|
424 | 423 |
'type' => 'serial', |
425 | 424 |
'unsigned' => TRUE, |
426 | 425 |
'not null' => TRUE, |
427 | 426 |
'description' => 'Primary ID field for the table. Only used internally.', |
428 | 427 |
'no export' => TRUE, |
429 |
),
|
|
430 |
),
|
|
431 |
'sid' => array(
|
|
432 |
'schema' => array(
|
|
428 |
],
|
|
429 |
],
|
|
430 |
'sid' => [
|
|
431 |
'schema' => [
|
|
433 | 432 |
'type' => 'varchar', |
434 | 433 |
'length' => 20, |
435 | 434 |
'not null' => TRUE, |
436 |
),
|
|
437 |
),
|
|
438 |
'consumer_type' => array(
|
|
439 |
'schema' => array(
|
|
435 |
],
|
|
436 |
],
|
|
437 |
'consumer_type' => [
|
|
438 |
'schema' => [
|
|
440 | 439 |
'type' => 'varchar', |
441 | 440 |
'length' => 20, |
442 | 441 |
'not null' => TRUE, |
443 |
),
|
|
444 |
),
|
|
445 |
'consumer_module' => array(
|
|
446 |
'schema' => array(
|
|
442 |
],
|
|
443 |
],
|
|
444 |
'consumer_module' => [
|
|
445 |
'schema' => [
|
|
447 | 446 |
'type' => 'varchar', |
448 | 447 |
'length' => 30, |
449 | 448 |
'not null' => TRUE, |
450 |
),
|
|
451 |
),
|
|
449 |
],
|
|
450 |
],
|
|
452 | 451 |
|
453 |
'status' => array(
|
|
454 |
'schema' => array(
|
|
452 |
'status' => [
|
|
453 |
'schema' => [
|
|
455 | 454 |
'type' => 'int', |
456 | 455 |
'size' => 'tiny', |
457 | 456 |
'not null' => TRUE, |
458 | 457 |
'default' => 0, |
459 |
),
|
|
460 |
),
|
|
461 |
'only_ldap_authenticated' => array(
|
|
462 |
'schema' => array(
|
|
458 |
],
|
|
459 |
],
|
|
460 |
'only_ldap_authenticated' => [
|
|
461 |
'schema' => [
|
|
463 | 462 |
'type' => 'int', |
464 | 463 |
'size' => 'tiny', |
465 | 464 |
'not null' => TRUE, |
466 | 465 |
'default' => 1, |
467 |
),
|
|
468 |
),
|
|
466 |
],
|
|
467 |
],
|
|
469 | 468 |
|
470 |
'use_first_attr_as_groupid' => array(
|
|
471 |
'schema' => array(
|
|
469 |
'use_first_attr_as_groupid' => [
|
|
470 |
'schema' => [
|
|
472 | 471 |
'type' => 'int', |
473 | 472 |
'size' => 'tiny', |
474 | 473 |
'not null' => TRUE, |
475 | 474 |
'default' => 0, |
476 |
),
|
|
477 |
),
|
|
475 |
],
|
|
476 |
],
|
|
478 | 477 |
|
479 |
'mappings' => array(
|
|
480 |
'form_default' => array(),
|
|
481 |
'schema' => array(
|
|
478 |
'mappings' => [
|
|
479 |
'form_default' => [],
|
|
480 |
'schema' => [
|
|
482 | 481 |
'type' => 'text', |
483 | 482 |
'size' => 'medium', |
484 | 483 |
'not null' => FALSE, |
485 | 484 |
'default' => NULL, |
486 |
),
|
|
487 |
),
|
|
485 |
],
|
|
486 |
],
|
|
488 | 487 |
|
489 |
'use_filter' => array(
|
|
490 |
'schema' => array(
|
|
488 |
'use_filter' => [
|
|
489 |
'schema' => [
|
|
491 | 490 |
'type' => 'int', |
492 | 491 |
'size' => 'tiny', |
493 | 492 |
'not null' => TRUE, |
494 | 493 |
'default' => 1, |
495 |
),
|
|
496 |
),
|
|
494 |
],
|
|
495 |
],
|
|
497 | 496 |
|
498 |
'synchronization_modes' => array(
|
|
499 |
'form_default' => array('user_logon'),
|
|
500 |
),
|
|
497 |
'synchronization_modes' => [
|
|
498 |
'form_default' => ['user_logon'],
|
|
499 |
],
|
|
501 | 500 |
|
502 |
'synchronization_actions' => array(
|
|
503 |
'form_default' => array('revoke_ldap_provisioned', 'create_consumers'),
|
|
504 |
),
|
|
501 |
'synchronization_actions' => [
|
|
502 |
'form_default' => ['revoke_ldap_provisioned', 'create_consumers'],
|
|
503 |
],
|
|
505 | 504 |
|
506 |
'synch_to_ldap' => array(
|
|
507 |
'schema' => array(
|
|
505 |
'synch_to_ldap' => [
|
|
506 |
'schema' => [
|
|
508 | 507 |
'type' => 'int', |
509 | 508 |
'size' => 'tiny', |
510 | 509 |
'not null' => TRUE, |
511 | 510 |
'default' => 0, |
512 |
),
|
|
513 |
),
|
|
511 |
],
|
|
512 |
],
|
|
514 | 513 |
|
515 |
'synch_on_logon' => array(
|
|
516 |
'schema' => array(
|
|
514 |
'synch_on_logon' => [
|
|
515 |
'schema' => [
|
|
517 | 516 |
'type' => 'int', |
518 | 517 |
'size' => 'tiny', |
519 | 518 |
'not null' => TRUE, |
520 | 519 |
'default' => 0, |
521 |
),
|
|
522 |
),
|
|
520 |
],
|
|
521 |
],
|
|
523 | 522 |
|
524 |
'revoke_ldap_provisioned' => array(
|
|
525 |
'schema' => array(
|
|
523 |
'revoke_ldap_provisioned' => [
|
|
524 |
'schema' => [
|
|
526 | 525 |
'type' => 'int', |
527 | 526 |
'size' => 'tiny', |
528 | 527 |
'not null' => TRUE, |
529 | 528 |
'default' => 0, |
530 |
),
|
|
531 |
),
|
|
529 |
],
|
|
530 |
],
|
|
532 | 531 |
|
533 |
'create_consumers' => array(
|
|
534 |
'schema' => array(
|
|
532 |
'create_consumers' => [
|
|
533 |
'schema' => [
|
|
535 | 534 |
'type' => 'int', |
536 | 535 |
'size' => 'tiny', |
537 | 536 |
'not null' => TRUE, |
538 | 537 |
'default' => 0, |
539 |
),
|
|
540 |
),
|
|
538 |
],
|
|
539 |
],
|
|
541 | 540 |
|
542 |
'regrant_ldap_provisioned' => array(
|
|
543 |
'schema' => array(
|
|
541 |
'regrant_ldap_provisioned' => [
|
|
542 |
'schema' => [
|
|
544 | 543 |
'type' => 'int', |
545 | 544 |
'size' => 'tiny', |
546 | 545 |
'not null' => TRUE, |
547 | 546 |
'default' => 0, |
548 |
),
|
|
549 |
),
|
|
550 |
);
|
|
547 |
],
|
|
548 |
],
|
|
549 |
];
|
|
551 | 550 |
return $fields; |
552 | 551 |
} |
553 | 552 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules