From e086d5a5f2f25a557449d1495b23706d00ca28c6 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Mon, 31 Jan 2022 16:09:31 +0100 Subject: [PATCH 1/3] NEW Exclude filter --- htdocs/core/lib/functions.lib.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 54320ddf928..5b05a9a2071 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9148,7 +9148,15 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) if (preg_match('/\.(id|rowid)$/', $field)) { // Special case for rowid that is sometimes a ref so used as a search field $newres .= $field." = ".(is_numeric(trim($tmpcrit)) ? ((float) trim($tmpcrit)) : '0'); } else { - $newres .= $field." LIKE '"; + $tmpcrit = trim($tmpcrit); + $tmpcrit2 = $tmpcrit; + $tmpbefore = '%'; + $tmpafter = '%'; + if(preg_match('/^!/', $tmpcrit)) { + $newres .= $field." NOT LIKE '"; // ! as exclude character + $tmpcrit2 = preg_replace('/^!/', '', $tmpcrit2); + } + else $newres .= $field." LIKE '"; $tmpcrit = trim($tmpcrit); $tmpcrit2 = $tmpcrit; From e17d3b029e25ce4383a488e2685bdd4959be3898 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Tue, 1 Feb 2022 12:24:04 +0100 Subject: [PATCH 2/3] FIX delete criteria --- htdocs/core/lib/functions.lib.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5b05a9a2071..fa6d7bee21b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9158,10 +9158,6 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) } else $newres .= $field." LIKE '"; - $tmpcrit = trim($tmpcrit); - $tmpcrit2 = $tmpcrit; - $tmpbefore = '%'; - $tmpafter = '%'; if (preg_match('/^[\^\$]/', $tmpcrit)) { $tmpbefore = ''; $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2); From f36a513a10855a5086bd06c003564ff1a5614ad1 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Tue, 1 Feb 2022 16:18:02 +0100 Subject: [PATCH 3/3] fix sticler --- htdocs/core/lib/functions.lib.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index fa6d7bee21b..52695e99c28 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9151,12 +9151,11 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) $tmpcrit = trim($tmpcrit); $tmpcrit2 = $tmpcrit; $tmpbefore = '%'; - $tmpafter = '%'; - if(preg_match('/^!/', $tmpcrit)) { + $tmpafter = '%'; + if (preg_match('/^!/', $tmpcrit)) { $newres .= $field." NOT LIKE '"; // ! as exclude character $tmpcrit2 = preg_replace('/^!/', '', $tmpcrit2); - } - else $newres .= $field." LIKE '"; + } else $newres .= $field." LIKE '"; if (preg_match('/^[\^\$]/', $tmpcrit)) { $tmpbefore = '';