function ldap_authorization_og1_get_group in Lightweight Directory Access Protocol (LDAP) 7
Same name and namespace in other branches
- 8.2 ldap_authorization/ldap_authorization_og/ldap_authorization_og.module \ldap_authorization_og1_get_group()
Generic function to convert between query values and organic groups structures and attributes
Parameters
mixed $value signifies query value e.g. 'bakers', 7 etc.:
mixed $value_type signifies query type e.g. 'group_name', 'gid', etc.:
string $return signifying return type. e.g. 'object', 'label', 'name', 'gid':
Return value
mixed organic group object, gid, label, etc.
1 call to ldap_authorization_og1_get_group()
- LdapAuthorizationConsumerOG::normalizeMappings in ldap_authorization/
ldap_authorization_og/ LdapAuthorizationConsumerOG.class.php - function to normalize mappings should be overridden when mappings are not stored as map|authorization_id format where authorization_id is the format returned by LdapAuthorizationConsumerAbstract::usersAuthorizations()
File
- ldap_authorization/
ldap_authorization_og/ ldap_authorization_og.module, line 84 - controls organic group membership based on LDAP values
Code
function ldap_authorization_og1_get_group($value, $value_type = 'group_name', $return = 'object') {
$groups = og_load_multiple(og_get_all_group());
$group = NULL;
$node = NULL;
if ($value_type == 'gid') {
$group = $groups[$value];
}
elseif ($value_type == 'group_name') {
foreach ($groups as $gid => $discard) {
$group_obj = og_load($gid);
$group_node = node_load($group_obj->etid);
if ($group_node && $group_node->type == $value) {
$group = $group_obj;
$node = $group_node;
break;
}
}
}
if ($return == 'object' && is_object($group) && is_object($node)) {
return array(
$group,
$node,
);
}
elseif ($return == 'label' || $return == 'name' && is_object($group)) {
return $group->label;
}
elseif ($return == 'gid' && is_object($group)) {
return $group->gid;
}
else {
return FALSE;
}
}