From 78de23332172162e021a8bb178db36f8e1e84fe7 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 14 Jun 2021 11:48:07 +0200 Subject: [PATCH] API: add search parameters in return on LSobject search --- doc/api/api.docbook | 21 +++++++++++++++++++++ src/includes/routes.php | 17 +++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/doc/api/api.docbook b/doc/api/api.docbook index d953207d..59b1c463 100644 --- a/doc/api/api.docbook +++ b/doc/api/api.docbook @@ -258,6 +258,27 @@ } }, "total": 14, + "params": { + "keepParamsBetweenSearches": false, + "filter": null, + "pattern": null, + "predefinedFilter": false, + "basedn": null, + "scope": null, + "sizelimit": 0, + "attronly": false, + "approx": false, + "recursive": true, + "attributes": [], + "onlyAccessible": true, + "sortDirection": null, + "sortBy": null, + "sortlimit": 0, + "displayFormat": "%{cn}", + "nbObjectsByPage": 25, + "withoutCache": false, + "extraDisplayedColumns": true + }, "page": 1, "nbPages": 3 }]]> diff --git a/src/includes/routes.php b/src/includes/routes.php index 6d09e2fc..77dbb931 100644 --- a/src/includes/routes.php +++ b/src/includes/routes.php @@ -1621,8 +1621,25 @@ function handle_api_LSobject_search($request) { 'success' => true, 'objects' => array(), 'total' => $search -> total, + 'params' => array( + 'keepParamsBetweenSearches' => $keepParamsBetweenSearches, + ), ); + // Export search parameters + $exportedParams = array( + 'filter', 'pattern', 'predefinedFilter', 'basedn', 'scope', 'sizelimit', 'attronly', + 'approx', 'recursive', 'attributes', 'onlyAccessible', 'sortDirection', 'sortBy', 'sortlimit', + 'displayFormat', 'nbObjectsByPage', 'withoutCache', 'extraDisplayedColumns' + ); + if (LSsession :: subDnIsEnabled()) + $exportedParams = array_merge($exportedParams, array('displaySubDn', 'subDn')); + foreach ($exportedParams as $param) { + $data['params'][$param] = $search->getParam($param); + if ($param == 'filter' && $data['params'][$param]) + $data['params'][$param] = $data['params'][$param] -> as_string(); + } + // Instanciate LSform export to handle custom requested attributes if (!LSsession :: loadLSclass('LSform')) LSlog :: fatal("Fail to load LSform.");