public function LdapAuthorizationConsumerOG::authorizationDiff in Lightweight Directory Access Protocol (LDAP) 8.2
Same name and namespace in other branches
- 7.2 ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php \LdapAuthorizationConsumerOG::authorizationDiff()
Parameters
string $op 'grant' or 'revoke' signifying what to do with the $consumer_ids:
drupal user object $object:
array $user_auth_data is array specific to this consumer_type. Stored at $user->data['ldap_authorizations'][<consumer_type>]:
$consumers as associative array in form of LdapAuthorizationConsumerAbstract::populateConsumersFromConsumerIds:
array $ldap_entry, when available user's ldap entry.:
boolean $user_save indicates is user data array should be saved or not. this is always overridden for og:
Overrides LdapAuthorizationConsumerAbstract::authorizationDiff
File
- ldap_authorization/
ldap_authorization_og/ LdapAuthorizationConsumerOG.class.php, line 408
Class
Code
public function authorizationDiff($existing, $desired) {
if ($this->ogVersion != 1) {
return parent::authorizationDiff($existing, $desired);
}
/**
* for og 1.5, goal is not to recognize X-2 consumer ids if X-N exist
* since X-2 consumer ids are granted as a prerequisite of X-N
*/
$diff = array_diff($existing, $desired);
$desired_group_ids = array();
foreach ($desired as $i => $consumer_id) {
list($gid, $rid) = $this
->og1ConsumerIdParts($consumer_id);
$desired_group_ids[$gid] = TRUE;
}
foreach ($diff as $i => $consumer_id) {
list($gid, $rid) = $this
->og1ConsumerIdParts($consumer_id);
// if there are still roles in this group that are desired, do
// not remove default mambership role id
if ($rid == $this->defaultMembershipRid && !empty($desired_group_ids[$gid])) {
unset($diff[$i]);
}
}
// dpm("diff"); dpm($diff); dpm("existing"); dpm($existing); dpm("desired"); dpm($desired); dpm("final diff"); dpm($diff);
return $diff;
}