function ldap_authorization_og2_get_group in Lightweight Directory Access Protocol (LDAP) 7
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, label, etc.
3 calls to ldap_authorization_og2_get_group()
- LdapAuthorizationOg2Tests::testAuthorizationsOnLogon in ldap_authorization/
tests/ Og/ Og2.test - IV. Test authorizations granted on logon
- LdapAuthorizationOg2Tests::testAuthorizationsWithoutLogon in ldap_authorization/
tests/ Og/ Og2.test - LdapAuthorizationOg2Tests::testBasicFunctionsAndApi in ldap_authorization/
tests/ Og/ Og2.test - just make sure install succeeds and
File
- ldap_authorization/
ldap_authorization_og/ ldap_authorization_og.module, line 129 - controls organic group membership based on LDAP values
Code
function ldap_authorization_og2_get_group($entity_type, $value, $value_type = 'group_name', $return = 'object') {
require_once drupal_get_path('module', 'ldap_authorization_og') . '/LdapAuthorizationConsumerOG.class.php';
list($groups, $availableConsumerIDs) = LdapAuthorizationConsumerOG::og2Groups();
$group = NULL;
$node = NULL;
if ($value_type == 'gid') {
$group = $groups[$entity_type][$value];
}
elseif ($value_type == 'group_name') {
foreach ($groups[$entity_type] as $gid => $group) {
if ($group['name'] == $value) {
$node = node_load($gid);
break;
}
}
}
if ($return == 'object' && is_array($group) && is_object($node)) {
return array(
$group,
$node,
);
}
elseif ($return == 'label' || $return == 'name' && is_object($node)) {
return $node->title;
}
else {
return FALSE;
}
}