diff --git a/extension/Documentation/Manual.rst b/extension/Documentation/Manual.rst index 288914901c92d5bde75e436f2ddbf3dc697dac0d..a4cc52f550adb584b25be55c6786021533d5a576 100644 --- a/extension/Documentation/Manual.rst +++ b/extension/Documentation/Manual.rst @@ -904,13 +904,25 @@ Pedantic In case the typed value (technically this is the value of the *id*, latest in the moment when loosing the focus) have to be a valid (= exist on the LDAP server), the *typeAheadPedantic* mode can be activated. If the user typed something and that is not a valid *id*, the client (=browser) will delete the input when loosing the focus. -To identify the exact *id*, an additional search filter is necessary. +To identify the exact *id*, an additional search filter is necessary: `ypeAheadLdapSearchPrefetch` - see next topic. * *Form.parameter* or *FormElement.parameter*: * *typeAheadPedantic* + +Prefetch +^^^^^^^^ + +After 'form load' with an existing record, the user epects to see the previous saved data. In case there is an *id* to +*value* translation, the *value* does not exist in the database, instead it has to be fetched again dynamically from the +LDAP server. A precise LDAP query has to be defined to force this: + +* *Form.parameter* or *FormElement.parameter*: + * *typeAheadLdapSearchPrefetch* = `(mail=?)` +This situation also applies in *pedantic* mode to verify the user input after each change. + PerToken ^^^^^^^^ diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php index 3936fda35ed2d922c48940412d1ac3468db757b6..29d7c32f4006f47d0a065578a38ab24344795b19 100644 --- a/extension/qfq/qfq/AbstractBuildForm.php +++ b/extension/qfq/qfq/AbstractBuildForm.php @@ -918,7 +918,7 @@ abstract class AbstractBuildForm { $formElement[FE_TYPEAHEAD_LDAP_SEARCH] = Support::setIfNotSet($formElement, FE_TYPEAHEAD_LDAP_SEARCH); $formElement[FE_TYPEAHEAD_LDAP_SEARCH_PREFETCH] = Support::setIfNotSet($formElement, FE_TYPEAHEAD_LDAP_SEARCH_PREFETCH); $formElement[FE_TYPEAHEAD_LDAP_VALUE_PRINTF] = Support::setIfNotSet($formElement, FE_TYPEAHEAD_LDAP_VALUE_PRINTF); - $formElement[FE_TYPEAHEAD_LDAP_KEY_PRINTF] = Support::setIfNotSet($formElement, FE_TYPEAHEAD_LDAP_KEY_PRINTF); + $formElement[FE_TYPEAHEAD_LDAP_ID_PRINTF] = Support::setIfNotSet($formElement, FE_TYPEAHEAD_LDAP_ID_PRINTF); $formElement[FE_LDAP_USE_BIND_CREDENTIALS] = Support::setIfNotSet($formElement, FE_LDAP_USE_BIND_CREDENTIALS); foreach ([FE_LDAP_SERVER, FE_LDAP_BASE_DN, FE_TYPEAHEAD_LDAP_SEARCH] as $key) { @@ -927,8 +927,8 @@ abstract class AbstractBuildForm { } } - if ($formElement[FE_TYPEAHEAD_LDAP_VALUE_PRINTF] . $formElement[FE_TYPEAHEAD_LDAP_KEY_PRINTF] == '') { - throw new UserFormException('Missing definition: ' . FE_TYPEAHEAD_LDAP_VALUE_PRINTF . ' or ' . FE_TYPEAHEAD_LDAP_KEY_PRINTF, ERROR_MISSING_DEFINITON); + if ($formElement[FE_TYPEAHEAD_LDAP_VALUE_PRINTF] . $formElement[FE_TYPEAHEAD_LDAP_ID_PRINTF] == '') { + throw new UserFormException('Missing definition: ' . FE_TYPEAHEAD_LDAP_VALUE_PRINTF . ' or ' . FE_TYPEAHEAD_LDAP_ID_PRINTF, ERROR_MISSING_DEFINITON); } $arr = [ @@ -937,6 +937,7 @@ abstract class AbstractBuildForm { FE_TYPEAHEAD_LDAP_SEARCH => $formElement[FE_TYPEAHEAD_LDAP_SEARCH], FE_TYPEAHEAD_LDAP_SEARCH_PREFETCH => $formElement[FE_TYPEAHEAD_LDAP_SEARCH_PREFETCH], FE_TYPEAHEAD_LDAP_VALUE_PRINTF => $formElement[FE_TYPEAHEAD_LDAP_VALUE_PRINTF], + FE_TYPEAHEAD_LDAP_ID_PRINTF => $formElement[FE_TYPEAHEAD_LDAP_ID_PRINTF], FE_TYPEAHEAD_LIMIT => $formElement[FE_TYPEAHEAD_LIMIT], ]; diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index c83d22ba5958d5e88d97fef7712a77236bb161ed..6e2a16cefaf737f56eaac88537ec4efe2f8d0165 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -691,7 +691,7 @@ const FE_TYPEAHEAD_MINLENGTH = F_TYPEAHEAD_MINLENGTH; const FE_TYPEAHEAD_PEDANTIC = F_TYPEAHEAD_PEDANTIC; const FE_TYPEAHEAD_SQL = 'typeAheadSql'; const FE_TYPEAHEAD_LDAP_VALUE_PRINTF = F_TYPEAHEAD_LDAP_VALUE_PRINTF; -const FE_TYPEAHEAD_LDAP_KEY_PRINTF = F_TYPEAHEAD_LDAP_ID_PRINTF; +const FE_TYPEAHEAD_LDAP_ID_PRINTF = F_TYPEAHEAD_LDAP_ID_PRINTF; const FE_TYPEAHEAD_LDAP = 'typeAheadLdap'; const FE_TYPEAHEAD_LDAP_SEARCH = F_TYPEAHEAD_LDAP_SEARCH; const FE_TYPEAHEAD_LDAP_SEARCH_PREFETCH = F_TYPEAHEAD_LDAP_SEARCH_PREFETCH; diff --git a/extension/qfq/qfq/helper/Ldap.php b/extension/qfq/qfq/helper/Ldap.php index d7c9f5b8f48976015cd8e1b741680b6240eaade4..f745420d9bce0aab3e03177bcf6183da80d9315f 100644 --- a/extension/qfq/qfq/helper/Ldap.php +++ b/extension/qfq/qfq/helper/Ldap.php @@ -157,6 +157,10 @@ class Ldap { $config[FE_TYPEAHEAD_LIMIT] = ($mode == MODE_LDAP_MULTI) ? $config[FE_TYPEAHEAD_LIMIT] : 1; + if ($mode == MODE_LDAP_PREFETCH) { + $config[FE_LDAP_SEARCH] = str_replace(TYPEAHEAD_PLACEHOLDER, $searchValue, $config[FE_LDAP_SEARCH]); + } + if ($mode == MODE_LDAP_MULTI) { if (isset($config[F_TYPEAHEAD_LDAP_SEARCH_PER_TOKEN])) { @@ -165,19 +169,19 @@ class Ldap { $config[FE_LDAP_SEARCH] = str_replace(TYPEAHEAD_PLACEHOLDER, $searchValue, $config[FE_LDAP_SEARCH]); } - $config[FE_TYPEAHEAD_LDAP_KEY_PRINTF] = Support::setIfNotSet($config, FE_TYPEAHEAD_LDAP_KEY_PRINTF, ''); + $config[FE_TYPEAHEAD_LDAP_ID_PRINTF] = Support::setIfNotSet($config, FE_TYPEAHEAD_LDAP_ID_PRINTF, ''); $config[FE_TYPEAHEAD_LDAP_VALUE_PRINTF] = Support::setIfNotSet($config, FE_TYPEAHEAD_LDAP_VALUE_PRINTF, ''); - if ($config[FE_TYPEAHEAD_LDAP_KEY_PRINTF] == '') { - $config[FE_TYPEAHEAD_LDAP_KEY_PRINTF] = $config[FE_TYPEAHEAD_LDAP_VALUE_PRINTF]; + if ($config[FE_TYPEAHEAD_LDAP_ID_PRINTF] == '') { + $config[FE_TYPEAHEAD_LDAP_ID_PRINTF] = $config[FE_TYPEAHEAD_LDAP_VALUE_PRINTF]; } if ($config[FE_TYPEAHEAD_LDAP_VALUE_PRINTF] == '') { - $config[FE_TYPEAHEAD_LDAP_VALUE_PRINTF] = $config[FE_TYPEAHEAD_LDAP_KEY_PRINTF]; + $config[FE_TYPEAHEAD_LDAP_VALUE_PRINTF] = $config[FE_TYPEAHEAD_LDAP_ID_PRINTF]; } - if ($config[FE_TYPEAHEAD_LDAP_KEY_PRINTF] == '') { - throw new UserFormException("Missing parameter '" . FE_TYPEAHEAD_LDAP_KEY_PRINTF . "' and/or '" . FE_TYPEAHEAD_LDAP_VALUE_PRINTF); + if ($config[FE_TYPEAHEAD_LDAP_ID_PRINTF] == '') { + throw new UserFormException("Missing parameter '" . FE_TYPEAHEAD_LDAP_ID_PRINTF . "' and/or '" . FE_TYPEAHEAD_LDAP_VALUE_PRINTF); } } @@ -232,7 +236,7 @@ class Ldap { } } - $keyArr = $this->preparePrintf($config, FE_TYPEAHEAD_LDAP_KEY_PRINTF, $keyFormat); + $keyArr = $this->preparePrintf($config, FE_TYPEAHEAD_LDAP_ID_PRINTF, $keyFormat); $valueArr = $this->preparePrintf($config, FE_TYPEAHEAD_LDAP_VALUE_PRINTF, $valueFormat); $specificArr = OnArray::arrayValueToLower(OnArray::trimArray(explode(',', $config[FE_LDAP_ATTRIBUTES])));