Pārlūkot izejas kodu

Merge pull request #27228 from artis-auxilium/fix_forge_criteria

Fix: Add not in operator
Laurent Destailleur 1 gadu atpakaļ
vecāks
revīzija
858825be6d
1 mainītis faili ar 11 papildinājumiem un 9 dzēšanām
  1. 11 9
      htdocs/core/lib/functions.lib.php

+ 11 - 9
htdocs/core/lib/functions.lib.php

@@ -12593,20 +12593,22 @@ function dolForgeCriteriaCallback($matches)
 
 	$operator = strtoupper(preg_replace('/[^a-z<>!=]/i', '', trim($tmp[1])));
 
-	if ($operator == 'NOTLIKE') {
-		$operator = 'NOT LIKE';
-	}
-	if ($operator == 'ISNOT') {
-		$operator = 'IS NOT';
-	}
-	if ($operator == '!=') {
-		$operator = '<>';
+	$realOperator = [
+		'NOTLIKE' => 'NOT LIKE',
+		'ISNOT' => 'IS NOT',
+		'NOTIN' => 'NOT IN',
+		'!=' => '<>',
+	];
+
+	if (array_key_exists($operator, $realOperator)) {
+		$operator = $realOperator[$operator];
 	}
 
+
 	$tmpescaped = $tmp[2];
 	$regbis = array();
 
-	if ($operator == 'IN') {	// IN is allowed for list of ID or code only
+	if ($operator == 'IN' || $operator == 'NOT IN') {	// IN is allowed for list of ID or code only
 		//if (!preg_match('/^\(.*\)$/', $tmpescaped)) {
 		$tmpescaped2 = '(';
 		// Explode and sanitize each element in list