function ldap_authorization_og2_has_consumer_id in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_authorization/ldap_authorization_og/ldap_authorization_og.module \ldap_authorization_og2_has_consumer_id()
2 calls to ldap_authorization_og2_has_consumer_id()
- LdapAuthorizationConsumerOG::hasAuthorization in ldap_authorization/
ldap_authorization_og/ LdapAuthorizationConsumerOG.class.php - NOTE this is in mixed case, since we must rely on whatever module is storing the authorization id.
- LdapAuthorizationOg2Tests::testBasicFunctionsAndApi in ldap_authorization/
tests/ Og2Tests.test - Just make sure install succeeds and.
File
- ldap_authorization/
ldap_authorization_og/ ldap_authorization_og.module, line 95 - Controls organic group membership based on LDAP values.
Code
function ldap_authorization_og2_has_consumer_id($consumer_id, $uid) {
$parts = explode(':', $consumer_id);
$result = FALSE;
$watchdog_tokens = [
'%consumer_id' => $consumer_id,
'%uid' => $uid,
];
if (count($parts) == 3) {
list($group_type, $gid, $rid) = $parts;
// Need to make sure entity exists before calling og_get_user_roles which will throw fatal error.
if ($group = entity_load_single($group_type, $gid)) {
if (og_is_group($group_type, $group)) {
$roles = og_get_user_roles($group_type, $gid, $uid, TRUE);
$result = isset($roles[$rid]);
}
else {
watchdog('ldap_authorization_og', "ldap_authorization_og2_has_consumer_id passed value of non og group consumer_id=%consumer_id, uid=%uid", $watchdog_tokens, WATCHDOG_ERROR);
}
}
else {
watchdog('ldap_authorization_og', "ldap_authorization_og2_has_consumer_id could not load entity requested: consumer_id=%consumer_id, uid=%uid", $watchdog_tokens, WATCHDOG_ERROR);
}
}
return $result;
}