Commit d645dee0 authored by Carsten  Rose's avatar Carsten Rose
Browse files

#3573 / TypeaheadLdap: Prefetch funktioniert nicht

Manual.rst: Prefetch doc enhanced.
Ldap.php: replacement of '?' in LDAP search not processed with MODE_LDAP_PREFETCH - fixed. FE_TYPEAHEAD_LDAP_KEY_PRINTF renamed to FE_TYPEAHEAD_LDAP_ID_PRINTF
AbstractBuildForm.php: copy 'FE_TYPEAHEAD_LDAP_ID_PRINTF' to SIP seems never be done - fixed
parent 566c5581
...@@ -904,13 +904,25 @@ Pedantic ...@@ -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 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. 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. 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*: * *Form.parameter* or *FormElement.parameter*:
* *typeAheadPedantic* * *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=?)` * *typeAheadLdapSearchPrefetch* = `(mail=?)`
This situation also applies in *pedantic* mode to verify the user input after each change.
PerToken PerToken
^^^^^^^^ ^^^^^^^^
......
...@@ -918,7 +918,7 @@ abstract class AbstractBuildForm { ...@@ -918,7 +918,7 @@ abstract class AbstractBuildForm {
$formElement[FE_TYPEAHEAD_LDAP_SEARCH] = Support::setIfNotSet($formElement, FE_TYPEAHEAD_LDAP_SEARCH); $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_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_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); $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) { foreach ([FE_LDAP_SERVER, FE_LDAP_BASE_DN, FE_TYPEAHEAD_LDAP_SEARCH] as $key) {
...@@ -927,8 +927,8 @@ abstract class AbstractBuildForm { ...@@ -927,8 +927,8 @@ abstract class AbstractBuildForm {
} }
} }
if ($formElement[FE_TYPEAHEAD_LDAP_VALUE_PRINTF] . $formElement[FE_TYPEAHEAD_LDAP_KEY_PRINTF] == '') { 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_KEY_PRINTF, ERROR_MISSING_DEFINITON); throw new UserFormException('Missing definition: ' . FE_TYPEAHEAD_LDAP_VALUE_PRINTF . ' or ' . FE_TYPEAHEAD_LDAP_ID_PRINTF, ERROR_MISSING_DEFINITON);
} }
$arr = [ $arr = [
...@@ -937,6 +937,7 @@ abstract class AbstractBuildForm { ...@@ -937,6 +937,7 @@ abstract class AbstractBuildForm {
FE_TYPEAHEAD_LDAP_SEARCH => $formElement[FE_TYPEAHEAD_LDAP_SEARCH], FE_TYPEAHEAD_LDAP_SEARCH => $formElement[FE_TYPEAHEAD_LDAP_SEARCH],
FE_TYPEAHEAD_LDAP_SEARCH_PREFETCH => $formElement[FE_TYPEAHEAD_LDAP_SEARCH_PREFETCH], 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_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], FE_TYPEAHEAD_LIMIT => $formElement[FE_TYPEAHEAD_LIMIT],
]; ];
......
...@@ -691,7 +691,7 @@ const FE_TYPEAHEAD_MINLENGTH = F_TYPEAHEAD_MINLENGTH; ...@@ -691,7 +691,7 @@ const FE_TYPEAHEAD_MINLENGTH = F_TYPEAHEAD_MINLENGTH;
const FE_TYPEAHEAD_PEDANTIC = F_TYPEAHEAD_PEDANTIC; const FE_TYPEAHEAD_PEDANTIC = F_TYPEAHEAD_PEDANTIC;
const FE_TYPEAHEAD_SQL = 'typeAheadSql'; const FE_TYPEAHEAD_SQL = 'typeAheadSql';
const FE_TYPEAHEAD_LDAP_VALUE_PRINTF = F_TYPEAHEAD_LDAP_VALUE_PRINTF; 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 = 'typeAheadLdap';
const FE_TYPEAHEAD_LDAP_SEARCH = F_TYPEAHEAD_LDAP_SEARCH; const FE_TYPEAHEAD_LDAP_SEARCH = F_TYPEAHEAD_LDAP_SEARCH;
const FE_TYPEAHEAD_LDAP_SEARCH_PREFETCH = F_TYPEAHEAD_LDAP_SEARCH_PREFETCH; const FE_TYPEAHEAD_LDAP_SEARCH_PREFETCH = F_TYPEAHEAD_LDAP_SEARCH_PREFETCH;
......
...@@ -157,6 +157,10 @@ class Ldap { ...@@ -157,6 +157,10 @@ class Ldap {
$config[FE_TYPEAHEAD_LIMIT] = ($mode == MODE_LDAP_MULTI) ? $config[FE_TYPEAHEAD_LIMIT] : 1; $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 ($mode == MODE_LDAP_MULTI) {
if (isset($config[F_TYPEAHEAD_LDAP_SEARCH_PER_TOKEN])) { if (isset($config[F_TYPEAHEAD_LDAP_SEARCH_PER_TOKEN])) {
...@@ -165,19 +169,19 @@ class Ldap { ...@@ -165,19 +169,19 @@ class Ldap {
$config[FE_LDAP_SEARCH] = str_replace(TYPEAHEAD_PLACEHOLDER, $searchValue, $config[FE_LDAP_SEARCH]); $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, ''); $config[FE_TYPEAHEAD_LDAP_VALUE_PRINTF] = Support::setIfNotSet($config, FE_TYPEAHEAD_LDAP_VALUE_PRINTF, '');
if ($config[FE_TYPEAHEAD_LDAP_KEY_PRINTF] == '') { if ($config[FE_TYPEAHEAD_LDAP_ID_PRINTF] == '') {
$config[FE_TYPEAHEAD_LDAP_KEY_PRINTF] = $config[FE_TYPEAHEAD_LDAP_VALUE_PRINTF]; $config[FE_TYPEAHEAD_LDAP_ID_PRINTF] = $config[FE_TYPEAHEAD_LDAP_VALUE_PRINTF];
} }
if ($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] == '') { if ($config[FE_TYPEAHEAD_LDAP_ID_PRINTF] == '') {
throw new UserFormException("Missing parameter '" . FE_TYPEAHEAD_LDAP_KEY_PRINTF . "' and/or '" . FE_TYPEAHEAD_LDAP_VALUE_PRINTF); throw new UserFormException("Missing parameter '" . FE_TYPEAHEAD_LDAP_ID_PRINTF . "' and/or '" . FE_TYPEAHEAD_LDAP_VALUE_PRINTF);
} }
} }
...@@ -232,7 +236,7 @@ class Ldap { ...@@ -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); $valueArr = $this->preparePrintf($config, FE_TYPEAHEAD_LDAP_VALUE_PRINTF, $valueFormat);
$specificArr = OnArray::arrayValueToLower(OnArray::trimArray(explode(',', $config[FE_LDAP_ATTRIBUTES]))); $specificArr = OnArray::arrayValueToLower(OnArray::trimArray(explode(',', $config[FE_LDAP_ATTRIBUTES])));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment