Allow null as well as NULL infilter values

This commit is contained in:
Isaac Connor 2021-02-20 12:32:38 -05:00
parent e562888ed0
commit 0fc4b00ac1
1 changed files with 8 additions and 8 deletions

View File

@ -68,7 +68,7 @@ class FilterTerm {
$vals = is_array($this->val) ? $this->val : preg_split('/["\'\s]*?,["\'\s]*?/', preg_replace('/^["\']+?(.+)["\']+?$/', '$1', $this->val)); $vals = is_array($this->val) ? $this->val : preg_split('/["\'\s]*?,["\'\s]*?/', preg_replace('/^["\']+?(.+)["\']+?$/', '$1', $this->val));
foreach ( $vals as $value ) { foreach ( $vals as $value ) {
$value_upper = strtoupper($value);
switch ( $this->attr ) { switch ( $this->attr ) {
case 'AlarmedZoneId': case 'AlarmedZoneId':
@ -96,36 +96,36 @@ class FilterTerm {
case 'ServerId': case 'ServerId':
if ( $value == 'ZM_SERVER_ID' ) { if ( $value == 'ZM_SERVER_ID' ) {
$value = ZM_SERVER_ID; $value = ZM_SERVER_ID;
} else if ( $value == 'NULL' ) { } else if ( $value_upper == 'NULL' ) {
} else { } else {
$value = dbEscape($value); $value = dbEscape($value);
} }
break; break;
case 'StorageId': case 'StorageId':
if ( $value != 'NULL' ) { if ( $value_upper != 'NULL' ) {
$value = dbEscape($value); $value = dbEscape($value);
} }
break; break;
case 'DateTime': case 'DateTime':
case 'StartDateTime': case 'StartDateTime':
case 'EndDateTime': case 'EndDateTime':
if ( $value != 'NULL' ) if ( $value_upper != 'NULL' )
$value = '\''.strftime(STRF_FMT_DATETIME_DB, strtotime($value)).'\''; $value = '\''.strftime(STRF_FMT_DATETIME_DB, strtotime($value)).'\'';
break; break;
case 'Date': case 'Date':
case 'StartDate': case 'StartDate':
case 'EndDate': case 'EndDate':
if ( $value == 'CURDATE()' or $value == 'NOW()' ) { if ( $value_upper == 'CURDATE()' or $value_upper == 'NOW()' ) {
$value = 'to_days('.$value.')'; $value = 'to_days('.$value.')';
} else if ( $value != 'NULL' ) { } else if ( $value_upper != 'NULL' ) {
$value = 'to_days(\''.strftime(STRF_FMT_DATETIME_DB, strtotime($value)).'\')'; $value = 'to_days(\''.strftime(STRF_FMT_DATETIME_DB, strtotime($value)).'\')';
} }
break; break;
case 'Time': case 'Time':
case 'StartTime': case 'StartTime':
case 'EndTime': case 'EndTime':
if ( $value != 'NULL' ) if ( $value_upper != 'NULL' )
$value = 'extract(hour_second from \''.strftime(STRF_FMT_DATETIME_DB, strtotime($value)).'\')'; $value = 'extract(hour_second from \''.strftime(STRF_FMT_DATETIME_DB, strtotime($value)).'\')';
break; break;
default : default :
@ -133,7 +133,7 @@ class FilterTerm {
$value = 1; $value = 1;
} else if ( $value == 'Even' ) { } else if ( $value == 'Even' ) {
$value = 0; $value = 0;
} else if ( $value != 'NULL' ) } else if ( $value_upper != 'NULL' )
$value = dbEscape($value); $value = dbEscape($value);
break; break;
} }