You are here

public function LdapAuthorizationConsumerConfAdmin::validate in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php \LdapAuthorizationConsumerConfAdmin::validate()
  2. 7 ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php \LdapAuthorizationConsumerConfAdmin::validate()
1 call to LdapAuthorizationConsumerConfAdmin::validate()
LdapAuthorizationConsumerConfAdmin::drupalFormValidate in ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php

File

ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php, line 336

Class

LdapAuthorizationConsumerConfAdmin
LDAP Authorization Consumer Configration Admin Class.

Code

public function validate($form_values = []) {
  $errors = [];
  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;
}