Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Add operand MySQL for the Widgets #6391

Closed
wants to merge 13 commits into from
6 changes: 6 additions & 0 deletions www/class/centreonUtils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ public static function operandToMysqlFormat($str)
case "notlike":
$result = "NOT LIKE";
break;
case "regex":
$result = "REGEXP";
break;
case "notregex":
$result = "NOT REGEXP";
break;
default:
$result = "";
break;
Expand Down
6 changes: 4 additions & 2 deletions www/class/centreonWidget/Params/Compare.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public function init($params)
"eq" => "=",
"ne" => "!=",
"like" => "LIKE",
"notlike" => "NOT LIKE"
"notlike" => "NOT LIKE",
"regex" => "REGEXP",
"notregex"=> "NOT REGEXP"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ERROR: Expected at least 1 space before "=>"; 0 found

);
$elems[] = $this->quickform->addElement('select', 'op_' . $params['parameter_id'], '', $operands);
$elems[] = $this->quickform->addElement(
Expand All @@ -83,7 +85,7 @@ public function setValue($params)
$target = $params['default_value'];
}
if (isset($target)) {
if (preg_match("/(gt |lt |gte |lte |eq |ne |like |notlike )(.+)/", $target, $matches)) {
if (preg_match("/(gt |lt |gte |lte |eq |ne |like |notlike |regex |notregex )(.+)/", $target, $matches)) {
$op = trim($matches[1]);
$val = trim($matches[2]);
}
Expand Down