function ldap_authorization_og2_get_group_from_name 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_get_group_from_name()
Generic function to convert between query values and organic groups structures and attributes.
Parameters
mixed $entity_type: signifies query value e.g. 'bakers', 7 etc.
mixed $group_name: signifies query type e.g. 'group_name', 'gid', etc.
Return value
mixed organic group object, gid, label, etc.
3 calls to ldap_authorization_og2_get_group_from_name()
- LdapAuthorizationConsumerOG::normalizeMappings in ldap_authorization/
ldap_authorization_og/ LdapAuthorizationConsumerOG.class.php - LdapAuthorizationOg2Tests::getTestData in ldap_authorization/
tests/ Og2Tests.test - Get test data in convenient format, so tests are easier to read and write.
- 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 71 - Controls organic group membership based on LDAP values.
Code
function ldap_authorization_og2_get_group_from_name($entity_type, $group_name) {
require_once drupal_get_path('module', 'ldap_authorization_og') . '/LdapAuthorizationConsumerOG.class.php';
$group_entity = FALSE;
$group_entity_id = FALSE;
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', $entity_type)
->propertyCondition('title', $group_name);
$result = $query
->execute();
if (isset($result[$entity_type])) {
$group_ids = array_keys($result[$entity_type]);
if (count($group_ids) == 1) {
$group_entity = entity_load_single($entity_type, $group_ids[0]);
$group_entity_id = $group_ids[0];
}
}
return [
$group_entity,
$group_entity_id,
];
}