public function LdapAuthorizationConsumerOG::validateAuthorizationMappingTarget 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::validateAuthorizationMappingTarget()
- 7.2 ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php \LdapAuthorizationConsumerOG::validateAuthorizationMappingTarget()
* Validate authorization mappings on LDAP Authorization OG Admin form. * *
Parameters
string $map_to from mapping tables in authorization configuration form: * @param array $form_values from authorization configuration form * @param boolean $clear_cache * * @return array of form array($message_type, $message_text) where message type is status, warning, or error * and $message_text is what the user should see. *
Overrides LdapAuthorizationConsumerAbstract::validateAuthorizationMappingTarget
File
- ldap_authorization/
ldap_authorization_og/ LdapAuthorizationConsumerOG.class.php, line 474
Class
Code
public function validateAuthorizationMappingTarget($map_to, $form_values = NULL, $clear_cache = FALSE) {
$has_form_values = is_array($form_values);
$message_type = NULL;
$message_text = NULL;
$tokens = array(
'!map_to' => $map_to,
);
$available_authorization_ids = $this
->availableConsumerIDs($clear_cache);
$pass = FALSE;
if ($this->ogVersion == 1) {
$normalized = $this
->normalizeMappings(array(
array(
'placeholder',
$map_to,
),
));
if (is_array($normalized) && isset($normalized[0][1]) && $normalized[0][1] !== FALSE) {
list($gid, $rid) = explode('-', $normalized[0][1]);
$pass = in_array($normalized[0][1], $available_authorization_ids);
}
}
else {
$normalized = TRUE;
// not relevant to og 2
$parts = explode(':', $map_to);
if (count($parts) == 3) {
list($entity_type, $entity_id, $rid) = $parts;
$pass = isset($this->ogs[$entity_type][$entity_id]['roles'][$rid]);
}
}
if (!$pass) {
$message_text = '<code>"' . t('!map_to', $tokens) . '"</code> ' . t('does not map to any existing organic groups and roles. ');
if ($has_form_values) {
$create_consumers = isset($form_values['synchronization_actions']['create_consumers']) && $form_values['synchronization_actions']['create_consumers'];
}
else {
$create_consumers = $this->consumerConf->create_consumers;
}
if ($normalized === FALSE) {
$message_type = 'error';
$message_text .= t('Can not normalize mappings. Please check the syntax in Mapping of LDAP to OG Group', $tokens);
}
elseif ($create_consumers && $this->allowConsumerObjectCreation) {
$message_type = 'warning';
$message_text .= t('It will be created when needed. If "!map_to" is not intentional, please fix it', $tokens);
}
elseif (!$this->allowConsumerObjectCreation) {
$message_type = 'error';
$message_text .= t('Since automatic organic group creation is not possible with this module, an existing group must be mapped to.');
}
elseif (!$create_consumers) {
$message_type = 'error';
$message_text .= t('Since automatic organic group creation is disabled, an existing group must be mapped to. Either enable organic group creation or map to an existing group.');
}
}
return array(
$message_type,
$message_text,
);
}