Enhance search / filter

This commit is contained in:
Laurent Destailleur 2020-05-26 12:46:51 +02:00
parent 2d30d33303
commit 05ac3de2f0
2 changed files with 9 additions and 7 deletions

View File

@ -780,26 +780,26 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
if (!is_object($weblangs)) $weblangs = $langs;
if (empty($searchstring))
if (empty($searchstring) && empty($type) && empty($langcode) && empty($otherfilters))
{
$error++;
$arrayresult['code'] = 'KO';
$arrayresult['message'] = $weblangs->trans("EmptySearchString");
} elseif (dol_strlen($searchstring) < 2) {
} elseif ($searchstring && dol_strlen($searchstring) < 2) {
$weblangs->load("errors");
$error++;
$arrayresult['code'] = 'KO';
$arrayresult['message'] = $weblangs->trans("ErrorSearchCriteriaTooSmall");
} else {
$tmparrayoftype = explode(',', $type);
foreach ($tmparrayoftype as $tmptype) {
/*foreach ($tmparrayoftype as $tmptype) {
if (!in_array($tmptype, array('', 'page', 'blogpost'))) {
$error++;
$arrayresult['code'] = 'KO';
$arrayresult['message'] = 'Bad value for parameter type';
break;
}
}
}*/
}
$searchdone = 0;
@ -819,7 +819,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
$tmparrayoftype = explode(',', $type);
$typestring = '';
foreach ($tmparrayoftype as $tmptype) {
$typestring .= ($typestring ? ", " : "")."'".trim($tmptype)."'";
$typestring .= ($typestring ? ", " : "")."'".$db->escape(trim($tmptype))."'";
}
$sql .= " AND wp.type_container IN (".$typestring.")";
}

View File

@ -374,9 +374,10 @@ if ($action == 'unsetshowsubcontainers')
exit;
}
if (($action == 'replacesite' || $action == 'replacesiteconfirm') && !$searchkey)
if ($massaction == 'replace' && GETPOST('confirmmassaction', 'alpha') && !$searchkey)
{
$action = 'replacesite';
$massaction = '';
}
// Replacement of string into pages
@ -3648,9 +3649,10 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction =
// List of mass actions available
$arrayofmassactions = array();
if ($user->rights->website->writephp) $arrayofmassactions['replace'] = $langs->trans("Replace");
if ($user->rights->website->writephp && $searchkey) $arrayofmassactions['replace'] = $langs->trans("Replace");
if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$massactionbutton .= '<div class="massactionother hidden">';
$massactionbutton .= $langs->trans("ReplaceString");