public function LdapAuthorizationConsumerConfAdmin::validate in Lightweight Directory Access Protocol (LDAP) 8.2
Same name and namespace in other branches
- 7.2 ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php \LdapAuthorizationConsumerConfAdmin::validate()
- 7 ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php \LdapAuthorizationConsumerConfAdmin::validate()
1 call to LdapAuthorizationConsumerConfAdmin::validate()
File
- ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php, line 313 
Class
- LdapAuthorizationConsumerConfAdmin
- LDAP Authorization Consumer Configration Admin Class
Code
public function validate($form_values = array()) {
  $errors = array();
  if (!$this->consumerType) {
    $errors['consumer_type'] = t('Consumer type is missing.');
  }
  if ($this->inDatabase && !$this->consumerType) {
    $errors['consumer_type'] = t('Edit or delete called without consumer type in form.');
  }
  if (count($this->mappings) > 0) {
    foreach ($this->mappings as $mapping_item) {
      list($type, $text) = $this->consumer
        ->validateAuthorizationMappingTarget($mapping_item, $form_values);
      if ($type == 'error') {
        $errors['mappings'] = $text;
      }
      elseif ($type == 'warning' || $type == 'status') {
        drupal_set_message(check_plain($text), $type);
      }
    }
  }
  if ($this->useMappingsAsFilter && !count($this->mappings)) {
    $errors['mappings'] = t('Mappings are missing.  Mappings must be supplied if filtering is enabled.');
  }
  return $errors;
}