Révision 59ae487e
Ajouté par Assos Assos il y a presque 7 ans
drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php | ||
---|---|---|
429 | 429 |
unset($diff[$i]); |
430 | 430 |
} |
431 | 431 |
} |
432 |
// dpm("diff"); dpm($diff); dpm("existing"); dpm($existing); dpm("desired"); dpm($desired); dpm("final diff"); dpm($diff); |
|
433 | 432 |
return $diff; |
434 | 433 |
} |
435 | 434 |
|
436 | 435 |
protected function grantsAndRevokes($op, &$user, &$user_auth_data, $consumers, &$ldap_entry = NULL, $user_save = TRUE) { |
437 |
// debug("grantsAndRevokes, op=$op, user_save=$user_save"); debug($user_auth_data); debug($consumers); |
|
438 | 436 |
|
439 | 437 |
if (!is_array($user_auth_data)) { |
440 | 438 |
$user_auth_data = array(); |
... | ... | |
468 | 466 |
$consumer_ids_log = ""; |
469 | 467 |
$log = ""; |
470 | 468 |
|
471 |
//dpm('consumers');dpm($consumers); dpm('users_authorization_consumer_ids'); dpm($users_authorization_consumer_ids); |
|
472 | 469 |
foreach ($consumers as $consumer_id => $consumer) { |
473 | 470 |
if ($detailed_watchdog_log) { |
474 | 471 |
watchdog('ldap_authorization', "consumer_id=$consumer_id, user_save=$user_save, op=$op", $watchdog_tokens, WATCHDOG_DEBUG); |
... | ... | |
573 | 570 |
* - remove and grant og roles |
574 | 571 |
* - flush appropriate caches |
575 | 572 |
*/ |
576 |
//debug("og_actions"); debug($og_actions); debug("user_auth_data"); debug($user_auth_data); |
|
577 | 573 |
if ($this->ogVersion == 1) { |
578 | 574 |
$this->og1Grants($og_actions, $user, $user_auth_data); |
579 | 575 |
$this->og1Revokes($og_actions, $user, $user_auth_data); |
... | ... | |
639 | 635 |
$users_group_rids = array_keys(og_get_user_roles($group_entity_type, $gid, $user->uid, TRUE)); // users current rids w/authen or anon roles returned |
640 | 636 |
$users_group_rids = array_diff($users_group_rids, array($anonymous_rid)); |
641 | 637 |
$new_rids = array_diff($granting_rids, $users_group_rids, array($anonymous_rid)); // rids to be added without anonymous rid |
642 |
// debug("new rids"); debug($new_rids);debug("granting_rids"); debug($granting_rids);debug("users_group_rids"); debug($users_group_rids); |
|
643 |
|
|
638 |
|
|
644 | 639 |
// if adding OG_AUTHENTICATED_ROLE or any other role and does not currently have OG_AUTHENTICATED_ROLE, group |
645 | 640 |
if (!in_array($authenticated_rid, $users_group_rids) && count($new_rids) > 0) { |
646 | 641 |
$values = array( |
... | ... | |
650 | 645 |
'state' => OG_STATE_ACTIVE, |
651 | 646 |
); |
652 | 647 |
$og_membership = og_group($group_entity_type, $gid, $values); |
653 |
// debug("consumer_id=$consumer_id, og group called( $group_entity_type, $gid, values:"); debug($values); debug("response og_membership"); debug($og_membership); |
|
654 | 648 |
$consumer_id = join(':', array($group_entity_type, $gid, $authenticated_rid)); |
655 | 649 |
$user_auth_data[$consumer_id] = array( |
656 | 650 |
'date_granted' => time(), |
... | ... | |
660 | 654 |
|
661 | 655 |
} |
662 | 656 |
foreach ($new_rids as $i => $rid) { |
663 |
// debug("role grant $group_entity_type $gid $user->uid $rid"); |
|
664 | 657 |
og_role_grant($group_entity_type, $gid, $user->uid, $rid); |
665 | 658 |
} |
666 | 659 |
foreach ($granting_rids as $i => $rid) { |
... | ... | |
886 | 879 |
|
887 | 880 |
if (!empty($og_fields['bundles'])) { |
888 | 881 |
foreach ($og_fields['bundles'] as $entity_type => $bundles) { |
889 |
|
|
890 | 882 |
foreach ($bundles as $i => $bundle) { |
891 |
|
|
892 | 883 |
$query = new EntityFieldQuery(); |
893 | 884 |
$query->entityCondition('entity_type', $entity_type) |
894 | 885 |
->entityCondition('bundle', $bundle) |
895 | 886 |
->range(0, 5) |
896 | 887 |
->addMetaData('account', user_load(1)); // run the query as user 1 |
897 | 888 |
$result = $query->execute(); |
898 |
$entities = entity_load($entity_type, array_keys($result[$entity_type])); |
|
899 |
$i=0; |
|
900 |
foreach ($entities as $entity_id => $entity) { |
|
901 |
$i++; |
|
902 |
$rid = ldap_authorization_og2_rid_from_role_name($entity_type, $bundle, $entity_id, OG_AUTHENTICATED_ROLE); |
|
903 |
$title = (is_object($entity) && property_exists($entity, 'title')) ? $entity->title : ''; |
|
904 |
$middle = ($title && $i < 3) ? $title : $entity_id; |
|
905 |
$group_role_identifier = ldap_authorization_og_authorization_id($middle, $rid, $entity_type); |
|
906 |
$example = "<code>ou=IT,dc=myorg,dc=mytld,dc=edu|$group_role_identifier</code>"; |
|
907 |
$rows[] = array("$entity_type $title - $role_name", $example); |
|
908 |
|
|
889 |
if (!empty($result)) { |
|
890 |
$entities = entity_load($entity_type, array_keys($result[$entity_type])); |
|
891 |
$i=0; |
|
892 |
foreach ($entities as $entity_id => $entity) { |
|
893 |
$i++; |
|
894 |
$rid = ldap_authorization_og2_rid_from_role_name($entity_type, $bundle, $entity_id, OG_AUTHENTICATED_ROLE); |
|
895 |
$title = (is_object($entity) && property_exists($entity, 'title')) ? $entity->title : ''; |
|
896 |
$middle = ($title && $i < 3) ? $title : $entity_id; |
|
897 |
$group_role_identifier = ldap_authorization_og_authorization_id($middle, $rid, $entity_type); |
|
898 |
$example = "<code>ou=IT,dc=myorg,dc=mytld,dc=edu|$group_role_identifier</code>"; |
|
899 |
$rows[] = array("$entity_type $title - $role_name", $example); |
|
900 |
} |
|
909 | 901 |
} |
910 |
|
|
911 | 902 |
} |
912 | 903 |
} |
913 | 904 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules