API: add keepParamsBetweenSearches on LSobject search

This commit is contained in:
Benjamin Renard 2021-06-14 11:46:44 +02:00
parent 36eae85bc3
commit 0360ab7951
3 changed files with 19 additions and 2 deletions

View file

@ -221,6 +221,13 @@
<listitem><simpara>Booléen permettant de désactiver l'utilisation du cache. Les valeurs acceptées <listitem><simpara>Booléen permettant de désactiver l'utilisation du cache. Les valeurs acceptées
sont <literal>1</literal> ou <literal>0</literal>.</simpara></listitem> sont <literal>1</literal> ou <literal>0</literal>.</simpara></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>keepParamsBetweenSearches</term>
<listitem><simpara>Booléen permettant d'activer/désactiver le stockage en session des paramètres de
recherche (optionel, par défaut : <literal>Faux</literal>). Les valeurs acceptées sont
<literal>1</literal> ou <literal>0</literal>.</simpara></listitem>
</varlistentry>
</variablelist> </variablelist>
</para> </para>
<programlisting linenumbering="unnumbered"> <programlisting linenumbering="unnumbered">

View file

@ -781,7 +781,7 @@ class LSsearch extends LSlog_staticLoggerClass {
if(in_array($key,array_keys($this -> params))) { if(in_array($key,array_keys($this -> params))) {
if ($key == 'nbObjectsByPageChoices' && !is_array($this -> params['nbObjectsByPageChoices'])) { if ($key == 'nbObjectsByPageChoices' && !is_array($this -> params['nbObjectsByPageChoices'])) {
return (isset($GLOBALS['NB_LSOBJECT_LIST_CHOICES']) && is_array($GLOBALS['NB_LSOBJECT_LIST_CHOICES'])?$GLOBALS['NB_LSOBJECT_LIST_CHOICES']:range(NB_LSOBJECT_LIST, NB_LSOBJECT_LIST*4, NB_LSOBJECT_LIST)); return (isset($GLOBALS['NB_LSOBJECT_LIST_CHOICES']) && is_array($GLOBALS['NB_LSOBJECT_LIST_CHOICES'])?$GLOBALS['NB_LSOBJECT_LIST_CHOICES']:range(NB_LSOBJECT_LIST, NB_LSOBJECT_LIST*4, NB_LSOBJECT_LIST));
} }
return $this -> params[$key]; return $this -> params[$key];
} }
return NULL; return NULL;

View file

@ -1569,7 +1569,17 @@ function handle_api_LSobject_search($request) {
} }
// Instanciate a LSsearch // Instanciate a LSsearch
$search = new LSsearch($LSobject, 'api', null, isset($_REQUEST['reset'])); $keepParamsBetweenSearches = (
isset($_REQUEST['keepParamsBetweenSearches'])?
boolval($_REQUEST['keepParamsBetweenSearches']):
false
);
$search = new LSsearch(
$LSobject,
'api',
null,
!$keepParamsBetweenSearches
);
$search -> setParam('onlyAccessible', True); $search -> setParam('onlyAccessible', True);
if (!$search -> setParamsFromRequest()) { if (!$search -> setParamsFromRequest()) {
LSsession :: displayAjaxReturn(); LSsession :: displayAjaxReturn();