pass modification date to search() functions

This commit is contained in:
Uwe Steinmann 2023-05-03 16:21:57 +02:00
parent b3e50278b1
commit 3739f9e658

View File

@ -91,6 +91,31 @@ if(!empty($_GET["created"]["to"])) {
}
/* }}} */
/* Modification date {{{ */
$modifystartts = null;
$modifystartdate = null;
$modifyendts = null;
$modifyenddate = null;
$modified['from'] = null;
$modified['to'] = null;
if(!empty($_GET["modified"]["from"])) {
$modifystartts = makeTsFromDate($_GET["modified"]["from"]);
$modifystartdate = array('year'=>(int)date('Y', $modifystartts), 'month'=>(int)date('m', $modifystartts), 'day'=>(int)date('d', $modifystartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
if (!checkdate($modifystartdate['month'], $modifystartdate['day'], $modifystartdate['year'])) {
UI::exitError(getMLText("search"),getMLText("invalid_modification_date_end"));
}
$modified['from'] = $modifystartts;
}
if(!empty($_GET["modified"]["to"])) {
$modifyendts = makeTsFromDate($_GET["modified"]["to"]);
$modifyenddate = array('year'=>(int)date('Y', $modifyendts), 'month'=>(int)date('m', $modifyendts), 'day'=>(int)date('d', $modifyendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
if (!checkdate($modifyenddate['month'], $modifyenddate['day'], $modifyenddate['year'])) {
UI::exitError(getMLText("search"),getMLText("invalid_modification_date_end"));
}
$modified['to'] = $modifyendts;
}
/* }}} */
// Check to see if the search has been restricted to a particular
// document owner.
// $_GET['owner'] can be a name of an array of names or ids {{{
@ -291,7 +316,7 @@ if($fullsearch) {
$terms = $index->terms($lastterm, $settings->_suggestTerms);
}
$lucenesearch = $fulltextservice->Search();
$searchresult = $lucenesearch->search($query, array('record_type'=>$record_type, 'owner'=>$ownernames, 'status'=>$status, 'category'=>$categorynames, 'user'=>$user->isAdmin() ? [] : [$user->getLogin()], 'mimetype'=>$mimetype, 'startFolder'=>$startFolder, 'rootFolder'=>$rootFolder, 'created_start'=>$createstartts, 'created_end'=>$createendts, 'attributes'=>$attributes), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1))));
$searchresult = $lucenesearch->search($query, array('record_type'=>$record_type, 'owner'=>$ownernames, 'status'=>$status, 'category'=>$categorynames, 'user'=>$user->isAdmin() ? [] : [$user->getLogin()], 'mimetype'=>$mimetype, 'startFolder'=>$startFolder, 'rootFolder'=>$rootFolder, 'created_start'=>$createstartts, 'created_end'=>$createendts, 'modified_start'=>$modifystartts, 'modified_end'=>$modifyendts, 'attributes'=>$attributes), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1))), ['by'=>'', 'dir'=>'desc']);
if($searchresult === false) {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
$dcount = 0;
@ -581,8 +606,8 @@ if($fullsearch) {
'status'=>$status,
'creationstartdate'=>$created['from'], //$createstartdate ? $createstartdate : array(),
'creationenddate'=>$created['to'], //$createenddate ? $createenddate : array(),
'modificationstartdate'=>array(),
'modificationenddate'=>array(),
'modificationstartdate'=>$modified['from'],
'modificationenddate'=>$modified['to'],
'categories'=>$categories,
'attributes'=>$attributes,
'mode'=>$resultmode,