public function LdapAuthorizationConsumerDrupalRole::normalizeMappings in Lightweight Directory Access Protocol (LDAP) 8.2
Same name and namespace in other branches
- 7.2 ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php \LdapAuthorizationConsumerDrupalRole::normalizeMappings()
Overrides LdapAuthorizationConsumerAbstract::normalizeMappings
See also
LdapAuthorizationConsumerAbstract::normalizeMappings
File
- ldap_authorization/
ldap_authorization_drupal_role/ LdapAuthorizationConsumerRole.class.php, line 249
Class
Code
public function normalizeMappings($mappings) {
$new_mappings = array();
$roles = user_roles(TRUE);
// in rid => role name format
$roles_by_name = array_flip($roles);
foreach ($mappings as $i => $mapping) {
$new_mapping = array();
$new_mapping['user_entered'] = $mapping[1];
$new_mapping['from'] = $mapping[0];
$new_mapping['normalized'] = $mapping[1];
$new_mapping['simplified'] = $mapping[1];
$create_consumers = (bool) ($this->allowConsumerObjectCreation && $this->consumerConf->createConsumers);
$new_mapping['valid'] = (bool) (!$create_consumers && !empty($roles_by_name[$mapping[1]]));
$new_mapping['error_message'] = $new_mapping['valid'] ? '' : t("Role %role_name does not exist and role creation is not enabled.", array(
'%role' => $mapping[1],
));
$new_mappings[] = $new_mapping;
}
return $new_mappings;
}