public function LdapAuthorizationConsumerDrupalRole::normalizeMappings in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.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 268
Class
Code
public function normalizeMappings($mappings) {
$new_mappings = [];
// In rid => role name format.
$roles = user_roles(TRUE);
$roles_by_name = array_flip($roles);
foreach ($mappings as $i => $mapping) {
$new_mapping = [];
$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.", [
'%role' => $mapping[1],
]);
$new_mappings[] = $new_mapping;
}
return $new_mappings;
}