Update extrafields.class.php

This commit is contained in:
Vaadasch 2018-10-29 22:00:08 +01:00 committed by GitHub
parent 2b91067966
commit a4c7787d8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1333,7 +1333,7 @@ class ExtraFields
// current object id can be use into filter // current object id can be use into filter
if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) { if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) {
$InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]); $InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]);
} else { } else if (preg_match("#^.*list.php$#",$_SERVER["DOCUMENT_URI"])) {
// Pattern for word=$ID$ // Pattern for word=$ID$
$word = '\b[a-zA-Z0-9-\.-_]+\b=\$ID\$'; $word = '\b[a-zA-Z0-9-\.-_]+\b=\$ID\$';
@ -1359,7 +1359,7 @@ class ExtraFields
} }
// Si l'on a un AND ou un OR, avant ou après // Si l'on a un AND ou un OR, avant ou après
preg_match( '#(AND|OR|) *(' . $word . ') *(AND|OR|)#' ,$InfoFieldList[4],$matchCondition); preg_match('#(AND|OR|) *('.$word.') *(AND|OR|)#',$InfoFieldList[4],$matchCondition);
while(!empty($matchCondition[0])) { while(!empty($matchCondition[0])) {
// If the two sides differ but are not empty // If the two sides differ but are not empty
if (! empty($matchCondition[1]) && ! empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3] ) { if (! empty($matchCondition[1]) && ! empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3] ) {
@ -1369,7 +1369,7 @@ class ExtraFields
else { else {
if (! empty($matchCondition[1])) { if (! empty($matchCondition[1])) {
$boolCond =(( $matchCondition[1] == "AND" )?' AND 1 ':' OR 0 '); $boolCond =(( $matchCondition[1] == "AND" )?' AND 1 ':' OR 0 ');
$InfoFieldList[4]=str_replace($matchCondition[0],$boolCond.$matchCondition[3] ,$InfoFieldList[4]); $InfoFieldList[4]=str_replace($matchCondition[0],$boolCond.$matchCondition[3],$InfoFieldList[4]);
} }
else if (! empty($matchCondition[3])) { else if (! empty($matchCondition[3])) {
$boolCond =(( $matchCondition[3] == "AND" )?' 1 AND ':' 0 OR'); $boolCond =(( $matchCondition[3] == "AND" )?' 1 AND ':' 0 OR');
@ -1381,9 +1381,12 @@ class ExtraFields
} }
// Si l'on a un AND ou un OR, avant ou après // Si l'on a un AND ou un OR, avant ou après
preg_match( '#(AND|OR|) *(' . $word . ') *(AND|OR|)#' ,$InfoFieldList[4],$matchCondition); preg_match('#(AND|OR|) *('.$word.') *(AND|OR|)#',$InfoFieldList[4],$matchCondition);
} }
} }
else {
$InfoFieldList[4]=str_replace('$ID$','0',$InfoFieldList[4]);
}
// We have to join on extrafield table // We have to join on extrafield table
if (strpos($InfoFieldList[4], 'extra') !== false) { if (strpos($InfoFieldList[4], 'extra') !== false) {