public function LdapAuthorizationConsumerOG::mappingExamples in Lightweight Directory Access Protocol (LDAP) 7
Same name and namespace in other branches
- 8.2 ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php \LdapAuthorizationConsumerOG::mappingExamples()
- 7.2 ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php \LdapAuthorizationConsumerOG::mappingExamples()
* Get list of mappings based on existing Organic Groups and roles * *
Parameters
associative array $tokens of tokens and replacement values: * @return html examples of mapping values
File
- ldap_authorization/
ldap_authorization_og/ LdapAuthorizationConsumerOG.class.php, line 533
Class
Code
public function mappingExamples($tokens) {
if ($this->ogVersion == 1) {
$groups = og_get_all_group();
$ogEntities = og_load_multiple($groups);
$OGroles = og_roles(0);
$rows = array();
foreach ($ogEntities as $group) {
foreach ($OGroles as $rid => $role) {
$example = "<code>ou=IT,dc=myorg,dc=mytld,dc=edu|gid=" . $group->gid . ',rid=' . $rid . '</code><br/>' . '<code>ou=IT,dc=myorg,dc=mytld,dc=edu|group-name=' . $group->label . ',role-name=' . $role . '</code>';
$rows[] = array(
$group->label,
$group->gid,
$role,
$example,
);
}
}
$variables = array(
'header' => array(
'Group Name',
'OG Group ID',
'OG Membership Type',
'example',
),
'rows' => $rows,
'attributes' => array(),
);
}
else {
/**
* OG 7.x-2.x mappings:
* $entity_type = $group_type,
* $bundle = $group_bundle
* $etid = $gid where edid is nid, uid, etc.
*
* og group is: entity_type (eg node) x entity_id ($gid) eg. node:17
* group identifier = group_type:gid; aka entity_type:etid e.g. node:17
*
* membership identifier is: group_type:gid:entity_type:etid
* in our case: group_type:gid:user:uid aka entity_type:etid:user:uid e.g. node:17:user:2
*
* roles are simply rids ((1,2,3) and names (non-member, member, and administrator member) in og_role table
* og_users_roles is simply uid x rid x gid
*
* .. so authorization mappings should look like:
* <ldap group>|group_type:gid:rid such as staff|node:17:2
*/
$rows = array();
foreach ($this->ogs as $entity_type => $entities) {
foreach ($entities as $entity_id => $entity) {
foreach ($entity['roles'] as $rid => $role) {
$group_role_identifier = ldap_authorization_og_authorization_id($entity_id, $rid, $entity_type);
$example = "<code>ou=IT,dc=myorg,dc=mytld,dc=edu|{$group_role_identifier}</code>";
$rows[] = array(
$entity['name'] . ' - ' . $role,
$example,
);
}
}
}
$variables = array(
'header' => array(
'Group Name - OG Membership Type',
'example',
),
'rows' => $rows,
'attributes' => array(),
);
}
$table = theme('table', $variables);
$link = l('admin/config/people/ldap/authorization/test/og_group', 'admin/config/people/ldap/authorization/test/og_group');
$examples = <<<EOT
<br/>
Examples for some (or all) existing OG Group IDs can be found in the table below.
This is complex. To test what is going to happen, uncheck "When a user logs on" in IV.B.
and use {<span class="php-variable">$link</span>} to see what memberships sample users would receive.
{<span class="php-variable">$table</span>}
EOT;
$examples = t($examples, $tokens);
return $examples;
}