@@ -1490,11 +1490,11 @@ public static function getWhereCriteria($nott, $itemtype, $ID, $searchtype, $val
14901490 $ append_criterion_with_search ($ criteria , "$ table.id " );
14911491 return $ criteria ;
14921492 }
1493- $ toadd = '' ;
1493+ $ text_criteria = null ;
14941494
1495- $ tmplink = ' OR ' ;
1495+ $ link_operator = Operator:: OR ;
14961496 if ($ nott ) {
1497- $ tmplink = ' AND ' ;
1497+ $ link_operator = Operator:: AND ;
14981498 }
14991499
15001500 if (is_a ($ itemtype , CommonITILObject::class, true )) {
@@ -1503,15 +1503,7 @@ public static function getWhereCriteria($nott, $itemtype, $ID, $searchtype, $val
15031503 if ($ has_join && in_array ($ opt ["joinparams " ]["beforejoin " ]["table " ], $ itil_user_tables , true )) {
15041504 $ bj = $ opt ["joinparams " ]["beforejoin " ];
15051505 $ linktable = $ bj ['table ' ] . '_ ' . Search::computeComplexJoinID ($ bj ['joinparams ' ]) . $ addmeta ;
1506- //$toadd = "`$linktable`.`alternative_email` $SEARCH $tmplink ";
1507- $ toadd = self ::makeTextCriteria (
1508- "` $ linktable`.`alternative_email` " ,
1509- $ val ,
1510- $ nott ,
1511- $ tmplink
1512- );
1513- // Remove $tmplink (may have spaces around it) from front of $toadd
1514- $ toadd = preg_replace ('/^\s* ' . preg_quote ($ tmplink , '/ ' ) . '\s*/ ' , '' , $ toadd );
1506+
15151507 if ($ val === '^$ ' ) {
15161508 return [
15171509 'OR ' => [
@@ -1520,6 +1512,13 @@ public static function getWhereCriteria($nott, $itemtype, $ID, $searchtype, $val
15201512 ],
15211513 ];
15221514 }
1515+
1516+ $ text_criteria = self ::getTextCriteria (
1517+ "$ linktable.alternative_email " ,
1518+ $ val ,
1519+ $ nott ,
1520+ $ link_operator
1521+ );
15231522 }
15241523 }
15251524 if ($ use_subquery_on_text_search ) {
@@ -1543,13 +1542,13 @@ public static function getWhereCriteria($nott, $itemtype, $ID, $searchtype, $val
15431542 break ;
15441543 } else {
15451544 $ criteria = [
1546- $ tmplink => [],
1545+ $ link_operator -> value => [],
15471546 ];
1548- $ append_criterion_with_search ($ criteria [$ tmplink ], "$ table. $ name1 " );
1549- $ append_criterion_with_search ($ criteria [$ tmplink ], "$ table. $ name2 " );
1550- $ append_criterion_with_search ($ criteria [$ tmplink ], "$ table. $ field " );
1547+ $ append_criterion_with_search ($ criteria [$ link_operator -> value ], "$ table. $ name1 " );
1548+ $ append_criterion_with_search ($ criteria [$ link_operator -> value ], "$ table. $ name2 " );
1549+ $ append_criterion_with_search ($ criteria [$ link_operator -> value ], "$ table. $ field " );
15511550 $ append_criterion_with_search (
1552- $ criteria [$ tmplink ],
1551+ $ criteria [$ link_operator -> value ],
15531552 QueryFunction::concat ([
15541553 "$ table. $ name1 " ,
15551554 new QueryExpression ($ DB ::quoteValue (' ' )),
@@ -1559,15 +1558,15 @@ public static function getWhereCriteria($nott, $itemtype, $ID, $searchtype, $val
15591558
15601559 if ($ nott && ($ val !== 'NULL ' ) && ($ val !== 'null ' )) {
15611560 $ criteria = [
1562- $ tmplink => [
1561+ $ link_operator -> value => [
15631562 'OR ' => [
15641563 $ criteria ,
15651564 "$ table. $ field " => null ,
15661565 ],
15671566 ],
15681567 ];
1569- if ($ toadd !== '' ) {
1570- $ criteria [$ tmplink ][] = new QueryExpression ( $ toadd ) ;
1568+ if ($ text_criteria !== null ) {
1569+ $ criteria [$ link_operator -> value ][] = $ text_criteria ;
15711570 }
15721571 }
15731572 return $ criteria ;
@@ -1707,15 +1706,15 @@ public static function getWhereCriteria($nott, $itemtype, $ID, $searchtype, $val
17071706 break ;
17081707
17091708 case "glpi_tickets_tickets.tickets_id_1 " :
1710- $ tmplink = ' OR ' ;
1709+ $ link_operator = Operator:: OR ;
17111710 $ compare = '= ' ;
17121711 if ($ nott ) {
1713- $ tmplink = ' AND ' ;
1712+ $ link_operator = Operator:: AND ;
17141713 $ compare = '<> ' ;
17151714 }
17161715
17171716 $ criteria = [
1718- $ tmplink => [
1717+ $ link_operator -> value => [
17191718 "$ table.tickets_id_1 " => [$ compare , $ val ],
17201719 "$ table.tickets_id_2 " => [$ compare , $ val ],
17211720 ],
@@ -1971,9 +1970,7 @@ public static function getWhereCriteria($nott, $itemtype, $ID, $searchtype, $val
19711970 // Date format modification if needed
19721971 $ val = preg_replace ('@(\d{1,2})(-|/)(\d{1,2})(-|/)(\d{4})@ ' , '\5-\3-\1 ' , $ val );
19731972 if ($ date_computation ) {
1974- return [
1975- new QueryExpression (self ::makeTextCriteria ($ date_computation , $ val , $ nott , '' )),
1976- ];
1973+ return self ::getTextCriteria ($ date_computation , $ val , $ nott , Operator::NONE );
19771974 }
19781975 return [];
19791976
0 commit comments